var non=0;
var ValueTxt="";
var flg=0;
function CheckFields1(Ident1, Ligne){
	var pform1 = new Object;
	var pformV1 = new Object;
   pform1 = eval(document.getElementById(Ident1));
   pformV1=pform1.value;
   non=0;
   if (pformV1.substring(0,1)=="0" && Ident1!="Code_Post" && Ident1!="Code_Post_livr"){
	   	alert( "Rien ne peut commencer par '0'\nVeillez à ce que ce champ soit bien rempli." );non=1;pform1.disabled=false; pformv1="";pform1.focus();
	   }
   if (pformV1!=""){
	   var cmp="0123456789";
	   var tst="";
	   var nr1=pformV1;
	   flg=0;
	  for (var i=0;i<nr1.length;i++){
		   tst=nr1.substring(i,i+1)
		   if (cmp.indexOf(tst)<0){flg++;}
	  }
	  if (flg>0){
		  alert(pformV1+" est invalide, recommencez!");
		  pform1.disabled=false; pformv1="";
		  pform1.focus();
	  }else{
		var a=0;
		var Dvi="";
		var valeur=0;
		a=Ident1.indexOf("_");
		Dvi="DeS"+Ident1.slice(a);
		valeur=eval(document.getElementById(Dvi).value);
		Dvi="PrX"+Ident1.slice(a);
		document.getElementById(Dvi).value=base4[valeur].prx;
		Dvi="PdS"+Ident1.slice(a);
		document.getElementById(Dvi).value=base4[valeur].pds;
		Dvi="ReF"+Ident1.slice(a);
		document.getElementById(Dvi).value=base4[valeur].ref;
	  }
	}else{
		pform1.disabled=false; pformv1="";
		pform1.focus();
	}
}

function idem(pform){
	document.getElementById("Nom_livr").value=document.getElementById("Nom").value+" "+document.getElementById("Prenom").value;
	document.getElementById("Ste_livr").value=document.getElementById("Ste").value;
	document.getElementById("Adresse_livr").value=document.getElementById("Adresse").value;
	document.getElementById("Adresse2_livr").value=document.getElementById("Adresse2").value;
	document.getElementById("Code_Post_livr").value=document.getElementById("Code_Post").value;
	document.getElementById("Ville_livr").value=document.getElementById("Ville").value;
	document.getElementById("Pays_livr").value=document.getElementById("Pays").value;
	document.getElementById("Email_livr").value=document.getElementById("Email").value;
	document.getElementById("Telephone_livr").value=document.getElementById("Telephone").value;
	if (document.getElementById("PaysChx").value=="."){
		document.getElementById("Pays").value=document.getElementById("Autre_Pays").value;
		document.getElementById("PaysChxL").value=".";
		document.getElementById("AutrePL").style.visibility="hidden";
		document.getElementById("Autre_PaysL").value=document.getElementById("Autre_Pays").value;
	}else{
		document.getElementById("PaysChxL").value=document.getElementById("PaysChx").value;
		document.getElementById("Pays").value=document.getElementById("PaysChx").value;
	}
	document.getElementById("SbMiT").disabled=false;
}
var non=0;var UpperWord=""
function ControlFields(Ident,pformV,suiv) {
	//alert (Ident);
	var pform = new Object;
	non=0;
	pform = eval(document.getElementById(Ident));
	var UpperWord=pformV;//alert(UpperWord+ " / " +pformV);
	if ( Ident!='NoTVA'  && Ident!='Telephone' && Ident!='Telecopie' && Ident!='Telephone_livr' && Ident!="Email" && Ident!="Email_livr"){
		if ( UpperWord!="" ){UpperWord=UpperWord.toUpperCase();}
	}
	if ( Ident!='NoTVA' && Ident!='Adresse2' && Ident!='Telecopie' && Ident!='Adresse2_livr'){
		
		if ((Ident=="Email" || Ident=="Email_livr")){
				if ( pformV!=""){
					if (pformV.length <= 6|| pformV.indexOf ('@', 0) == -1 ||pformV.indexOf ('.', 0) == -1){non=1;alert("'' " + pformV + " '', n'est pas une adresse e-mail Correcte.");pform.value="";pform.focus();return(false);}
					if (pformV.indexOf ('@', 0) < 4 ){non=1;alert("'' " + pformV + " '', n'est pas une adresse e-mail Correcte.");pform.value="";pform.focus();return(false);}
					
				}else{
					non=1;alert("Une adresse e-mail est obligatoire.");pform.focus();
				}
		}
		if (( Ident=="Code_Post" || Ident=="Code_Post_livr" ) && pformV!=""){
			if ( flg==0 && pformV.length < 4){non=1;alert("Vérifier votre Code Postal il n'a que "+pformV.length+" chiffres ! Il doit en avoir minimum 4 (Belgique, Suisse)");pform.value="";pform.focus();}
		}
	}
	if( non == 0 ){
			if (suiv!=""){
				document.getElementById(Ident).style.background="#FFFFFF";
				document.getElementById(Ident).value=UpperWord;
				//document.getElementById(Ident).style.disabled=true
				var a = new Object;
				a=eval(document.getElementById(suiv));
				a.style.background="#D5EDF6";
				a.focus();
			}
	}
}
function AutrePays(data){
	if (data==""){alert("vous devez entrer un pays !");document.getElementById("PaysChx").focus();return;}
	if (data  == "." ){
		document.getElementById("AutreP").style.visibility="visible";
		document.getElementById("Autre_Pays").focus();
	}else{
		document.getElementById("Pays").value=document.getElementById("PaysChx").value;
		document.getElementById("PaysChx").style.background="#FFFFFF";
		if (data!="FRANCE"){
			document.getElementById("SIR").style.visibility="hidden";
			document.getElementById("TVA").style.visibility="visible";
			document.getElementById("NoTVA").style.background="#D5EDF6";
			document.getElementById("NoTVA").focus();
		}else{
			document.getElementById("TVA").style.visibility="hidden";
			document.getElementById("SIR").style.visibility="visible";
			document.getElementById("Siret").style.background="#D5EDF6";
			document.getElementById("Siret").focus();
		}
	}
	
	//return;
}
function AutrePaysL(data){
	if (data==""){alert("vous devez entrer un pays !");document.getElementById("PaysChxL").focus();return;}
	if (data  == "." ){
		document.getElementById("AutrePL").style.visibility="visible";
		document.getElementById("Autre_PaysL").focus();
	}else{
		document.artform.Pays_livr.value=document.artform.PaysChxL.value;
		document.getElementById("PaysChxL").style.background="#D5EDF6";
		document.getElementById('SbMit').disabled=false;
		document.getElementById('SbMit').focus();
	}
	
	//return;
}


function Confirme(){
	 document.cookie="Coord_prf=?";
	 document.cookie="Coord_prf="+"["+document.artform.Nom.value+"%"+document.artform.Prenom.value+"¤"+document.artform.Ste.value+"+"+document.artform.Siret.value+">"+document.artform.Adresse.value+"&"+document.artform.Adresse2.value+"$"+document.artform.Code_Post.value+"#"+document.artform.Ville.value+"£"+document.artform.Pays.value+"â"+document.artform.Email.value+"µ"+document.artform.Telephone.value+"_"+document.artform.Telecopie.value+"<"+document.artform.Nom_livr.value+"!"+document.artform.Ste_livr.value+"*"+document.artform.Adresse_livr.value+"ô"+document.artform.Adresse2_livr.value+"}"+document.artform.Code_Post_livr.value+"{"+document.artform.Ville_livr.value+"/"+document.artform.Pays_livr.value+"û"+document.artform.Email_livr.value+"|"+document.artform.Telephone_livr.value+"]?";
	 document.cookie="Prof=µ";
	 var chaine1="";
		var Qt="";
		var Rf="";
		var Pr="";
		var Pd="";
		var cook="";
		for ( var i=0;i<=n2;i++){
				Qt="Qte_"+i;
				Ds="DeS_"+i;
				Rf="ReF_"+i;
				Pr="PrX_"+i;
				Pd="PdS_"+i;
				//alert(Qt);
			if (document.getElementById(Qt)!=null){
				if (document.getElementById(Qt).value!=""){
					cook = cook + "[" +document.getElementById(Ds).value + "*";
					cook = cook + document.getElementById(Rf).value + "$";
					cook = cook + document.getElementById(Pr).value + "£";
					cook = cook + document.getElementById(Qt).value + "%";
					cook = cook + document.getElementById(Pd).value + "]";
				}
			}
		}
		if ( cook!=""){
			document.cookie="Prof=" + cook + "µ";
			document.location.href="proforma2.html";
		}else{
			alert("Vous n'avez sélectionné aucun article !");
			return;
		}
	 //
}
