// JavaScript Document



 function fermer_popup() {
	$.fn.colorbox.close();
}

function hidediv(IdDiv) { 
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(IdDiv).style.visibility = 'hidden'; 
	} 

}

function showdiv(IdDiv) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(IdDiv).style.visibility = 'visible';
	}

}

 function add_favori(nomproduit,rewrite) {
	if ( navigator.appName != 'Microsoft Internet Explorer' )
	{ window.sidebar.addPanel("Powersante - "+nomproduit ,"http://www.powersante.com/fiche_produit.php?p="+rewrite,""); }
	else { window.external.AddFavorite("http://www.powersante.com/fiche_produit.php?p="+rewrite,"Powersante - "+nomproduit); }

}


function file(fichier)
{
if(window.XMLHttpRequest) // FIREFOX
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // IE
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else
return(false);
xhr_object.open("GET", fichier, false);
xhr_object.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=iso-8859-1");
xhr_object.send(null);
if(xhr_object.readyState == 4) return(xhr_object.responseText);
else return(false);
}





function charge_produit(cursor,chp,ext,ext2) {

var contenu;

   contenu = file("_ajax_home_produits.php?"+chp+"="+cursor+"&"+ext+"&"+ext2);
   document.getElementById('header-home-ajax').innerHTML = contenu;


}

function charge_ss_menu(idfamille,onglet_actif,i,nb_menu) {

  // recharge_nav(idfamille,onglet_nav);

   /** document.getElementById('nav').style.borderBottom = '1px #d2d2d2 solid';**/

     for (j=0;j<nb_menu;j++) {
        if (i!=j) {
            document.getElementById('famille-'+j).style.color = '#ffffff';
            document.getElementById('famille-'+j).style.backgroundColor = '#01887e';
           // document.getElementById('lien-famille-'+j).style.color = '#ffffff';
            document.getElementById('menu-famille-'+j).style.border = '1px #01887e solid';
            document.getElementById('famille-'+j).style.border = '1px #01887e solid';
        }
    }

    if (onglet_actif != i && onglet_actif !=-1)  {
            document.getElementById('famille-'+onglet_actif).style.color = '#ffffff';
            document.getElementById('famille-'+onglet_actif).style.backgroundColor = '#e2017b';
            document.getElementById('menu-famille-'+onglet_actif).style.border = '1px #e2017b solid';
            document.getElementById('famille-'+onglet_actif).style.border = '1px #e2017b solid';


    }

    document.getElementById('famille-'+i).style.color = '#e2017b';
    document.getElementById('famille-'+i).style.backgroundColor = '#f6f6f6';
   // document.getElementById('lien-famille-'+i).style.color = '#e2017b';
    document.getElementById('menu-famille-'+i).style.borderTop = '1px #e2017b solid';
    document.getElementById('menu-famille-'+i).style.borderRight = '1px #e2017b solid';
    document.getElementById('menu-famille-'+i).style.borderLeft = '1px #e2017b solid';
    document.getElementById('menu-famille-'+i).style.borderBottom = '1px #f6f6f6 solid';

    document.getElementById('famille-'+i).style.borderTop = '1px #d2d2d2 solid';
    document.getElementById('famille-'+i).style.borderRight = '1px #d2d2d2 solid';
    document.getElementById('famille-'+i).style.borderLeft = '1px #d2d2d2 solid';
    document.getElementById('famille-'+i).style.borderBottom = '1px #f6f6f6 solid';

    contenu = file("_ajax_ss_menu_famille.php?id="+idfamille);
    document.getElementById('sous-menu-famille').innerHTML = contenu;
    document.getElementById('sous-menu-famille').style.visibility = 'visible';

}

 function uncharge_ss_menu(nb_menu,onglet_actif) {

    hide_ss_nav();
    for (i=0;i<nb_menu;i++) {
        document.getElementById('famille-'+i).style.color = '#ffffff';
        document.getElementById('famille-'+i).style.backgroundColor = '#01887e';
        // document.getElementById('lien-famille-'+i).style.color = '#ffffff';
        document.getElementById('menu-famille-'+i).style.border = '1px #01887e solid';
        document.getElementById('famille-'+i).style.border = '1px #01887e solid';
    }

 if (onglet_actif !=-1) {
      document.getElementById('famille-'+onglet_actif).style.color = '#ffffff';
      document.getElementById('famille-'+onglet_actif).style.backgroundColor = '#e2017b';
      document.getElementById('menu-famille-'+onglet_actif).style.border = '1px #e2017b solid';
      document.getElementById('famille-'+onglet_actif).style.border = '1px #e2017b solid';
 }

}

function recharge_nav(idfamille,onglet_nav) {

    contenu = file("_ajax_menu.php?id="+idfamille+"&onglet_nav="+onglet_nav);
    document.getElementById('nav').innerHTML = contenu;

}

function hide_ss_nav() {

     document.getElementById('sous-menu-famille').style.visibility = 'hidden';


}

/**
function charge_produit(cursor,chp,ext) {

	new Ajax('_ajax_home_produits.php', {
		postBody: chp+'='+cursor+ext,
		method: 'get',		
		update: $('header-home-ajax')
	}).request();

	
}**/


function old_charge_produit(cursor,chp,ext) {

	document.location='index.php?'+chp+'='+cursor+ext;

}


function send_contact() {

if(check_form_champs_oblig("form1", "email,civilite,nom,prenom,adresse,cp,ville,pays,tel") && check_mail('form1','email')) {
		document.form1.actiontype.value='send';
		document.form1.submit();
	}	

}

function send_un_conseiller() {

	if (document.forma.nom.value=='Votre nom') document.forma.nom.value='';
	if (document.forma.prenom.value=='Votre prenom') document.forma.prenom.value='';
	if (document.forma.tel.value=='Votre telephone') document.forma.tel.value='';
	if (document.forma.sujet.value=='Sujet a aborder') document.forma.sujet.value='';

	if(check_form_champs_oblig("forma", "nom,prenom,tel,sujet")) {
		myDatas = "nom=" + document.forma.nom.value +"&prenom=" + document.forma.prenom.value +"&tel=" + document.forma.tel.value+"&sujet=" + document.forma.sujet.value;
        contenu = file("ajax_un_conseiller_vous_rappelle.php?"+myDatas);
        alert("Un conseiller vous rappelera rapidement");
        fermer_popup();
	}

}



function send_devenir_partenaire() {

if(check_form_champs_oblig("form1", "email,nom,prenom,cp,ville,pays,tel,adresse,societe,tel") && check_mail('form1','email')) {
		document.form1.actiontype.value='send';
		document.form1.submit();
	}	
}




// Fonctions a checker

function search_decompte() {

date1 = document.form1.date1.value;
date2 = document.form1.date2.value;

if (date1 !="" && date2 !="") {
	
	if ((get_difference_date(date1,date2)) > 32) alert("La période de recherche des décomptes ne doit pas excéder 1 mois");
	else {
		document.form1.actiontype.value='search';
		document.form1.submit();
	}
} else {
	if (check_form_champs_oblig("form1", "acte")) {
		document.form1.actiontype.value='search';
		document.form1.submit();
	}
}

}

function get_difference_date(date1,date2) {
		
   var x = date1;
   var y = date2;
   //assuming that the delimiter for dt time picker is a '/'.        
   var arr1 = x.split('-');        
   var arr2 = y.split('-');         
   var dt1 = new Date();       
   dt1.setFullYear(arr1[0], arr1[1], arr1[2]);
   var dt2 = new Date();  
   dt2.setFullYear(arr2[0], arr2[1], arr2[2]);
   return (dt2.valueOf() - dt1.valueOf()) / (60 * 60 * 24 * 1000);

}

function loggue_adherent() {

	new Ajax('form_loggue.php', {
		update: $('espace_loggue')
	}).request();
}



function perdu_mdp() {

	if(check_form_champs_oblig("form1", "email") && check_mail('form1','email')) {
		document.form1.actiontype.value='send';
		document.form1.submit();
	}	
}

function connexion() {

if(check_form_champs_oblig("form_loggue", "login,pwd") && (check_form_champs_egal ("form_loggue", "login", "Identifiant")==false) && (check_form_champs_egal ("form_loggue", "pwd", "Mot de passe")==false)) {
		document.form_loggue.submit();
	}	
else alert("Merci de saisir tous les champs obligatoires");
}

function connexion2() {

if(check_form_champs_oblig("form_loggue2", "login,pwd") && (check_form_champs_egal ("form_loggue2", "login", "Identifiant")==false) && (check_form_champs_egal ("form_loggue2", "pwd", "Mot de passe")==false)) {
		document.form_loggue2.submit();
	}	
else alert("Merci de saisir tous les champs obligatoires");
}

function supprime_all_contact() {

if (confirm('\312tes-vous certain de vouloir supprimer tous les contacts s\351lectionn\351s ?')) {

	document.action.actiontype.value='delete_all';
	document.action.submit();
}

}


function reload_form() {

	document.form1.actiontype.value='reload';
	document.form1.submit();

}


function send_etape1() {

var bool_ok = true;

if (!check_form_champs_oblig("form1", "date_naiss,dept")) bool_ok=false;
if (bool_ok) {
	if (check_form_champs_egal ("form1", "conjoint", "1")) {
		if (!check_form_champs_oblig("form1", "date_naiss_conj")) bool_ok=false;	
	}
	if (bool_ok) {
		nb_enfants = document.form1.nb_enfants.value;
		for (e=1;((e<=nb_enfants) && (bool_ok));e++) {
			if (!check_form_champs_oblig("form1", "date_naiss_enf"+e)) bool_ok=false;			
		}
	}
	
	if (bool_ok) {
		nb_adultes = document.form1.nb_adultes.value;
		for (e=1;((e<=nb_adultes) && (bool_ok));e++) {
			if (!check_form_champs_oblig("form1", "date_naiss_adulte"+e)) bool_ok=false;			
		}
	}

}

  if (bool_ok) { 
  	
  	document.form1.actiontype.value='send';
  	document.form1.submit();
  }	

}


function send_etape2() {

var bool_ok = true;
if((check_form_champs_oblig("form1", "civilite,nom,prenom,email,adresse,ville,cp,pays,tel,secu")==false) || (check_mail('form1','email')==false)) bool_ok=false;
if (bool_ok) {
	if (digit_champ("secu","form1",15)==false) bool_ok=false;
}	

if (bool_ok) {
	if (digit_champ("cp","form1",5)==false) bool_ok=false;
}

if (bool_ok) {
	if (digit_champ("tel","form1",10)==false) bool_ok=false;
}

if (bool_ok) {
	if (type_donnne ("nom", "form1","alpha")==false) bool_ok=false;
}

if (bool_ok) {
	if (type_donnne ("prenom", "form1","alpha")==false) bool_ok=false;
}


if (bool_ok) {
	if (type_donnne ("secu", "form1","num")==false) bool_ok=false;
}

if (bool_ok) {
	if (type_donnne ("tel", "form1","num")==false) bool_ok=false;
}

if (bool_ok) {
	if (type_donnne ("cp", "form1","num")==false) bool_ok=false;
}


if (bool_ok) {

	// on check le numero de secu
	if (digit_champ("secu","form1",15)==false) bool_ok=false;

	if (check_form_champs_egal ("form1", "conjoint", "1")) {		
		if (!check_form_champs_oblig("form1", "nom_conjoint,prenom_conjoint,secu_conjoint")) bool_ok=false;	
		if (bool_ok) {
			if (digit_champ("secu_conjoint","form1",15)==false) bool_ok=false;
		}	
		
		if (bool_ok) {
			if (type_donnne ("nom_conjoint", "form1","alpha")==false) bool_ok=false;
		}

		if (bool_ok) {
			if (type_donnne ("prenom_conjoint", "form1","alpha")==false) bool_ok=false;
		}
		
		if (bool_ok) {
			if (type_donnne ("secu_conjoint", "form1","num")==false) bool_ok=false;
		}
		
	}
	if (bool_ok) {
		nb_enfants = document.form1.nb_enfants.value;
		for (e=1;((e<=nb_enfants) && (bool_ok));e++) {
			if (!check_form_champs_oblig("form1", "nom_enfant"+e+",prenom_enfant"+e+",secu_enfant"+e)) bool_ok=false;			
			if (bool_ok) {
				if (digit_champ("secu_enfant"+e,"form1",15)==false) bool_ok=false;
			}
			
			if (bool_ok) {
				if (type_donnne ("nom_enfant"+e, "form1","alpha")==false) bool_ok=false;
			}

			if (bool_ok) {
				if (type_donnne ("prenom_enfant"+e, "form1","alpha")==false) bool_ok=false;
			}
			if (bool_ok) {
				if (type_donnne ("secu_enfant"+e, "form1","num")==false) bool_ok=false;
			}

				
		}
	}
	
	if (bool_ok) {
		nb_adultes = document.form1.nb_adultes.value;
		for (e=1;((e<=nb_adultes) && (bool_ok));e++) {
			if (!check_form_champs_oblig("form1", "nom_adulte"+e+",prenom_adulte"+e+",secu_adulte"+e)) bool_ok=false;	
			if (bool_ok) {
				if (digit_champ("secu_adulte"+e,"form1",15)==false) bool_ok=false;		
			}	
			
			if (bool_ok) {
				if (type_donnne ("nom_adulte"+e, "form1","alpha")==false) bool_ok=false;
			}

			if (bool_ok) {
				if (type_donnne ("prenom_adulte"+e, "form1","alpha")==false) bool_ok=false;
			}
			if (bool_ok) {
				if (type_donnne ("secu_adulte"+e, "form1","num")==false) bool_ok=false;
			}


			
		}
	}

}

	
	
 if (bool_ok) { 
 	if (confirm('Vos coordonn\351es et les informations concernant vos b\351n\351ficiaires sont-elles bien exactes ?	')) {
	  	document.form1.actiontype.value='send';
  		document.form1.submit();
	}	
  }	

}

function recevoir_devis(produit) {

	document.form1.produit_select.value=produit;
	document.form1.actiontype.value='devis';
  	document.form1.submit();

}

function adherer_enligne(produit) {

	document.form1.produit_select.value=produit;
	document.form1.actiontype.value='adherer';
  	document.form1.submit();

}



function send_contactez_nous_extranet() { // formulaire contact de l'espace extranet
	if(check_form_champs_oblig("form1", "type_demande,demande")) {
		document.form1.actiontype.value='send';
		document.form1.submit();
	}	
}

function send_contactez_nous() { // formulaire contactez-nous de l'espace Internet

	if(check_form_champs_oblig("form1", "nom,prenom,email,adresse,ville,cp,pays,tel,type_demande")&& check_mail('form1','email')) {
		document.form1.submit();
	}	

}

function affiche_guide(id) {

}



function update_profil() {

}

function update_mdp() {

	if(check_form_champs_oblig("form1", "login,old_mdp,mdp,mdp2") && sont_egaux("form1", "mdp", "mdp2")) {
		document.form1.actiontype.value='send';
		document.form1.submit();
	}


}


function recherche() {
	document.tri.submit();
}

function charge_rs(table,id) {

		document.action.actiontype.value = 'LOAD_RS';	
		document.action.AjaxtableF.value = table;
		document.action.AjaxFK.value = id;
		document.action.submit();

}

function reload_rs(id) {

		document.ajouter_produit.actiontype.value = 'LOAD_RS';			
		//document.ajouter_produit.AjaxFK.value = id;
		if (isInForm("titre1", "ajouter_produit")) {
			document.ajouter_produit.titre1.value = '';
		}
		if (isInForm("titre2", "ajouter_produit")) {
			 document.ajouter_produit.titre2.value = '';		
		}
		if (isInForm("contenu", "ajouter_produit")) {
			document.ajouter_produit.contenu.value = '';				
		}
		
		if (isInForm("mots_cles", "ajouter_produit")) {
			document.ajouter_produit.mots_cles.value = '';				
		}
		
		if (isInForm("descriptif", "ajouter_produit")) {
			document.ajouter_produit.descriptif.value = '';				
		}
		
		if (isInForm("titre", "ajouter_produit")) {
			document.ajouter_produit.titre.value = '';				
		}
					
		document.ajouter_produit.submit();

}

function reload_grille() {
		document.action.actiontype.value = '';
		//document.ajouter_produit.AjaxFK.value = id;
		document.action.submit();

}

function search() {

		document.action.actiontype.value = 'FILTRE';
		document.action.debut.value = '0';
		document.action.submit();

}

function searchfaq() {

    if (document.formsearchfaq.keyword.value.substr(0,9)=="Saisissez") document.formsearchfaq.keyword.value='';
	if (estvide("formsearchfaq", "filtre_theme") && estvide("formsearchfaq", "keyword")) alert("Vous devez saisir un mot cl\351 ou choisir un th\350me.");
    else {
        document.formsearchfaq.action = 'faq.php';
		document.formsearchfaq.submit();

    }

}

function faq() {

    if (document.search_faq.keyword.value.substr(0,9)=="Saisissez") document.search_faq.keyword.value='';
	if (estvide("search_faq", "keyword")) alert("Vous devez saisir un mot cl\351.");
    else {
        document.search_faq.action = 'faq.php';
		document.search_faq.submit();

    }

}

function newsletter() {

    if (document.newsletter.keyword.value.substr(0,13)=="Votre adresse") document.newsletter.keyword.value='';
	if (estvide("newsletter", "keyword")) alert("Vous devez saisir votre email.");
    else {
      	if (check_mail('newsletter','keyword')) {
                contenu = file("_ajax_newsletter.php?m="+document.newsletter.keyword.value);
                alert(trim(contenu));
          }
    }
}

function filtre_produits() {

	if (estvide("filtre_produit", "ordre") && estvide("filtre_produit", "filtre1")) alert("Vous devez choisir un filtre dans un des 2 menus.");
    else {
        document.filtre_produit.action = 'produits.php';
		document.filtre_produit.submit();
    }

}

function filtre_produits_topvente() {

	if (estvide("filtre_produit", "ordre") && estvide("filtre_produit", "filtre1")) alert("Vous devez choisir un filtre dans un des 2 menus.");
    else {
        document.filtre_produit.action = 'meilleures_ventes.php';
		document.filtre_produit.submit();
    }

}

function filtre_marque() {

	if (estvide("filtre_produit", "ordre")) alert("Vous devez choisir un filtre.");
    else {
        document.filtre_produit.action = 'marques.php';
		document.filtre_produit.submit();
    }

}



function new_page(cursor,form,page) {

    eval("document."+form+".cursor.value="+cursor+";")
    eval("document."+form+".action='"+page+"';")
    eval("document."+form+".submit();");

}


function search_fulltxt() {
   if (document.searchfulltxt.keyword.value.substr(0,18)=="Marques, produits,") document.searchfulltxt.keyword.value='';
	if (estvide("searchfulltxt", "keyword")) alert("Vous devez saisir un mot cl\351.");
    else {
        document.searchfulltxt.action = 'produits.php';
		document.searchfulltxt.submit();

    }

}

function sendforum() {

	if(check_form_champs_oblig("form1", "pseudo,sujet,message")) {
		document.form1.actiontype.value='send';
        document.form1.action='message_forum.php';
		document.form1.submit();
	}


}

function forumdiscussion() {

    if(check_form_champs_oblig("form1", "pseudo,sujet,message,id_theme")) {
		document.form1.actiontype.value='send';
        document.form1.action='extranet_ecrire_forum.php';
		document.form1.submit();
	}

}

function sendcoordcompte() {

    if(check_form_champs_oblig("form_inscription", "civilite,nom,prenom,adresse,cp,ville,pays,tel,email,mdp") && check_mail("form_inscription",'email')) {
		document.form_inscription.actiontype.value='send';
        document.form_inscription.action='inscription.php';
		document.form_inscription.submit();
	}

}

function sendcoordcompte_process() {

      if(check_form_champs_oblig("form1", "civilite,nom,prenom,adresse,cp,ville,pays,tel,email,mdp") && check_mail("form1",'email')) {
        if (check_form_champs_oblig("form1","adresse_differente")==1) {
            if (check_form_champs_oblig("form1", "livr_civilite,livr_nom,livr_prenom,livr_adresse,livr_cp,livr_ville,pays_livr,livr_tel")) {
               	document.form1.actiontype.value='send';
                document.form1.action='coordonnees_client.php';
	    	    document.form1.submit();
             }
        } else {

    		document.form1.actiontype.value='send';
            document.form1.action='coordonnees_client.php';
		    document.form1.submit();
        }

	}

}

function loggue() {

 if (document.mon_compte.login.value=="Votre e-mail") document.mon_compte.login.value='';
 if (document.mon_compte.password.value=="Mot de passe") document.mon_compte.password.value='';
 if (estvide("mon_compte", "login")) alert("Vous devez saisir votre login.");
 else {
     if (estvide("mon_compte", "password")) alert("Vous devez saisir votre mot de passe.");
     else {
        document.mon_compte.action = 'loggue.php';
        document.mon_compte.submit();
    }
  }

}

function loggue_process() {

 if (document.mon_compte_process.login.value=="Votre e-mail") document.mon_compte_process.login.value='';
 if (document.mon_compte_process.password.value=="Mot de passe") document.mon_compte_process.password.value='';
 if (estvide("mon_compte_process", "login")) alert("Vous devez saisir votre login.");
 else {
     if (estvide("mon_compte_process", "password")) alert("Vous devez saisir votre mot de passe.");
     else {
        document.mon_compte_process.action = 'loggue.php';
        document.mon_compte_process.submit();
    }
  }

}

function reload_form_client() {

      document.form1.action = 'coordonnees_client.php#1';
      document.form1.actiontype.value='reload';
      document.form1.submit();

}

function delete_expert(id) {


    if (confirm("Voulez-vous vraiment supprimer cet \351change ?")) {
		document.depot_question_expert.actiontype.value='delete';
        document.depot_question_expert.id.value=id;
        document.depot_question_expert.action='extranet_deposer_question_expert.php';
		document.depot_question_expert.submit();
	}

}


function depot_question_expert() {


    if(check_form_champs_oblig("depot_question_expert", "sujet,question,id_theme")) {
		document.depot_question_expert.actiontype.value='insert';
        document.depot_question_expert.action='extranet_deposer_question_expert.php';
		document.depot_question_expert.submit();
	}

}

function send_reponse_expert() {
   if(check_form_champs_oblig("depot_question_expert", "question")) {
		document.depot_question_expert.actiontype.value='insert';
        document.depot_question_expert.action='extranet_question_expert_detail.php';
		document.depot_question_expert.submit();
	}

}

function send_perdu_mdp(){
       if(check_form_champs_oblig("perdu_mdp", "email") && check_mail("perdu_mdp",'email')) {

    	myDatas = "email=" + document.perdu_mdp.email.value ;
        contenu = file("_ajax_perdu_mdp.php?"+myDatas);
        if (trim(contenu)!="NO") {
           alert("Un email a \351t\351 envoy\351 avec votre identifiant");
           fermer_popup();
        }
        else alert("Cet email ne corresponds \340 aucun de nos membres");


	}

}


function open_cat(cat,cat1) {

     if(cat !="") {

    	myDatas = "cat=" + cat + "&cat1="+cat1 ;
        contenu = file("_ajax_nav_categories.php?"+myDatas);
        document.getElementById('ajax_plan_cat').innerHTML = contenu;

	}

}

function envoi_ami() {
     if(check_form_champs_oblig("form1", "email,nom,email1") && check_mail("form1",'email') && check_mail("form1",'email1')) {

    	myDatas = "email=" + document.form1.email.value +"&nom="+ document.form1.nom.value +"&email1="+ document.form1.email1.value +"&email2="+ document.form1.email2.value +"&email3="+ document.form1.email3.value +"&email4="+ document.form1.email4.value+"&rewrite="+document.form1.rewrite.value  ;
        contenu = file("_ajax_envoi_ami.php?"+myDatas);
        alert("Merci, votre email a \351t\351 envoy\351");
        fermer_popup();

	}

}


function add_panier(form1) {

   eval("id = document."+form1+".id.value;");
   eval("color = document."+form1+".color.value;");
   eval("qte = document."+form1+".qte.value;");
   myDatas = "id=" +id+"&color="+color+"&qte="+qte ;
   contenu = file("_ajax_add_panier.php?"+myDatas);
   if (trim(contenu)=="NON") alert("Ce produit n'est plus disponible");
   else {
      //alert(contenu);
      document.getElementById('mini-panier').innerHTML = contenu;
      alert("Le produit a bien \351t\351 ajout\351 \340 votre panier");
   }

}


function add_panier2(form1) {

   eval("id = document."+form1+".id.value;");
   eval("color = document."+form1+".color.value;");
   eval("qte = document."+form1+".qte.value;");
   myDatas = "id=" +id+"&color="+color+"&qte="+qte ;
   contenu = file("_ajax_add_panier.php?"+myDatas);
   if (trim(contenu)=="NON") alert("Ce produit n'est plus disponible");
   else {
        document.location = 'panier.php';
   }

}

function add_kdo_panier(form1,retour) {
   eval("id = document."+form1+".id.value;");
   eval("color = document."+form1+".color.value;");
   eval("qte = document."+form1+".qte.value;");
   myDatas = "id=" +id+"&color="+color+"&qte="+qte ;
   contenu = file("_ajax_add_kdo_panier.php?"+myDatas);
   if (trim(contenu)=="NO") alert("Vous ne pouvez plus ajouter de cadeaux \340 cette commande");
   else {
        document.location = retour;
   }


}

function commander(form1) {

if (!unecasecoche_cgv (form1, "cgv")) alert("Vous devez cocher la case pour accepter les conditions g\351n\351rales de ventes.");
else {
       document.form1.action="recap_commande.php";
	  document.form1.actiontype.value="order";
	  document.form1.submit();
}

}


function add_select(id) {

   	myDatas = "id=" +id  ;
    contenu = file("_ajax_add_selection.php?"+myDatas);
    if (trim(contenu)=="OK") alert("Le produit a \351t\351 ajout\351 \340 votre s\351lection");
    if (trim(contenu)=="DEJA") alert("Ce produit est d\351j\340 dans votre s\351lection");

}

function add_filleul() {

  code = document.form1.code_parrainage.value;
  myDatas = "code=" +code  ;
  contenu = file("_ajax_add_filleul.php?"+myDatas);
  if (trim(contenu)=="OK") alert("Votre code parrainage a \351t\351 pris en compte, le parrainage  sera effectif \340 la r\351ception du paiement de votre commande");
  else alert("ce code parrainage est invalide");
}

function update_livraison(id) {
   	myDatas = "ml=" +id  ;
    contenu = file("_ajax_update_livraison.php?"+myDatas);
    document.form1.action="panier.php#1";
    document.form1.submit();
}

function update_livraison_recap(id) {
   	myDatas = "ml=" +id  ;
    contenu = file("_ajax_update_livraison.php?"+myDatas);
     document.form1.action="recap_commande.php#1";
    document.form1.submit();

}


function updateprofil() {

form_valid = false;
 if(check_form_champs_oblig("form1", "civilite,nom,prenom,adresse,cp,ville,pays,tel,email") && check_mail("form1",'email')) {
        if ( (estvide ("form1", "mdp")==false) || (estvide ("form1", "new_mdp")==false) ||  (estvide ("form1", "new_mdp2")==false)) {
            if ((estvide ("form1", "mdp")) || (estvide ("form1", "new_mdp")) ||  (estvide ("form1", "new_mdp2")))  alert("Merci de remplir votre mot de passe actuel et votre nouveau mot de passe 2 fois.");
            else {
                if (sont_egaux ("form1", "new_mdp","new_mdp2")) form_valid = true;
             }
        } else form_valid = true;
}

 if (form_valid) {
            envoi_form = false;
            if (estvide ("form1", "mdp")) envoi_form = true;
            else {
                myDatas = "m=" +document.form1.mdp.value;
                contenu = file("_ajax_check_mdp.php?"+myDatas);
                if (trim(contenu)=="OK")  envoi_form = true;
                else alert("Votre mot de passe actuel est invalide.")
    }

     if (envoi_form) {
        document.form1.actiontype.value='updateprofil';
        document.form1.action='extranet_mon_compte.php';
        document.form1.submit();
     }

   }

}

function parrainer_un_ami(){

   if(check_form_champs_oblig("form2", "nom_ami,email_ami") && check_mail("form2",'email_ami')) {
           myDatas = "nom=" +document.form2.nom_ami.value+"&email="+document.form2.email_ami.value;
           contenu = file("_ajax_parrainer.php?"+myDatas);
           alert("Le code parrainage a \351t\351 envoy\351 \340 votre ami");
    }

}

function recalcul_panier() {

    document.form1.action="panier.php";
    document.form1.actiontype.value="recalcul";
    document.form1.submit();

}

function recupere_panier(id) {


   myDatas = "id=" +id ;
   contenu = file("_ajax_recupere_panier.php?"+myDatas);
   if (trim(contenu)=="NON") alert("Ce panier n'est plus disponible");
   else {
      document.getElementById('mini-panier').innerHTML = contenu;
      alert("Votre panier a \351t\351 mis a jour");
   }

}

function transfert_panier(id) {
   myDatas = "id=" +id ;
   contenu = file("_ajax_transfert_panier.php?"+myDatas);
   if (trim(contenu)=="NON") alert("Cette commande n'est plus disponible");
   else {
      document.getElementById('mini-panier').innerHTML = contenu;
      alert("Votre panier a \351t\351 mis a jour");
   }

}


function del_select(id) {

   	myDatas = "id=" +id  ;
    contenu = file("_ajax_del_selection.php?"+myDatas);
    document.location = "ma_selection.php";

}

function del_from_panier(id) {

   	myDatas = "id=" +id  ;
    contenu = file("_ajax_del_panier.php?"+myDatas);
    document.form1.action="panier.php";
    document.form1.submit();

}


function top_cat(rewrite) {


      contenu = file("_ajax_top_vente.php?top_cat="+rewrite);
      document.getElementById('top_categories_content').innerHTML = contenu;


}

function sendquizz() {

     score = calcul_score_quizz();
     id = document.form_quizz.id.value;
     prix = document.form_quizz.prix.value;
     //alert(prix);
     contenu = file("_ajax_quizz.php?score="+score+"&id="+id+"&prix="+prix);
     document.getElementById('reponse_quizz').innerHTML = contenu;


}

function noter_pdt() {

    if (unecasecoche ("noter_un_produit", "note"))  {
       	document.noter_un_produit.actiontype.value='send';

        document.noter_un_produit.action='extranet_noter_pdt.php';
		document.noter_un_produit.submit();
   }

}

function calcul_score_quizz() {

var score=0;
nb_questions = document.form_quizz.nb_questions.value;
for (i=0;i<nb_questions;i++) {
   eval("if (document.form_quizz.reponse_"+i+".value==1) score = parseInt(score + parseInt(document.form_quizz.score1_"+i+".value));");
   eval("if (document.form_quizz.reponse_"+i+".value==2) score = parseInt(score + parseInt(document.form_quizz.score2_"+i+".value));");
   eval("if (document.form_quizz.reponse_"+i+".value==3) score = parseInt(score + parseInt(document.form_quizz.score3_"+i+".value));");

}

return score;

}


function trim (myString)
{
    return myString.replace(/^\s+/g,'').replace(/\s+$/g,'');
}

function tri(id) {
	
		document.action.debut.value = '0';	
		document.action.tri.value = id;
		document.action.submit();
	
}	

function rewriting(table) {
	if(confirm('Voulez-vous vraiment reg\351n\351rer tous les mots rewriting des '+table+' ? ')) {
		document.location = 'rewriting_table.php?table='+table;		
	}	
}

function del_favori(id) {

	if(confirm('Voulez-vous vraiment retirer cet enregistrement de la vitrine ?')) {
		document.action.actiontype.value = 'DEL_VITRINE';
		document.action.valeur.value = id;
		document.action.submit();
	}	

}

function send() {
	var msg ="";
	if(document.formSend.dest.value == '') alert("Vous devez choisir un destinataire.");
	else {
		if(document.formSend.dest.value == 'T') {
			if(check_form_champs_oblig("formSend", "testmail")&& check_mail('formSend','testmail')) msg = "Etes vous sure de vouloir envoyer la newsletter a l'adresse test : "+document.formSend.testmail.value+" ?";
		}
		else { 		
			msg = 'Etes vous sure de vouloir envoyer la newsletter aux  abonnes selectionnes ?';
		}
		if(msg != "") {
			if(confirm(msg)) {
				document.formSend.actiontype.value='send';
				document.formSend.submit();
			}
		}
	}
}


function add_ref(){

    if (check_form_champs_oblig("action", "vitrine_type,add_ref")) {
        document.action.actiontype.value="ADD_REF_VITRINE";
        document.action.submit();
    } else alert("Merci de choisir une vitrine avant d'ajouter le produit");

}

function add_promo_ref(){

var promo =  document.action.promo.value;
var promo_qte =  document.action.promo_qte.value;
var prix_promo =  document.action.prix_promo.value;
var xprix =  document.action.xprix.value;
var xremise =  document.action.xremise.value;
var xyoffert =  document.action.xyoffert.value;

    if (document.action.add_ref.value !='') {
        if (promo!=0 || promo_qte!=0 || prix_promo!=0 || xremise!='' || xprix!='' || xyoffert !='') {
            document.action.actiontype.value="ADD_REF_PROMO";
            document.action.submit();
        } else alert("Merci de remplir une des six promotions");
    } else alert("Merci de remplir la r\351f\351rence du produit");

}



function payer(id) {

	if(confirm('Voulez-vous vraiment indiquer la r\351ception du paiement de cette commande ?')) {
		document.action.actiontype.value = 'PAYER';
		document.action.valeur.value = id;
		document.action.submit();
	}

}

function colis_recu(id) {

	if(confirm('Voulez-vous vraiment indiquer la r\351ception du colis par le client pour cette commande ?')) {
		document.action.actiontype.value = 'RECEPTION_COLIS';
		document.action.valeur.value = id;
		document.action.submit();
	}

}

function reception_doc(id) {

	if(confirm('Voulez-vous vraiment indiquer la reception des documents requis pour cette commande ?')) {
		document.action.actiontype.value = 'RECEPTION_DOC';
		document.action.valeur.value = id;
		document.action.submit();
	}	

}

function livrer(id) {

	if(confirm('Voulez-vous vraiment indiquer l`exp\351dition de cette commande ?')) {
		document.action.actiontype.value = 'EXPEDIER';
		document.action.valeur.value = id;
		document.action.submit();
	}	

}

function del_reduction(id) {

	if(confirm('Voulez-vous vraiment retirer la promotion sur ce produit ?')) {
		document.action.actiontype.value = 'DEL_REDUCTION';
		document.action.valeur.value = id;
		document.action.submit();
	}	

}

function del(id) {
	if(confirm('Voulez-vous vraiment supprimer cet enregistrement ?')) {
		document.action.actiontype.value = 'DEL';
		document.action.valeur.value = id;
		document.action.submit();
	}
}

function annule(id) {
	if(confirm('Voulez-vous vraiment annuler cette commande ?')) {
		document.action.actiontype.value = 'ANNULE';
		document.action.valeur.value = id;
		document.action.submit();
	}
}

function dup(id) {
	if(confirm('Voulez-vous vraiment dupliquer cet enregistrement ?')) {
		document.action.actiontype.value = 'DUP';
		document.action.valeur.value = id;
		document.action.submit();
	}
}	



function mdp(id) {
	if(confirm('Voulez-vous vraiment regénérer le mot de passe de cet enregistrement ?')) {
		document.action.actiontype.value = 'MDP';
		document.action.valeur.value = id;
		document.action.submit();
	}
}	

function genere_all_mdp() {
	if(confirm('Voulez-vous vraiment reg\351n\351rer le mot de passe de tous les contacts ?')) {
		document.location = 'genere_all_mdp.php';	
	}
}	

function send_all_mdp() {
	if(confirm('Voulez-vous vraiment envoyer les mots de passe \340 chacun des contacts ?')) {
		document.location = 'send_all_mdp.php';	
	}
}	

function envoi_mdp(id) {
	if(confirm('Voulez-vous vraiment envoyer le mot de passe par email au contact ?')) {
		document.action.actiontype.value = 'ENVOI_MDP';
		document.action.valeur.value = id;
		document.action.submit();
	}
}	

function enligne(id) {

  if (confirm("\312tes-vous sure de bien vouloir valider cet enregistrement ? ")) {
        document.action.actiontype.value = 'enligne';
    	document.action.valeur.value = id;
	    document.action.submit();
  }



}

function enligneexclu(id) {
	document.action.actiontype.value = 'enligneExlusif';
	document.action.valeur.value = id;
	document.action.submit();
}


function horsligne(id) {
	document.action.actiontype.value = 'horsligne';
	document.action.valeur.value = id;
	document.action.submit();
}

function reload(lettre) {
	document.action.actiontype.value = 'RELOAD';
	document.action.valeur.value = lettre;
	document.action.debut.value = 0;
	document.action.submit();
}

function addline() {
	document.action.actiontype.value = 'ADDLINE';		
	document.action.submit();
}
	
function next_page(debut) {

		document.action.debut.value = debut;
		document.action.submit();

}	

function documents() {
	if(valid_form()) {
		document.ajouter_produit.actiontype.value = 2;
		document.ajouter_produit.submit();
	}
}

/* Fonctions de formulaires */
function check_form_champs_oblig (form1, lst_chps) {

	
	tab_chps = lst_chps.split(",");
	for (i=0; i<tab_chps.length;i++) {
		if (isInForm(tab_chps[i], form1)) {	
			eval ("var monchps = document."+form1+"."+tab_chps[i]+".value");	
			 if (monchps=="" || monchps==null)	
			 {		
			 	alert("Vous devez remplir le champ "+tab_chps[i]);
				if (tab_chps[i]!="dept") eval ("document."+form1+"."+tab_chps[i]+".focus();");
				color_form("input");
				return false; 
				
			}	
		}
	}
	return true;
}
function check_form_champs_un_oblig (form1, lst_chps) {
	tab_chps = lst_chps.split(",");
	for (i=0; i<tab_chps.length;i++) {
		if (isInForm(tab_chps[i], form1)) {	
			eval ("var monchps = document."+form1+"."+tab_chps[i]+".value");	
			 if (monchps!="" && monchps!=null)	
			 {		
				alert("Vous devez remplir le champ "+tab_chps[i]);
				eval ("document."+form1+"."+tab_chps[i]+".focus();");
				color_form("input");
				return false;
			}	
		}
	}
	return false;
}



//prise en charge du focus par IE
function color_form(nom){
 if(document.getElementsByTagName(nom)){
   for(i=0;i<document.getElementsByTagName(nom).length;i++){
     document.getElementsByTagName(nom)[i].onfocus=colour;
     document.getElementsByTagName(nom)[i].onblur=none;    
   }
 }
}
//Couleur du focus
function colour(event){
/** this.style.backgroundColor='#eee';
 this.style.border='#27A6BA 1px solid';
 **/
 
 this.style.backgroundColor='#d2d7de';
 this.style.border='#7498b1 1px solid';
 
 
}
//Pas de couleur
function none(event){
 this.style.backgroundColor='#ececec';
 this.style.border='#b5becb 1px solid';
}


function check_form_champs_oblig_menu_deroulant (form1, lst_chps) {
	tab_chps = lst_chps.split(",");
	for (i=0; i<tab_chps.length;i++) {	
		eval ("var monIndexSel = document."+form1+"."+tab_chps[i]+".selectedIndex");
		 if (monIndexSel==0)	
		 {			
		 	alert("Vous devez remplir le champ "+tab_chps[i]);
			eval ("document."+form1+"."+tab_chps[i]+".focus();");
			return false; 
		}	
	}
	return true;
}

function check_form_champs_egal (form1, champs, valeur) {
	eval ("var monchps = document."+form1+"."+champs+".value");
	if (monchps==valeur)	{			
		return true; 
	}	
	return false;
}

function check_form_liste_egal (form1, champs, valeur) {
	eval ("var monIndexSelected = document."+form1+"."+champs+".selectedIndex");
	eval ("var maValeur = document."+form1+"."+champs+".options["+monIndexSelected+"].value");
	if (maValeur==valeur) {			
		return true; 
	}	
	return false;
}

function get_valeur_list (form1, champs) {
	eval ("var monIndexSelected = document."+form1+"."+champs+".selectedIndex");
	eval ("var maValeur = document."+form1+"."+champs+".options["+monIndexSelected+"].value");
	return maValeur;
}

function check_form_case_a_cocher_egal (form1, champs, valeur) {
	var ret_val = false;
	var debut = IndicePremierElem (form1, champs);
	var fin = IndiceFinElem (form1, champs,debut);
	for (i=debut; i<=fin; i++) {	
		eval ("var elemcour = document."+form1+".elements["+i+"].checked");
		if (elemcour == true) {
			eval ("var valeurElem = document."+form1+".elements["+i+"].value");	
			if (valeurElem==valeur) { 
				ret_val = true;
			}
		}	
	}
	return ret_val;
}


function unecasecoche (form1, champ) {
	var debut = IndicePremierElem (form1, champ);
	var fin = IndiceFinElem (form1, champ,debut);
	for (i=debut; i<=fin; i++) {
		eval ("var elemcour = document."+form1+".elements["+i+"].checked");
		if (elemcour == true) {
			 return true;
		}
	}
	alert("Merci de choisir une des cases "+champ);
	return false;
}

function unecasecoche_cgv (form1, champ) {
	var debut = IndicePremierElem (form1, champ);
	var fin = IndiceFinElem (form1, champ,debut);
	for (i=debut; i<=fin; i++) {
		eval ("var elemcour = document."+form1+".elements["+i+"].checked");
		if (elemcour == true) {
			 return true;
		}
	}
	return false;
}


function estvide (form1, chps) {
	eval ("var val1 = document."+form1+"."+chps+".value");
	if (val1==null || val1 =="") {
		return true;
	} else {
		return false;
	}
}

function pasvide (form1, chps) {
	eval ("var val1 = document."+form1+"."+chps+".value");
	if (val1!=null && val1 !="") {
		return true;
	} else {
		return false;
	}
}


function sont_egaux (form1, chp1, chp2) {
	eval ("var val1 = document."+form1+"."+chp1+".value");
	eval ("var val2 = document."+form1+"."+chp2+".value");
	if (val1 != val2) {
		alert("Les 2 mots de passe ne sont pas identiques");
		return false;
	}
	return true;
}


function isInForm(myvalue, form1) {
	eval ("var nb_elem = document."+form1+".elements.length");
	for (j=0;j<nb_elem;j++) {	
		eval ("var maval = document."+form1+".elements["+j+"].name");
		if (maval==myvalue) {
			return true;
		}
	}
	return false;
}


function IndicePremierElem (form1, champ) {
	eval ("var nbelem = document."+form1+".elements.length");
	for (i=0; i<nbelem; i++) {
		eval ("var elemcour = document."+form1+".elements["+i+"].name");
		if (elemcour == champ) {
			return i;
		}	
	
	}
	return 0;
}


function IndiceFinElem (form1, champ,debut) {
	eval ("var nbelem = document."+form1+".elements.length");
	for (i=debut; i<nbelem; i++) {
		eval ("var elemcour = document."+form1+".elements["+i+"].name");
		if (elemcour != champ) {
			return i-1;
		}	
	}
	return nbelem-1;
}


function IndiceFinElem2 (form1, champ,debut,pas) {
	eval ("var nbelem = document."+form1+".elements.length");
	for (i=debut+pas; i<nbelem; i=i+pas) {
		eval ("var elemcour = document."+form1+".elements["+i+"].name");
		if (elemcour != champ) {
			return i-pas;
		}	
	}
	return nbelem-1;
}


function check_mail (form1, chps) {
eval ("var email=document."+form1+"."+chps+".value");
	if (email != "" && email != null) {
		var aroba = email.indexOf("@");	
		if (aroba == -1) {	 
		  alert("Votre email n'est pas valide");
		  eval ("document."+form1+"."+chps+".focus();");
		  color_form("input");
		  return false;
		}
		
		var point = email.indexOf(".", aroba);
		if ((point == -1) || (point == (aroba + 1))) {	
		  alert("Votre email n'est pas valide");
		  eval ("document."+form1+"."+chps+".focus();");
		  color_form("input");	
		  return false;
		}
		
		var point = email.lastIndexOf(".");
		if ((point + 1) == email.length) {	
		   alert("Votre email n'est pas valide");
		  eval ("document."+form1+"."+chps+".focus();");
		  color_form("input");	
		  return false;
		}	
		point = email.indexOf("..")
		if (point != -1) {	  
		   alert("Votre email n'est pas valide");
		  eval ("document."+form1+"."+chps+".focus();");
		  color_form("input");	
		  return false;
		}
	}
	return true;
}

function check_site (form1, chps) {

eval ("var email=document."+form1+"."+chps+".value");

if (email != "" && email != null) {

	var aroba = email.indexOf("http://");	
	if (aroba == -1) {	 
	  return false;
	}
	
	var point = email.indexOf(".", aroba);
	if ((point == -1) || (point == (aroba + 1))) {	
	  return false;
	}
	
	var point = email.lastIndexOf(".");
	if ((point + 1) == email.length) {	
	  return false;
	}	
	point = email.indexOf("..")
	if (point != -1) {	  
	  return false;
	}
}
return true;

}


function ikoltte (form1, champ) {

var madate = format_date (form1,champ+"jour", champ+"mois", champ+"annee");

eval ("var indicejj = document."+form1+"."+champ+"jour.options.selectedIndex");		
eval ("var monjour = document."+form1+"."+champ+"jour.options[indicejj].value");

if (madate.getDate() != monjour) {	
	return false;
}

return true;

}

function Date2SupDate1 (form1, champ1, champ2) {


	var madate1 = format_date (form1,champ1+"jour", champ1+"mois", champ1+"annee");
	var madate2 = format_date (form1,champ2+"jour", champ2+"mois", champ2+"annee");
	if (madate2<=madate1) {
		return false;
	}
	return true;
}

function DateSupAuj (form1, champ) {

	var TodayDate = new Date;
	var madate = format_date (form1, champ+"jour", champ+"mois", champ+"annee");
	
	if (madate<=TodayDate) {	
		return false;
	
	}
	return true;

}

function isChampsNumeric (champ, form1) {

	eval ("var chp = document."+form1+"."+champ+".value");
	if (isNaN (chp)) {
		return false;
	}
	return true;
}


function is_a_pourcentage (champs, form1) {

	if (isInForm(champs, form1)) {		
			eval ("var mavaleur = document."+form1+"."+champs+".value");
			if (mavaleur >=0 && mavaleur <= 100) return true;
			else return false;
			
		}	
	return true;
}

function digit_champ (champs, form1,taille) {

	if (isInForm(champs, form1)) {		
			eval ("var mavaleur = document."+form1+"."+champs+".value");			
			if (mavaleur.length==taille) { 				
				return true;
			}	
			else { 
				alert("Le champ "+champs+" doit comporter "+taille+" caractères ");
				eval ("document."+form1+"."+champs+".focus();");				
				return false;
			}	
			
		}	
	return true;
}


function type_donnne (champs, form1,chiffre) {

	if (isInForm(champs, form1)) {		
			eval ("var mavaleur = document."+form1+"."+champs+".value");	
			
			if (chiffre=="num") { // doit être que des chiffres
			
				for (i=0;i<mavaleur.length;i++) {
					if (isNaN(mavaleur.charAt(i))) {
						alert("Le champ "+champs+" ne peut comporter que des chiffres ");
						eval ("document."+form1+"."+champs+".focus();");	
						return false;
					}	
				}			
			} else { // ne doit pas avoir de chiffre
				for (i=0;i<mavaleur.length;i++) {
					if (!isNaN(mavaleur.charAt(i))) {
						alert("Le champ "+champs+" ne peut pas comporter de chiffre ");
						eval ("document."+form1+"."+champs+".focus();");	
						return false;
					}	
				}
			}											
				
		}	
	
	return true;
}



function isListChampsNumeric (lstchps, form1) {
	
	
	tab_chps = lstchps.split(",");	
	for (i=0; i<tab_chps.length;i++) {			
		if (isInForm(tab_chps[i], form1)) {		
			if (isChampsNumeric (tab_chps[i], form1) ==false) return false; 
		}	
	}
	return true
	
}

function TourChampsNumeric (tabnom, form1, pas) {

var indice1 = IndicePremierElem (form1, tabnom);
var indice2 = IndiceFinElem2 (form1, tabnom, indice1, pas);
var nomchps;

	for (i=indice1; i<=indice2;i=i+pas) {
		eval (" nomchps = document."+form1+".elements["+i+"].value");						
		if (nomchps !="") {					
			if (isNaN (nomchps)) return false; 
		}
	}
	return true;
}

function senddata(form1) {

	eval ("document."+form1+".submit()");

}

function senddata_changeval(form1, champ, newval) {

	eval ("document."+form1+"."+champ+".value='"+newval+"'");
	eval ("document."+form1+".submit()");

}

function senddata_changeval_niv (form1, champ, newval, level) {

	
	eval ("document."+form1+"."+champ+".value='"+newval+"'");
	
	enleve_valeur_menu (level+1, "tidcat[]",form1);
	eval ("document."+form1+".submit()");
}

function enleve_valeur_menu (level, champ, form1) {

	var debut = IndicePremierElem (form1, champ);
	var fin = IndiceFinElem (form1, champ,debut);
	//alert (debut);
	//alert (fin);
	var debuti = new Number (debut);
	var leveli = new Number (level);
	var indice_debut = new Number (debuti + leveli);	
	//alert (indice_debut);
	for (i=indice_debut;i<=fin;i++)	{			
		eval ("document."+form1+".elements["+i+"].value='';");	
	}

}

function senddata_changeval_action(form1, champ, newval, newaction) {

	eval ("document."+form1+"."+champ+".value='"+newval+"'");
	eval ("document."+form1+".action='"+newaction+"'");
	eval ("document."+form1+".submit()");

}


function senddata_changeval_action2(form1, champ, newval, newaction, niveau_act) {

	eval ("document."+form1+"."+champ+".value='"+newval+"'");
	eval ("var niveau = document."+form1+".niveau_actuel.value");
	if (niveau_act == niveau) niveau++;
	eval ("document."+form1+".niveau_actuel.value=niveau");
	eval ("document."+form1+".action='"+newaction+"'");
	eval ("document."+form1+".submit()");

}

function senddata_changeval_action3(form1, champ, newval, newaction) {

	eval ("document."+form1+"."+champ+".value='"+newval+"'");	
	eval ("document."+form1+".niveau_actuel.value=0");
	eval ("document."+form1+".action='"+newaction+"'");
	eval ("document."+form1+".submit()");

}

function senddata_newurl(form1, newurl) {

 eval ("document."+form1+".action="+newurl);
 eval ("document."+form1+".submit()");

}

function format_date (form1,jour, mois, an) {

eval ("var indiceaa = document."+form1+"."+an+".options.selectedIndex");		
eval ("var indicejj = document."+form1+"."+jour+".options.selectedIndex");		
eval ("var indicemm = document."+form1+"."+mois+".options.selectedIndex");		
eval ("var madate = new Date (document."+form1+"."+an+".options[indiceaa].value, document."+form1+"."+mois+".options[indicemm].value-1, document."+form1+"."+jour+".options[indicejj].value)");		
return madate;

}


function chp1_sup_valeur (form1, chp1, chp2) {

eval ("var val1 = document."+form1+"."+chp1+".value");
eval ("var val2 = document."+form1+"."+chp2+".value");
if (val1 > val2) return true;	
else return false;

}

function contient_char (form1, chp1, monchar) {

	eval ("var val1 = document."+form1+"."+chp1+".value");
	if (val1.indexOf(monchar) == -1) return false;
	else return true;

}



function checkformLoggue(nameform) {
	if (check_form_champs_oblig (nameform, "login,mdp")==false) alert("Pour vous identifier, merci de bien vouloir renseigner votre login et mot de passe.");
	else eval("document."+ nameform + ".submit();");
}

function gotoTo(adresse) {

document.location.href=adresse;

}

function gotoBlank(adresse) {

window.open(adresse);

}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// Site specific
function deconnexion() {
	document.logout.submit();
}


function recommander(id) {
	window.open('recommander.php?id_produit='+id,'recommander','width=434,height=313,toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0');
}
function logout() {
	document.login.submit();
}


function utf8_encode ( argString ) {
    // Encodes an ISO-8859-1 string to UTF-8
    //
    // version: 1006.1915
    // discuss at: http://phpjs.org/functions/utf8_encode    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: sowberry
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman    // +   improved by: Yves Sucaet
    // +   bugfixed by: Onno Marsman
    // +   bugfixed by: Ulrich
    // *     example 1: utf8_encode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'

    var string = (argString+''); // .replace(/\r\n/g, "\n").replace(/\r/g, "\n");
    var utftext = "";
    var start, end;
    var stringl = 0;
    start = end = 0;
    stringl = string.length;
    for (var n = 0; n < stringl; n++) {
        var c1 = string.charCodeAt(n);        var enc = null;

        if (c1 < 128) {
            end++;
        } else if (c1 > 127 && c1 < 2048) {            enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
        } else {
            enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
        }
        if (enc !== null) {            if (end > start) {
                utftext += string.substring(start, end);
            }
            utftext += enc;
            start = end = n+1;        }
    }

    if (end > start) {
        utftext += string.substring(start, string.length);    }

    return utftext;
}

