// JavaScript Document

// ================================================ AFFICHAGE DES FLASH
	function afficheFlash(version,nom,largeur,hauteur){
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version+',0,0,0" width='+largeur+' height='+hauteur+'>\n');
		document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
		document.write('<param name="movie" value='+nom+' />\n');
		document.write('<param name="quality" value="high" />\n');
		document.write('<param name="wmode" value="transparent" />\n');
		document.write('<embed src='+nom+' quality="high" wmode="transparent" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" width='+largeur+' height='+hauteur+'></embed>\n');
		document.write('</object>\n');
	}
// ================================================ AFFICHAGE DES FLASH


// ================================================ SURVOL OK RECHERCHE
	function survolEnvoyerOn(envoyer)
	{
		envoyer.className = "translucide";
	}
	
	function survolEnvoyerOff(envoyer)
	{
		envoyer.className = "";
	}

	function survolEnvoyer()
	{
		document.getElementById("rechercheOk").onmouseover = function() {survolEnvoyerOn(this);};
		document.getElementById("rechercheOk").onmouseout = function() {survolEnvoyerOff(this);};
	}
// ================================================ SURVOL OK RECHERCHE


// ================================================ MENU
	function hover(obj)
	{
		UL = obj.getElementsByTagName('ul');
		if(UL.length > 0)
		{
			sousMenu = UL[0].style;
			if(sousMenu.display == 'none' || sousMenu.display == '')
			{
				sousMenu.display = 'block';
			}
			else
			{
				sousMenu.display = 'none';
			}
		}
	}
	
	function setHover()
	{
		LI = document.getElementById('menu').getElementsByTagName('li');
		nLI = LI.length;
		for(i=0; i < nLI; i++)
		{
			LI[i].onmouseover = function(){hover(this);}
			LI[i].onmouseout = function(){hover(this);}
		}
	}
	
	
	function survolMenu()
	{
		var table = new Array;
		var tableLi = new Array;
		var tableLiAvecUl = new Array;
		var tableUl = new Array;
		var testUl = new Array;
		var rang;
	
		var table = document.getElementById("menu").getElementsByTagName("li"); // tableau avec tous les li contenu dans "menu"
		var tableUl = document.getElementById("menu").getElementsByTagName("ul"); // tableau avec tous les ul contenus dans "menu"
		
		
		function survolOn(objet)
		{
			if(objet.id == "menuLien1")
			{
				objet.style.backgroundColor = "#dbc165";
			}
			if(objet.id == "menuLien2")
			{
				objet.style.backgroundColor = "#b28eb8";
			}
			if(objet.id == "menuLien3")
			{
				objet.style.backgroundColor = "#adc273";
			}
			if(objet.id == "menuLien4")
			{
				objet.style.backgroundColor = "#8fabd0";
			}
			if(objet.id == "menuLien5")
			{
				objet.style.backgroundColor = "#dd9f74";
			}
			objet.style.color = "#fff";
		}
		
		function survolOff(objet)
		{
			objet.style.backgroundColor = "#e5e5e2";
			objet.style.color = "#848484";
		}
		
		function survol2On(objet)
		{
			identificateur = objet.id;
			n5 = tableUl.length;
			for(i=0; i<n5; i++)
			{
				if(tableUl[i].id == identificateur)
				{
					rang = i;
				}
			}
			if(identificateur== "sousMenu1")
			{
				tableLiAvecUl[rang].getElementsByTagName("a")[0].style.backgroundColor = "#dbc165";
			}
			if(identificateur == "sousMenu2")
			{
				tableLiAvecUl[rang].getElementsByTagName("a")[0].style.backgroundColor = "#b28eb8";
			}
			if(identificateur == "sousMenu3")
			{
				tableLiAvecUl[rang].getElementsByTagName("a")[0].style.backgroundColor = "#adc273";
			}
			if(identificateur == "sousMenu4")
			{
				tableLiAvecUl[rang].getElementsByTagName("a")[0].style.backgroundColor = "#8fabd0";
			}
			if(identificateur == "sousMenu5")
			{
				tableLiAvecUl[rang].getElementsByTagName("a")[0].style.backgroundColor = "#dd9f74";
			}
			tableLiAvecUl[rang].getElementsByTagName("a")[0].style.color = "#fff";
		}
		
		function survol2Off(objet)
		{
			identificateur = objet.id;
			n5 = tableUl.length;
			for(i=0; i<n5; i++)
			{
				if(tableUl[i].id == identificateur)
				{
					rang = i;
				}
			}
			tableLiAvecUl[rang].getElementsByTagName("a")[0].style.backgroundColor = "#e5e5e2";
			tableLiAvecUl[rang].getElementsByTagName("a")[0].style.color = "#848484";
		}
			
		n = table.length;
		for(i=0; i<n; i++)
		{
			if (table[i].className == "menu" || table[i].className == "dernierMenu")
			{
				tableLi.push(table[i]); // tableau avec tous les li de niveau 1
			}
		}
		
		n2 = tableLi.length;
		for(i=0; i<n2; i++)
		{
			testUl = tableLi[i].getElementsByTagName("ul");
			if (testUl.length > 0)
			{
				tableLiAvecUl.push(tableLi[i]); // tableau avec tous les li possédant un ul
			}
		}
		
		n3 = tableLiAvecUl.length;
		for(i=0; i<n3; i++)
		{
			tableLiAvecUl[i].getElementsByTagName("a")[0].onmouseover = function() {survolOn(this);}
			tableLiAvecUl[i].getElementsByTagName("a")[0].onmouseout = function() {survolOff(this);}
		}
		
		n4 = tableUl.length;
		for(i=0; i<n4; i++)
		{
			tableUl[i].onmouseover = function() {survol2On(this);}
			tableUl[i].onmouseout = function() {survol2Off(this);}
		}

	}
// ================================================ MENU
	
// ================================================ CHOIX HEBERGEMENT
	function validHeb(monform)
	{
		if(monform.heb.selectedIndex == 0)
		{
			alert('Merci de choisir un type d\'hébergement.')
			return false;
		}
		return true;
	}
	
// ================================================== Google Map
	
	function point_google(coordX,coordY,texte,map)
	{
		var point = new GLatLng(coordX,coordY, 16);
		var marker = new GMarker(point);
		marker.value=1;
        
        //marker.icon=letteredIcon;
        GEvent.addListener(marker, "click", function() {
   			 var myHtml = texte;
    		map.openInfoWindowHtml(point, myHtml, maxTitle='test');
  			});
  		map.addOverlay(marker);
	}

	function point_google_icone(coordX,coordY,texte,map,icone)
	{

		var blueIcon = new GIcon(G_DEFAULT_ICON);
		blueIcon.image = icone;                
		markerOptions = { icon:blueIcon };

		var point = new GLatLng(coordX,coordY, 16);
		var marker = new GMarker(point,markerOptions);
		marker.value=1;
        
        //marker.icon=letteredIcon;
        GEvent.addListener(marker, "click", function() {
   			 var myHtml = texte;
    		map.openInfoWindowHtml(point, myHtml, maxTitle='test');
  			});
  		map.addOverlay(marker);
	}
	
//verification email
	function verifier_email(monform){
		var reg_email = /^[A-Za-z0-9\.\-_]+[@][A-Za-z0-9\-\.]+[\.][A-Za-z][A-Za-z][A-Za-z]?$/;
		if (monform.email.value=='')
		{
			alert("Veuillez indiquer un email");
			monform.email.focus();
			return false;
		}
		if(!reg_email.test(monform.email.value))
		{
			alert("Le format de votre adresse email est incorrect");
			monform.email.focus();
			return false;
		}
		return true;
	}
	
// ================================================ AJAX
	
	var http_request = false; 
	function makeRequest(url) 
	{ 
		if (window.XMLHttpRequest) http_request = new XMLHttpRequest(); 
		else if (window.ActiveXObject) http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
		http_request.onreadystatechange = alertContents; 
		http_request.open('GET', url, true); 
		http_request.send(null); 
	} 

	function alertContents() 
	{ 
		if (http_request.readyState == 4) 
		{ 
			if (http_request.status == 200) 
			{
				//alert(http_request.responseText); 
				eval(http_request.responseText); 
			}
			else alert('Erreur de chargement!'); 
		} 
	} 

	function change_div(nom,valeur)
	{
		if (document.getElementById) document.getElementById(nom).innerHTML = valeur;
		else if (document.all) document.all[nom].innerHTML = valeur;
}
	function afficheDiaporama(gid,deb,lien,liste){
		liens=document.getElementById(liste).getElementsByTagName('a');
		for(i=0;i<liens.length;i++)
			liens[i].className='';
		lien.className='actif';
		makeRequest('ajax-diaporama.php?GID='+gid+'&DEB='+deb);
	}
// ================================================ AJAX