
function GrandePhoto(titre,photo,W,H) {
  myWin=open("","newin","width="+W+",height="+H+",resizable=1,scrollbars=0,status=0");
  myWin.document.open();
  if (myWin.blur) myWin.focus();
  myWin.resizeTo(W+12,H+27);
  myWin.document.write('<html><head><title>'+titre+'</title></head><body BGCOLOR="#ffffff" marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">');
  myWin.document.write('<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"><tr><td>');
  myWin.document.write('<A HREF="javascript:window.close();" ALT="Cliquez pour fermer">');  
  myWin.document.write('<IMG SRC="'+photo+'" WIDTH="'+W+'" HEIGHT="'+H+'" BORDER="0">');
  myWin.document.write('</A>');  
  myWin.document.write("</table></tr></td>");
  myWin.document.write("</body></html>");
  myWin.document.close();  
}
function Autres_Photos(id) {
  myWin=open("popup_photo.php?id="+id,"newin","width=400,height=300,resizable=1,scrollbars=0,status=0");
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function Visibilite(bloc,valeur)
{
	if(valeur==0)
	{
		//alert('on masque');
		document.getElementById(bloc).style.display='none';
		
	}else{
		//alert('on affiche');
		document.getElementById(bloc).style.display='block';
	}
}
function Visibilite_Auto(bloc)
{
	if(document.getElementById(bloc).style.display=='block')
	{
		document.getElementById(bloc).style.display='none';
	}else{
		document.getElementById(bloc).style.display='block';
	}
}
	

function Chg_Sous_Menu(i) {
	var elementDeReference = document.getElementById("headerSous");
	elementDeReference.className = 'header'+i;
}

function ChangeMessage(message,champ) {
 	if(document.getElementById)
    	document.getElementById(champ).innerHTML = message;
}


function Help(type_message, zone) {
	Visibilite(zone,1);
	ChangeMessage(msg[type_message],zone);
}

function Verifie_Formulaire_Contact(langue,id_s) {
	erreur = false;
	
	getXhr();
	// On défini ce qu'on va faire quand on aura la réponse
	xhr.onreadystatechange = function(){
		// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
		if(xhr.readyState == 4 && xhr.status == 200){
			//si un ! figure dans la réponse >> ca veut dire que tout est ok
			//sinon on a un champ mal rempli
			alert(xhr.responseText);
			index = xhr.responseText.indexOf('!',0);
			if (index>0) {
				document.getElementById("contact_nom").value= '';
				document.getElementById("contact_prenom").value= '';
				document.getElementById("contact_email").value= '';
				document.getElementById("contact_pays").value= '';
				document.getElementById("contact_telephone").value= '';
				document.getElementById("contact_message").value= '';
				document.getElementById("contact_captcha").value= '';
			}
		}
	}
			
	// Ici on va voir comment faire du post
	xhr.open("POST","../inc/ajax-verif-contact.php",true);
	// ne pas oublier ça pour le post
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	
	// ne pas oublier de poster les arguments
	nom = document.getElementById("contact_nom").value;
	prenom = document.getElementById("contact_prenom").value;
	email = document.getElementById("contact_email").value;
	pays = document.getElementById("contact_pays").value;
	telephone = document.getElementById("contact_telephone").value;
	message = document.getElementById("contact_message").value;
	captcha_valeur = document.getElementById("contact_captcha").value;
	var data = 'nom='+nom+'&prenom='+prenom+'&email='+email+'&pays='+pays+'&telephone='+telephone+'&message='+message+'&langue_consultation='+langue+'&id_site='+id_s+'&captcha='+captcha_valeur;
	xhr.send(data);			
	//xhr.send(null);	
}

function ChangeMessage(message,champ) {
	if(document.getElementById)
    	document.getElementById(champ).innerHTML = message;
}
////////////////////////////////////////////////////////////
function getXhr() {
	if (window.XMLHttpRequest) // Firefox et autres
		xhr = new XMLHttpRequest(); 
	else if(window.ActiveXObject){ // Internet Explorer 
	   try {
          xhr = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
          xhr = new ActiveXObject("Microsoft.XMLHTTP");
	     }
				}
	else { // XMLHttpRequest non supporté par le navigateur 
	   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	   xhr = false; 
	} 
}
