//--- Début de SCRIPT Fonctions et Scripts Pieds de page ----
//-----------------------------------------------------------------------------

//***************************************************************************************************
// Copyright (c) 2008, Multivix Technologies
// Copyright (c) 2008-2009, Multivix Technologies (r)
// Toute Reproduction, Copie, Modification, même partielle du code est soumise à accord préalable.
// www.multivix.tech@free.fr
// Basic code has been developed by Multivix Technologies.
// Further development and coding by Multivix Technologies.
//***************************************************************************************************

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

//-------- Fonctions Traitement des Noms de Pages -----------------------------
//-----------------------------------------------------------------------------    
//nouvel objet date
var aujourdhui = new Date() ;
//nouvel objet date
var expdate = new Date() ;
//plus an an à partir d'aujourdh'ui le cookie ne s'efface jamais
expdate.setTime( aujourdhui.getTime() + ( 3600 ) ) ;

    
			var VarPages = (window.location.href.split("/")[(window.location.href.split("/").length - 1)]);

//alert(VarPages);
var VarPays = (VarPages.split("_"));
//alert("VarPays : " + VarPays[0] );
VarPays = document.getElementById("country").getAttribute('name'); //VarPays[0];

	   
document.cookie = "VarPages=" + VarPages + ";expires=" + expdate.toGMTString() ;
			
//alert("function Traitement TestNomPage Début");

		var texte = VarPages ;
	   		
		var xhr_object = null; 
	     
	   if(window.XMLHttpRequest) // Firefox 
	      xhr_object = new XMLHttpRequest(); 
	   else if(window.ActiveXObject) // Internet Explorer 
	      xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	   else { // XMLHttpRequest non supporté par le navigateur 
	      alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	      //return; 
	   } 
	 
	   xhr_object.open("POST", "./TestNomPage.php", true);
	     
	   xhr_object.onreadystatechange = function() { 
	      if(xhr_object.readyState == 4) {
			 //alert(xhr_object.responseText); // DEBUG MODE
			 // --- ICI le retour (c'est à dire tout ce qui est écrit dans le fichier de traitement)
			 // --- est interprété, donc il suffi d'écrire du code JS dans traitement.php pour
			 // --- qu'il soit interprété au retour.
	         //eval(xhr_object.responseText);
	         //document.getElementById("CompanyPassword").value = (GetCookieVar ("Pass"));
setTimeout("IdentificationClient ()",250)
		  }
	   } 
	 
	   xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	   // --- ICI TU PASSE TES ARGUMENTS AU SCRIPT :
	   var data = "VarPages=" + texte  + "&VarPays=" + VarPays;
	   xhr_object.send(data);
	   
//alert("function Traitement TestNomPage Fin");


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

function getCookieVal(offset)
{

var endstr=document.cookie.indexOf (";", offset);
if (endstr==-1) endstr=document.cookie.length;
return unescape(document.cookie.substring(offset, endstr)); 
}

 
//récupère la valeur du cookie
function GetCookieVar (nom)
{
var arg=nom+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while (i<clen)
{

var j=i+alen;
if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
i=document.cookie.indexOf(" ",i)+1;
if (i==0) break;
}
//alert("Valeur inconnue")
return "";

}

function IdentificationClient ()
{
//alert ("Debut function IdentificationClient");
VarPays = document.getElementById("country").getAttribute('name');
VarAction = (GetCookieVar ("VarAction"));
VarPseudo = (GetCookieVar ("Pseudo"));
SessionWB = (GetCookieVar ("SessionWB"));
DeconnecterClient = "DeconnecterClient.php?VarPays="+VarPays;

PageIdentification = (GetCookieVar ("PageIdentification"));
PageIdentificationEchoue = (GetCookieVar ("PageIdentificationEchoue"));
PageEnregistrement = (GetCookieVar ("PageEnregistrement"));
PageValidEnregistrement = (GetCookieVar ("PageValidEnregistrement"));
PageMotdePassOublie = (GetCookieVar ("PageMotdePassOublie"));
PageMonCompte = (GetCookieVar ("PageMonCompte"));
VarPseudo = (GetCookieVar ("Pseudo"));

//alert ("VarPays  = " + VarPays );

 //var NomPage = window.location.href.split("/");
//			alert (NomPage[(NomPage.length - 1)]);

		//var VarPages = (window.location.href.split("/")[(window.location.href.split("/").length - 1)]);			
			//alert (VarPages);
		var VarPagesRef = (window.location.href.split("/")[(window.location.href.split("/").length - 1)]);			
		var ExtPage = (VarPagesRef.split("."))[1];						
					
					if (VarPages == (VarPays + "_cart." + ExtPage)) 
					{ //alert("VarPages == PageCommande1");
					VarPages = ("PageCommande1");	   					
//PageCommande1();
ClientIdentifier ();					
					}else{
						if (VarPages == (VarPays + "_cart_step1." + ExtPage))
						{ //alert("VarPages == PageCommande2");
						VarPages = ("PageCommande2");
ClientIdentifier ();										
						}else{
							//alert ("ExtPage : " + ExtPage);	//  php?&coupon=BDR10				
							if (VarPages == (VarPays + "_cart_step2." + ExtPage))
							{ //alert("VarPages == PageCommande3");
								VarPages = ("PageCommande3");
ClientIdentifier ();								
var VarPseudo = (GetCookieVar ("Pseudo"));
if ((GetCookieVar ("Pseudo")) == "")
{ //alert("Client Non Identifier! ");

//  if (confirm(" Bonjour visiteur, vous n'êtes pas encore enregistré(e).\n Voulez-vous que nous vous enregistrions?\n Cela vous permettra de consulter votre historique de commandes et facilement modifier vos coordonnées.\n\n Hello visitor, you are not yet registered. \n Would you like us you registered? \n This will allow you to view your history of commands and easily change your details. \n\n Hallo bezoeker, u bent nog niet geregistreerd. \n Wilt u dat wij u geregistreerd? \n Dit zal u toelaten om uw geschiedenis van de commando's en gemakkelijk uw gegevens wijzigen. \n\n Hola visitante, que aún no se ha registrado(a). \n Deseas nos estás registrado(a)? \n Esto le permitirá ver el historial de comandos y cambiar fácilmente sus datos.")) {
//	javascript: location.href = (PageEnregistrement);
		//    alert("oui")
//  }
//  else {
		//    alert("non")
//  }

}else{
 //Traitement();
setTimeout("PageCommande3()",250)
//setTimeout("Traitement1()",450)
//setTimeout("EffaceCookies()",650)
}

							}else{
								if (VarPages == (VarPays + "_cart_step3." + ExtPage))
								{ //alert("VarPages == PageCommande4");
								VarPages = ("PageCommande4");
ClientIdentifier ();
setTimeout("SauveCdeTemp()",250)	
																										
								}else{
								
									if (VarPages == (VarPays + "_cart_step4." + ExtPage))
									{ //alert("VarPages == PageCommande5");
										VarPages = ("PageCommande5");
ClientIdentifier ();
//SauveCdeHistoClient ();																				
									}else{
									
									if (VarPages == (PageMotdePassOublie))
									{ //alert("VarPages == PageMotdePassOublie");
										//VarPages = ("PageMotdePassOublie");					
ClientPasIdentifier ();					
									}else{
									
									if (VarPages == (PageMonCompte))
									{ //alert("VarPages == PageMonCompte");
										//VarPages = ("PageMonCompte");					
															
if ((GetCookieVar ("Pseudo")) == "")
{
var VoirPasvoir = "none";
alert ("Vous devez vous enregistrer pour pouvoir faire vos modifications, nous vous redirigeons vers la page voulue.")
javascript: location.href = (PageIdentification);
}else{
ClientIdentifier ();
setTimeout("PageModification()",50)
	}										
									}else{
																		
									if (VarPages == (PageEnregistrement))
										{ //alert("VarPages == PageEnregistrement");
										//VarPages = ("PageEnregistrement");
ClientPasIdentifier ();																				
											}else{	
																				
											if (VarPages == (PageIdentification))
												{ //alert("VarPages == PageIdentification");
												//ClientPasIdentifier ();
												//VarPages = ("PageIdentification");					

//alert("function PageIdentification");

Varmotdepass = GetCookieVar ("Pass");

if (Varmotdepass == "0"){
//Rien
}else{
if (Varmotdepass == ""){
//alert("if = Null");
ClientPasIdentifier ();
}else{

//var exp_reg = /%40/gi; 
//document.messagerie.login.value = (GetCookie ("Email").replace(exp_reg, "@"));

document.getElementById("EMail").value = GetCookieVar ("EMail");
document.getElementById("Pseudo").value = GetCookieVar ("Pseudo");
document.getElementById("Pass").value = GetCookieVar ("Pass");

varzero="0";
var aujourdhui = new Date() ;
var expdate = new Date() ;
//plus an an à partir d'aujourdh'ui le cookie ne s'efface jamais
expdate.setTime( aujourdhui.getTime() + ( 1*60*60*1000 ) ) ;
document.cookie = "Pass=" + varzero + ";expires=" + expdate.toGMTString() ;
//-----------------------------------------------------------------------------
document.formulaire1.submit();
alert("Vos données sont modifiées, merci");
}
}
//} //Fin du IF

											}else{	
																				
												if (VarPages == (PageIdentificationEchoue))
													{ //alert("VarPages == PageIdentificationEchoue");
													//VarPages = ("PageIdentificationEchoue");
ClientPasIdentifier ();																		
//PageCommande5();					
											}else{	
																				
												if (VarPages == (PageValidEnregistrement))
													{ //alert("VarPages == PageValidEnregistrement");
													//ClientPasIdentifier ();
													//VarPages = ("PageValidEnregistrement");					
	         	var aujourdhui = new Date() ;
				var expdate = new Date() ;
				ValleurPass = "0";				

				date=new Date;
				date.setFullYear(date.getFullYear()-1);
			
				expdate.setTime( aujourdhui.getTime() - ( 3600 ) ) ;
				EcrireCookie("ValNvxPseudo",null,date);
				EcrireCookie("Pseudo",null,date);								
				EcrireCookie("CodeClient",null,date);
				EcrireCookie("Pass",null,date);
			
				EcrireCookie("Salutation",null,date);
				EcrireCookie("FirstName",null,date);
				EcrireCookie("LastName",null,date);
				EcrireCookie("Company",null,date);
				EcrireCookie("NumSiret",null,date);
				EcrireCookie("Street",null,date);
				EcrireCookie("ZipCode",null,date);
				EcrireCookie("Town",null,date);
				EcrireCookie("Country",null,date);
				EcrireCookie("Phone",null,date);
				EcrireCookie("EMail",null,date);
				EcrireCookie("DelName",null,date);
				EcrireCookie("DelCompany",null,date);
				EcrireCookie("DelStreet",null,date);
				EcrireCookie("DelZipCode",null,date);
				EcrireCookie("DelTown",null,date);
				EcrireCookie("DelCountry",null,date);
				EcrireCookie("DelPhone",null,date);				
									
											}else{VarPages = ("Ventes");
												}										

if (VarPages == "Ventes")
{ 
//alert("VarPages == Ventes");
														
	if (VarPseudo == "")
	{ //alert("VarPseudo == Vide");
	ClientPasIdentifier ();
	}
	else{ //alert("VarPseudo == PasVide");	

		if (VarAction == "EnregistrementNvxClient")
				{ //alert("VarAction == EnregistrementNvxClient");
ClientPasIdentifier ();
				}else{ //alert("VarAction == Pas EnregistrementNvxClient");	
						
					if (VarAction == "Identification")
					{ //alert("VarAction == Identification1");
ClientPasIdentifier ();
					}else{ //alert("VarAction == PasIdentification");
				
						if (VarAction == "ClientIdentifier")
						{ //alert("VarAction == ClientIdentifier");
ClientIdentifier ();					
						}else{ //alert("VarAction == ClientIdentifier");
					
							if (SessionWB == "Ouverte") 
							{ //alert("SessionWB == Ouverte");
ClientIdentifier ();
							}else{//alert("SessionWB == Pas Ouverte");
							}
						}
					}

			}
	}	
	
		}
	else{}
																
							}
							}
							}
							}
							}
							}
							}
							}
							}
							}
							
							
} //FindeFonction								

//-----------------------------------------------------------------------------
    
function ClientPasIdentifier ()
{
//alert("function ClientPasIdentifier");
//document.getElementById("MsgAcceuil").innerHTML = "Bienvenu(e) Visiteur";

//document.getElementById("MonCompte").style.display = "none";
//document.getElementById("MonCompte0").style.display = "none";
//document.getElementById("AccueilNouveauClientEmail").style.display = "none";

//document.getElementById("SEnregistrer").style.display = "block";
//document.getElementById("SIdentifier").style.display = "block";
}

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

function ClientIdentifier ()
{
//alert("function ClientIdentifier");
VarPseudo = (GetCookieVar ("Pseudo"));
if (VarPseudo == "PseudoInconnu")
{ }
else{
//document.getElementById("SEnregistrer0").style.display = "none";
//document.getElementById("SIdentifier0").style.display = "none";
//document.getElementById("Motdepasseoublier0").style.display = "none";

//document.getElementById("SEnregistrer").style.display = "none";
//document.getElementById("SIdentifier").style.display = "none";
//document.getElementById("Motdepasseoublier").style.display = "none";

document.getElementById("MonCompteEtDeconnexion").style.display = "block";
//document.getElementById("MonCompte").style.display = "block";
//document.getElementById("AccueilNouveauClientEmail").style.display = "block";

document.AccueilNouveauClient.EMail.value = (GetCookieVar ("EMail"));
document.AccueilNouveauClient.Pseudo.value = (GetCookieVar ("Pseudo"));

document.getElementById("MsgAcceuil").innerHTML = (VarPseudo);
}

}

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

function PageCommande1 ()
{
//alert ("PageCommande1 == " + PageCommande1 ) ;
var VarPseudo = (GetCookieVar ("Pseudo"));
if ((GetCookieVar ("Pseudo")) == "")
{ //alert("Client Non Identifier! ");

  if (confirm(" Bonjour visiteur, vous n'êtes pas encore enregistré(e).\n Voulez-vous que nous vous enregistrions?\n Cela vous permettra de consulter votre historique de commandes et facilement modifier vos coordonnées.\n\n Hello visitor, you are not yet registered. \n Would you like us you registered? \n This will allow you to view your history of commands and easily change your details. \n\n Hallo bezoeker, u bent nog niet geregistreerd. \n Wilt u dat wij u geregistreerd? \n Dit zal u toelaten om uw geschiedenis van de commando's en gemakkelijk uw gegevens wijzigen. \n\n Hola visitante, que aún no se ha registrado(a). \n Deseas nos estás registrado(a)? \n Esto le permitirá ver el historial de comandos y cambiar fácilmente sus datos.")) {
javascript: location.href = (PageEnregistrement);
//    alert("oui")
  }
  else {
//    alert("non")
  }
}  

}

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

function PageCommande3 ()
{
//alert("fonction PageCommande3 Début");
var exp_reg = /[+]/gi; 
//alert("function Traitement Début");
VarPseudo = (GetCookieVar ("Pseudo"));
		var texte = VarPseudo ;
		
		var xhr_object = null; 
	     
	   if(window.XMLHttpRequest) // Firefox 
	      xhr_object = new XMLHttpRequest(); 
	   else if(window.ActiveXObject) // Internet Explorer 
	      xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	   else { // XMLHttpRequest non supporté par le navigateur 
	      alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	      return; 
	   } 
	 
	   xhr_object.open("POST", "./traitement.php", true);
	     
	   xhr_object.onreadystatechange = function() { 
	      if(xhr_object.readyState == 4) {
			 //alert(xhr_object.responseText); // DEBUG MODE
			 var tmp = (xhr_object.responseText).split(";");

		document.form1.CompanyCode.value = tmp[3];(GetCookieVar ("CodeClient"));   
		document.form1.CompanyPassword.value = tmp[2]; //(GetCookieVar ("Pass"));
		document.form1.FirstName.value = (GetCookieVar ("FirstName").replace(exp_reg, " "));

		document.form1.LastName.value = (GetCookieVar ("LastName").replace(exp_reg, " "));
		document.form1.Company.value = (GetCookieVar ("Company").replace(exp_reg, " "));
		document.form1.Street.value = (GetCookieVar ("Street").replace(exp_reg, " "));
		document.form1.ZipCode.value = (GetCookieVar ("ZipCode").replace(exp_reg, " "));
		document.form1.Town.value = (GetCookieVar ("Town").replace(exp_reg, " "));
		document.form1.Country.value = (GetCookieVar ("Country").replace(exp_reg, " "));
		document.form1.Phone.value = (GetCookieVar ("Phone").replace(exp_reg, " "));
		document.form1.EMail.value = (GetCookieVar ("EMail").replace(exp_reg, " "));


		document.form1.DelName.value = "";
		document.form1.DelStreet.value = "";
		document.form1.DelZipCode.value = "";
		document.form1.DelTown.value = "";
		document.form1.DelCountry.value = "";
		document.form1.DelPhone.value = "";

		//document.getElementById("copy").checked = true;
	javascript:DelToInvAdd();

		document.form1.DelName.value = (GetCookieVar ("DelName").replace(exp_reg, " "));
		document.form1.DelStreet.value = (GetCookieVar ("DelStreet").replace(exp_reg, " "));
		document.form1.DelZipCode.value = (GetCookieVar ("DelZipCode").replace(exp_reg, " "));
		document.form1.DelTown.value = (GetCookieVar ("DelTown").replace(exp_reg, " "));
		document.form1.DelCountry.value = (GetCookieVar ("DelCountry").replace(exp_reg, " "));
		document.form1.DelPhone.value = (GetCookieVar ("DelPhone").replace(exp_reg, " "));

	setTimeout("Traitement1()",250)
	setTimeout("EffaceCookies()",650)
		  }
	   } 
	 
	   xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	   // --- ICI TU PASSE TES ARGUMENTS AU SCRIPT :
	   var data = "Pseudo="+texte;
	   xhr_object.send(data);
	   
}
//-------------------------	

function EffaceCookies ()
{
//alert("Pause avant effacement Pass");
				date=new Date;
				date.setFullYear(date.getFullYear()-1);
			
				expdate.setTime( aujourdhui.getTime() - ( 3600 ) ) ;
				//EcrireCookie("CodeClient",null,date);
				EcrireCookie("Pass",null,date);
				EcrireCookie("ValNvxPseudo",null,date);
				
				EcrireCookie("Salutation",null,date);
				EcrireCookie("FirstName",null,date);
				EcrireCookie("LastName",null,date);
				EcrireCookie("Company",null,date);
				EcrireCookie("NumSiret",null,date);
				EcrireCookie("Street",null,date);
				EcrireCookie("ZipCode",null,date);
				EcrireCookie("Town",null,date);
				EcrireCookie("Country",null,date);
				EcrireCookie("Phone",null,date);
				//EcrireCookie("EMail",null,date);
				EcrireCookie("DelName",null,date);
				EcrireCookie("DelCompany",null,date);
				EcrireCookie("DelStreet",null,date);
				EcrireCookie("DelZipCode",null,date);
				EcrireCookie("DelTown",null,date);
				EcrireCookie("DelCountry",null,date);
				EcrireCookie("DelPhone",null,date);					
 	      	   
}
//-----------------------------------
function EcrireCookie(nom, valeur)
{
var argv=EcrireCookie.arguments;
var argc=EcrireCookie.arguments.length;
var expires=(argc > 2) ? argv[2] : null;
var path=(argc > 3) ? argv[3] : null;
var domain=(argc > 4) ? argv[4] : null;
var secure=(argc > 5) ? argv[5] : false;
document.cookie=nom+"="+escape(valeur)+
((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
((path==null) ? "" : ("; path="+path))+
((domain==null) ? "" : ("; domain="+domain))+
((secure==true) ? "; secure" : "");
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function Traitement ()
{
//alert("function Traitement Début");
VarPseudo = (GetCookieVar ("Pseudo"));
		var texte = VarPseudo ;
		
		var xhr_object = null; 
	     
	   if(window.XMLHttpRequest) // Firefox 
	      xhr_object = new XMLHttpRequest(); 
	   else if(window.ActiveXObject) // Internet Explorer 
	      xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	   else { // XMLHttpRequest non supporté par le navigateur 
	      alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	      return; 
	   } 
	 
	   xhr_object.open("POST", "./traitement.php", true);
	     
	   xhr_object.onreadystatechange = function() { 
	      if(xhr_object.readyState == 4) {
			 //alert(xhr_object.responseText); // DEBUG MODE
			 //var varpass = (xhr_object.responseText);
			 // --- ICI le retour (c'est à dire tout ce qui est écrit dans le fichier de traitement)
			 // --- est interprété, donc il suffi d'écrire du code JS dans traitement.php pour
			 // --- qu'il soit interprété au retour.
	         //eval(xhr_object.responseText);

		  }
	   } 
	 
	   xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	   // --- ICI TU PASSE TES ARGUMENTS AU SCRIPT :
	   var data = "Pseudo="+texte;
	   xhr_object.send(data);
   	      	   
}
//-----------------------------------------------------------------------------

function Traitement1 ()
{
//alert("function Traitement1 Début");

		//var texte = document.getElementById("Pseudo").value;
		var texte = VarPseudo ;
		
		var xhr_object = null; 
	     
	   if(window.XMLHttpRequest) // Firefox 
	      xhr_object = new XMLHttpRequest(); 
	   else if(window.ActiveXObject) // Internet Explorer 
	      xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	   else { // XMLHttpRequest non supporté par le navigateur 
	      alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	      return; 
	   } 
	 
	   xhr_object.open("POST", "./traitement1.php", true);
	     
	   xhr_object.onreadystatechange = function() { 
	      if(xhr_object.readyState == 4) {
			 //alert(xhr_object.responseText); // DEBUG MODE
			 // --- ICI le retour (c'est à dire tout ce qui est écrit dans le fichier de traitement)
			 // --- est interprété, donc il suffi d'écrire du code JS dans traitement.php pour
			 // --- qu'il soit interprété au retour.
	         //eval(xhr_object.responseText);
	         //document.getElementById("CompanyPassword").value = (GetCookieVar ("Pass"));

		  }
	   } 
	 
	   xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	   // --- ICI TU PASSE TES ARGUMENTS AU SCRIPT :
	   var data = "Pseudo="+texte;
	   xhr_object.send(data);
	   
//alert("function Traitement1 Fin");   	      	   
}
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
function PageCommande5 ()
{
var aujourdhui = new Date() ;
var expdate = new Date() ;
//plus an an à partir d'aujourdh'ui le cookie ne s'efface jamais
expdate.setTime( aujourdhui.getTime() + ( 3600 ) ) ;
VarAction = "ClientIdentifier";
document.cookie = "VarAction=" + VarAction + ";expires=" + expdate.toGMTString() ;
}

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

function PageMotdePassOublier ()
{
//alert("function PageMotdePassOublier ");
javascript: location.href = (PageMotdePassOublie);
}

//-----------------------------------------------------------------------------
function PageModificationAcces ()
{
//alert("function PageMonCompte ");
if ((GetCookieVar ("Pseudo")) == "")
{
var VoirPasvoir = "none";
alert ("Vous devez vous enregistrer pour pouvoir faire vos modifications, nous vous redirigeons vers la page voulue.")
javascript: location.href = (PageIdentification);
}else{
//ClientIdentifier ();
javascript: location.href = (PageMonCompte);
	}
}

//-----------------------------------------------------------------------------
function PageSIdentifier ()
{
//alert("function SIdentifier ");
//nouvel objet date
var aujourdhui = new Date() ;
//nouvel objet date
var expdate = new Date() ;
//plus an an à partir d'aujourdh'ui le cookie ne s'efface jamais
expdate.setTime( aujourdhui.getTime() + ( 3600 ) ) ;
VarAction = "Identification";
document.cookie = "VarAction=" + VarAction + ";expires=" + expdate.toGMTString() ;
VarPages = "Identification";
document.cookie = "VarPages=" + VarPages + ";expires=" + expdate.toGMTString() ;
javascript: location.href = (PageIdentification);
}

//-----------------------------------------------------------------------------
function PageSEnregistrer ()
{
//alert("function SEnregistrer ");
//nouvel objet date
var aujourdhui = new Date() ;
//nouvel objet date
var expdate = new Date() ;
//plus an an à partir d'aujourdh'ui le cookie ne s'efface jamais
expdate.setTime( aujourdhui.getTime() + ( 3600 ) ) ;
VarAction = "EnregistrementNvxClient";
document.cookie = "VarAction=" + VarAction + ";expires=" + expdate.toGMTString() ;
VarPages = "EnregistrementNvxClient";
document.cookie = "VarPages=" + VarPages + ";expires=" + expdate.toGMTString() ;
javascript: location.href = (PageEnregistrement);
}

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

function SuppVarAction ()
{
//alert("function SuppVarAction ");
//nouvel objet date
var aujourdhui = new Date() ;
//nouvel objet date
var expdate = new Date() ;
//plus an an à partir d'aujourdh'ui le cookie ne s'efface jamais
expdate.setTime( aujourdhui.getTime() + ( 3600 ) ) ;
VarAction = "Rien";
document.cookie = "VarAction=" + VarAction + ";expires=" + expdate.toGMTString() ;
}

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

function PageModification ()
{
Traitement();
//alert("Fonction Page Modification!");
	         
document.InscriptionClient.style.display = "none";
document.myform.style.display = "none";

document.InscriptionClient.InformationErreureSaisie.style.display = "none";

document.InscriptionClient.Pass.style.display = "none";

document.InscriptionClient.CodeClient.style.display = "none";

PageIdentification = (GetCookieVar ("PageIdentification"));

if ((GetCookieVar ("Pseudo")) == "PremierEnregistrement")
{
var VoirPasvoir = "none";
alert ("Vous devez vous enregistrer pour pouvoir faire vos modifications, nous vous redirigeons vers la page voulue.")
javascript: location.href = (PageIdentification);
}else{
document.InscriptionClient.style.display = "block";
document.InscriptionClient.Societe.checked = true;
document.InscriptionClient.NumSiret.value = (GetCookieVar ("NumSiret"));
var VoirPasvoir = "block";
}

TextNoMachine();

setTimeout("AutoRemplissage ()",500)

}
//-----------------------------------------------------------------------------

function AutoRemplissage ()
{
//alert("fonction AutoRemplissage Début");

if ((GetCookieVar ("Salutation")) == "Mme"){document.InscriptionClient.SalutationMme.checked = true;}
document.InscriptionClient.FirstName.value = (GetCookieVar ("FirstName"));
document.InscriptionClient.LastName.value = (GetCookieVar ("LastName"));

VarCompagny = (GetCookieVar ("Company"));

if ((VarCompagny) == ""){ 
document.InscriptionClient.Societe.checked = false;
javascript:SteCheck();
}
else{ 
document.InscriptionClient.Societe.checked = true;
javascript:SteCheck();
setTimeout("AutoRemplissage2 ()",250)
}
//-----------------------------------------------------------------------------

function AutoRemplissage2 ()
{
//alert("fonction AutoRemplissage2 Début");

document.InscriptionClient.Company.value = (GetCookieVar ("Company"));
document.InscriptionClient.NumSiret.value = (GetCookieVar ("NumSiret"));
document.InscriptionClient.DelCompany.value = (GetCookieVar ("Company"));}


document.InscriptionClient.Company.value = (GetCookieVar ("Company"));
document.InscriptionClient.Street.value = (GetCookieVar ("Street"));
document.InscriptionClient.ZipCode.value = (GetCookieVar ("ZipCode"));
document.InscriptionClient.Town.value = (GetCookieVar ("Town"));
document.InscriptionClient.Country.value = (GetCookieVar ("Country"));
document.InscriptionClient.Phone.value = (GetCookieVar ("Phone"));
document.InscriptionClient.EMail.value = (GetCookieVar ("EMail"));

document.InscriptionClient.DelName.value = "";
document.InscriptionClient.DelStreet.value = "";
document.InscriptionClient.DelZipCode.value = "";
document.InscriptionClient.DelTown.value = "";
document.InscriptionClient.DelCountry.value = "";
document.InscriptionClient.DelPhone.value = "";

document.InscriptionClient.DelCompany.value = (GetCookieVar ("DelCompany"));
document.InscriptionClient.DelName.value = (GetCookieVar ("DelName"));
document.InscriptionClient.DelStreet.value = (GetCookieVar ("DelStreet"));
document.InscriptionClient.DelZipCode.value = (GetCookieVar ("DelZipCode"));
document.InscriptionClient.DelTown.value = (GetCookieVar ("DelTown"));
document.InscriptionClient.DelCountry.value = (GetCookieVar ("DelCountry"));
document.InscriptionClient.DelPhone.value = (GetCookieVar ("DelPhone"));


document.InscriptionClient.Pseudo.value = (VarPseudo);
document.InscriptionClient.Pass.value = (GetCookieVar ("Pass"));
document.InscriptionClient.CodeClient.value = (GetCookieVar ("CodeClient"));

//document.getElementById("copy").checked = true;
//javascript:CopyAdresse();

//alert("fonction AutoRemplissage Fin");
Traitement1();
document.InscriptionClient.style.display = "none";    
}

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

function SauveCdeTemp ()
{
//alert("function SauveCdeTemp Début");
VarPseudo = (GetCookieVar ("Pseudo"));
		var DateCde = document.getElementById("DateCde").value;
		var Total = document.getElementById("Total").value;
		var from = document.getElementById("From").value;
		var To = document.getElementById("To").value;
		var Subject = document.getElementById("Subject").value;
		var SubjectMailClient = document.getElementById("SubjectMailClient").value;
		var Message = document.getElementById("Message").value;
		var Messagehtml = document.getElementById("Messagehtml").value;
		var Attachment = document.getElementById("Attachment").value;
		var OrderID = document.getElementById("OrderID").value;
		var redirect = document.getElementById("redirect").value;
		//alert(texte);
		var xhr_object = null; 
	     
	   if(window.XMLHttpRequest) // Firefox 
	      xhr_object = new XMLHttpRequest(); 
	   else if(window.ActiveXObject) // Internet Explorer 
	      xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	   else { // XMLHttpRequest non supporté par le navigateur 
	      alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	      return; 
	   } 
	 
	   xhr_object.open("POST", "./SauveCdeTemp.php", true);
	     
	   xhr_object.onreadystatechange = function() { 
	      if(xhr_object.readyState == 4) {
			 //alert(xhr_object.responseText); // DEBUG MODE
			 // --- ICI le retour (c'est à dire tout ce qui est écrit dans le fichier de traitement)
			 // --- est interprété, donc il suffi d'écrire du code JS dans traitement.php pour
			 // --- qu'il soit interprété au retour.
	         //eval(xhr_object.responseText);

		  }
	   } 
	 
	   xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	   // --- ICI TU PASSE TES ARGUMENTS AU SCRIPT :
	   var data = "DateCde=" + DateCde + "&Total=" + Total + "&OrderID="+OrderID + "&from=" + from + "&To=" + To + "&Subject=" + Subject + "&SubjectMailClient=" + SubjectMailClient + "&Message=" + Message + "&Messagehtml=" + Messagehtml + "&Attachment=" + Attachment + "?redirect=" + redirect;	   
	   xhr_object.send(data);
   	   //alert(data);   	   
}

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

function SauveCdeHistoClient ()
{
//alert("function SauveCdeHistoClient Début");
VarPseudo = (GetCookieVar ("Pseudo"));
		var varAction = "PaiementAccepter";
		
		var xhr_object = null; 
	     
	   if(window.XMLHttpRequest) // Firefox 
	      xhr_object = new XMLHttpRequest(); 
	   else if(window.ActiveXObject) // Internet Explorer 
	      xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	   else { // XMLHttpRequest non supporté par le navigateur 
	      alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	      return; 
	   } 
	 
	   xhr_object.open("POST", "./SauveCdeHistoClient.php", true);
	     
	   xhr_object.onreadystatechange = function() { 
	      if(xhr_object.readyState == 4) {
			 //alert(xhr_object.responseText); // DEBUG MODE
			 // --- ICI le retour (c'est à dire tout ce qui est écrit dans le fichier de traitement)
			 // --- est interprété, donc il suffi d'écrire du code JS dans traitement.php pour
			 // --- qu'il soit interprété au retour.
	         //eval(xhr_object.responseText);

		  }
	   } 
	 
	   xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	   // --- ICI TU PASSE TES ARGUMENTS AU SCRIPT :
	   var data = "varAction=" + varAction;	   
	   xhr_object.send(data);
   	   //alert("Nous sauvegardons votre commande");   	   
}
//--- Fin de SCRIPT --

