var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

var net=ns4
var cpt=new Array()	
var clt=new Array()	
var bgprec=""
var ligneprec = -1 ;


// =========================================================================
function getElement(racine,id) {
var Out_getElement=false

if(ie4)
	if(racine)
		Out_getElement=racine.eval(id)
	else
		Out_getElement=eval(id)
if(ns6)
	if(racine)
		Out_getElement=racine.document.getElementById(id)
	else	
		Out_getElement=document.getElementById(id)

return Out_getElement
}
// =========================================================================
function dw(txt) {
  document.write(txt+"\n\r") ;
}
// =========================================================================
function antisp(antisp1, antisp3, antisp2)
{
  document.write('<a class=bleu href=mailto:' + antisp1 + '@' + antisp2 + '.' + antisp3 + '>');
}
// =========================================================================
function affichetr(nomtableau,il){
  var idp=0;
	var divpil=nomtableau.indexOf("NODIV")==-1
	var lientmp=""
	var divtmp=""
	if(nomtableau!="" && nomtableau!="NODIV") idp=nomtableau+'data['+nomtableau+'ptrs['+il+']][0]'; else idp=il
	if(divpil)
		lientmp='lien("pilote",'+idp+',"pilote",2)'
    else
		lientmp='lien("'+debut_lien+'",'+idp+',"res_gauche",1)'
  return "<TR border=0>"
}
// =========================================================================
function trouve(ou,quoi,type) {
  if(ou.length==0) return 0
  var il = 0

  if(type=='"')
      while(type+ou[il][0]+type != type+quoi+type) il++;
  else
      while(ou[il][0]< quoi) il++;

  if(type+ou[il][0]+type == type+quoi+type) return il; else return 0
}
// =========================================================================
function place(buffer)
{
if (buffer==1)
	tmp="er";
else
	tmp="eme";
if (buffer==999)
	return "open";
else
	return buffer+tmp;
}
function placeopen(buffer)
{
if (buffer==999)
	return "open";
else
	return buffer;
}

// =========================================================================
// utilise fenetre() de fenetres.js
function lien(a1,a2,cible,mode) {
	var url=""
	var id=0
	if((!window.opener) && (self==top))
		return "";			
	if(cible=="") cible="res_droite"
	if(a1=="pilote" && (a2+" ").indexOf("=")==-1)
		{			
		id=trouve(pilotes,a2,"")
		a2="pilote="+pilotes[id][0]+"&annee="+pilotes[id][2]
		}

    url="../"+ ((parent.frames[cible] || mode==2) ? "resultats/"+a1+".php?" : "php?quoi="+a1+"&") + a2
	if(!parent.frames[cible]) cible="droite"

	switch (mode)
		{
		case 0:
			return " target="+(parent.frames[cible] ? cible : "_self")+" href='"+url+"' "
			break;
		case 2:
			if(!parent.fenetre)
				{
				parent.frame_droite_chargee=false;
				document.location.href=url
				}
			else
				parent.fenetre(url,"pilote","width=410,height="+(screen.height-150)+",toolbar=no,menubar=yes,scrollbars=yes,location=no,left="+(screen.width-430)+",top=100")
			break;
		default :
			if(parent.frames[cible])
				{
				parent.frame_droite_chargee=false;
				parent.frames[cible].location.href=url;
				}
			else
			if(window.opener.frames[cible])
				{
				window.opener.frame_droite_chargee=false;
				window.opener.frames[cible].location.href=url;
				}
			else
				document.location.href=url;
			break;
		}
}
function bande(txt,dv)
{
return "<TABLE class=bandeau width=99% border=0 cellspacing=0 cellpadding=0 >"
	   +"<TR border=0>"
	   +"<TD class=bandeau style='font-size:11px;'>"
	   +txt+"</TD>"
	   +"<TD title='cliquer pour fermer' onclick='parent.bascule("+dv+")' width=10px class=fermer style='font-size:10px;'>X</TD>"
	   +"</TR>"
	   +"</TABLE>"
//<IMG border=0 src='../images/fermer.gif'>
}

function reduit_innerHTML(txt)
{
var i
var sortie

txt=txt.substring(0,20)
sortie=txt.substring(0,1)
for(i=1;i<txt.length;i++)
	sortie+="<BR>"+txt.substring(i,i+1)

return sortie
}
function aff_onmouseover(txt)
{
if((window.opener) || !(self==top))
return " onmouseover='bgprec=this.style.background;this.style.background=\"#ffffe0\";window.status=\""+txt+"\";return true;'"
		+" onmouseout='this.style.background=bgprec;window.status=\"\";return true;' "
}

function lien_pil(id,annee)
{
var idpil=0;
var pil;
if(!pilotes) return
if(("LIC"+id).length==11)
	{
	while(pilotes[idpil][14] != id) idpil++;
	}
else
	idpil=trouve(pilotes,id,'');
pil=pilotes[idpil]
dw("<a class=bleu "+aff_onmouseover("afficher les resultats de ce pilote ...\";affiche_div("+pil[0]+");var toto=\"")
	+" href='competition/resultats/pilote/"+pil[0]+"/"+pil[2]+"'>"
	+pil[3]+" "+pil[4].substring(0,1).toUpperCase()+pil[4].substring(1,100).toLowerCase()+"</a>")
//dw("<a class=bleu "+aff_onmouseover("afficher les resultats de ce pilote ...\";affiche_div("+pil[0]+");var toto=\"")
//	+"onclick='lien(\"pilote\",\"pilote="+pil[0]+"&annee="+pil[2]+"\",\"pilote\",2);'>"
//	+pil[3]+" "+pil[4].substring(0,1).toUpperCase()+pil[4].substring(1,100).toLowerCase()+"</a>")
}

