////////////////
// scripts.js //
////////////////
objAsterix1='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="15" height="15" id="AnimPro" align="middle">'
objAsterix1+='<param name="allowScriptAccess" value="sameDomain" />'
objAsterix1+='<param name="movie" value="./img/AnimPro.swf" />'
objAsterix1+='<param name="quality" value="high" />'
objAsterix1+='<param name="bgcolor" value="#ffffff" />'
objAsterix1+='<param name="wmode" value="transparent" />'					
objAsterix1+='<embed src="./img/AnimPro.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="15" height="15" name="AnimPro" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
objAsterix1+='</object>'
objAsterix=objAsterix1;
//////////////////////////////FONCTION//////////////////////////////////////////////
			function affPays()
			{				
				if(document.getElementById("divAgence").innerHTML=="")//Les agences
				{
					var param="<? echo $lang_url ?>";
					result=file("./../agence.php"+param);
					document.getElementById("mFloat").style.width="100%";
					document.getElementById("trMFloat").className="trMFloat";
					document.getElementById("trListeAgence").className="";
					document.getElementById("mFloat").innerHTML=result;
					
				}
				else//Sinon listing des pays selon continent (voir php haut de cette page
				{
					document.getElementById("mFloat").innerHTML="<? echo $_SESSION['affiche']; ?>\n";
					document.getElementById("trMFloat").className="trMFloat";
					document.getElementById("trListeAgence").className="trMFloat";					
					document.getElementById("mFloat").style.width="100%";
					document.getElementById("mFloat").style.height="100%";
						
				}
			}
			function retPays(cont, id, ref, pays)	
			{
				//Clique sur un pays
				var param="?continent="+cont+"&pays="+id+"&ref="+ref+"&nomPays="+pays;
				result=file("affInfoGp.php"+param);
				//alert(result);
				document.getElementById("listeAgence").style.height="100%";
				document.getElementById("listeAgence").innerHTML=result;					
			}

////////////////////////////////////////////////////////////////////////////////////

////XMLHttpRequest*********************************************************************************
	function file(fichier)
     {	 //Requete php vers le serveur retourne un string grâce à echo (le retour est à splitter)
		 //alert(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 changePlanisphere(messageDrapeau, messagePays)
{
	//alert(messageDrapeau+", "+messagePays);
	var imgPlanisphere=document.getElementById("planisphere");
	//alert("changePlanisphere");
	switch (obj.langueDuClient)
	{
		case "fr" :		imgPlanisphere.src="./img/planisphere/worldFr.jpg";break;
		case "de" :		imgPlanisphere.src="./img/planisphere/worldDe.jpg";break;
		case "ru" :		imgPlanisphere.src="./img/planisphere/worldRu.jpg";break;
		case "en" :		imgPlanisphere.src="./img/planisphere/worldEn.jpg";break;
		case "es" :		imgPlanisphere.src="./img/planisphere/worldEs.jpg";break;
		default: 		imgPlanisphere.src="./img/planisphere/worldFr.jpg";break;
	}
}

//**************************** Planisphère ******************************************//
function ileCaraibe()
{
	objetContinent.continent="2";
  	objetContinent.nom="Îles caraïbes";	
	infoPays();
}
function afrique()
{
	objetContinent.continent="4";	
	objetContinent.nom="Afrique";	
	infoPays();
}
function europe()
{
  	objetContinent.nom="Europe";	
	objetContinent.continent="5";		
	infoPays();
}
function moyenOrient()
{
	objetContinent.continent="6";	
  	objetContinent.nom="Moyen-Orient";	
	infoPays();
}

function oceanIndien()
{
	objetContinent.continent="7";	
  	objetContinent.nom="Océan indien";	
	infoPays();
}
function asie()
{
	objetContinent.continent="8";	
  	objetContinent.nom="Asie";	
	infoPays();
}
//***************************************************************************************//
function objContinent()  //Objet GLOBALE pour le planisphere
{
	this.continent;
	this.nom="";
	this.dimunitif="";
}
objetContinent=new objContinent();	
//***************************************************************************************//
function planisphere100(arg)
{
	//alert("planisphere");
	document.location="selection_golf_packageLch.php"+arg;
}

function infoPays()
{
	//alert("infoPays");
	//alert(messageDrapeau+", "+messagePays); //Variable globale Javascript	
	var blsMessage=document.getElementById("baliseMessage");
	blsMessage.style.visibility="hidden";
	
	tableauPays=new Array();  //Tableau ppour eviter les doublons	
	var divCombo=document.getElementById("divCombo");
	
	divCombo.innerHTML="";
	divCombo.innerHTML='<select class="select" id="selectPays" size="0" name="selectPays" onChange="selectionPays()">' ;
	var slPays=document.getElementById("selectPays");
	slPays.innerHTML+='<option >'+ messagePays +'</option>';//init option	
	slPays.innerHTML+='<option >'+ messagePays +'</option>';//init option	
	slPays.innerHTML+='<option value=&nbsp;>&nbsp;</option>';
	num=2; //On demarre à 2 Cause message début
	for(var i=0; i < golfPackage.length;i++)
	{
		for(var j=0; j < golfPackage[i].length;j++)
		{				
			obj=golfPackage[i][j];
			if(parseInt(objetContinent.continent)==parseInt(obj.continent))
			{	
			//alert("Numero de pays= "+obj.numPays+"		Pays: "+obj.pays);
				if(tableauPays[i]!=obj.numPays)  //Eviter les doublons
				{
			//if(i<2)alert(obj.continent+", "+obj.pays+", "+obj.drapeau+", "+obj.nom+", "+obj.ville+", "+obj.idPackage+", "+obj.lienPromotion+", "+obj.idPromotion+", "+obj.langueEtAgenceDuClient);
					slPays.innerHTML+='<option style="text-align:center;" value='+obj.numPays+'>'+obj.pays+'</option>';	
					tableauPays[i]=obj.numPays;
					num++;
				}
			}
		}
	}
	slPays.size=num;

	divCombo.innerHTML+='</select></div>';
	document.getElementById("divGolfPackage").scrollTop=0;
	//slPays.options[0].value="Votre pays de destination";
	//obj.drapeau;
	//Reduit le planisphere apres selection d'un pays**************
	var imgPlanisphere=document.getElementById("planisphere");
	imgPlanisphere.width="0%";
	imgPlanisphere.height="0%";
	//*************************************************************
}
function autoSelect(nomPays,txtPromo)
{
	//alert("autoSelect");
	//alert("autoSelect fonction: "+ nomPays);
	var premiereFois=true;

	if(nomPays!="")//retour gofPackage ne pas afficher le planisphere
	{
		var imgPlanisphere=document.getElementById("planisphere");
		imgPlanisphere.width="0%";
		imgPlanisphere.height="0%";	
		document.getElementById("baliseMessage").innerHTML="";
	}
		tableau='<div align="left">';
		tableau+='<table border="0">';
	
	for(var i=0;i<golfPackage.length;i++)//Afficher selectionner votre GolfPackage 
	{										//Selon la langue du client
		for(var j=0;j<golfPackage[i].length;j++)
		{
			obj=golfPackage[i][j];
			if(nomPays==obj.pays)
			{
				if (premiereFois)//La 1ere fois on affiche le drapeau du pays
				{
					divCombo.innerHTML="<div align='center' ><h6>"+obj.drapeau+"  "+obj.pays+"<br>"+ obj.messageLangueClient +"</h6></div>";	
					premiereFois=false;
				}
				
				if(obj.idPromotion!="")
				{	
					//Modifié ville cause apostrophe (remplacé par &rsquo;)
					tableau+='<tr>';
					tableau+='<td class="md1" align="right">';
					tableau+=obj.ville;
					tableau+='</td>';
					tableau+='<td>';
					//tableau+=obj.lienPromotion;
					tableau+=objAsterix;
					tableau+='</td>';				
					tableau+='<td>';
					tableau+='<a class=md2 align="left" href=\"golf_package.php'+obj.langueEtAgenceDuClient+'&golf_package='+obj.idPackage+'\" title=\"n°'+obj.idPackage+' : '+obj.nom+'\">'+obj.nom+'</a>';								
					tableau+='</td>';
					tableau+='</tr>';								
					//divCombo.innerHTML+='<div class=md1 align="left" >'+obj.ville.replace("&rsquo;","'")+':&nbsp;<a class=md2 align="center" href=\"golf_package.php'+obj.langueEtAgenceDuClient+'&golf_package='+obj.idPackage+'\" title=\"n°'+obj.idPackage+' : '+obj.nom+'\">'+obj.nom+'</a>&nbsp<a href="  promotion.php'+obj.langueEtAgenceDuClient+'&promotion='+obj.idPromotion+'" > <img title="'+txtPromo+'" border=0 src="img/AnimPro.gif"></a></div>';					
				}
				else
				{
					tableau+='<tr>';					
					tableau+='<td class="md1" align="right">';
					tableau+=obj.ville;
					tableau+='</td>';
					tableau+='<td>';
					tableau+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
					tableau+='</td>';				
					tableau+='<td>';
					tableau+='<a class=md2 align="left" href=\"golf_package.php'+obj.langueEtAgenceDuClient+'&golf_package='+obj.idPackage+'\" title=\"n°'+obj.idPackage+' : '+obj.nom+'\">'+obj.nom + obj.lienPromotion +'</a>';								
					tableau+='</td>';
					tableau+='</tr>';								
					//divCombo.innerHTML+='<div class=md1 align="left" >'+obj.ville+':&nbsp;<a class=md2 align="center" href=\"golf_package.php'+obj.langueEtAgenceDuClient+'&golf_package='+obj.idPackage+'\" title=\"n°'+obj.idPackage+' : '+obj.nom+'\">'+obj.nom+'</a></div>';									
				}
				//divCombo.innerHTML+="<br>";
			}
		}	
	}
	tableau+='</table>';
	tableau+='</div>';
	divCombo.innerHTML=tableau;	
}

function selectionPays()
{
	//alert("selectionPays");
	var divCombo=document.getElementById("divCombo");
	var slPays=document.getElementById("selectPays");  //sl comme select
	var index=slPays.selectedIndex;  //Index du pays
	var numPays=slPays[index].value;
	
	for(var i=0;i<golfPackage.length;i++)//Afficher selectionner votre GolfPackage 
	{										//Selon la langue du client
		for(var j=0;j<golfPackage[i].length;j++)
		{
			obj=golfPackage[i][j];
			if(numPays==obj.numPays)
			{
				//alert("message"+ obj.messageLangueClient);
				divCombo.innerHTML="<div align='center' ><h6>"+obj.drapeau+"  "+obj.pays+"<br>"+ obj.messageLangueClient +"</h6></div>";	
				break;
			}
		}
	}
	//alert(nomPays);
	tableau='<div align="left">';
	tableau+='<table border="0">';
	for(var i=0;i<golfPackage.length;i++)
	{
		for(var j=0;j<golfPackage[i].length;j++)
		{
			obj=golfPackage[i][j];
			//alert("debut"+nomPays+"fin"+", "+"debut"+obj.pays+"fin");
			//alert(obj.continent+", "+obj.pays+", "+obj.drapeau+", "+obj.nom+", "+obj.ville+", "+obj.idPackage+", "+obj.lienPromotion+", "+obj.idPromotion+", "+obj.langueEtAgenceDuClient);
			if(numPays==obj.numPays)
			{
				//alert("trouvé: "+nomPays+", "+obj.pays);
				//divCombo.innerHTML+=obj.drapeau;
				//divCombo.innerHTML+='<div class=md1 ><div class=md1 align="left" >'+obj.ville+':&nbsp;<a class=md2 align="center" href=\"golf_package.php'+obj.langueEtAgenceDuClient+'&golf_package='+obj.idPackage+'\" title=\"n°'+obj.idPackage+' : '+obj.nom+'\">'+obj.nom + obj.lienPromotion +'</a></div></div><br>';				
				tableau+='<tr>';
				tableau+='<td class="md1" align="right">';
					tableau+=obj.ville;
				tableau+='</td>';
				
				tableau+='<td>';
					if(obj.lienPromotion=="")//Mettre espace si pas de promo
					{
						tableau+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
					}
					else
					{					
						//tableau+=obj.lienPromotion;
						tableau+=objAsterix;						
					}
				tableau+='</td>';				
				
				tableau+='<td>';
					tableau+='<a class=md2 align="left" href=\"golf_package.php'+obj.langueEtAgenceDuClient+'&golf_package='+obj.idPackage+'\" title=\"n°'+obj.idPackage+' : '+obj.nom+'\">'+obj.nom +'</a>';								
				tableau+='</td>';
				tableau+='</tr>';
			}
		}
	}
	tableau+='</table>';
	tableau+='</div>';
	divCombo.innerHTML="<div style='font-size:18px' class='md1'>"+obj.messageLangueClient+"</div><br>"+tableau;
}




function infoVille()
{
	//alert("infoVille");
		document.write('<select id="selectVille" name="selectVille" size="3" onChange="selectionVille()">');
		for(var i=0; i < golfPackage.length;i++)
		{
			for(var j=0; j < golfPackage.length;j++)
			{
				document.write('<option > </option>');	
			}
		}
		document.write('</select></div>');
		var slVille=document.getElementById("selectVille");		
		//slVille.style.visibility="hidden";
}


function selectionVille()
{
	//alert("SelectionVille");
	var index=document.getElementById("selectVille").selectedIndex;
	nomSelectionne=document.getElementById("selectVille").options[index].innerHTML;
	for(var i=0; i< golfPackage.length;i++)
	{
		for(var j=0;j< golfPackage[i].length;j++)
		{		
			obj=golfPackage[i][j];
			nomBoucle=obj.ville +" " +obj.nom;
			if(nomSelectionne==nomBoucle)
			{
				//alert(obj.continent);
				window.open("golf_package.php"+obj.langueEtAgenceDuClient+"&golf_package="+obj.idPackage,"_self");
			}
		}
	}
}



//*********************************************************************************************//
function genere_men(menus, nbMenus)
{
	
  document.write('<table width=100% border=0 cellpadding=0 cellspacing=0>\n');
  i=0;
  while (i<nbMenus)
  {
	  if(!(i%4)) document.write('<tr>\n');
	  document.write('<td align=center width=25%>\n');
    document.write('<a class=pack href="javascript:CacheTout(\'bloc\');DivStatus(\'bloc\', \'' + i + '\')">');
    document.write('<div style="border: 1px solid black;">' + menus[i] + '</div></a>\n');
	  document.write('</td>\n');
	  i++;
	  if(!(i%4)) document.write('</tr>\n');
	  
  }
  document.write('</table>\n');

}



//================================================================================

function genere_div(menus, ssmenusNom, nbMenus)
{
	//var txt = new Array ('Matériel','Poissons','Sécurité'); 	
	planisphere=document.getElementById("planisphere");
	//planisphere.document.getElementById("golfPackage").options[0].text=txt;
	//alert(planisphere.document.getElementById("pays").value);

		//alert("menus= "+menus);
		//alert("ssmenusNom: "+ssmenusNom);
		//alert("nbMenus: "+nbMenus);

  for (i=0; i<nbMenus; i++)
  {
    document.write('<div style="border:1px solid black;display:none" name="bloc' + i + '" id="bloc' + i + '">\n');
    document.write('<div style="margin-bottom: 5px; margin-top: 5px">\n');
		document.write('<div align=center>' + menus[i] + '</div><br />');
		for (z=0; z<ssmenusNom[i].length; z++)
		{
      		document.write('&nbsp;&nbsp;' + ssmenusNom[i][z] + '<br />\n');
		}
    document.write('</div></div>\n');
  }
}

/////////////////////////////////
function DivStatus(nom, numero)
	{
		

		var divID = nom + numero;
		if(document.getElementById && document.getElementById(divID)) // Pour les navigateurs récents
			{
				Pdiv=document.getElementById(divID);
				Pdiv.style.display='block';
				PcH = true;
	 		}
		else if(document.all && document.all[ divID ]) // Pour les veilles versions
			{
				Pdiv=document.all[ divID ];
				Pdiv.style.display='block';
				PcH=true;
			}
		else if(document.layers && document.layers[ divID ]) // Pour les très veilles versions
			{
				Pdiv=document.layers[ divID ];
				Pdiv.style.display='block';
				PcH=true;
			}
		else
			PcH=false;
		if(PcH)
			Pdiv.className = (Pdiv.className == 'cachediv') ? '' : 'cachediv';
	}
	
/////////////////////////
function CacheTout(nom)
	{	
		var NumDiv = 0;
		if(document.getElementById)
			{
				while(document.getElementById(nom + NumDiv))
					{
						SetDiv = document.getElementById(nom + NumDiv);
						if(SetDiv && SetDiv.className != 'cachediv')
							DivStatus(nom, NumDiv);
						NumDiv++;
					}
			}
		else if(document.all)
			{
				while(document.all[ nom + NumDiv ])
					{
						SetDiv = document.all[ nom + NumDiv ];
						if(SetDiv && SetDiv.className != 'cachediv')
							DivStatus(nom, NumDiv);
						NumDiv++;
					}
			}
		else if(document.layers)
			{
				while(document.layers[ nom + NumDiv ])
					{
						SetDiv = document.layers[ nom + NumDiv ];
						if(SetDiv && SetDiv.className != 'cachediv')
							DivStatus(nom, NumDiv);
						NumDiv++;
					}
			}
	}

//////////////////////////
function MontreTout(nom)
	{	
	alert("montreTout NOM= "+nom);
		var NumDiv = 0;
		if(document.getElementById)
			{
				while(document.getElementById(nom + NumDiv))
					{
						SetDiv = document.getElementById(nom + NumDiv);
						if(SetDiv && SetDiv.className != '')
							DivStatus(nom, NumDiv);
						NumDiv++;
					}
			}
		else if(document.all)
			{
				while(document.all[ nom + NumDiv ])
					{
						SetDiv = document.all[ nom + NumDiv ];
						if(SetDiv && SetDiv.className != '')
							DivStatus(nom, NumDiv);
						NumDiv++;
					}
			}
		else if(document.layers)
			{
				while(document.layers[ nom + NumDiv ])
					{
						SetDiv = document.layers[ nom + NumDiv ];
						if(SetDiv && SetDiv.className != '')
							DivStatus(nom, NumDiv);
						NumDiv++;
					}
			}
	}

/////////////////////////////////////////////////////////
function genere_menu(menus, ssmenusNom, nbMenus, message)
{
  for(i=0; i<nbMenus; i++)
  {
     document.write('<a href="javascript:ouvre_menu(' + i + ', ' + nbMenus + ')"><ul>' + menus[i] + '</a>');
     document.write('<div style="display: none" id="ssmenu' + i + '"><li>');
     if(message)
     		document.write(message+'<br/><br/>');
	  for(z=0; z<ssmenusNom[i].length; z++)
	  {	
	    document.write('&nbsp;&nbsp;' + ssmenusNom[i][z] + '<br />');
	  }
	  document.write('</li></div>');
	  document.write('</ul>');
  }
}

var ie=document.all;
var ns6=document.getElementById&&!document.all;
var ancien_num_menu=-1;

function ouvre_menu(num, nbMenus)
{
  if(ancien_num_menu==num)
  {
    if(objet.style.display == 'none')
      objet.style.display = 'block';
    else
      objet.style.display = 'none';
  }
  else
  {
    for(i=0; i<nbMenus; i++)
    {
      if(ie)
        objet=document.all['ssmenu' + i];
      else if (ns6)
        objet=document.getElementById('ssmenu' + i);
      if (objet.style.display == 'block')
        objet.style.display = 'none';
    }
    if(ie)
		  objet=document.all['ssmenu' + num];
    else if(ns6)
      objet=document.getElementById('ssmenu' + num);
    if(objet.style.display == 'none')
      objet.style.display = 'block';
    ancien_num_menu=num;
  }
}

//////////////////////////// fdf ////////////////////////////////