// JavaScript Document
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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

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

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function PopupImage(monImage, maLargeur, maHauteur)
{
	varLargeur = (screen.width - maLargeur) / 0;
	varHauteur = (screen.height - maHauteur) / 0;
	titre="* > Henri Lamouroux < *";
	w=open("",'image','toolbar=no,scrollbars=no,resizable=no,width='+maLargeur+',height='+maHauteur+',top='+varHauteur+',left='+varLargeur); 
	w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
	w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+10,document.images[0].height+25); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
	w.document.write(" <body onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><A HREF='JavaScript:window.close();'><IMG SRC='"+monImage+"' border=0></A>");
	w.document.write("");
	w.document.write("</BODY></HTML>");
	w.document.close();
}

function Tendance(){
	document.form1.submit();	
}

function Prestige(){
	document.form2.submit();	
}

function ChgColor(color){
	if(color!="") window.location.href="<? echo $_SERVER["PHP_SELF"]; ?>?id="+color;
}

function AjoutPanier(i){
	document.form2.idproduit.value=i;
	document.form2.submit();
}

function Retour(){
	//document.formRetour.submit();	
	window.location.href="produits.php?"+document.formRetour.qs.value;
}

function verifiermail(mail) {
      if ((mail.indexOf("@")>=0)&&(mail.indexOf(".")>=0)) {
         return true 
      } else {
         return false
      }
   }
   
function verifiercp(code_postal) {
      if (code_postal>=01000 && code_postal<=99999) {
         return true 
      } else {
         return false
      }
   }
function veriftel(telephone) {
      regexp = /^[0-9+][0-9 -]*[0-9]$/;
      if (regexp.test(telephone)) {
         return true 
      } else {
         return false
      }
   }
	
	
function Valider(){
		msg="";
		msg2="";
		tmp="";	
		for (i=0;i<Champs.length;i++){
			
			if (eval("document.form1."+Champs[i]+".value")==""){
				msg+="- "+Message[i]+"\n";
			}
		}
		
		var mail_v=1;
		if (document.form1.email.value!="" && verifiermail(document.form1.email.value)==false){
			msg2+="- Adresse email incorrecte\n";
			mail_v=0;
		}
		
		var mail2_v=1;
		if (document.form1.emailbis.value!="" && verifiermail(document.form1.emailbis.value)==false){
			msg2+="- Confirmation de l'adresse email incorrecte\n";
			mail2_v=0;
		}
		
		if(document.form1.email.value != document.form1.emailbis.value) msg2+="- L'adresse email et la confirmation de l'adresse email sont différents\n";
		
		var cpok=1;
		if (document.form1.codepostal.value!="" && verifiercp(document.form1.codepostal.value)==false){
			msg2+="- Code Postal incorrecte\n";
			cpok=0;
		}
		
		var telok=1;
		if (document.form1.tel.value!="" && veriftel(document.form1.tel.value)==false){
			msg2+="- Numéro de téléphone incorrect\n";
			telok=0;
		}
		
		if (msg=="" && msg2=="" && mail_v!=0 && mail2_v!=0 && cpok!=0 && telok!=0){
			document.form1.submit();
		}else{
			if (msg!=""){ 
				tmp="Merci de remplir les champs suivants:\n\n"+msg;				
			}
			if (msg2!=""){
				if(tmp!="") tmp+="\n\nEt de corriger les champs suivants :\n\n"+msg2;
				else tmp+="\n\nMerci de corriger les champs suivants :\n\n"+msg2;
			}
			if(tmp!=""){
				window.alert(tmp);
				tmp = "";
			}
		}
}



