     var perline = 9;
     var divSet = false;
     var curId;
     var colorLevels = Array('0', '3', '6', '9', 'C', 'F');
     var colorArray = Array('#000000','#FFA500','#fff114','#b414ff','#50ddf6','#eac206','#f38213','#FFFFFF','#FFFFFF');
     var ie = false;
     var nocolor = 'none';
	 if (document.all) { ie = true; nocolor = ''; }
	 function getObj(id) {
		if (ie) { return document.all[id]; } 
		else {	return document.getElementById(id);	}
	 }

     function addColor(r, g, b) {
     	var red = colorLevels[r];
     	var green = colorLevels[g];
     	var blue = colorLevels[b];
     	addColorValue(red, green, blue);
     }

     function addColorValue(r, g, b) {
     	colorArray[colorArray.length] = '#' + r + r + g + g + b + b;
     }
     
     function setColor(color) {
     	var link = getObj(curId);
     	var field = getObj(curId + 'field');
     	var picker = getObj('colorpicker');
     	field.value = color;
     	if (color == '') {
	     	
	     	link.style.color = nocolor;
	     	color = nocolor;
     	} else {
	     	link.style.background = color;
	     	link.style.color = color;
	    }
     	picker.style.display = 'none';
	    eval(getObj(curId + 'field').title);
     }
        
     function setDiv() {     
     	if (!document.createElement) { return; }
        var elemDiv = document.createElement('div');
        if (typeof(elemDiv.innerHTML) != 'string') { return; }
        genColors();
        elemDiv.id = 'colorpicker';
	    elemDiv.style.position = 'absolute';
        elemDiv.style.display = 'none';
        elemDiv.style.border = '#000000 1px solid';
        elemDiv.style.background = '#FFFFFF';
        elemDiv.innerHTML = '<span style="font-family:Verdana; font-size:11px;">Couleur: ' 
          	+ '(<a href="javascript:setColor(\'\');">Aucune</a>)<br>' 
        	+ getColorTable() 
        	+ '</span>';

        document.body.appendChild(elemDiv);
        divSet = true;
     }
     
     function pickColor(id) {
     	if (!divSet) { setDiv(); }
     	var picker = getObj('colorpicker');     	
		if (id == curId && picker.style.display == 'block') {
			picker.style.display = 'none';
			return;
		}
     	curId = id;
     	var thelink = getObj(id);
     	picker.style.top = getAbsoluteOffsetTop(thelink) + 20;
     	picker.style.left = getAbsoluteOffsetLeft(thelink);     
	picker.style.display = 'block';
     }
     
     function genColors() {
        addColorValue('0','0','0');
        addColorValue('3','3','3');
        addColorValue('6','6','6');
        addColorValue('8','8','8');
        addColorValue('9','9','9');                
        addColorValue('A','A','A');
        addColorValue('C','C','C');
        addColorValue('E','E','E');
        addColorValue('F','F','F');                                
			
        for (a = 1; a < colorLevels.length; a++)
			addColor(0,0,a);
        for (a = 1; a < colorLevels.length - 1; a++)
			addColor(a,a,5);

        for (a = 1; a < colorLevels.length; a++)
			addColor(0,a,0);
        for (a = 1; a < colorLevels.length - 1; a++)
			addColor(a,5,a);
			
        for (a = 1; a < colorLevels.length; a++)
			addColor(a,0,0);
        for (a = 1; a < colorLevels.length - 1; a++)
			addColor(5,a,a);
			
			
        for (a = 1; a < colorLevels.length; a++)
			addColor(a,a,0);
        for (a = 1; a < colorLevels.length - 1; a++)
			addColor(5,5,a);
			
        for (a = 1; a < colorLevels.length; a++)
			addColor(0,a,a);
        for (a = 1; a < colorLevels.length - 1; a++)
			addColor(a,5,5);

        for (a = 1; a < colorLevels.length; a++)
			addColor(a,0,a);			
        for (a = 1; a < colorLevels.length - 1; a++)
			addColor(5,a,5);
			
       	return colorArray;
     }
     function getColorTable() {
         var colors = colorArray;
      	 var tableCode = '';
         tableCode += '<table border="0" cellspacing="1" cellpadding="1">';
         for (i = 0; i < colors.length; i++) {
              if (i % perline == 0) { tableCode += '<tr>'; }
              tableCode += '<td bgcolor="#000000"><a style="outline: 1px solid #000000; color: ' 
              	  + colors[i] + '; background: ' + colors[i] + ';font-size: 10px;" title="' 
              	  + colors[i] + '" href="javascript:setColor(\'' + colors[i] + '\');">&nbsp;&nbsp;&nbsp;</a></td>';
              if (i % perline == perline - 1) { tableCode += '</tr>'; }
         }
         if (i % perline != 0) { tableCode += '</tr>'; }
         tableCode += '</table>';
      	 return tableCode;
     }
     function relateColor(id, color) {
     	var link = getObj(id);
     	if (color == '') {
	     	link.style.background = nocolor;
	     	link.style.color = nocolor;
	     	color = nocolor;
     	} else {
	     	link.style.background = color;
	     	link.style.color = color;
	    }
	    eval(getObj(id + 'field').title);
     }
     function getAbsoluteOffsetTop(obj) {
     	var top = obj.offsetTop;
     	var parent = obj.offsetParent;
     	while (parent != document.body) {
     		top += parent.offsetTop;
     		parent = parent.offsetParent;
     	}
     	return top;
     }
     
     function getAbsoluteOffsetLeft(obj) {
     	var left = obj.offsetLeft;
     	var parent = obj.offsetParent;
     	while (parent != document.body) {
     		left += parent.offsetLeft;
     		parent = parent.offsetParent;
     	}
     	return left;
     }










function writediv(texte,nomid)
{

document.getElementById('id'+nomid).innerHTML = "<img src=images/drapeaux/"+texte+".png>";
}

function lespays(id,nomid)
{

texte= file('include/cherchepays.php?id='+escape(id));
writediv(texte,nomid);
}


function file(fichier)
{
if(window.XMLHttpRequest) // FIREFOX
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // IE
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else
return(false);
xhr_object.open("GET", fichier, false);
xhr_object.send(null);
if(xhr_object.readyState == 4) return(xhr_object.responseText);
else return(false);
}

function onglet(id) {
var d = document.getElementById('ong'+id);
	for (var i = 1; i<=4; i++) {
		if (document.getElementById('ong'+i)) {document.getElementById('ong'+i).style.display='none'; 
		document.getElementById('a'+i).style.background ='#ffffff';}
	}
if (d) {d.style.display=''; 
document.getElementById('a'+id).style.background ='#FFCD31';
}
}


function OpenPopUp(MyFile,MyWindow,MyWidth,MyHeight)
//MyFile :   nom du fichier contenant le code HTML du pop-up 
//MyWindow :   nom de la fenêtre (ne pas mettre d'espace) 
//MyWidth :   entier indiquant la largeur de la fenêtre en pixels 
//MyHeight :   entier indiquant la hauteur de la fenêtre en pixels 

{    
var ns4 = (document.layers)? true:false;    //NS 4 
var ie4 = (document.all)? true:false;   //IE 4 
var dom = (document.getElementById)? true:false;   //DOM 
var xMax, yMax, xOffset, yOffset;;    

    if (ie4 || dom)
        {
        xMax = screen.width;
        yMax = screen.height;
        }
    else if (ns4)
        {
        xMax = window.outerWidth;
        yMax = window.outerHeight;
        }
    else
        {
        xMax = 800;
        yMax = 600;
        }
    xOffset = (xMax - MyWidth)/2+95;
    yOffset = (yMax - MyHeight)/2-83;
    window.open(MyFile,MyWindow,'width='+MyWidth
+',height='+MyHeight
+',screenX='+xOffset
+',screenY='+yOffset
+',top='+yOffset
+',left='+xOffset
+',scrollbars=no,resizable=no');
    }
	
	
function verif_club() {
 erreur="";
 if(document.club.nomcommun.value == "") 
  { 
   erreur=erreur+"- le nom commun\n"; 
  } 
 if(document.club.ville.value == "") 
  { 
   erreur=erreur+"- la ville\n"; 
  } 
 if(document.club.pays.value == "") 
  { 
   erreur=erreur+"- le pays\n"; 
  } 
   
if (erreur!="")
 {
  alert("Veuillez remplir les champs suivants : \n\n"+erreur);
  return false;
 }
return true;
} 
function verif_editclub() {
 erreur="";
 if(document.editclub.nomcommun.value == "") 
  { 
   erreur=erreur+"- le nom commun\n"; 
  } 
 if(document.editclub.ville.value == "") 
  { 
   erreur=erreur+"- la ville\n"; 
  } 
 if(document.editclub.pays.value == "") 
  { 
   erreur=erreur+"- le pays\n"; 
  } 
   
if (erreur!="")
 {
  alert("Veuillez remplir les champs suivants : \n\n"+erreur);
  return false;
 }
return true;
} 
function verif_identite() {
 erreur="";
 if(document.joueur.nom.value == "") 
  { 
   erreur=erreur+"- le nom\n"; 
  } 
 if(document.joueur.prenom.value == "") 
  { 
   erreur=erreur+"- le prenom\n"; 
  } 
 if(document.joueur.nation1.value == "") 
  { 
   erreur=erreur+"- la première nationnalité\n"; 
  } 
   
if (erreur!="")
 {
  alert("Veuillez remplir les champs suivants : \n\n"+erreur);
  return false;
 }
return true;
} 