	function ajouter_commande(num,MyCode){
		var Clef="";
		if (MyCode!=""){
			var saisie = prompt("Saisissez le code ( " + MyCode + " ) :", "");
			if(saisie){
				if(VerifClef(saisie,MyCode)){
	        		Clef=saisie;
					window.location.href="commandestep1.asp?action=ajouter&num=" + num + "&CodeVerif=" + Clef;
				}
				else{
					alert("Code non valide");
				}
			}
		}
		else
			window.location.href="commandestep1.asp?action=ajouter&num=" + num + "&MyCode=" + Clef;
	}
	
	function AddCommandeStickers(num,MyCode){
		var Clef="";
		var NumColor="";
		var NumColorFond="";
		var SensOrientation="";
		if(CarreCrayon)
			NumColor=CarreCrayon.value;
		if(Orientation)
			SensOrientation=Orientation.value;
		if(CarreFond)
			NumColorFond=CarreFond.value;
		if(Taille)
			NumTaille=Taille.value;
       	if (MyCode!=""){
			var saisie = prompt("Saisissez le code ( " + MyCode + " ) :", "");
			if(saisie){
				if(VerifClef(saisie,MyCode)){
	        		Clef=saisie;
					window.location.href="commandestep1.asp?action=ajouter&num=" + num + "&CodeVerif=" + Clef + "&NumTaille=" + NumTaille;
				}
				else{
					alert("Code non valide");
				}
			}
		}
		else
			window.location.href="commandestep1.asp?action=ajouter&num=" + num + "&MyCode=" + Clef + "&NumColor=" + NumColor + "&NumColorFond=" + NumColorFond + "&NumTaille=" + NumTaille + "&Orientation=" + SensOrientation;
	}

	function ouvre_commande(){
		window.location.href="commandestep1.asp";
	}
	
function VerifClef(MaChaine,FormatAllowed){
	var res=false;

	// Si MaChaine a été saisie 
	if (MaChaine.length>0){
		//Retranscription de MaChaine sous forme de format "AAANNN"
		var Format="";
		var Encodage = new Array();
		for(var i = 0; i < MaChaine.length; i++) {
			// On retranscrit le format en  Numerique iou Caractere
			if (!parseFloat(MaChaine.charAt(i)))
				Encodage [i] = "A";
			else
				Encodage [i] = "N";
		}
		for(var i = 0; i < MaChaine.length; i++){
			Format = Format + Encodage [i];
		}
		
		//Comparaison avec FormatAllowed
		var MyTableau=FormatAllowed.split(";");
		for (var i=0; i<MyTableau.length; i++){
			if(MyTableau[i]==Format)
				res=true;
		}
	}
	return res;
}