// AJAX FONCTIONS
function changePage(pUrl, obj) {
	obj.href='#top';
	var  ajaxCall = new Ajax.Updater("conteneurPages", pUrl);
	//document.getElementById("conteneurPages").scrollIntoView(true);
}





// MOTEUR PLEIN ECRAN
function windowFullScreen( url, name ) { 
	aw = screen.availWidth;
	ah = screen.availHeight; 
	str  = ""; 
	str += "resizable=1,"; 
	str += "scrollbars=no"+","; 
	str += "width=" + aw + ","; 
	str += "height=" + ah + ","; 
	str += "left=0"+","; 
	str += "top=0";  
	
	window.open( url, name, str ); 
}


// FONCTION POPUP PANORAMIQUES
function centerPopUp( url, name, width, height, scrollbars ) { 
	aw = screen.availWidth;
	ah = screen.availHeight; 
	str  = ""; 
	str += "resizable=1,"; 
	str += "scrollbars=yes"+","; 
	str += "width=" + aw + ","; 
	str += "height=" + ah + ","; 
	str += "left=0"+","; 
	str += "top=0";  
	
	window.open( url, name, str );
} 


// VERIFICATION ABONNEMENT/DESABONNEMENT NEWSLETTER FR
function InscriptionNewsletter(){
	if (window.document.inscriptionForm.nom.value == "") {
		alert("Merci d'indiquer votre nom");
	} else if (window.document.inscriptionForm.email.value == "") {
		alert("Merci d'indiquer votre email");
	} else if (window.document.inscriptionForm.optin.checked == false) {
		alert("Merci de confirmer votre inscription en cochant la case");
	} else {
		
		$('BTsubmit').disabled='disabled';
		$('BTsubmit').value='Abonnement en cours...';
		$('nom').disabled='disabled';
		$('email').disabled='disabled';

		new Ajax.Request('newsletter-submit.php',{
			method: 'post',
			asynchronous: true,
			contentType:  'application/x-www-form-urlencoded',
			encoding:     'UTF-8',
			parameters: { email : $F('email'),nom: $F('nom'),optin: $F('optin')},
			onSuccess: function() {mailOK();},
			onFailure: function() {}
			});
	}
}

function DesinscriptionNewsletter(){
	if (window.document.desinscriptionForm.nom.value == "") {
		alert("Merci d'indiquer votre nom");
	} else if (window.document.desinscriptionForm.email.value == "") {
		alert("Merci d'indiquer votre email");
	} else if (window.document.desinscriptionForm.optin.checked == false) {
		alert("Merci de confirmer votre desinscription en cochant la case");
	} else {
		
		$('BTsubmit').disabled='disabled';
		$('BTsubmit').value='Désabonnement en cours...';
		$('nom').disabled='disabled';
		$('email').disabled='disabled';

		new Ajax.Request('newsletter-desabonnement-submit.php',{
			method: 'post',
			asynchronous: true,
			contentType:  'application/x-www-form-urlencoded',
			encoding:     'UTF-8',
			parameters: { email : $F('email'),nom: $F('nom'),optin: $F('optin')},
			onSuccess: function() {mailOK();},
			onFailure: function() {}
			});
	}
}




function mailOK(){
	$('BTsubmit').style.visibility = 'hidden';
	$('BTsubmit').style.display = 'none';
	$('textOK').style.visibility = 'visible';
	$('textOK').style.display = 'block';
}


// CONNEXION CLIENT
function connexionClients() {
	if (window.document.accesClient.login.value == "") {
		alert("Merci d'indiquer votre identifiant");
	} else if (window.document.accesClient.password.value == "") {
		alert("Merci d'indiquer votre mot de passe");
	} else {
		
		$('BTsubmit').value='Connexion en cours...';
		$('textOK').style.visibility = 'visible';
		$('textOK').style.display = 'block';
	}
}


// DETECTION DES NAVIGATEURS
function navigateur() {
	var strChUserAgent = navigator.userAgent;
	var intSplitStart = strChUserAgent.indexOf("(", 0);
	var intSplitEnd = strChUserAgent.indexOf(")", 0);
	var strChStart = strChUserAgent.substring(0, intSplitStart);
	var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
	var strChEnd = strChUserAgent.substring(intSplitEnd);
	
	if(strChMid.indexOf("MSIE 7") != -1)
	{	return "IE7";  }
	else if(strChMid.indexOf("MSIE 6") != -1)
	{	return "IE6";  }
	else if(strChEnd.indexOf("Firefox/2") != -1)
	{	return "Firefox2";  }
	else if(strChEnd.indexOf("Firefox") != -1)
	{	return "Firefox";  }
	else if(strChEnd.indexOf("Netscape/7") != -1)
	{	return "NS7";  }
	else if(strChEnd.indexOf("Netscape") != -1)
	{	return "NS";  }
	else if(strChStart.indexOf("Opera/9") != -1)
	{	return "Opera9";  }
	else if(strChStart.indexOf("Opera") != -1)
	{	return "Opera";  }
	else if(strChEnd.indexOf("Safari") != -1)
	{	return "Safari";  }
	else 
	{	return "Autre";  }
}




// VERIFICATION COMMANDE COFFRET CADEAU
function CommandeCoffretCadeau(){
	if (window.document.commandeForm.nom.value == "") {
		alert("Merci d'indiquer votre nom");
	} else if (window.document.commandeForm.prenom.value == "") {
		alert("Merci d'indiquer votre prenom");
	} else if (window.document.commandeForm.adresse.value == "") {
		alert("Merci d'indiquer votre adresse");
	} else if (window.document.commandeForm.cp.value == "") {
		alert("Merci d'indiquer votre code postal");
	} else if (window.document.commandeForm.ville.value == "") {
		alert("Merci d'indiquer votre ville");
	} else if (window.document.commandeForm.email.value == "") {
		alert("Merci d'indiquer votre email");
	} else if (window.document.commandeForm.telephone.value == "") {
		alert("Merci d'indiquer votre telephone");
	} else {
		
		$('BTsubmit').disabled='disabled';
		$('BTsubmit').value='Commande en cours...';
		$('nom').disabled='disabled';
		$('email').disabled='disabled';

		new Ajax.Request('commande-coffret-cadeau-submit.php',{
			method: 'post',
			asynchronous: true,
			contentType:  'application/x-www-form-urlencoded',
			encoding:     'UTF-8',
			parameters: { nom: $F('nom'),prenom: $F('prenom'),adresse: $F('adresse'),cp: $F('cp'),ville: $F('ville'),telephone: $F('telephone'),email: $F('email'),nombeneficiaire: $F('nombeneficiaire'),prenombeneficiaire: $F('prenombeneficiaire'),adressebeneficiaire: $F('adressebeneficiaire'),cpbeneficiaire: $F('cpbeneficiaire'),villebeneficiaire: $F('villebeneficiaire'),pack1: $F('pack1'),pack2: $F('pack2'),pack3: $F('pack3'),pack4: $F('pack4'),optin: $F('optin')},
			onSuccess: function() {mailOK();},
			onFailure: function() {}
			});
	}
}



// CORRECTION DES PNG
function correctPNG() {
	if (navigateur() == "IE6") {
		for(var i=0; i<document.images.length; i++) {
			var img = document.images[i];
			var imgName = img.src.toUpperCase();
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText 
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
         img.outerHTML = strNewHTML
         i = i-1
      }

		}
	}
}





// NAVIGATION IMAGEREADY

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




// INITIALISATION AU DEPART DU SITE
function initDisplay() {
	if (document.body) {
		var larg = (document.body.clientWidth);
	} else {
		var larg = (window.innerWidth);
	}
	
	
	if (larg <= 1000) {
		larg = 1000;
		self.resizeTo(larg, 760);
		self.moveTo((screen.availWidth/2)-(larg/2), (screen.availHeight/2)-380);
	}
}
