<!-- javascript document
		checked = 0;
		
		function checkbox(form,element){ //v3.0
if (checked == 0) {
document.getElementById('checkboxbullet').src = 'images/checkbox_bullet.gif';
checked = 1;
document.forms[form][element].value = 1;	}
else {
document.getElementById('checkboxbullet').src = 'images/spacercheckbox.gif';
checked = 0;
document.forms[form][element].value = 0;	}
}

		function checkboxes(id){
	switch(id) {
case 0:
document.getElementById(0).src = 'images/checkbox_bullet.gif';
document.getElementById(1).src = 'images/spacercheckbox.gif';
if (document.getElementById('shipping').value == 1) {
new Effect.Fade('shipform', {duration:0.3});
document.getElementById('verticalsep').style.height = "160px";
document.getElementById('vtab').style.height = "400px";
addaddress(0); }
break;

case 1:
document.getElementById(1).src = 'images/checkbox_bullet.gif';
document.getElementById(0).src = 'images/spacercheckbox.gif';
document.getElementById('verticalsep').style.height = "300px";
document.getElementById('vtab').style.height = "575px";
new Effect.Appear('shipform', {duration:0.3});
break;
	}
document.getElementById('shipping').value = id;
}


		function checkfill(form) {
var emptyfield = 0;	var i = 0;	
		while (document.forms[form][i]) {
if (document.forms[form][i].value.length == 0) {
emptyfield = 1;	
document.forms[form][i].style.borderColor = "#D27611";
document.forms[form][i].style.backgroundColor = '#fff9f3';	}
i++;	}
if (emptyfield == 1) affiche_overlay_window(errors['empty']);
else if (form == 'returning_customer') submitForm();
else if (form == 'shipform') addaddress(1);
else if (form == 'contact') sendmessage();
else document.forms[form].submit();
		}

// fonction de verification du format de l'email
		function checkmail(texte,form,nameinput) {
if (texte.length >0) {
	var check = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/;
	if ((check.exec(texte)!=null) == false) showerror(form,nameinput,nameinput);
	else { //check if mail exists, via ajax request
		var xhr = getXhr();
		xhr.onreadystatechange = function(){
		if(xhr.readyState == 4 && xhr.status == 200){
		reply = xhr.responseText;
		if ((reply == 1) && (form == 'returning_customer'))									thatsok(form,nameinput);
		else if ((reply == 1) && ((form == 'new_customer') || (form == 'connexion_info')))	showerror(form,nameinput,'taken');
		else if ((reply == 0) && (form == 'returning_customer'))							showerror(form,nameinput,'void');
		else if ((reply == 0) && ((form == 'new_customer') || (form == 'connexion_info'))) 	thatsok(form,nameinput);
		else if(form == 'contact') thatsok(form,nameinput);
		}	}
		xhr.open("POST","php/checkmail.php");
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send("email="+texte); //thatsok(form,nameinput);	
		}
	}
	else thatsok(form,nameinput);
}

// check if its a text (no numbers or special caracters)
		function veriftext(texte, form, nameinput) {
		if (texte.length >0) {
var check = /^[^\\\&\$\[\]\(\)\{\}\^\?\*\+]+[^0-9]+$/;
if (((check.exec(texte)!=null) == false) || (texte.length <2)) {
showerror(form,nameinput,'texte');	}
else thatsok(form,nameinput);	}
else thatsok(form,nameinput);	}

// check if its a correct 1001 listes card number
		function verifcarte(texte, form, nameinput) {
		/*if (texte.length >0) {
debut = texte.substring(0,3);
if (texte.length == 10 && (debut == "301" || debut == "500")) thatsok(form,nameinput); 
else alert(debut); }
else thatsok(form,nameinput);*/	}

// check if its a number (no letters or special caracters)
		function verifnumber(texte, form, nameinput) {
		if (texte.length >0) {
var check = /^[^\\\$\[\]\(\)\{\}\^\?\*]+[^a-z]+[^A-Z]+$/;
if (((check.exec(texte)!=null) == false) || (texte.length <2)) {
showerror(form,nameinput,'number');	}
else thatsok(form,nameinput);	}
else thatsok(form,nameinput);	}

// password check function
		function verifmdp(texte, form, nameinput) {
		if (texte.length >0) {
var check = /^[^ÀÂÇÈÉÊËÎÔÙÛàâçèéêëîôùû\\\.\$\[\]\(\)\{\}\^\?\*\+\-\&@\s]+$/;
if (((check.exec(texte)!=null) == false) || (texte.length <6) || (texte.length >15)) {
showerror(form,nameinput,nameinput);	}
else thatsok(form,nameinput);	}
else thatsok(form,nameinput);	}

// passwords match function
		function verifmdp2(texte,form,nameinput) {
if (texte.length >0) {
if (document.forms[form]['password'].value != texte) {
showerror(form,nameinput,nameinput);	}
else thatsok(form,nameinput);	}
else thatsok(form,nameinput);	}

// fonction de verification du format de l'email
		function retrievepassword(texte) {
if (texte.length >0) {

var xhr = getXhr();
xhr.open("POST","php/checkmail.php");
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.send("email="+texte+"&mode=1");
xhr.onreadystatechange = function(){
if(xhr.readyState == 4 && xhr.status == 200){
reply = xhr.responseText;
if (reply == 1) document.getElementById('inputdata').innerHTML = errors["mailsent"];
if (reply == 2) document.getElementById('inputdata').innerHTML = errors["void"];
document.getElementById('buttonok').innerHTML = '<a href="javascript:cachetout()" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'ok\',\'\',\'images/ok_button_hover.gif\',1)"><img src="images/ok_button.gif" width="52" height="26" border="0" id="ok" /></a>';
}	}

}	}

// fonction de verification du format de l'email
		function submitForm() {
var xhr = getXhr();
xhr.onreadystatechange = function(){
if(xhr.readyState == 4 && xhr.status == 200){
reply = xhr.responseText;
if (reply == 1) document.location.reload(true);
else (affiche_overlay_window(errors['wrongpassword']));
}	}
xhr.open("POST","php/returning_customer.php");
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.send("email="+document.forms['returning_customer'][0].value+"&password="+document.forms['returning_customer'][1].value);

}

// add new address as session var for the _ship.php page
	function addaddress(action) {
var xhr = getXhr();
xhr.onreadystatechange = function(){
if(xhr.readyState == 4 && xhr.status == 200){
reply = xhr.responseText;
if (reply == 1) affiche_overlay_window(errors['addressadded']);
}	}
xhr.open("POST","php/add_address.php");
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xhr.send("action="+action+"&firstname="+document.forms['shipform'][0].value+"&name="+document.forms['shipform'][1].value+"&address="+document.forms['shipform'][2].value+"&zipcode="+document.forms['shipform'][3].value+"&city="+document.forms['shipform'][4].value+"&state="+document.forms['shipform'][5].value);
}

<!-- generic functions for the form verification -->
	function showerror(form,nameinput,msg) {
affiche_overlay_window(errors[msg]);
document.forms[form][nameinput].value = "";
document.forms[form][nameinput].style.borderColor = "#D27611";
document.forms[form][nameinput].style.backgroundColor = '#fff9f3';	}

	function thatsok(form,nameinput) {
document.forms[form][nameinput].style.borderColor = "#cccccc"; }


<!-- Rollover OK buttun fonctions -->
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
