// JavaScript Document
/* <![CDATA[ */
<!--
String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

String.prototype.replaceAll = function (toreplace, replaceby) {
	str=this;
	if (this.length<1) return str;
	else 
	{
	var idx = str.indexOf( toreplace );
    while ( idx > -1 ) {
        str = str.replace( toreplace, replaceby );
        idx = str.indexOf( toreplace );
        }
	return str;
	}
}

String.prototype.striptags = function () {
   oldString=this;
   if (oldString.length<1) return oldString;
   else
   {   
   var newString = "";
   var inTag = false;
   for(var i = 0; i < oldString.length; i++) {
   
        if(oldString.charAt(i) == '<') inTag = true;
        if(oldString.charAt(i) == '>') {
              if(oldString.charAt(i+1)=="<")
              {
              		//dont do anything
	}
	else
	{
		inTag = false;
		i++;
	}
        }
   
        if(!inTag) newString += oldString.charAt(i);

   }
  newString=newString.replace(/<&#91;^>&#93;*>/g, "");
  return newString.replace(/^\s*/, "").replace(/\s*$/, "");
  }
}

//--FIN PROTO------------------------------------------

function stripHTML(oldString) {
  return oldString.striptags();  
}

function Chr(AsciiNum) {
  return String.fromCharCode(AsciiNum)
}


function replaceAll( str, toreplace, replaceby ) {
	return str.replaceAll(toreplace, replaceby );
}

//------------------------------------------
//------------------------------------------
//------------------------------------------

function favoris() {
if ( navigator.appName != 'Microsoft Internet Explorer' )
{ window.sidebar.addPanel(document.title,document.location.href,""); }
else { window.external.AddFavorite(document.location.href, document.title); } 
}

function open_fen(page,w,h) {
if (!w) w="400";
if (!h) h="300";
in_fen=window.open(page,"ext_page","location=no,status=no,directories=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width="+w+",height="+h);
in_fen.focus();
}

var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;

var toolTipSTYLE="";


function propr_gen(objet,nom) {
var texte = nom;
 for (var i in objet ) texte =texte+"."+i+" " +objet[i] +"<br>";
return texte;
}

function checkEmail_gen(formelem) {
	if ((formelem.value != null) && (formelem.value != "") && (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(formelem.value)))
	 {return (true);}
	 else {
		alert("Votre adresse e-mail est invalide.Veuillez la ressaisir SVP.");
		if (formelem.value=="Votre E-mail") formelem.value="";
		formelem.focus();
		formelem.select();
		return (false)
	}
}

function ajax_data_exec(ptarget,data,post_exec) { 
if (!post_exec) var post_exec='';
if ((!data)||(data=="")||(!ptarget)||(ptarget=="")) return false;
ajax_data_eval(data,ptarget,post_exec);
}

function ajax_data_eval(data,ptarget,post_exec) { 
if (!post_exec) var post_exec='';
if ((!data)||(data=="")||(!ptarget)||(ptarget=="")) return false;


if (window.XMLHttpRequest) {// Firefox 
	      var xhr_object = new XMLHttpRequest(); 
		  }
   else if (window.ActiveXObject) {// OLD Internet Explorer    
		  try {
                xhr_object = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
            }
		  }
	   else { // XMLHttpRequest non supporté par le navigateur 
	   		var xhr_object = null; 
		    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	    	return; 
		    } 
	    
xhr_object.onreadystatechange = function() { 
	if(xhr_object.readyState == 4) 
	 	{	
	 
//		alert("AJAX response  :\n"+xhr_object.responseText);
							
		if (xhr_object.responseText!="") 
				{
				try {
					eval(xhr_object.responseText); // evecute le code javascript contenu dans la réponse 																																	
					}
				catch(err) 
					{
					//alert('RESPONSE ERROR :\n'+xhr_object.responseText);
					}
				}		
		if (post_exec!='') 
			{
			try {eval(post_exec);}
			catch(err) {}				
			}
		delete(xhr_object);	
		xhr_object=null;
		}	 
   } 
	  
xhr_object.open("POST", ptarget, true); 
xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); // Only for POST

xhr_object.send(data); 
}

function ajax_form_eval(form,ptarget) {
if (form) {
	var data = "formname="+form.name+"&";
	for (i=0;i<form.elements.length;i++) {
		if (
			((form.elements[i].type!="radio")&&(form.elements[i].type!="checkbox"))||
	        ((form.elements[i].type=="radio")&&(form.elements[i].checked))||
			((form.elements[i].type=="checkbox")&&(form.elements[i].checked))
			
			) data=data+form.elements[i].name+"="+(form.elements[i].value=="" ? "" : encode64(form.elements[i].value))+"&";				
		}
	} else data="rien=0";
//	alert(data);
ajax_data_eval(data,ptarget);
return false;	
}

function ajax_main_showit(data,ptarget,divname,post_exec,noHide) { 
if (!noHide) bodyHide=true; else bodyHide=false;

if (bodyHide==true) add_masqued_divs();

if (!post_exec) var post_exec='';
if (
		(!data)||(data=="")||
		(!ptarget)||(ptarget=="")||
		(!divname)||(divname=="")||
		(!document.getElementById(divname))
	) return false;

//if (document.getElementById(divname).style.display=='none') 
	{
	document.getElementById(divname).style.display='';	
	document.getElementById(divname).innerHTML='<img src="../img/loader.gif" width="24" height="24" />';
	}

if (window.XMLHttpRequest) {// Firefox 
	      var xhr_object = new XMLHttpRequest(); 
		  }
   else if (window.ActiveXObject) {// OLD Internet Explorer    
		  try {
                xhr_object = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
            }
		  }
	   else { // XMLHttpRequest non supporté par le navigateur 
	   		var xhr_object = null; 
		    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	    	return; 
		    } 
	    
xhr_object.onreadystatechange = function() { 
	if(xhr_object.readyState == 4) 
	 	{	
/*	 
		alert("AJAX response  :\n"+xhr_object.responseText);
*/				
		if (xhr_object.responseText!="") 
				{
				if (bodyHide==true) my_disablebody(divname);				
				document.getElementById(divname).innerHTML=xhr_object.responseText;
				}		
		if (post_exec!='') 
			{
			try {eval(post_exec);}
			catch(err) {}				
			}
		delete(xhr_object);	
		xhr_object=null;
		}	 
   } 
	  
xhr_object.open("POST", ptarget, true); 
xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); // Only for POST
xhr_object.send(data); 
}

function ajax_show_noteTXT_nomove(frameid,page,params,postjs,no_check_visibility) {
if (!no_check_visibility) no_check_visibility=false;
if (!postjs) var postjs="";
if 	(!document.getElementById(frameid)) return false;
if (params!="type=nohide") document.getElementById(frameid).innerHTML='<img src="../img/loader.gif" border="0">';

if (!no_check_visibility) {
	window.document.getElementById(frameid).style.visibility='visible';
	window.document.getElementById(frameid).style.display='';
}

if (window.XMLHttpRequest) {var xhr_object = new XMLHttpRequest();}
   else if (window.ActiveXObject) {try {xhr_object = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {xhr_object = new ActiveXObject("Microsoft.XMLHTTP");}}
	   else {var xhr_object = null; return;} 
	    
xhr_object.onreadystatechange = function() { 
	if(xhr_object.readyState == 4) 
	 	{																
		if ((window.document)&&(window.document.getElementById(frameid))) 
			{									
			rtxt=xhr_object.responseText;
			if (rtxt.indexOf('<script>')>0) 
				{
				postjs=rtxt.substr(rtxt.indexOf('<script>'),rtxt.length);											
				postjs=postjs.substr(0,postjs.indexOf('<'+'/script>'));											
				rtxt=rtxt.replace(postjs+'<'+'/script>','');
				postjs=postjs.replace('<script>','');											
				}  
			window.document.getElementById(frameid).innerHTML=xhr_object.responseText;
			}
		if (postjs!="") {try{eval(postjs);}catch(err) {}}			
		delete(xhr_object);	xhr_object=null;
		}
	} 
	 
xhr_object.open("POST", page+"?"+params+"", true); 
xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); // Only for POST
var data = params+"";
xhr_object.send(data); 
}

//---- add panier procs
function continueshopping(n) {
my_enablebody();	
if (document.getElementById('centered_div')) 
	s=document.getElementById('centered_div');
	else s=document.getElementById('addpan_infodiv'+n);
//s.style.visibility='hidden';
s.style.display='none';
if (document.forms['fprod'+n]) document.forms['fprod'+n].style.display='';
}

lastshown=-1;
function masqit() {
if (lastshown!=-1) {continueshopping(lastshown);lastshown=-1;}
}

function close_addpaninfodiv(n) {
if (document.getElementById('centered_div')) 
	{
	s=document.getElementById('centered_div');	
	}
	else
	{
	s=document.getElementById('addpan_infodiv'+n);	
	}

s.style.width="440px";
s.style.height="120px";
s.style.display='';	
/*
if (document.location.href.replace('/fr/','')!=document.location.href) 
	s.innerHTML='<div style="width:500px; border:2px solid #7A7EC7; padding:15px; font-weight:bold; background-color:#FFFFFF;background-image:url(../images/fond_continuer_valider.png); background-position:top right; background-repeat:no-repeat; text-align:center;">Produit ajouté au panier<br>&nbsp;<table width="100%" border="0" cellspacing="0" cellpadding="15"><tr><td align="center"><div class="formbutton_fond_jaune"><a onClick="continueshopping(\''+n+'\');" title="continuer vos achats" style=" text-decoration:none;">&nbsp;<&nbsp;Continuer&nbsp;vos&nbsp;achats</a></div></td><td align="center"><div class="formbutton_fond_jaune"><a href="panier.php" title="Finaliser votre commande" style=" text-decoration:none;">Finaliser&nbsp;votre&nbsp;commande</a></div></td></tr></table></div>';
	else s.innerHTML='<div style="width:500px; border:2px solid #7A7EC7; padding:15px; font-weight:bold; background-color:#FFFFFF;background-image:url(../images/fond_continuer_valider.png); background-position:top right; background-repeat:no-repeat; text-align:center;">Product added to your caddy<br>&nbsp;<table width="100%" border="0" cellspacing="0" cellpadding="15"><tr><td align="center"><div class="formbutton_fond_jaune"><a onClick="continueshopping(\''+n+'\');" title="continue shopping" style=" text-decoration:none;">&nbsp;<&nbsp;Continue&nbsp;shopping</a></div></td><td align="center"><div class="formbutton_fond_jaune"><a href="panier.php" title="Finalise your order" style=" text-decoration:none;">Finalise&nbsp;your&nbsp;order</a></div></td></tr></table></div>';
*/
lastshown=n;
//setTimeout("document.getElementById('addpan_infodiv"+n+"').style.visibility='hidden';",1500);
}

function just_addtp(n,idpack,qty,tartype,infoLot) {
if (!infoLot) infoLot="";
if (!tartype) tartype="pkPvt"; //pkPvt pkPvtPro pkPvtRvd1
masqit();

targetDiv='centered_div';

my_disablebody(targetDiv);

if (document.getElementById('centered_div')) 
	{	
	targetDiv='centered_div';
	}
	else
	{
	targetDiv='addpan_infodiv'+n;
	}

s=document.getElementById(targetDiv);
s.style.width="200px";
s.style.height="48px";
s.style.display='';


if (idpack*qty!=0) 
	{
	s.innerHTML="Ajout en cours..";
	s.style.visibility='visible';	
	ajax_show_noteTXT_nomove(targetDiv,'ajax_addpanier.php','adp='+idpack+'&qty='+qty+'&tartype='+tartype+'&infoLot='+infoLot,false,false);
	}	
	else
	{
	s.innerHTML='<div style="padding:8px; color:#CC0000; font-sise:16px; " title="Veuillez spécifier une quantité svp.." onmouseout="document.getElementById(\'addpan_infodiv'+n+'\').style.display=\'none\'">Veuillez spécifier<br>la quantité svp..</div>';
	}
}



function preaddtp(n) {
masqit();

yform=document.forms['fprod'+n];
//qty=yform.qty.options[yform.qty.selectedIndex].value;
qty=1;
s=document.getElementById('addpan_infodiv'+n);
s.style.width="200px";
s.style.height="48px";
s.style.display='';

if (yform.selectYe_prod.options[yform.selectYe_prod.selectedIndex].value!="") 
	{
	s.innerHTML="Ajout en cours..";
	s.style.visibility='visible';
	ajax_data_eval('adp='+yform.selectYe_prod.options[yform.selectYe_prod.selectedIndex].value+'&qty='+qty+'','ajax_addpanier.php','close_addpaninfodiv(\''+n+'\')');	
	}
	else
	{
	s.innerHTML='<div style="padding:8px;" title="Veuillez sélectionner une taille svp.." onmouseout="document.getElementById(\'addpan_infodiv'+n+'\').style.display=\'none\'">Veuillez sélectionner<br>une taille svp..</div>';
	//setTimeout("continueshopping("+n+")",1000);
	}
}

// LOGIN PROCS
//------------------- 
function trylogin(form) {
mylogin=form.mylogin.value;
mypass=form.mypass.value;

lng="Fr";
if ((form.lng)&&(form.lng.value=="En")) lng="En";

remember_me=((!form.remember_me)||((form.remember_me)&&(form.remember_me.checked))) ? 1 : 0;

stay_cnctd=0;
if (form.stay_cnctd) stay_cnctd=(form.stay_cnctd.checked) ? 1 : 0;	

// check if empty
alarm="";
if (mylogin.length<1) alarm=(lng=="Fr") ? "> Précisez votre email" : "> Precise your email";
if (mypass.length<1) alarm+=(alarm.length==0 ? '' : '<br>')+((lng=="Fr") ? "> Précisez votre mot de passe" : "> Precise your password");

if (alarm.length==0) {	

	ajax_data_exec('../scripts/ajax_try_login.php','ylg='+gocrypt(mylogin)+'&ypd='+gocrypt(mypass)+'&rmb='+remember_me+'&stc='+stay_cnctd+'');
	}
	else 
		{
		if (document.getElementById('infoconn')) document.getElementById('infoconn').innerHTML='<br>'+alarm;
			else document.location.href='identification.php';
		}
	
}
//--------------------
//---------------- crypt -----------------------------
//First things first, set up our array that we are going to use.
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + //all caps
"abcdefghijklmnopqrstuvwxyz" + //all lowercase
"0123456789+/=§!&#|-_"; // all numbers plus +/=

var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=§!&#|-_";
 
function encode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;
 
   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);
 
      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;
 
      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }
 
      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + 
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);
   
   return output;
}
 
function decode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;
 
   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   //input = input.replace(/[A-Za-z0-9]+\+\/\=\§\!\&\#\|\-\_/g, "");
   input = input.replace(/[A-Za-z0-9]+\++\/+\=+\§+\!+\&+\#+\|+\-+\_/g, "");
 
   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));
 
      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;
 
      output = output + String.fromCharCode(chr1);
 
      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);
 
   return output;
}

function aciival(input) {
str="";
var i = 0;
if (input.length>0) do {n=input.charCodeAt(i)+132-(i*3);n=(n<10 ? "00"+n : (n<100 ? "0"+n : ""+n));str=str+n;i++;} while (i < input.length);
return str;
}

function gocrypt(input) {
str="";
if (input.length>0) str=encode64(aciival(input));
return str;
}
//------------------------------------------------------

function checkEmail(email) {
	if ((email != null) && (email != "")&& (email.length > 9) && (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email)))
	 return true;
	 else return false;
}

function check_alpha(input, yediv) {	

if (!yediv) yediv="";
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
rr = input.replace(/[A-Za-z0-9]/g, "");

//alert(rr);

if (rr!="") test=false; else test=true;

if ((!test)&&(yediv!="")&&(document.getElementById(yediv))) {
	document.getElementById(yediv).innerHTML="Caractères interdits<br>Utilisez uniquement des caractères alphabétique et/ou des chiffres (0-9)";
	}
return test;
}
//------------------- 
function go_inscription(form) {
ytusername=form.ytusername.value;

document.getElementById('isdispodiv').innerHTML='&nbsp;';
document.getElementById('isinfo').innerHTML='&nbsp;';

// check username only A-Z et 0-9
if (check_alpha(ytusername,'isdispodiv')==true) 
	{
	ytgenre=form.ytgenre.value;
	ytcountry=form.ytcountry.value;
	ytanniv=form.a_ann.value+'-'+form.m_ann.value+'-'+form.j_ann.value;

	// no check if empty
	ajax_data_exec('../scripts/ajax_creercompte.php','ylg='+ytusername+'&yco='+ytcountry+'&ybd='+ytanniv+'&ygr='+ytgenre+'');
	}
}
//--------------------

//-- INSCRIPTION PROC --------
//------------------- 
function tryinscription(form) {
	
mylogin=form.mylogin.value;
mypass=form.mypass.value;

lng="Fr";
if ((form.lng)&&(form.lng.value=="En")) lng="En";

conf_mylogin=form.conf_mylogin.value;
conf_mypass=form.conf_mypass.value;

inputchapkacode=form.inputchapkacode.value;

// check if empty
alarm="";

if (mylogin.length<1) alarm=(lng=="Fr") ? "> Précisez votre email" : "> Precise your email";
	else 
		{
		if (!checkEmail(mylogin)) alarm+=(alarm.length==0 ? '' : '<br>')+((lng=="Fr") ? "> Email incorrect" : "> Email incorrect");
			else if ((conf_mylogin.length<1)||(conf_mylogin!=mylogin)) alarm+=(alarm.length==0 ? '' : '<br>')+((lng=="Fr") ? "> Confirmation email incorrecte" : "> incorrect email confirmation");
		}

if (mypass.length<1) alarm+=(alarm.length==0 ? '' : '<br>')+((lng=="Fr") ? "> Précisez votre mot de passe" : "> Precise your password");
	else if ((conf_mypass.length<1)||(conf_mypass!=mypass)) alarm+=(alarm.length==0 ? '' : '<br>')+((lng=="Fr") ? "> Confirmation mot de passe incorrecte" : "> incorrect password confirmation");

if (inputchapkacode=='') alarm+=(alarm.length==0 ? '' : '<br>')+((lng=="Fr") ? "> Code vide" : "> Code is empty");

if (alarm.length==0) {	

	ajax_data_exec('../scripts/ajax_try_create.php','ylg='+gocrypt(mylogin)+'&ypd='+gocrypt(mypass)+'&chp='+gocrypt(inputchapkacode)+'');
	}
	else document.getElementById('infocrea').innerHTML='<br>'+alarm;
}
//--------------------

function check_fiche_client(form) {
	

// check if empty
alarm="";

if (!checkEmail(form.elements['cdEmail'].value)) alarm+=(alarm.length==0 ? '' : '<br>')+"> Email manquant ou incorrect";

if (form.elements['cdCivilite'].value=="") {alarm+=(alarm.length==0 ? '' : '<br>')+"> Civilité manquante";form.elements['cdCivilite'].className="input_alarm";}
if (form.elements['cdNom'].value=="") {alarm+=(alarm.length==0 ? '' : '<br>')+"> Nom manquant";form.elements['cdNom'].className="input_alarm";}
if (form.elements['cdPrenom'].value=="") {alarm+=(alarm.length==0 ? '' : '<br>')+"> Prénom manquant";form.elements['cdPrenom'].className="input_alarm";}
if (form.elements['cdAdresse'].value=="") {alarm+=(alarm.length==0 ? '' : '<br>')+"> Adresse manquante";form.elements['cdAdresse'].className="input_alarm";}
if (form.elements['cdCp'].value=="") {alarm+=(alarm.length==0 ? '' : '<br>')+"> Code postal manquant";form.elements['cdCp'].className="input_alarm";}
if (form.elements['cdVille'].value=="") {alarm+=(alarm.length==0 ? '' : '<br>')+"> Ville manquant";form.elements['cdVille'].className="input_alarm";}
if (form.elements['cdPays'].value=="") {alarm+=(alarm.length==0 ? '' : '<br>')+"> Pays manquant";form.elements['cdPays'].className="input_alarm";}
if (form.elements['cdTel'].value=="") {alarm+=(alarm.length==0 ? '' : '<br>')+"> Téléphone manquant";form.elements['cdTel'].className="input_alarm";}

if (form.elements['cdUNCryptedPassw'].value.length<6) {alarm+=(alarm.length==0 ? '' : '<br>')+"> mot de passe trop court (au moins 6 caractères)";form.elements['cdUNCryptedPassw'].className="input_alarm";}
if ((form.elements['tp_cdDateNaissance'].value=="")||(form.elements['tp_cdDateNaissance'].value=="01/01/1970")) {alarm+=(alarm.length==0 ? '' : '<br>')+"> date de naissance invalide";form.elements['tp_cdDateNaissance'].className="input_alarm";}

//---------- check if pro
if (form.elements['cdType'].value*1!=0) 
	{
	if (replaceAll(form.elements['cdRaisonSociale'].value, " ", "")=="") {alarm+=(alarm.length==0 ? '' : '<br>')+"> Raison sociale manquante";	form.elements['cdRaisonSociale'].className="input_alarm";}

	if ((replaceAll(form.elements['cdCodeTva'].value, " ", "")=="")&&(replaceAll(form.elements['cd_SIRET'].value, " ", "")=="")) 
		{
		form.elements['cdCodeTva'].className="input_alarm";
		form.elements['cd_SIRET'].className="input_alarm";
		alarm+=(alarm.length==0 ? '' : '<br>')+"> Code TVA ou SIRET manquant";
		}
	} 


if (alarm.length==0) {	

	form.elements['cdTPro'].value=(form.elements['cdType'].value*1!=0 ? 1 : 0);
	// check if email not already here again and date naissance valide // needs id
	ajax_data_exec('../scripts/ajax_controle_create.php','id='+form.elements['idContact'].value+'&ylg='+gocrypt(form.elements['cdEmail'].value)+'&ypd='+gocrypt(form.elements['cdUNCryptedPassw'].value)+'&dte='+form.elements['tp_cdDateNaissance'].value+'');

	}
	else 
	{
	document.getElementById('infocrea').innerHTML='<div style="width:280px;background-color:#FFFFFF; border:1px solid #FF0000; padding:5px;">ERREURS : <br>'+alarm+'</div>';
	return false;
	}
}
//--------------------

function show_alert(yediv,msg) {
if (document.getElementById(yediv))	
	{
	document.getElementById(yediv).style.display='';
	document.getElementById(yediv).innerHTML=msg;
	}
}

function open_bdcomm(idCommande,ptpe) {
if (document.location.href.replace('/fr/','')!=document.location.href) 
	document.getElementById('main_plain').innerHTML='<br>Votre commande à été enregistrée.<br><br>Vous pouvez suivre l\'avancement de celle-ci dans votre <a href="compte_perso.php">&laquo;espace personnel&raquo;</a><br>&nbsp;<br><iframe id="bdcomm" src="final_commandeV2.php?idC='+idCommande+'&stt='+(ptpe*1==0 ? "-2" : "-1")+'&ptp='+ptpe+'" width="99%" frameborder="0" allowtransparency="false" class="transparent_block" marginwidth="0" height="800" marginheight="0" scrolling="yes" style="border:1px solid #C0A956; margin-right:12px;margin-bottom:12px;"></iframe>';
	else document.getElementById('main_plain').innerHTML='<br>Yout order has been validated.<br><br>You can follow the progress of it in your <a href="compte_perso.php">&laquo;personal space&raquo;</a><br>&nbsp;<br><iframe id="bdcomm" src="final_commandeV2.php?idC='+idCommande+'&stt='+(ptpe*1==0 ? "-2" : "-1")+'&ptp='+ptpe+'" width="99%" frameborder="0" allowtransparency="false" class="transparent_block" marginwidth="0" height="800" marginheight="0" scrolling="yes" style="border:1px solid #C0A956; margin-right:12px;margin-bottom:12px;"></iframe>';
}


function add_masqued_divs() {

	if (!document.getElementById('disable_bodydiv')) 
		{
		var disable_bodydiv = document.createElement("div");
		disable_bodydiv.style.zIndex=0;
		disable_bodydiv.id = 'disable_bodydiv';
		self.document.body.appendChild(disable_bodydiv);
		}
		
	if (!document.getElementById('centered_div')) 
		{
		var centered_div = document.createElement("div");
		centered_div.id = 'centered_div';
		disable_bodydiv.style.zIndex=1;
		//centered_div.style.className = 'centered_div';
		self.document.body.appendChild(centered_div);
		}
		
}

function my_enablebody() {
	if (document.getElementById('disable_bodydiv'))
	{
	s=document.getElementById('disable_bodydiv');
	s.style.display="none";
	s.style.height="0px";
	s.style.zIndex="0";
	
	if (document.all) 
		{		
		if (document.getElementById("body_drop_menu_place")) 
			{
			document.getElementById("body_drop_menu_place").style.position="";
			document.getElementById("body_drop_menu_place").style.zIndex="";
			
			}
		if (document.getElementById("form_search")) 
			{			
			document.getElementById("form_search").style.zIndex="";
			document.getElementById("form_search").style.visibility="visible";
			}
		}
	}
	}
	
	
function my_disablebody(butId) {
	

	add_masqued_divs();
	
	s=document.getElementById('disable_bodydiv');
	s.style.display="";
	s.style.height="100%";
	
	if (document.all) 
		{
		s.style.zIndex=1;		
		document.getElementById("centered_div").style.zIndex=1;
		
		if (document.getElementById("body_drop_menu_place")) 
			{
			s=document.getElementById("body_drop_menu_place");
			s.style.position="relative";
			s.style.zIndex="-1";
			}
		if (document.getElementById("form_search")) 
			{
			s=document.getElementById("form_search");
			s.style.zIndex="-1";
			s.style.visibility="hidden";
			}
		//alert(document.getElementById("centered_div").style.zIndex);
		} 
		else s.style.zIndex="3000";
	
	if (document.getElementById(butId)) 
		{
		s=document.getElementById(butId);
		if (document.all) s.style.zIndex=1; else s.style.zIndex="999999";
		//alert(document.getElementById("disable_bodydiv").style.zIndex+' '+document.getElementById("centered_div").style.zIndex);
		}
	}
	
	
//Encode une chaîne
function htmlentities(texte) {
	texte = texte.replace(/"/g,'&quot;'); // 34 22
	texte = texte.replace(/&/g,'&amp;'); // 38 26
	texte = texte.replace(/\'/g,'&#39;'); // 39 27
	texte = texte.replace(/</g,'&lt;'); // 60 3C
	texte = texte.replace(/>/g,'&gt;'); // 62 3E
	texte = texte.replace(/\^/g,'&circ;'); // 94 5E
	texte = texte.replace(/‘/g,'&lsquo;'); // 145 91
	texte = texte.replace(/’/g,'&rsquo;'); // 146 92
	texte = texte.replace(/“/g,'&ldquo;'); // 147 93
	texte = texte.replace(/”/g,'&rdquo;'); // 148 94
	texte = texte.replace(/•/g,'&bull;'); // 149 95
	texte = texte.replace(/–/g,'&ndash;'); // 150 96
	texte = texte.replace(/—/g,'&mdash;'); // 151 97
	texte = texte.replace(/˜/g,'&tilde;'); // 152 98
	texte = texte.replace(/™/g,'&trade;'); // 153 99
	texte = texte.replace(/š/g,'&scaron;'); // 154 9A
	texte = texte.replace(/›/g,'&rsaquo;'); // 155 9B
	texte = texte.replace(/œ/g,'&oelig;'); // 156 9C
	texte = texte.replace(//g,'&#357;'); // 157 9D
	texte = texte.replace(/ž/g,'&#382;'); // 158 9E
	texte = texte.replace(/Ÿ/g,'&Yuml;'); // 159 9F
	texte = texte.replace(/ /g,'&nbsp;'); // 160 A0
	texte = texte.replace(/¡/g,'&iexcl;'); // 161 A1
	texte = texte.replace(/¢/g,'&cent;'); // 162 A2
	texte = texte.replace(/£/g,'&pound;'); // 163 A3
	texte = texte.replace(/ /g,'&curren;'); // 164 A4
	texte = texte.replace(/¥/g,'&yen;'); // 165 A5
	texte = texte.replace(/¦/g,'&brvbar;'); // 166 A6
	texte = texte.replace(/§/g,'&sect;'); // 167 A7
	texte = texte.replace(/¨/g,'&uml;'); // 168 A8
	texte = texte.replace(/©/g,'&copy;'); // 169 A9
	texte = texte.replace(/ª/g,'&ordf;'); // 170 AA
	texte = texte.replace(/«/g,'&laquo;'); // 171 AB
	texte = texte.replace(/¬/g,'&not;'); // 172 AC
	texte = texte.replace(/­/g,'&shy;'); // 173 AD
	texte = texte.replace(/®/g,'&reg;'); // 174 AE
	texte = texte.replace(/¯/g,'&macr;'); // 175 AF
	texte = texte.replace(/°/g,'&deg;'); // 176 B0
	texte = texte.replace(/±/g,'&plusmn;'); // 177 B1
	texte = texte.replace(/²/g,'&sup2;'); // 178 B2
	texte = texte.replace(/³/g,'&sup3;'); // 179 B3
	texte = texte.replace(/´/g,'&acute;'); // 180 B4
	texte = texte.replace(/µ/g,'&micro;'); // 181 B5
	texte = texte.replace(/¶/g,'&para'); // 182 B6
	texte = texte.replace(/·/g,'&middot;'); // 183 B7
	texte = texte.replace(/¸/g,'&cedil;'); // 184 B8
	texte = texte.replace(/¹/g,'&sup1;'); // 185 B9
	texte = texte.replace(/º/g,'&ordm;'); // 186 BA
	texte = texte.replace(/»/g,'&raquo;'); // 187 BB
	texte = texte.replace(/¼/g,'&frac14;'); // 188 BC
	texte = texte.replace(/½/g,'&frac12;'); // 189 BD
	texte = texte.replace(/¾/g,'&frac34;'); // 190 BE
	texte = texte.replace(/¿/g,'&iquest;'); // 191 BF
	texte = texte.replace(/À/g,'&Agrave;'); // 192 C0
	texte = texte.replace(/Á/g,'&Aacute;'); // 193 C1
	texte = texte.replace(/Â/g,'&Acirc;'); // 194 C2
	texte = texte.replace(/Ã/g,'&Atilde;'); // 195 C3
	texte = texte.replace(/Ä/g,'&Auml;'); // 196 C4
	texte = texte.replace(/Å/g,'&Aring;'); // 197 C5
	texte = texte.replace(/Æ/g,'&AElig;'); // 198 C6
	texte = texte.replace(/Ç/g,'&Ccedil;'); // 199 C7
	texte = texte.replace(/È/g,'&Egrave;'); // 200 C8
	texte = texte.replace(/É/g,'&Eacute;'); // 201 C9
	texte = texte.replace(/Ê/g,'&Ecirc;'); // 202 CA
	texte = texte.replace(/Ë/g,'&Euml;'); // 203 CB
	texte = texte.replace(/Ì/g,'&Igrave;'); // 204 CC
	texte = texte.replace(/Í/g,'&Iacute;'); // 205 CD
	texte = texte.replace(/Î/g,'&Icirc;'); // 206 CE
	texte = texte.replace(/Ï/g,'&Iuml;'); // 207 CF
	texte = texte.replace(/Ð/g,'&ETH;'); // 208 D0
	texte = texte.replace(/Ñ/g,'&Ntilde;'); // 209 D1
	texte = texte.replace(/Ò/g,'&Ograve;'); // 210 D2
	texte = texte.replace(/Ó/g,'&Oacute;'); // 211 D3
	texte = texte.replace(/Ô/g,'&Ocirc;'); // 212 D4
	texte = texte.replace(/Õ/g,'&Otilde;'); // 213 D5
	texte = texte.replace(/Ö/g,'&Ouml;'); // 214 D6
	texte = texte.replace(/×/g,'&times;'); // 215 D7
	texte = texte.replace(/Ø/g,'&Oslash;'); // 216 D8
	texte = texte.replace(/Ù/g,'&Ugrave;'); // 217 D9
	texte = texte.replace(/Ú/g,'&Uacute;'); // 218 DA
	texte = texte.replace(/Û/g,'&Ucirc;'); // 219 DB
	texte = texte.replace(/Ü/g,'&Uuml;'); // 220 DC
	texte = texte.replace(/Ý/g,'&Yacute;'); // 221 DD
	texte = texte.replace(/Þ/g,'&THORN;'); // 222 DE
	texte = texte.replace(/ß/g,'&szlig;'); // 223 DF
	texte = texte.replace(/à/g,'&agrave;'); // 224 E0
	texte = texte.replace(/á/g,'&aacute;'); // 225 E1
	texte = texte.replace(/â/g,'&acirc;'); // 226 E2
	texte = texte.replace(/ã/g,'&atilde;'); // 227 E3
	texte = texte.replace(/ä/g,'&auml;'); // 228 E4
	texte = texte.replace(/å/g,'&aring;'); // 229 E5
	texte = texte.replace(/æ/g,'&aelig;'); // 230 E6
	texte = texte.replace(/ç/g,'&ccedil;'); // 231 E7
	texte = texte.replace(/è/g,'&egrave;'); // 232 E8
	texte = texte.replace(/é/g,'&eacute;'); // 233 E9
	texte = texte.replace(/ê/g,'&ecirc;'); // 234 EA
	texte = texte.replace(/ë/g,'&euml;'); // 235 EB
	texte = texte.replace(/ì/g,'&igrave;'); // 236 EC
	texte = texte.replace(/í/g,'&iacute;'); // 237 ED
	texte = texte.replace(/î/g,'&icirc;'); // 238 EE
	texte = texte.replace(/ï/g,'&iuml;'); // 239 EF
	texte = texte.replace(/ð/g,'&eth;'); // 240 F0
	texte = texte.replace(/ñ/g,'&ntilde;'); // 241 F1
	texte = texte.replace(/ò/g,'&ograve;'); // 242 F2
	texte = texte.replace(/ó/g,'&oacute;'); // 243 F3
	texte = texte.replace(/ô/g,'&ocirc;'); // 244 F4
	texte = texte.replace(/õ/g,'&otilde;'); // 245 F5
	texte = texte.replace(/ö/g,'&ouml;'); // 246 F6
	texte = texte.replace(/÷/g,'&divide;'); // 247 F7
	texte = texte.replace(/ø/g,'&oslash;'); // 248 F8
	texte = texte.replace(/ù/g,'&ugrave;'); // 249 F9
	texte = texte.replace(/ú/g,'&uacute;'); // 250 FA
	texte = texte.replace(/û/g,'&ucirc;'); // 251 FB
	texte = texte.replace(/ü/g,'&uuml;'); // 252 FC
	texte = texte.replace(/ý/g,'&yacute;'); // 253 FD
	texte = texte.replace(/þ/g,'&thorn;'); // 254 FE
	texte = texte.replace(/ÿ/g,'&yuml;'); // 255 FF
	return texte;
}
//Décode une chaîne
function html_entity_decode(texte) {
	texte = texte.replace(/&quot;/g,'"'); // 34 22
	texte = texte.replace(/&amp;/g,'&'); // 38 26	
	texte = texte.replace(/&#39;/g,"'"); // 39 27
	texte = texte.replace(/&lt;/g,'<'); // 60 3C
	texte = texte.replace(/&gt;/g,'>'); // 62 3E
	texte = texte.replace(/&circ;/g,'^'); // 94 5E
	texte = texte.replace(/&lsquo;/g,'‘'); // 145 91
	texte = texte.replace(/&rsquo;/g,'’'); // 146 92
	texte = texte.replace(/&ldquo;/g,'“'); // 147 93
	texte = texte.replace(/&rdquo;/g,'”'); // 148 94
	texte = texte.replace(/&bull;/g,'•'); // 149 95
	texte = texte.replace(/&ndash;/g,'–'); // 150 96
	texte = texte.replace(/&mdash;/g,'—'); // 151 97
	texte = texte.replace(/&tilde;/g,'˜'); // 152 98
	texte = texte.replace(/&trade;/g,'™'); // 153 99
	texte = texte.replace(/&scaron;/g,'š'); // 154 9A
	texte = texte.replace(/&rsaquo;/g,'›'); // 155 9B
	texte = texte.replace(/&oelig;/g,'œ'); // 156 9C
	texte = texte.replace(/&#357;/g,''); // 157 9D
	texte = texte.replace(/&#382;/g,'ž'); // 158 9E
	texte = texte.replace(/&Yuml;/g,'Ÿ'); // 159 9F
	texte = texte.replace(/&nbsp;/g,' '); // 160 A0
	texte = texte.replace(/&iexcl;/g,'¡'); // 161 A1
	texte = texte.replace(/&cent;/g,'¢'); // 162 A2
	texte = texte.replace(/&pound;/g,'£'); // 163 A3
	texte = texte.replace(/&curren;/g,' '); // 164 A4
	texte = texte.replace(/&yen;/g,'¥'); // 165 A5
	texte = texte.replace(/&brvbar;/g,'¦'); // 166 A6
	texte = texte.replace(/&sect;/g,'§'); // 167 A7
	texte = texte.replace(/&uml;/g,'¨'); // 168 A8
	texte = texte.replace(/&copy;/g,'©'); // 169 A9
	texte = texte.replace(/&ordf;/g,'ª'); // 170 AA
	texte = texte.replace(/&laquo;/g,'«'); // 171 AB
	texte = texte.replace(/&not;/g,'¬'); // 172 AC
	texte = texte.replace(/&shy;/g,'­'); // 173 AD
	texte = texte.replace(/&reg;/g,'®'); // 174 AE
	texte = texte.replace(/&macr;/g,'¯'); // 175 AF
	texte = texte.replace(/&deg;/g,'°'); // 176 B0
	texte = texte.replace(/&plusmn;/g,'±'); // 177 B1
	texte = texte.replace(/&sup2;/g,'²'); // 178 B2
	texte = texte.replace(/&sup3;/g,'³'); // 179 B3
	texte = texte.replace(/&acute;/g,'´'); // 180 B4
	texte = texte.replace(/&micro;/g,'µ'); // 181 B5
	texte = texte.replace(/&para/g,'¶'); // 182 B6
	texte = texte.replace(/&middot;/g,'·'); // 183 B7
	texte = texte.replace(/&cedil;/g,'¸'); // 184 B8
	texte = texte.replace(/&sup1;/g,'¹'); // 185 B9
	texte = texte.replace(/&ordm;/g,'º'); // 186 BA
	texte = texte.replace(/&raquo;/g,'»'); // 187 BB
	texte = texte.replace(/&frac14;/g,'¼'); // 188 BC
	texte = texte.replace(/&frac12;/g,'½'); // 189 BD
	texte = texte.replace(/&frac34;/g,'¾'); // 190 BE
	texte = texte.replace(/&iquest;/g,'¿'); // 191 BF
	texte = texte.replace(/&Agrave;/g,'À'); // 192 C0
	texte = texte.replace(/&Aacute;/g,'Á'); // 193 C1
	texte = texte.replace(/&Acirc;/g,'Â'); // 194 C2
	texte = texte.replace(/&Atilde;/g,'Ã'); // 195 C3
	texte = texte.replace(/&Auml;/g,'Ä'); // 196 C4
	texte = texte.replace(/&Aring;/g,'Å'); // 197 C5
	texte = texte.replace(/&AElig;/g,'Æ'); // 198 C6
	texte = texte.replace(/&Ccedil;/g,'Ç'); // 199 C7
	texte = texte.replace(/&Egrave;/g,'È'); // 200 C8
	texte = texte.replace(/&Eacute;/g,'É'); // 201 C9
	texte = texte.replace(/&Ecirc;/g,'Ê'); // 202 CA
	texte = texte.replace(/&Euml;/g,'Ë'); // 203 CB
	texte = texte.replace(/&Igrave;/g,'Ì'); // 204 CC
	texte = texte.replace(/&Iacute;/g,'Í'); // 205 CD
	texte = texte.replace(/&Icirc;/g,'Î'); // 206 CE
	texte = texte.replace(/&Iuml;/g,'Ï'); // 207 CF
	texte = texte.replace(/&ETH;/g,'Ð'); // 208 D0
	texte = texte.replace(/&Ntilde;/g,'Ñ'); // 209 D1
	texte = texte.replace(/&Ograve;/g,'Ò'); // 210 D2
	texte = texte.replace(/&Oacute;/g,'Ó'); // 211 D3
	texte = texte.replace(/&Ocirc;/g,'Ô'); // 212 D4
	texte = texte.replace(/&Otilde;/g,'Õ'); // 213 D5
	texte = texte.replace(/&Ouml;/g,'Ö'); // 214 D6
	texte = texte.replace(/&times;/g,'×'); // 215 D7
	texte = texte.replace(/&Oslash;/g,'Ø'); // 216 D8
	texte = texte.replace(/&Ugrave;/g,'Ù'); // 217 D9
	texte = texte.replace(/&Uacute;/g,'Ú'); // 218 DA
	texte = texte.replace(/&Ucirc;/g,'Û'); // 219 DB
	texte = texte.replace(/&Uuml;/g,'Ü'); // 220 DC
	texte = texte.replace(/&Yacute;/g,'Ý'); // 221 DD
	texte = texte.replace(/&THORN;/g,'Þ'); // 222 DE
	texte = texte.replace(/&szlig;/g,'ß'); // 223 DF
	texte = texte.replace(/&agrave;/g,'à'); // 224 E0
	texte = texte.replace(/&aacute;/g,'á'); // 225 E1
	texte = texte.replace(/&acirc;/g,'â'); // 226 E2
	texte = texte.replace(/&atilde;/g,'ã'); // 227 E3
	texte = texte.replace(/&auml;/g,'ä'); // 228 E4
	texte = texte.replace(/&aring;/g,'å'); // 229 E5
	texte = texte.replace(/&aelig;/g,'æ'); // 230 E6
	texte = texte.replace(/&ccedil;/g,'ç'); // 231 E7
	texte = texte.replace(/&egrave;/g,'è'); // 232 E8
	texte = texte.replace(/&eacute;/g,'é'); // 233 E9
	texte = texte.replace(/&ecirc;/g,'ê'); // 234 EA
	texte = texte.replace(/&euml;/g,'ë'); // 235 EB
	texte = texte.replace(/&igrave;/g,'ì'); // 236 EC
	texte = texte.replace(/&iacute;/g,'í'); // 237 ED
	texte = texte.replace(/&icirc;/g,'î'); // 238 EE
	texte = texte.replace(/&iuml;/g,'ï'); // 239 EF
	texte = texte.replace(/&eth;/g,'ð'); // 240 F0
	texte = texte.replace(/&ntilde;/g,'ñ'); // 241 F1
	texte = texte.replace(/&ograve;/g,'ò'); // 242 F2
	texte = texte.replace(/&oacute;/g,'ó'); // 243 F3
	texte = texte.replace(/&ocirc;/g,'ô'); // 244 F4
	texte = texte.replace(/&otilde;/g,'õ'); // 245 F5
	texte = texte.replace(/&ouml;/g,'ö'); // 246 F6
	texte = texte.replace(/&divide;/g,'÷'); // 247 F7
	texte = texte.replace(/&oslash;/g,'ø'); // 248 F8
	texte = texte.replace(/&ugrave;/g,'ù'); // 249 F9
	texte = texte.replace(/&uacute;/g,'ú'); // 250 FA
	texte = texte.replace(/&ucirc;/g,'û'); // 251 FB
	texte = texte.replace(/&uuml;/g,'ü'); // 252 FC
	texte = texte.replace(/&yacute;/g,'ý'); // 253 FD
	texte = texte.replace(/&thorn;/g,'þ'); // 254 FE
	texte = texte.replace(/&yuml;/g,'ÿ'); // 255 FF
	return texte;
}	
	
//-----------------------------------------------------------------
/*
//-- MOUSE POSITION --------------------------------------------------------------
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;

var tempX = 0;
var tempY = 0;

function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
}
else {  // grab the x-y pos.s if browser is NS
tempX = e.pageX;
tempY = e.pageY;
}  

if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}  
//document.Show.MouseX.value = tempX;
//document.Show.MouseY.value = tempY;
return true;
}	
*/

function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}



//-------------------------------------------------------	
window.name="canibou";
//-->
/* ]]> */
