var xhr = null; 

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 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; 
	} 
}

function Inscription_Newsletter() {
	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){
			//alert(xhr.responseText);
			reponse = xhr.responseText;
			if (reponse==1) {
				alert('Félicitation, vous êtes désormais inscrit à notre newsletter');
				document.FORM_NEWSLETTER.email_newsletter.value = 'Votre email';
			}
			else{				
				if (reponse=='-1') alert('Cet email est déjà inscrit');
				if (reponse=='-2') alert('Email incorrect');
			}
		}
	}
				
	// Ici on va voir comment faire du post
	xhr.open("POST","../inc/ajax_inscription_newsletter.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
	email = document.FORM_NEWSLETTER.email_newsletter.value;
	var data = 'email='+email;
	xhr.send(data);				
	//xhr.send(null);
}

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 Code_Video(code) {
	document.getElementById('codevideo').innerHTML = code;
}