
var mailingListAction='';
var prod_empty=false;


//------------------------------------------------- Gestion affichage Fiche Produit
function showProd(pid){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETPROD&PID='+escape(pid)+'&RUB='+RUB+'&SRUB='+SRUB+'&PAGE='+PAGE+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}
function getStockback(txt){
$('dispo').innerHTML=txt;
}

function getStock(){
$('dispo').innerHTML="Interrogation du stock";
var req = new Ajax ("GET",getStockback);
req.exec(www2+'catalog.exe?SESSION='+MySession+'&CMD=GETSTOCK&PID='+escape(PID)+'&SIZE='+SIZE+'&COL='+COL+'&idcount='+Math.random()*10000);
}

function nextProd(){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETNEXTPROD&RUB='+RUB+'&SRUB='+SRUB+'&PAGE='+PAGE+'&SENS=1'+'&PID='+escape(PID)+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}

function prevProd(){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETNEXTPROD&RUB='+RUB+'&SRUB='+SRUB+'&PAGE='+PAGE+'&SENS=0'+'&PID='+escape(PID)+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}


function showSizes(){
show('sizes');

}
//------------------------------------------------- Gestion du panier

function showBasket(){
if ($('myBasket').innerHTML!='Votre Panier est vide'){
window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=SHOWBASKET&TRK='+TRACK+'&idcount='+Math.random()*10000;}
}

function add2Basketback(txt){
$('myBasket').innerHTML=txt;
show('ADD2BASKET_POPUP');
}

function add2Basket (){
var txt=$('dispo').innerHTML;
if (txt.indexOf('Epuisé')>-1) {showmessage("<center>Cet article est épuisé.<br>Vous ne pouvez pas l'ajouter à votre panier</center>")}
else {
var req = new Ajax ("GET",add2Basketback);
req.exec(www2+'catalog.exe?SESSION='+MySession+'&CMD=ADD2BASKET&PID='+escape(PID)+'&SIZE='+SIZE+'&COL='+COL+'&QTE='+QTE+'&TRK='+TRACK+'&idcount='+Math.random()*10000);}
}

function refreshBasket(txt){
var response=txt.split('|||');
$('myBasket').innerHTML=response[0];
$('basketdetail').innerHTML=response[1];
if (response[2]=="PRODOK") {prod_empty=false;}
if (response[2]=="PRODKO") {prod_empty=true;
				      		showmessage("<center><b>Cet article n'est pas disponible dans la<br>quantité, la taille ou la couleur sélectionnée.</b></center>");}
if (response[2]=="REDUCKO") {showmessage("<center><b>Le code réduction utilisé n'est pas valable<br>ou la date de validité est dépassée.</b></center>");}

}


function updateSize(id,size) {
var req = new Ajax ("GET",refreshBasket);
req.exec(www2+'catalog.exe?SESSION='+MySession+'&CMD=UPDATESIZE_BASKET&ID='+id+'&SIZE='+size+'&idcount='+Math.random()*10000);
}

function updateColor(id,col) {
var req = new Ajax ("GET",refreshBasket);
req.exec(www2+'catalog.exe?SESSION='+MySession+'&CMD=UPDATECOLOR_BASKET&ID='+id+'&COLOR='+col+'&idcount='+Math.random()*10000);
}

function updateQte(id,qte) {
var req = new Ajax ("GET",refreshBasket);
req.exec(www2+'catalog.exe?SESSION='+MySession+'&CMD=UPDATEQTE_BASKET&ID='+id+'&QTE='+qte+'&idcount='+Math.random()*10000);
}

function deleteprod(id) {
var req = new Ajax ("GET",refreshBasket);
req.exec(www2+'catalog.exe?SESSION='+MySession+'&CMD=DELETEPROD_BASKET&ID='+id+'&idcount='+Math.random()*10000);
}

function useReduc(reduc) {
var req = new Ajax ("GET",refreshBasket);
req.exec(www2+'catalog.exe?SESSION='+MySession+'&CMD=USE_REDUC&REDUC='+escape(reduc)+'&idcount='+Math.random()*10000);
}

function updateFport(fport) {
var req = new Ajax ("GET",refreshBasket);
req.exec(www2+'catalog.exe?SESSION='+MySession+'&CMD=UPDATEFPORT&FPORT='+fport+'&idcount='+Math.random()*10000);
}

function checkCGV() {
if ($('CGVvalid').checked) {window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=ORDER&TRK='+TRACK+'&idcount='+Math.random()*10000;}
else {alert ('Vous devez valider les conditions générales de vente pour continuer.');}
}


//------------------------------------------------- Gestion affichage page Divers
function showPage(page){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETPAGE&PAGE='+page+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}

function showQCM(qcm){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETQCM&IDQCM='+qcm+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}

//------------------------------------------------- Retour à l'accueil
function goHome(){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GOHOME&TRK='+TRACK+'&idcount='+Math.random()*10000;
}


//------------------------------------------------- Moteur de Recherche
function searchProd(searchstr){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=SEARCH&TXT='+searchstr+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}


//------------------------------------------------- Gestion affichage rubrique et sous rubrique
function back2Rub(){
if (RUB=='LOOK') { window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETLOOK&RUB='+RUB+'&SRUB='+SRUB+'&Page='+PAGE+'&TRK='+TRACK+'&idcount='+Math.random()*10000;}
	   else {window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETRUB&RUB='+RUB+'&SRUB='+SRUB+'&Page='+PAGE+'&TRK='+TRACK+'&idcount='+Math.random()*10000;}
}

function showRub(rub,srub,page){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETRUB&RUB='+rub+'&SRUB='+srub+'&Page='+page+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}

function prevPage(){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETRUB&RUB='+RUB+'&SRUB='+SRUB+'&Page='+(parseInt(PAGE)-1)+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}

function nextPage(){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETRUB&RUB='+RUB+'&SRUB='+SRUB+'&Page='+(parseInt(PAGE)+1)+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}



//------------------------------------------------- Gestion affichage des Look
function back2Look(){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETLOOK&RUB='+RUB+'&SRUB='+SRUB+'&Page='+PAGE+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}

function showLook(rub,srub,page){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETLOOK&RUB='+rub+'&SRUB='+srub+'&Page='+page+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}

function prevLook(){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETLOOK&RUB='+RUB+'&SRUB='+SRUB+'&Page='+(parseInt(PAGE)-1)+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}

function nextLook(){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETLOOK&RUB='+RUB+'&SRUB='+SRUB+'&Page='+(parseInt(PAGE)+1)+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}


//------------------------------------------------- Gestion affichage des LookBOOK

function back2Lookbook(id){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=BACK2LOOKBOOK&RUB='+RUB+'&SRUB='+SRUB+'&ID='+id+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}
function showLookbook(rub,srub,page){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETLOOKBOOK&RUB='+rub+'&SRUB='+srub+'&Page='+page+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}

function prevLookbook(){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETLOOKBOOK&RUB='+RUB+'&SRUB='+SRUB+'&Page='+(parseInt(PAGE)-1)+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}

function nextLookbook(){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETLOOKBOOK&RUB='+RUB+'&SRUB='+SRUB+'&Page='+(parseInt(PAGE)+1)+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}


//------------------------------------------------- Gestion Mailling List
function mailingListResult(txt){
showmessage("<center>Votre demande d'inscription a bien été prise en compte.</center>");
}

function mailingList(email,action){
mailingListAction=action;
if (email=="") {return;}

if ((email=="votre  e-mail") || (email=="Votre adresse e-mail") || (email.indexOf("@")==-1) || (email.indexOf(".")==-1) || (email.indexOf("'")>-1) || (email.indexOf('.@')>-1 ) || (email.indexOf('@.')>-1 ) || (email.indexOf('/')>-1 ) || (email.indexOf('"')>-1) || (email.indexOf("+")>-1)) {showmessage("<center>Votre adresse e-mail n'est pas valide.</center>");return;}

var req = new Ajax ("GET",mailingListResult);
req.exec(www2+'catalog.exe?SESSION='+MySession+'&CMD=MAILINGLIST&email='+escape(email)+'&action='+action+'&TRK='+TRACK+'&idcount='+Math.random()*10000);
}

//------------------------------------------------- Gestion Contactez-Nous
function Contactback(txt){
showmessage("<center>Votre message a bien été envoyé. <br>Nous vous répondrons très rapidement.</center>");
$('nom').value="";
$('email').value="";
$('message').value="";

}

function Contact(){
var req = new Ajax ("POST",Contactback);
req.exec(www2+'catalog.exe?CMD=CONTACT&email='+escape($F('email'))+'&nom='+escape($F('nom'))+'&MSG='+escape($F('message'))+'&idcount='+Math.random()*10000);
}

//------------------------------------------------- Gestion Compte Client

function getLogin(){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=GETLOGIN&PAGE=identification&TRK='+TRACK+'&idcount='+Math.random()*10000;
}

function createAccount(){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=CREATEACCOUNT&NUMCL=&TRK='+TRACK+'&idcount='+Math.random()*10000;
}

function editCL(numcl){
	window.location=www2+'catalog.exe?SESSION='+MySession+'&CMD=CREATEACCOUNT&NUMCL='+numcl+'&TRK='+TRACK+'&idcount='+Math.random()*10000;
}


function checkform() {
if ($F('fnom')=='' || $F('fprenom')==''){alert ("Vos nom et prénom sont obligatoire.");return }


if ($('ladr').checked && $F('lcp').indexOf(' ')>-1) {alert ("Attention le code postal de livraison ne doit pas contenir d'espace.");return }
if ($F('fcp').indexOf(' ')>-1) {alert ("Attention le code postal de facturation ne doit pas contenir d'espace.");return }

if ($('ladr').checked && $F('lcp').indexOf('-')>-1) {alert ("Le code postal ne doit pas contenir de tiret. Indiquez votre code postal sans indicatif international.");return }
if ($F('fcp').indexOf('-')>-1) {alert ("Le code postal ne doit pas contenir de tiret indiquez votre code postal sans indicatif international.");return }

if ($F('fpays')=='61' && $F('fcp').length<5){alert ("Votre code postal de facturation est incorrect");return }
if ($('ladr').checked && $F('lpays')=='61' && $F('lcp').length<5){alert ("Votre code postal de livraison est incorrect");return }

if ($F('tel').indexOf('+')>-1){alert ("Merci d'indiquer votre Numéro de téléphone sans indiquatif international. Renseignez votre numéro comme si vous le communiquez dans votre pays.");return }
if ($F('tel').indexOf('00000')>-1) {alert ("Un numéro de téléphone est obligatoire pour vous joindre rapidement en cas problème.");return }
if ($F('tel').indexOf('12345678')>-1) {alert ("Un numéro de téléphone est obligatoire pour vous joindre rapidement en cas problème.");return }


if ($F('email').indexOf('@')==-1 || $F('email').indexOf('.')==-1){alert ("L'adresse e-mail n'est pas valid.");return }
if ($F('email').indexOf('@.')>-1 ){alert ("L'adresse e-mail n'est pas valid.");return }
if ($F('email').indexOf('.@')>-1 ){alert ("L'adresse e-mail n'est pas valid.");return }
if ($F('email').indexOf('/')>-1 ){alert ("L'adresse e-mail n'est pas valid.");return }

if ($F('email')==''){alert ("L'adresse e-mail est obligatoire. Elle vous permettra de suivre vos commandes.");return }
if ($F('email')!=$F('email2')){alert ("Votre adresse e-mail n'est pas correctement confirmée.");return }
if ($F('tel').length<8) {alert ("Un numéro de téléphone est obligatoire pour vous joindre rapidement en cas problème.");return }
if ($F('password').length<6) {alert ("Votre mot de passe doit contenir au minimum 6 caractères.");return }
if ($F('password')!=$F('password2')) {alert ("Votre mot de passe n'est pas correctement confirmée");return }
if ($F('password').length>10) {alert ("Votre mot de passe ne peut dépasser 10 caractères.");return }

if ($F('fadr1')=='' || $F('fville')=='' || $F('fcp').length<4){alert ("Votre adresse postale complète est obligatoire.");return }
if ($('ladr').checked && ($F('ladr1')=='' || $F('lnom')=='' || $F('lville')=='' || $F('lcp').length<4)){alert ("Votre adresse de livraison complète est obligatoire.");return }
if ($F('fcp').substr(0,2)=='97' && $F('fpays')=='61') {alert ("Attention le code postal ne correspond pas aux pays sélectionner pour la facturation.");return }
if ($F('lcp').substr(0,2)=='97' && $F('lpays')=='61') {alert ("Attention le code postal ne correspond pas aux pays sélectionner pour la livraison.");return }

if ($F('fcp').substr(0,2)=='98' && $F('fpays')=='61') {alert ("Attention le code postal ne correspond pas aux pays sélectionner pour la facturation.");return }
if ($F('lcp').substr(0,2)=='98' && $F('lpays')=='61') {alert ("Attention le code postal ne correspond pas aux pays sélectionner pour la livraison.");return }


if ($F('fville').toUpperCase()=='FRANCE' || $F('lville').toUpperCase()=='FRANCE') {alert ("France n'est pas un nom de ville correct.");return }
$('contact').submit();
}


//------------------------------------------------- Send A Friend
function sendformfriendback(txt){
showmessage("<center>Votre message a bien été envoyé.</center>")
}


function sendformfriend(){

var req = new Ajax ("GET",sendformfriendback);
req.exec(www2+'catalog.exe?cmd=SENDAFRIEND&From='+escape($F('from'))+'&nom='+escape($F('zenom'))+'&sendto='+escape($F('sendto'))+'&PID='+escape(PID)+'&MSG='+escape($F('msg'))+'&idcount='+Math.random()*10000);

}

//------------------------------------------------- DLGBOX
function showmessage(txt){
$('DLGBOX_MSG').innerHTML=txt;
show('DLGBOX');
}


//------------------------------------------------- FORGETPASSWORD
function sendPSWDback(txt){
if (txt=='OK') {showmessage('Votre mot de passe vient de vous être envoyé sur votre adresse e-mail')}
else {showmessage("Vous ne disposez pas d'un compte client chez nous.")}
}

function sendPSWD(zemail){

var req = new Ajax ("GET",sendPSWDback);
req.exec(www2+'catalog.exe?cmd=FORGETPSWD&email='+escape(zemail)+'&idcount='+Math.random()*10000);

}
