<!--
      
	  function fdp(value) {
			alert(value);
	}
	  
	   function displayFlash(swf,largeur, hauteur, alternatif)
			{
				document.write('<object type="application/x-shockwave-flash" data="'+swf+'" width="'+largeur+'" height="'+hauteur+'">');
				document.write('<param name="allowScriptAccess" value="sameDomain" />');
				document.write('<param name="movie" value="'+swf+'" />');
				document.write(alternatif);
				document.write('</object>');
			}



var largeur;
var hauteur;

var gauche;
var haut;

var largeur_dispo = screen.width;
var hauteur_dispo = screen.height;

var parametres;

function centrage_popup(largeur, hauteur) {
  gauche = (largeur_dispo - largeur) / 2;
  haut   = (hauteur_dispo - hauteur) / 2;
  parametres = 'left=' + gauche + ', top=' + haut + ', width=' + largeur + ', height=' + hauteur + '';
}

function popup_constructeur(url) {
  largeur = largeur_dispo - 200;
  hauteur = hauteur_dispo - 100;
  centrage_popup(largeur, hauteur);

  window.open(url, '', 'scrollbars=1, ' + parametres);
}

function popup_contact(ville) {
  largeur = 250;
  hauteur = 200;
  centrage_popup(largeur, hauteur);

  window.open('contact/popup_' + ville + '.htm', '', parametres);
}

function popup_details(ref)
{ 
  largeur =  800;
  hauteur =  600;
  centrage_popup(largeur, hauteur);
  window.open('popup_details.php?ref='+ref, '','scrollbars=1, ' + parametres);
}

function popup_offres(page,w,h){
  centrage_popup(w, h);
  window.open(page,'','scrollbars=1, ' + parametres)
}

function selectionL(obj,color){
	obj.bgColor=color;
}

function TestSearch()
{
	if(document.formsearch.prod_rech.value=="")
	{
	        alert("Vous indiquez une référence !");
	        document.formsearch.prod_rech.focus();
	        document.formsearch.prod_rech.select();
	}
	else
	{
		document.formsearch.submit();
	}
}
function TestSearch2()
{
	if(document.formsearch2.Catalogue.selectedIndex<0)
	{
	        alert("Vous indiquez le catalogue !");
	        document.formsearch2.Catalogue.focus();
	        document.formsearch2.Catalogue.select();
	}
	else
	{
		document.formsearch2.submit();
	}
}
function rechercheProduit()
{
	if(document.formsearch3.Model.value=="")
	{
	        alert("Veuillez saisir un nom ou une référence produit !");
	        document.formsearch3.Model.focus();
	        document.formsearch3.Model.select();
	}
	else
	{
		document.formsearch3.submit();
	}
}

function identificationClient(obj)
{
	if(obj.login.value=="")
	{
	        alert("Vous n'avez pas saisi votre nom de client !");
	        obj.identifiant.focus();
	        obj.identifiant.select();
	}
	else if(obj.code.value=="")
	{
             alert("Vous n'avez pas saisi votre code client !");
	        obj.code.focus();
	        obj.code.select();                
	}
	else
	{
		obj.submit();
	}
}

function focusInscription()
{
	document.inscription.nbpdv.focus();
}

function valideInscription() 
{
	if(document.inscription.nom.value=="")
	{
	    alert("Nom de société obligatoire!");
	    document.inscription.nom.focus();
	    document.inscription.nom.select();
	}
	else if(! ValChiffre(document.inscription.nbpdv.value)){
		alert("Format nombre pdv invalide");
		document.inscription.nbpdv.focus();
        document.inscription.nbpdv.select();
	}
	else if(document.inscription.Siret.value=="")
	{
	    alert("N° Siret obligatoire!");
		document.inscription.Siret.focus();
		document.inscription.Siret.select();                
	}
	else if(document.inscription.adresse1.value=="")
	{
	    alert("Adresse 1 obligatoire!");
		document.inscription.adresse1.focus();
		document.inscription.adresse1.select();                
	}	
	else if(! ValChiffre(document.inscription.cp.value)){
		alert("Format du code postal non valide");
		document.inscription.cp.focus();
        document.inscription.cp.select();
	}
	else if(document.inscription.ville.value=="")
	{
    	alert("ville obligatoire!");
	    document.inscription.ville.focus();
	    document.inscription.ville.select();                
	}
	else if(document.inscription.ville.value=="")
	{
                alert("Ville obligatoire!");
	        document.inscription.ville.focus();
	        document.inscription.ville.select();                
	}
	else if(document.inscription.pays.value=="")
	{
                alert("Pays obligatoire!");
	        document.inscription.pays.focus();
	        document.inscription.pays.select();                
	}	
	else if(document.inscription.telephone.value=="")
	{
                alert("Telephone obligatoire!");
	        document.inscription.telephone.focus();
	        document.inscription.telephone.select();                
	}
	else if(document.inscription.Contact.value=="")
	{
                alert("Contact obligatoire!");
	        document.inscription.Contact.focus();
	        document.inscription.Contact.select();                
	}
	else if(! controleMail())
	{
            alert("Adresse email obligatoire!");
	        document.inscription.email.focus();
	        document.inscription.email.select();                
	}
	else if(document.inscription.identifiant.value=="")
	{
                alert("identifiant obligatoire!");
	        document.inscription.identifiant.focus();
	        document.inscription.identifiant.select();                
	}
	else if(document.inscription.code.value=="")
	{
                alert("Code obligatoire!");
	        document.inscription.code.focus();
	        document.inscription.code.select();                
	}	
	else
	{
		document.inscription.submit();
	}
}
function valideCode() 
{
	if(document.modification.identifiant.value=="")
	{
	        alert("Identifiant obligatoire!");
	        document.modification.identifiant.focus();
	        document.modification.identifiant.select();
	}
	else if(document.modification.code.value=="")
	{
                alert("Code client obligatoire!");
	        document.modification.code.focus();
	        document.modification.code.select();                
	}
	else
	{
		document.modification.submit();
	}	
}
function ValChiffre(valeur)
{
	if(valeur=="")
		return false;
	var m=parseFloat(valeur); 
  	if (isNaN(m)) { 
    	return false;
	}
	else {
		m=Number(valeur); 
		if (isNaN(m)) {
			return false;
		}
	}
	return true;
}
function controleMail()
{
	if ( (document.inscription.email.value =="") || (document.inscription.email.value.indexOf("@") =="-1") || (document.inscription.email.value.indexOf(".") =="-1")){
		return false;
	} 
	else {
		return true;
	}
}

function valideInfoLivre() 
{
	if(document.inscription.nom.value=="")
	{
	    alert("Nom de société obligatoire!");
	    document.inscription.nom.focus();
	    document.inscription.nom.select();
	}
	else if(document.inscription.adr1.value=="")
	{
	    alert("Adresse 1 obligatoire!");
		document.inscription.adresse1.focus();
		document.inscription.adresse1.select();                
	}	
	else if(! ValChiffre(document.inscription.cp.value)){
		alert("Format du code postal non valide");
		document.inscription.cp.focus();
        document.inscription.cp.select();
	}
	else if(document.inscription.ville.value==""){
    	alert("ville obligatoire!");
	    document.inscription.ville.focus();
	    document.inscription.ville.select();                
	}
	else if(document.inscription.pays.value==""){
        alert("Pays obligatoire!");
		document.inscription.pays.focus();
	    document.inscription.pays.select();                
	}	
	else{
		document.inscription.submit();
	}
}

function OpenPopupImage(IdProduit){
	window.open('description.php?id_produit='+IdProduit,'Description','toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=522');
}

function ModifQte(Obj,Action,Tarif){
	if(Action==-1 & Obj.valeur.value=="0"){
		return;
	}
	else{
		if(isNaN(parseInt(Obj.valeur.value))){
			Obj.valeur.value=Obj.vieux.value;	 
			
		}
		else{
			Obj.valeur.value=parseInt(Obj.valeur.value)+Action;
			Obj.vieux.value=Obj.valeur.value;
			Obj.action='ajout_caddie.php';
			Obj.submit();	 
					}
	}
}

function ModifQtePanier(Obj,Action,Tarif,Affiche){	  
    
	Affiche=Affiche;
	var Mont;
	if(Obj.blister[0].checked)
		Mont=Obj.blister[0].value;
	else
		Mont=Obj.blister[1].value;

	if(Action==-1 & Obj.valeur.value=="0")	 
	  {
		return;
	 }		
	 	   
     if(Action ==-2) {  
	 var fdp = Tarif;		 
	  Caddie.rows(nbelem+3).cells(3).innerHTML='<b>'+fdp+'€</b>';	
	   	var total=0;			
	     for(i=1;i<=nbelem;i++){
					total+=parseFloat(document.getElementsByName('List'+i).item(0).Monttotal.value);	
					
					}
	  				  totalht = total+fdp;	  
					
				  //totalht = float(totalht,2);	   
				  var afftotalht = totalht.toFixed(2)
				  Caddie.rows(nbelem+4).cells(3).innerHTML='<B>'+afftotalht+' €</B>';	
				  totalttc = Math.round(((total+fdp)*1.196)*100) / 100;
				  Caddie.rows(nbelem+5).cells(1).innerHTML='<B>'+totalttc+' €</B>';	
	}	
	
	else{
	       
		  
	
		if(isNaN(parseInt(Obj.valeur.value))){
		  Obj.valeur.value=Obj.vieux.value;
		}
		else{	
		
		     if(Action != "0.5")
			   { 
			Obj.valeur.value=parseInt(Obj.valeur.value)+Action;
			   }
			Obj.vieux.value=Obj.valeur.value;
			Obj.Monttotal.value=Math.round((parseInt(Obj.valeur.value)*100)*((parseFloat(Tarif)+parseFloat(Mont))*100))/10000;
			Affiche.innerText=Obj.Monttotal.value + '€';
			Obj.submit();
			var total=0;
			if(Obj.valeur.value!="0"){
				for(i=1;i<=nbelem;i++){
					total+=parseFloat(document.getElementsByName('List'+i).item(0).Monttotal.value);
				} 	
				 
				//total = float(total,2)   ;
				//total= Math.round((total)*100) / 100;		
				var afftotal = total.toFixed(2)
				Caddie.rows(nbelem+2).cells(3).innerHTML='<B>'+afftotal+' €</B>';	   
				if(total < 100) {
				Caddie.rows(nbelem+6).cells(0).innerHTML='Le montant de votre commande doit être superieur à 100 €';	
				document.getElementById('valider').style.visibility='hidden';

				}	  
				else
				 { 
				 				Caddie.rows(nbelem+6).cells(0).innerHTML='';	
								document.getElementById('valider').style.visibility='visible';

				 }	 
				   if(document.getElementById('fdp2').value == undefined )
						{
						var fdp1=15;
						}
						else	
						{
						var fdp1 = document.getElementById('fdp2').value ;
						}												  
				fdp = fdp1;		
				  
				 
				 
				 if(total > 249) {
				 Caddie.rows(nbelem+3).cells(3).innerHTML='<b>0 €</b>';	
				 fdp = 0;	
				
				 }		 
				 else
				  {	 
				   Caddie.rows(nbelem+3).cells(3).innerHTML='<b>'+fdp+'€</b>';	 
				    
				  // alert(fdp1);
				  }	  
				
				//  alert(document.getElementById('fdp2').value);
				  //alert(fdp);
				  totalht = total+fdp;	 
				  //totalht = float(totalht,2);	   
				  var afftotalht = totalht.toFixed(2)
				  Caddie.rows(nbelem+4).cells(3).innerHTML='<B>'+afftotalht+' €</B>';	
				  totalttc = Math.round(((total+fdp)*1.196)*100) / 100;
				  Caddie.rows(nbelem+5).cells(1).innerHTML='<B>'+totalttc+' €</B>';	
			
			}
			else{
				window.open('index2.php?Num=11','_self');
			}
		}
	}
}

function ModeTrie(col,tri){
	if(Search.Model!=""){
		Search.action=Search.action+'&tri='+tri+'&col='+col;
		Search.submit();
	}
	else
		window.open(Search.action=Search.action+'&tri='+tri+'&col='+col);
}

function TestValCaddie(){
	if(document.form_commande.SocLivre.value==""){
		alert('Vous devez indiquer le nom de la société');
		document.form_commande.SocLivre.focus();
		document.form_commande.SocLivre.select();
	}
	else if(document.form_commande.adresseLivr1.value==""){
		alert('Vous devez indiquer votre adresse');
		document.form_commande.adresseLivr1.focus();
		document.form_commande.adresseLivr1.select();
	}
	else if(document.form_commande.cpLivr.value==""){
		alert('Vous devez indiquer le code postal');
		document.form_commande.cpLivr.focus();
		document.form_commande.cpLivr.select();
	}
	else if(document.form_commande.villeLivr.value==""){
		alert('Vous devez indiquer la ville de livraison');
		document.form_commande.villeLivr.focus();
		document.form_commande.villeLivr.select();
	}
	else if(document.form_commande.paysLivr.value==""){
		alert('Vous devez indiquer le pays');
		document.form_commande.paysLivr.focus();
		document.form_commande.paysLivr.select();
	}
	else {	 
		document.form_commande.submit();
		}
}
function OpenPupup(IdProduit){
	window.open('description.php?id_produit='+IdProduit,'Description','toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=400,height=500');
}
//-->
				 
function telephone_choice(f)
  {	   	 
	  var l1    = f.elements["list1"];
	var l2    = f.elements["list2"];
	var index = l1.selectedIndex;
	if(index < 1)
	   l2.options.length = 0;
	else {
	   var xhr_object = null;
	   if(window.XMLHttpRequest) // Firefox
	      xhr_object = new XMLHttpRequest();
	   else if(window.ActiveXObject) // Internet Explorer
	      xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	   else { // XMLHttpRequest non supporté par le navigateur
	      alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
	      return;
	   }
	
	   xhr_object.open("POST", "query/query_tel.php", true);
		
	   xhr_object.onreadystatechange = function() {
	      if(xhr_object.readyState == 4)
	         eval(xhr_object.responseText);	  
			 }
	
	   xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	   var data = "data="+escape(l1.options[index].value)+"&form="+f.name+"&select=list2";
	   xhr_object.send(data);
	}

  
  }
