	// Tableaux pour les berlingots
	total = new Array(50);
	qte = new Array(50);
	pds = new Array(50);
	for(j=0; j<=21; j++)
	{
		total[j] = 0;
		qte[j] = 0;
		pds[j] = 0;
	}
	
	// Pour les berlingots
	function calcul(quant,i,prix)
		{
		   quant=Number(quant);
         reg_point=new RegExp("[^0-9]","gi");

         if (reg_point.test(quant))
         {
            alert("Attention, une quantité doit être un nombre entier!");
            eval("document.forms[0].qteb_"+i+".value = 0");
         }
        else
		{
            qte[i]=quant;
			
//Debut ajout
         //Pour eviter les erreurs d'arrondis
temp = Number(quant*prix);
         reg_sup=new RegExp("99999","gi");
         reg_inf=new RegExp("00000","gi");

         if (reg_sup.test(temp))
         {
            temp = (temp*100);
            temp = Math.round(temp);
            temp = temp/100;
         }
         else if (reg_inf.test(temp))
         {
            temp = (temp*100);
            temp = Math.round(temp);
            temp = temp/100;
         }
//Fin ajout
            total[i]= temp;
            eval("document.getElementById('tot"+i+"').innerHTML = total["+i+"];");
            CouTotal();
   		 }
		}

	function CouTotal()
		{
		   var temp = 0;
		for(j=0; j<=21; j++)
		   {
		      temp = temp + Number(total[j]);
		   }
         //Pour eviter les erreurs d'arrondis
         reg_sup=new RegExp("99999","gi");
         reg_inf=new RegExp("00000","gi");

         if (reg_sup.test(temp))
         {
            temp = (temp*100);
            temp = Math.round(temp);
            temp = temp/100;
         }
         else if (reg_inf.test(temp))
         {
            temp = (temp*100);
            temp = Math.round(temp);
            temp = temp/100;
         }
		   
		   if (document.getElementById('pays').value == "France")
		   {
			   if (temp >= 70)
			   {
	   			document.getElementById('offert').innerHTML = "offert";
	   			document.getElementById('port').innerHTML = "0";
			   }
			   else
			   {
	   			document.getElementById('offert').innerHTML = " forfait: ";
	   			document.getElementById('port').innerHTML = "8";
			   }
			}
			else
			{
	   			document.getElementById('port').innerHTML = "25";
			}
		   total[22] = temp + Number(document.getElementById('port').innerHTML);
		   //Pour eviter les erreurs d'arrondis
         if (reg_sup.test(total[22]))
         {
            total[22] = (total[22]*100);
            total[22] = Math.round(total[22]);
            total[22] = total[22]/100;
         }
         else if (reg_inf.test(total[22]))
         {
            total[22] = (total[22]*100);
            total[22] = Math.round(total[22]);
            total[22] = total[22]/100;
         }
		   
		   document.getElementById('tot_final').innerHTML = total[22];
		   }
	
	function init(){
	//Mise en place des cookies
		var varNom = GetCookie("_NOM_BERLINGOTS");
		var varPrenom = GetCookie("_PRENOM_BERLINGOTS");
		var varAdres_1 = GetCookie("_ADRESS1_BERLINGOTS");
		var varAdres_2 = GetCookie("_ADRESS2_BERLINGOTS");
		var varCod_post = GetCookie("_COD_POST_BERLINGOTS");
		var varVille = GetCookie("_VILLE_BERLINGOTS");
		var varPays = GetCookie("_PAYS_BERLINGOTS");
		var varPhone = GetCookie("_PHONE_BERLINGOTS");
	
		if (varNom == null || varNom == "") {
			varNom = "";
		}
		document.getElementById('nom').value = varNom;
	
		if (varPrenom == null || varPrenom == "") {
			varPrenom = "";
		}
		document.getElementById('prenom').value = varPrenom;

		if (varAdres_1 == null || varAdres_1 == "") {
			varAdres_1 = "";
		}
		document.getElementById('adres_1').value = varAdres_1;

		if (varAdres_2 == null || varAdres_2 == "") {
			varAdres_2 = "";
		}
		document.getElementById('adres_2').value = varAdres_2;

		if (varCod_post == null || varCod_post == "") {
			varCod_post = "";
		}
        document.getElementById('cod_post').value = varCod_post;

		if (varVille == null || varVille == "") {
			varVille = "";
		}
		document.getElementById('ville').value = varVille;

		if (varPays == null || varPays == "") {
			varPays = "France";
		}
		document.getElementById('pays').value = varPays;

		if (varPhone == null || varPhone == "") {
			varPhone = "";
		}
		document.getElementById('telephon').value = varPhone;
		RazTab();
	}

	function ecritCookies()
	{
  		var aExpDate = new Date();
  		aExpDate.setTime( aExpDate.getTime() + 1000 * 86400 *365 );//  1an!
  		SetCookie("_NOM_BERLINGOTS", document.getElementById('nom').value, aExpDate);
  		SetCookie("_PRENOM_BERLINGOTS", document.getElementById('prenom').value, aExpDate);
  		SetCookie("_ADRESS1_BERLINGOTS", document.getElementById('adres_1').value, aExpDate);
  		SetCookie("_ADRESS2_BERLINGOTS", document.getElementById('adres_2').value, aExpDate);
  		SetCookie("_COD_POST_BERLINGOTS", document.getElementById('cod_post').value, aExpDate);
  		SetCookie("_VILLE_BERLINGOTS", document.getElementById('ville').value, aExpDate);
  		SetCookie("_PAYS_BERLINGOTS", document.getElementById('pays').value, aExpDate);
  		SetCookie("_PHONE_BERLINGOTS", document.getElementById('telephon').value, aExpDate);
	}


	function RazTab()
		{
			for(j=0;j<=50;j=j+1)
			{
			   total[j]=0;
			   qte[j]=0;
			   pds[j]=0;
			}
			for(j=0;j<=16;j=j+1)
			{
//           eval("document.forms[0].qteb_"+j+".value = 0;");
            qte[j] = eval("document.forms[0].qteb_"+j+".value;");
            total[j] = eval("document.getElementById('tot"+j+"').innerHTML;");
           }
   		pds[22] = document.getElementById('port').innerHTML;
		   total[22] = document.getElementById('tot_final').innerHTML;
      }

   function NewWindow()
      {
         var hWnd = window.open('com_bonf.html',null,'location=no, menubar=yes, directories=no, fullscreen=no, resizable=no, scrollbars=yes, status=no, toolbar=no; width=700; height=600; top=50; left=200;');
         //var hWnd = window.open('com_bonf.html');

         hWnd.focus();
      }
