

function zoom_img_bon(aff,id){

	 

	 if (aff==1){

		   var div_zoom_imageStyle = document.getElementById('div_zoom_image_'+id).style;

		   div_zoom_imageStyle.display='block';

		   with (div_zoom_imageStyle) {

				position='absolute';

				border='1px solid #000000';

		   }

	  }else if (aff==0){

		   document.getElementById('div_zoom_image_'+id).style.display = 'none';

	  }

 }





function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}





function lien_special_pack(lien){

	window.opener.location = lien;

	window.close();

}



function plus(id, maxi)

{

	var proch = (parseInt(document.getElementById(id).value)+1);

	if (proch <= maxi)

	{

		document.getElementById(id).value = proch;

	}

}



function moins(id)

{		

	var proch = (parseInt(document.getElementById(id).value)-1);

	if (proch >= 1)

	{

		document.getElementById(id).value = proch;

	}

}





var popupImage;

function ImageMax(chemin)

   {

   if ((popupImage) && (!popupImage.closed)){

	popupImage.close();

   }



   i1 = new Image;

   i1.src = chemin;



   html = '<html><head><title>Zoom sur image</title></head><body leftmargin="0" rightmargin="0" bottommargin="0" topmargin="0"><table border="0" CELLPADDING=0 CELLSPACING=0 width="100%" height="100%"><tr><td background="images/anim_charg.gif"><IMG src="'+chemin+'" BORDER=0 NAME=ImageMax onLoad="window.resizeTo(document.ImageMax.width+10,document.ImageMax.height+50)"></td></tr></table></body></html>';

   popupImage = window.open('','popupImage','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=no,resizable=no, width=0, height=0, top=50, left=100, minimize=no, maximize=no');

   popupImage.document.open();

   popupImage.document.write(html);

   popupImage.document.close();

}









function envoi_contact()

{

	if (document.contact.prenom.value == '') {

		alert("Veuillez bien remplir le champs Prénom !");

		document.contact.prenom.focus();

		return false;

	}

	if (document.contact.nom.value == '') {

		alert("Veuillez bien remplir le champ Nom !");

		document.contact.nom.focus();

		return false;

	}

	if (document.contact.email.value == '') {

		alert("Veuillez bien remplir l'email.");

		document.contact.email.focus();

		return false;

	}

	var email   = document.contact.email.value;

    var verif   = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/

    if (verif.exec(email) == null){

       	alert("Votre email est incorrect.");

        document.contact.email.focus();

		return false;

    }

	return;

}



 function envoi_contact_tel(){

            if (document.contact.prenom.value == '') {

                alert("Veuillez bien remplir le champs Prénom !");

                document.contact.prenom.focus();

                return false;

            }

            if (document.contact.nom.value == '') {

                alert("Veuillez bien remplir le champ Nom !");

                document.contact.nom.focus();

                return false;

            }

            if (document.contact.email.value == '') {

                alert("Veuillez bien remplir l'email.");

                document.contact.email.focus();

                return false;

            }

            if (document.contact.tel.value == '') {

                alert("Veuillez bien remplir le champs Téléphone !");

                document.contact.email.focus();

                return false;

            }

            var email   = document.contact.email.value;

            var verif   = /^[A-Za-z0-9._-]+@[A-Za-z0-9.-]{2,}[.][A-Za-z]{2,4}$/

            if (verif.exec(email) == null){

                alert("Votre email est incorrect.");

                document.contact.email.focus();

                return false;

            }

            return true;

        }



/**

 *

 * @access public

 * @return void

 **/

function verif_email(){

    if (document.form_newsletter.email.value == '') {

		alert("Veuillez bien remplir l'email.");

		document.form_newsletter.email.focus();

		return false;

	}

	var email   = document.form_newsletter.email.value;

    var verif   = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/

    if (verif.exec(email) == null){

       	alert("Votre email est incorrect.");

        document.form_newsletter.email.focus();

		return false;

    }

	return;

}

function test_adresse_livraison(){

	var paysEurope = document.form_livraison.paysEurope.value;

	var arrayEurope = paysEurope.split(';');

	var europeen = false;

	if (document.form_livraison.choix_adherent.value == '') {
		alert("Veuillez Choisir votre magasin USHIP préféré.");						
		return false;		
	}


	for(i = 0; i < arrayEurope.length; i++) {

		if (arrayEurope[i]==document.form_livraison.pays.options[document.form_livraison.pays.selectedIndex].value){

			europeen = true;

			break;

		}

	}

	if (document.form_livraison.societe.value != '' && document.form_livraison.tvaintra.value == '' && europeen) {

		alert("Si vous êtes une société européenne, veuillez renseigner votre n° Intracommunautaire !");

		document.form_livraison.societe.focus();

		return false;

	}

	if (document.form_livraison.prenom.value == '') {

		alert("Veuillez bien remplir le champs Prénom !");

		document.form_livraison.prenom.focus();

		return false;

	}

	if (document.form_livraison.nom.value == '') {

		alert("Veuillez bien remplir le nom !");

		document.form_livraison.nom.focus();

		return false;

	}

	if (document.form_livraison.adresse.value == '') {

		alert("Veuillez bien remplir l'adresse !");

		document.form_livraison.adresse.focus();

		return false;

	}

	if (document.form_livraison.ville.value == '') {

		alert("Veuillez bien remplir la Ville !");

		document.form_livraison.ville.focus();

		return false;

	}



	// Test pour le relais colis
/*
	if (document.form_livraison.typeLivraison[1].checked){

		if (window.frames['frame_relais'].document.getElementById('aucun_relais_colis_trouve')){

			if (window.frames['frame_relais'].document.getElementById('aucun_relais_colis_trouve').value == 1){

				alert('Pour choisir le mode de livraison Relais Colis vous devez sélectionner un relais colis.');

				return false;

			}

		}else{

			alert('Pour choisir le mode de livraison Relais Colis vous devez sélectionner un relais colis.');

			return false;

		}

	} */

	var cpTape = document.form_livraison.cp.value;
	cpTape = cpTape.toLowerCase();

	if (document.form_livraison.typeLivraison[0].checked && (cpTape.substring(0,2)=="2b" || cpTape.substring(0,2)=="2a")){
		alert('Livraison valable en France métropolitaine uniquement hors Corse.');
		return false;
	}	

	return true;



}

function verif_inscr_newsletter_simple(){

	if (document.contact.prenom.value == '') {

		alert("Veuillez bien remplir le champs Prénom !");

		document.contact.prenom.focus();

		return false;

	}

	if (document.contact.nom.value == '') {

		alert("Veuillez bien remplir le nom !");

		document.contact.nom.focus();

		return false;

	}

	if (document.contact.email.value == '') {

		alert("Veuillez bien remplir l'email.");

		document.contact.email.focus();

		return false;

	}

	var email   = document.contact.email.value;

    var verif   = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/

    if (verif.exec(email) == null){

       	alert("Votre email est incorrect.");

        document.contact.email.focus();

		return false;

    }

	return true;

}

function pass_perdu(){

	myWindow = window.open("modules/boutique/pass_perdu_accueil.php", "Preview", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=340,height=170,left=100,top=100");

}

function comparatif_tailles(){

	myWindow = window.open("modules/boutique/conversion_de_taille.php", "Preview", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=590,height=500,left=100,top=50");

}

var form;

var quantite;

var id;

var num;



function test_qte(form, quantite, id, num)

{

	if (quantite<=0){

		alert("Quantité non valide !");

		num.value = id;

		return false;

	} else {

		form.submit();

		return true;

	}

}

function verif_compte(num){

	if (document.getElementById["login"].value == '') {

		alert("Veuillez bien remplir l'identifiant !");

		document.getElementById["login"].focus();

		return false;

	}

	var login   = document.getElementById["login"].value;

    var verif   = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/

    if (verif.exec(login) == null){

       	alert("Votre Identifiant est incorrect.");

        document.getElementById["login"].focus();

		return false;

    }

	if (document.getElementById["pass"].value == '') {

		alert("Veuillez bien remplir le mot de passe !");

		document.getElementById["pass"].focus();

		return false;

	}

	//document.forms[num].submit();

	return;

}

function recommandation()

{

	if (document.recommand.nom_envoyeur.value == '') {

		alert("Veuillez bien remplir le nom !");

		document.recommand.nom_envoyeur.focus();

		return false;

	}

	if (document.recommand.email_envoyeur.value == '') {

		alert("Veuillez bien remplir l'email.");

		document.recommand.email_envoyeur.focus();

		return false;

	}

	var email_envoyeur   = document.recommand.email_envoyeur.value;

    var verif   = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/

    if (verif.exec(email_envoyeur) == null){

       	alert("Votre email est incorrect.");

        document.recommand.email_envoyeur.focus();

		return false;

    }

	if (document.recommand.nom_dest.value == '') {

		alert("Veuillez bien remplir le nom du destinataire !");

		document.recommand.nom_dest.focus();

		return false;

	}

	if (document.recommand.email_dest.value == '') {

		alert("Veuillez bien remplir l'email du destinataire !");

		document.recommand.email_dest.focus();

		return false;

	}

	var email_dest   = document.recommand.email_dest.value;

    var verif   = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/

    if (verif.exec(email_dest) == null){

       	alert("L'email du destinataire est incorrect");

        document.recommand.email_dest.focus();

		return false;

    }

	return;

}

function recommandation_infos()

{

	if (document.recommand.nom_envoyeur.value == '') {

		alert("Veuillez bien remplir le nom !");

		document.recommand.nom_envoyeur.focus();

		return false;

	}

	if (document.recommand.email_envoyeur.value == '') {

		alert("Veuillez bien remplir l'email.");

		document.recommand.email_envoyeur.focus();

		return false;

	}

	var email_envoyeur   = document.recommand.email_envoyeur.value;

    var verif   = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/

    if (verif.exec(email_envoyeur) == null){

       	alert("Votre email est incorrect.");

        document.recommand.email_envoyeur.focus();

		return false;

    }

	return;

}

function inscription_test(action)

	{

	var paysEurope = document.inscription.paysEurope.value;

	var arrayEurope = paysEurope.split(';');

	var europeen = false;



	for(i = 0; i < arrayEurope.length; i++) {

		if (arrayEurope[i]==document.inscription.pays.options[document.inscription.pays.selectedIndex].value){

			europeen = true;

			break;

		}

	}

	if (document.inscription.societe.value != '' && document.inscription.tvaintracom.value == '' && europeen) {

		alert("Si vous êtes une société européenne, veuillez renseigner votre n° Intracommunautaire !");

		document.inscription.societe.focus();

		return false;

		}

	if (document.inscription.nom.value == '') {

		alert("Veuillez bien remplir le nom !");

		document.inscription.nom.focus();

		return false;

		}

	if (document.inscription.prenom.value == '') {

		alert("Veuillez bien remplir le champs Prénom !");

		document.inscription.prenom.focus();

		return false;

		}

	if (document.inscription.email.value == '') {

		alert("Veuillez bien remplir l'email.");

		document.inscription.email.focus();

		return false;

	}

	var email   = document.inscription.email.value;

    var verif   = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/

    if (verif.exec(email) == null){

       	alert("Votre email est incorrect.");

        document.inscription.email.focus();

		return false;

    }

	if (document.inscription.adresse.value == '') {

		alert("Veuillez bien remplir l'adresse !");

		document.inscription.adresse.focus();

		return false;

		}

	if (document.inscription.ville.value == '') {

		alert("Veuillez bien remplir la Ville !");

		document.inscription.ville.focus();

		return false;

		}

	if (document.inscription.tel.value == '') {

		alert("CONTACT_ALERT_TEL");

		document.inscription.tel.focus();

		return false;

		}



	if(action=='insert'){

		if (document.inscription.pass.value.length < 6) {

			alert("Votre mot de passe doit contenir au moins 6 caractères !");

			document.inscription.pass.value='';

			document.inscription.pass2.value='';

			document.inscription.pass.focus();

			return false;

			}

		if (document.inscription.pass2.value != document.inscription.pass.value) {

			alert("La confirmation du Mot de passe ne convient pas !");

			document.inscription.pass.value = '';

			document.inscription.pass2.value = '';

			document.inscription.pass.focus();

			return false;

			}

	}

	return;

}

function inscription_devis()

	{

	if (document.inscription.nom.value == '') {

		alert("Veuillez bien remplir le nom !");

		document.inscription.nom.focus();

		return false;

		}

	if (document.inscription.prenom.value == '') {

		alert("Veuillez bien remplir le champs Prénom !");

		document.inscription.prenom.focus();

		return false;

		}

	if (document.inscription.email.value == '') {

		alert("Veuillez bien remplir l'email.");

		document.inscription.email.focus();

		return false;

		}

	if (document.inscription.adresse.value == '') {

		alert("Veuillez bien remplir l'adresse !");

		document.inscription.adresse.focus();

		return false;

		}

	if (document.inscription.ville.value == '') {

		alert("Veuillez bien remplir la Ville !");

		document.inscription.ville.focus();

		return false;

		}



	return;

}











function validCgv(){

	if(document.form_conditions.valid_cgv.checked==false){

		alert("Vous devez accepter les Conditions Générales de Vente");

		return false;

	}

  }







function coche_tout(){

	var nb_checkbox = document.panier_produits.elements.length;



	for (i=0; i<nb_checkbox; i++){

		if (document.panier_produits.elements[i].type == 'checkbox'){

			document.panier_produits.elements[i].checked = true;

		}

	}

}







function decoche_tout(){

	var nb_checkbox = document.panier_produits.elements.length;



	for (i=0; i<nb_checkbox; i++){

		if (document.panier_produits.elements[i].type == 'checkbox'){

			document.panier_produits.elements[i].checked = false;

		}

	}

}



function article_supr(id){

	document.getElementById("article_suppr").value=id;

	document.getElementById("form_suppr").submit();

}



function panier_action(action){



	if(action=='update'){

		var test = confirm("Etes vous sur de vouloir modifier la quantité des produits ?");

		if(test==true){

			document.panier_produits.choix_action.value=action;

			document.panier_produits.submit();

		}

	}

    if(action=='apercu'){



		document.getElementById('tab_apercu').style.display = 'block';

		document.panier_produits.choix_action.value=action;

		document.panier_produits.action="modules/boutique/include/genere_apercu_liste_cadeaux.php";

		document.panier_produits.target="genere_apercu_liste_cadeaux";

		document.panier_produits.submit();



	}



	if(action=='delete'){

		

		var nb_checkbox = document.panier_produits.elements.length;

		var testSupp=false;

		for (i=0; i<nb_checkbox; i++){

			if (document.panier_produits.elements[i].type == 'checkbox' && document.panier_produits.elements[i].checked == true){

				testSupp=true;

				break;

			}

		}



		if(testSupp==false){

			alert("Vous devez cocher les Produits à supprimer");

		}else{

			var test = confirm("Etes vous sur de vouloir supprimer les produits sélectionnés ?");

			if(test==true){

				document.panier_produits.choix_action.value=action;

				document.panier_produits.submit();

			}

		}

	}



	



	if(action=='enreg_liste'){

		if (document.getElementById("nom_liste").value == ''){

			alert('Veuillez fournir un nom à votre liste de naissance.');

			document.getElementById("nom_liste").focus();

			return false;

		}

		if (!document.getElementsByName('groupage')[0].checked && !document.getElementsByName('groupage')[1].checked)

		{

			alert('Veuillez faire un choix pour le groupage.');

			return false;

		}

		var test = confirm("Enregistrer et envoyer votre liste de naissance à votre entourage ?");

        if(test==true){

            document.panier_produits.action="index.fr.php?page=include/gestion_panier_cadeaux&choix_action=enreg_liste";

            document.panier_produits.target="";

			document.panier_produits.choix_action.value=action;

			document.panier_produits.submit();

		}

	}

	if(action=='envoi_liste'){

		var test = confirm("Envoyer votre liste de naissance à votre entourage ?");

        if(test==true)

		{

            document.panier_produits.action="index.fr.php?page=include/gestion_panier_cadeaux&choix_action=envoi_liste";

            document.panier_produits.target="";

			document.panier_produits.choix_action.value=action;

			document.panier_produits.submit();

		}

	}

	

	if(action=='modif_liste'){

	

		if (document.panier_produits.nom_liste.value == ''){

			alert('Veuillez fournir un nom à votre liste de naissance.');

			document.panier_produits.nom_liste.focus();

			

			return false;

		}

		if (!document.getElementsByName('groupage')[0].checked && !document.getElementsByName('groupage')[1].checked)

		{

			alert('Veuillez faire un choix pour le groupage.');

			return false;

		}

		

		var test = confirm("Modifier votre liste de naissance ?");

		if(test==true){

			document.panier_produits.target = '';

			document.panier_produits.action = 'index.fr.php?page=include/gestion_panier_cadeaux&mod=boutique';

			document.panier_produits.choix_action.value=action;

			document.panier_produits.submit();

		}

	}



}





function focus_commentaire_cadeau(commentaire, textarea){

	if (commentaire=="Vous pouvez laisser ici un petit mot pour le destinataire de votre cadeau..."){

		textarea.value = '';

	}

}



function focus_texte(texte, base, input){

	if (texte == base)

	{

		input.value = '';

	}

}







function afficher_marques(){

	document.getElementById('lien_affiche_marques').style.display = 'none';

	for (i=1; i <= document.getElementById('cpt_marques').value; i++){

		document.getElementById('marque_' + i).style.display = 'block';

	}

}





function debloque_options(id_prod){

	for (i=0; i<10; i++){

		if (document.getElementById('option_' + id_prod + '_' + i)){

			document.getElementById('option_' + id_prod + '_' + i).disabled = false;

		}

		if (document.getElementById('option_' + id_prod + '_' + i)){

			if (document.getElementById('option_' + id_prod + '_' + i).type == "select-one"){

				if (document.getElementById('option_' + id_prod + '_' + i).selectedIndex == 0){

					alert("Options incomplètes: " + document.getElementById('option_' + id_prod + '_' + i).options[document.getElementById('option_' + id_prod + '_' + i).selectedIndex].text);

					return false;

				}

			}

		}

	}

}



function cacher_toutes_rubriques(){

	var i = 0;

    while(document.getElementById("blocniveau1_" + i)) {

    	if (document.getElementById("blocniveau1_"+i)){

			document.getElementById("blocniveau1_"+i).style.display = "none";

		}

		if(document.getElementById("bloc_courant")){

			if(document.getElementById("bloc_courant").value == i){

				if (document.getElementById("blocniveau1_"+i)){

					document.getElementById("blocniveau1_"+i).style.display = "block";

				}

		 	}

		}

		i++;

    }

	if (i == 1 && document.getElementById("blocniveau1_0")){

		document.getElementById("blocniveau1_0").style.display = "block";

	}

}

function montre(bloc){



      if(document.getElementById("affichage_"+bloc).value!=1){

          document.getElementById(bloc).style.display="block";

          document.getElementById("affichage_"+bloc).value = 1;

      }else{

          document.getElementById(bloc).style.display="none";

          document.getElementById("affichage_"+bloc).value = 0;

      }

}

function enreg_panier(){

	

	var logge=document.getElementById("client_log").value;

	

	if(logge==null){

		return false;

	}

	if (logge=="non"){

		alert("Vous devez avoir un compte et être identifié pour enregistrer ce panier");	

		window.location="moteur,page,mon_compte_login,mod,boutique.fr.html";	

		return false;

	}

	else{

		var lib = prompt("Donnez un nom à votre panier");

		if(lib==null){

			return false;

		}

		document.getElementById("enreg_panier_lib").value=lib;

		return true;

	}

}

function voir_le_panier(id_pan,e){

	if(e.pageX){

		x=e.pageX;

		y=e.pageY+10;

	}

	else{

		x=e.clientX;

		y=e.clientY;

	}

	if(document.getElementById(id_pan).style.display=="block"){

		document.getElementById(id_pan).style.display="none";	

	}

	else{

		document.getElementById(id_pan).style.left=x+"px";

		document.getElementById(id_pan).style.top=y+"px";

		document.getElementById(id_pan).style.display="block";

		

	}

}



// Saisie temps réel, rempli un élément HTML avec le contenu d'un champ spécifié (à mettre sur le onkeyup)

function saisieTempsReel(id_champ, id_element)

{

	var val = document.getElementById(id_champ).value;

	if (val != "")

	{

		// On va remplacer les \n par des <br/>

		var tmp = val.split("\n");

		var val_clean = tmp.join("<br/>");

		document.getElementById(id_element).innerHTML = val_clean;

	} else {

		document.getElementById(id_element).innerHTML = "&nbsp;";	

	}

}



function add_email(id_liste)

{

	var email = document.getElementsByName('txt_ajout')[0].value;

	

	var verif   = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/

    if (verif.exec(email) == null)

	{

       	alert("Votre email est incorrect.");

        document.contact.email.focus();

		return false;

    }else{

		document.getElementsByName('txt_ajout')[0].value = "";

		// Ajout dans la base de données en ajax

		http.open('GET', 'modules/boutique/include/ajax_gestion_contacts.php?op=add&id_liste='+id_liste+'&email='+email);

		http.onreadystatechange = do_add_email;

		http.send(null);

	}

}

function do_add_email()

{

	var tbody = document.getElementById('liste_email');

    if(http.readyState == 4)

	{

		var response = http.responseText;

		tbody.innerHTML = tbody.innerHTML + response;

	}

}



// Suppression d'un email dans la liste de contacts

function delete_email(id_contact)

{

	var noeud = document.getElementById('tr_mail_'+id_contact);

	document.getElementById('liste_email').removeChild(noeud);

	

	// Suppression dans la base de données en ajax

	http.open('GET', 'modules/boutique/include/ajax_gestion_contacts.php?op=del&id_contact='+id_contact);

    http.send(null);

}

function checked_email(id_contact)

{

	var chk = 0;

	if (document.getElementsByName('chk_mail_'+id_contact)[0].checked)

	{

		chk = 1;

	}

	http.open('GET', 'modules/boutique/include/ajax_gestion_contacts.php?op=chk&id_contact='+id_contact+'&chk='+chk);

    http.send(null);

}



// Suppression d'un article du panier

function article_supr(id_article, page)

{

	if (confirm("Souhaitez-vous réellement supprimer ce produit de votre panier ?"))

	{

		location.href = "index.fr.php?page=include/gestion_panier&mod=boutique&op=del_article&id_article="+id_article+"&lapage="+page;	

	}

}



function show_bloc(id){

	for(i = 0; i < document.getElementById("nb_listing").value; i++){

		if(id == i){

				document.getElementById("listing_"+i).style.display="block";

				document.getElementById("lien_"+i).className="actif";

				document.getElementById("onglets_listing").className="lien_actif_"+i;

		}else{

				document.getElementById("listing_"+i).style.display="none";

				document.getElementById("lien_"+i).className="non_actif";

				

		}

	}

}

function addFav() 

{ 

	if (document.all){ 

		window.external.AddFavorite(location.href, document.title); 

	}else{ 

		alert('Vous pouvez faire CTRL + D pour ajouter cette page dans vos signets, ou favoris.') 

	} 

} 