function Set_Cookie(name, value, expire) { 
    document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString())) 
}

function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function Get_VoidCookie(name) {
    ckval=Get_Cookie(name);
    if (ckval==null)
    	return "";
    else
    	return ckval;
}

function Get_Fullparam() {
	var start = location.search.indexOf("?");
	if ((!start)||(start==-1))  return null;
	return unescape(location.search.substring(start,location.search.length))
}

function Get_Param(name) {
    var start = location.search.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != location.search.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = location.search.indexOf("&",len);
    if (end == -1) end = location.search.length;
    return unescape(location.search.substring(len,end));
}

function verifycmd() {
	var champ="";
	if (document.formu.email.value.length==0)
		champ="mail";
	else if (document.formu.nom.value.length==0)
		champ="nom";
	else if (document.formu.prenom.value.length==0)
		champ="prénom";
	else if (document.formu.adresse.value.length==0)
		champ="adresse";
	else if (document.formu.codepostal.value.length==0)
		champ="code postal";
	else if (document.formu.ville.value.length==0)
		champ="ville";
	else if (document.formu.pays.value.length==0)
		champ="pays";
	else 
	{
		var text=document.formu.email.value;
  		if (text.indexOf("@")<2)
		{
			alert ("L'adresse email introduite est incorrecte.");
			return false;
		}
		else
		{
			var _envoi="";
			var _paiement="";

			for (var i=0;i<document.formu.envoi.length;i++)
			{
				if (document.formu.envoi[i].checked==true)
				{
					_envoi=document.formu.envoi[i].value;
					break;
				}
			}
			for (var i=0;i<document.formu.paiement.length;i++)
			{
				if (document.formu.paiement[i].checked==true)
				{
					_paiement=document.formu.paiement[i].value;
					break;
				}
			}
				document.formu.linkmail.value="http://127.0.0.1:24742/?mail="+escape(document.formu.email.value)+"&nom="+escape(document.formu.nom.value)+"&prenom="+escape(document.formu.prenom.value)+"&adresse="+escape(document.formu.adresse.value)+"&codepostal="+escape(document.formu.codepostal.value)+"&ville="+escape(document.formu.ville.value)+"&pays="+escape(document.formu.pays.value)+"&telephone="+escape(document.formu.telephone.value)+"&commentaire="+escape(document.formu.commentaire.value)+"&envoi="+_envoi+"&paiement="+_paiement+"&prix="+escape(document.formu.prix.value)+"&livre="+escape(document.formu.commande.value)+"&ref="+escape(document.formu.ref.value)+"&localdate="+escape(document.formu.localdate.value);
		
			var exp = new Date(); 
			exp.setTime(exp.getTime() + (1000*24*60*60*1000));
			Set_Cookie("nom", document.formu.nom.value,exp);
			Set_Cookie("prenom", document.formu.prenom.value,exp);
			Set_Cookie("email", document.formu.email.value,exp);
			Set_Cookie("adresse", document.formu.adresse.value,exp);
			Set_Cookie("ville", document.formu.ville.value,exp);
			Set_Cookie("codepostal", document.formu.codepostal.value,exp);
			Set_Cookie("telephone", document.formu.telephone.value,exp);
			return true;
		}
	}
	alert ("Veuillez remplir tout les champs.\nLe champ "+champ+" est manquant");
	return false;
}