function isnum(champ)
{
valeur=champ.value;
if (valeur=='') {return;}
var n=valeur.length;
var num=true;
var i=0;
while ((num) && (i<n))
  {
c=valeur.substring(i,i+1);

if (!(c=="0"||c=="1"||c=="2"||c=="3"||c=="4"||c=="5"||c=="6"||c=="7"||c=="8"||c=="9"))
     {
     num=false;
     alert(valeur+" n\'est pas un nombre entier !");
     champ.value='';
     return;
     }
  i=i+1;
   }

}





function voircommande()
{
var n=document.forms[0].elements.length;
var tm=0;
var pt=0;
var i=0;
var tpo=0;
var msg="";
while (i<n-8)
    {
	p=parseFloat(document.forms[0].elements[i].value);
	po=parseFloat(document.forms[0].elements[i+1].value);
    q=parseInt(document.forms[0].elements[i+2].value);
    nommod=document.forms[0].elements[i+2].name;
	 
    if (!(isNaN(p)||isNaN(q)))
        {
         tm=tm+q;
         pt=pt+ p*q;
		 tpo=tpo+q*po;
         msg=msg+"\n"+q+ " objets "+nommod+ " à "+p+" € ";
        }
    i=i+3;
    }
msg=msg+ "\n Soit "+tm+" objets pour un total (hors frais de port) de "+pt+" € \n Pour un poids total de : "+tpo+" kg";
ok=confirm("Vous avez sélectionné : \n"+msg);

if(ok)
   {
    if (formOK())
       {
        val=confirm('Voulez vous valider votre commande ?');
        if (val){document.forms[0].submit();}
       }
        else
       {
       alert('Formulaire non rempli !\n Remplissez le, puis cliquer à nouveau sur :\nVérifiez votre commande');
       self.location.hash='FORMULAIRE';
       document.forms[0].NOM.focus();
       }
    }
    else
   {document.forms[0].reset();}

}


function maj(x)
{var txt=x.value;
txt=txt.toUpperCase();
x.value=txt;
}

function formOK()
{
nom=(document.forms[0].NOM.value!="");
prenom=(document.forms[0].PRENOM.value!="");
adresse=(document.forms[0].ADRESSE.value!="");
ville=(document.forms[0].VILLE.value!="");
code=(document.forms[0].CODE.value!="");

if (nom&&prenom&&adresse&&ville&&code)
         {return true;}
         else
         {return false;}
}

function paypal()
{alert("Paypal est un système de paiement sécurisé en ligne\n qui permet de régler\n aux titulaires d'un compte PayPal ou d'une carte bancaire.");
}

function tarif(file)
{window.open(file, 'Barême', 'height=250, width=420, top=200, left=200, toolbar=no, menubar=no, location=n0, resizable=no, scrollbars=yes, status=no');
}
