//**************************************************************************************************************************
//-- FONCTIONS BASIQUES
//**************************************************************************************************************************

//-- AJOUTER LA PAGE AUX FAVORIS
function f_favoris() {
if ( navigator.appName != 'Microsoft Internet Explorer' )
	{
	window.sidebar.addPanel(document.title,location.href,"");
	}
	else
	{
	window.external.AddFavorite(location.href,document.title);
	}
}



//-- IMPRESSION DE LA PAGE EN COURS
function f_imprimer(){
	window.print();
}



//-- CONFIRMATION SUPPRESSION
function confirmSuppr(langue) {
	if(langue=='fr'){msg = "Voulez-vous vraiment supprimer ?";}
	if(langue=='en'){msg = "Do you really want to delete this item from your basket ?";}
	conf = confirm(msg);
	return conf;
}





//**************************************************************************************************************************
//-- REVUE DE PRESSE
//**************************************************************************************************************************
function f_presse(id,total){
	for(j=1;j<=total;j++)
		{
		//-- On masque toutes les réponses
		reponse = 'presse'+j;
		document.getElementById(reponse).style.display = 'none';
		
		//-- On affiche la bonne réponse
		if(j==id){document.getElementById(reponse).style.display = 'block';}
		}
}
function f_presse_close(id){
	//-- On masque toutes les réponses
	reponse = 'presse'+id;
	document.getElementById(reponse).style.display = 'none';
}




//**************************************************************************************************************************
//-- CONTACT
//**************************************************************************************************************************
//-- Verif des champs du Formulaire de Contact
function f_verif_contact() {
	lang  = getElt("langue").value;
	civil = getElt("civil").value;
	nom   = getElt("nom").value;
	prenom= getElt("prenom").value;
	email = getElt("email").value;
	tel   = getElt("tel").value;
	mess  = getElt("message").value;

	if(lang=="fr"){Msg="Le formulaire ne peut pas être validé car il manque les informations suivantes :\n";}
	if(lang=="en"){Msg="This form can not be sent. The following informations are not present :\n";}
	
	var email2 = true;
	var verif = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,4}$/;
	if (verif.exec(email) == null){email2 = false;}else{email2 = true;}
	
	if (!civil)
		{
		if(lang=="fr"){Msg=Msg+"- Titre\n";}
		if(lang=="en"){Msg=Msg+"- Title\n";}
		}
	
	if (!nom)
		{
		if(lang=="fr"){Msg=Msg+"- Nom\n";}
		if(lang=="en"){Msg=Msg+"- Name\n";}
		}
		
	if (!prenom)
		{
		if(lang=="fr"){Msg=Msg+"- Prénom\n";}
		if(lang=="en"){Msg=Msg+"- First Name\n";}
		}
		
	if (!tel)
		{
		if(lang=="fr"){Msg=Msg+"- Téléphone\n";}
		if(lang=="en"){Msg=Msg+"- Phone number\n";}
		}
		
	if (!email)
		{
		Msg=Msg+"- Email\n";
		}
		else
		{
		if(!email2)
			{
			if(lang=="fr"){Msg=Msg+"- Adresse Email incorrecte!\n";}
			if(lang=="en"){Msg=Msg+"- Error in your Email!\n";}
			}
		}
	
	if (!mess)
		{
		if(lang=="fr"){Msg=Msg+"- Votre message\n";}
		if(lang=="en"){Msg=Msg+"- Your message\n";}
		}
	
	if (!civil || !nom || !prenom || !email2 || !tel || !mess){alert(Msg); return false;}else{return true;}
}





//**************************************************************************************************************************
//-- ENVOYER A UN(E) AMI(E)
//**************************************************************************************************************************
function f_verif_ami(){
	lang   = getElt("langue").value;
	prenom = getElt("prenom").value;
	email  = getElt("mail").value;
	
	if(lang=="fr"){Msg="Le formulaire ne peut pas être validé :\n";}
	if(lang=="en"){Msg="This form can not be sent :\n";}
	
	if (!prenom)
		{
		if(lang=="fr"){Msg=Msg+"- Votre prénom\n";}
		if(lang=="en"){Msg=Msg+"- Your firstname\n";}
		}
	
	var email2 = true;
	var verif = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,4}$/;
	if (verif.exec(email) == null){email2 = false;}else{email2 = true;}
		
	if (!email)
		{
		if(lang=="fr"){Msg=Msg+"- Adresse email absente\n";}
		if(lang=="en"){Msg=Msg+"- Your Email is not present\n";}
		}
		else
		{
		if(!email2)
			{
			if(lang=="fr"){Msg=Msg+"- Adresse Email incorrecte!\n";}
			if(lang=="en"){Msg=Msg+"- Error in your Email!\n";}
			}
		}
		
	if(!prenom || !email || !email2) {alert(Msg);return false;}else{return true;}
}





//**************************************************************************************************************************
//-- NEWSLETTER
//**************************************************************************************************************************
function f_verif_newsletter() {
	lang  = getElt("langue").value;
	email = getElt("newsletter").value;
	
	if(lang=="fr"){Msg="Le formulaire ne peut pas être validé car il manque les informations suivantes :\n";}
	if(lang=="en"){Msg="This form can not be sent. The following informations are not present :\n";}
	
	var email2 = true;
	var verif = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,4}$/;
	if (verif.exec(email) == null){email2 = false;}else{email2 = true;}

	if (!email)
		{
		Msg=Msg+"- Email\n";
		}
		else
		{
		if(!email2)
			{
			if(lang=="fr"){Msg=Msg+"- Adresse Email incorrecte!\n";}
			if(lang=="en"){Msg=Msg+"- Error in your Email!\n";}
			}
		}
	
	if (!email || !email2){alert(Msg);return false;}else{return true;}
}





//**************************************************************************************************************************
//-- POP-UP
//**************************************************************************************************************************
function openPopup(mypage,largeur,hauteur){
      // Largeur et hauteur préconisées de la fenêtre SPPLUS
   	var PopupSpplus_largeur	= largeur;
   	var PopupSpplus_hauteur	= hauteur;

      // Position haut et gauche de la fenêtre SPPLUS pour affichage centré dans l'écran
   	var PopupSpplus_top	=((screen.height-PopupSpplus_hauteur)/2);
   	var PopupSpplus_left=((screen.width-PopupSpplus_largeur)/2);

   	// Ouverture du popup SPLUS avec barre état uniquement et focus sur la fenêtre
   	var win = window.open(mypage, "SP","status=yes,scrollbars=yes,top="+PopupSpplus_top+",left="+PopupSpplus_left+",width="+PopupSpplus_largeur+",height="+PopupSpplus_hauteur);
   	win.focus();
}











//**************************************************************************************************************************
//-- CLIENT / COMMANDE / LOGIN
//**************************************************************************************************************************
//-- Verif champs pour IDENTIFICATION
function f_verif_connect(){
	lang  = getElt("langue").value;
	email = getElt("login").value;
	mdp   = getElt("mdp").value;
	
	if(lang=="fr"){Msg="Le formulaire ne peut pas être validé :\n";}
	if(lang=="en"){Msg="This form can not be sent :\n";}
	
	var email2 = true;
	var verif = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,4}$/;
	if (verif.exec(email) == null){email2 = false;}else{email2 = true;}
			
	if (!email)
		{
		if(lang=="fr"){Msg=Msg+"- Adresse email absente!\n";}
		if(lang=="en"){Msg=Msg+"- Your Email is not present!\n";}
		}
		else
		{
		if(!email2)
			{
			if(lang=="fr"){Msg=Msg+"- Adresse Email incorrecte!\n";}
			if(lang=="en"){Msg=Msg+"- Error in your Email!\n";}
			}
		}
		
	if (!mdp)
		{
		if(lang=="fr"){Msg=Msg+"- Mot de passe absent!\n";}
		if(lang=="en"){Msg=Msg+"- Your password is not present!\n";}
		}
		
	if (!email || !email2 || !mdp) {alert(Msg);return false;}else{return true;}
}





//-- Verif des champs du Formulaire LIVRAISON
function f_verif_delivery() {
	lang  = getElt("langue2").value;
	nom   = getElt("nom2").value;
	prenom= getElt("prenom2").value;
	ad    = getElt("adresse2").value;
	cp    = getElt("cp2").value;
	ville = getElt("ville2").value;
	pays  = getElt("pays2").value;
	etat  = getElt("state2").value;
	tel   = getElt("tel2").value;
	
	
	if(lang=="fr"){Msg="Le formulaire ne peut pas être validé car il manque les informations suivantes :\n";}
	if(lang=="en"){Msg="This form can not be sent. The following informations are not present :\n";}
	
	
	if(document.forms['FLiv'].elements['choix1'].checked && document.forms['FLiv'].elements['choix2'].checked)
		{
		if(lang=="fr"){Msg=Msg+"- Vous ne pouvez cocher qu\'une case à la fois!\n";}
		if(lang=="en"){Msg=Msg+"- You can tick off only one box at the same time !\n";}
		}

	
	if (!nom)
		{
		if(lang=="fr"){Msg=Msg+"- Nom\n";}
		if(lang=="en"){Msg=Msg+"- Name\n";}
		}
		
	if (!prenom)
		{
		if(lang=="fr"){Msg=Msg+"- Prénom\n";}
		if(lang=="en"){Msg=Msg+"- First Name\n";}
		}

	if (!ad)
		{
		if(lang=="fr"){Msg=Msg+"- Adresse\n";}
		if(lang=="en"){Msg=Msg+"- Address\n";}
		}
		
	if (!cp)
		{
		if(lang=="fr"){Msg=Msg+"- Code postal\n";}
		if(lang=="en"){Msg=Msg+"- ZIP code\n";}
		}
		
	if (!ville)
		{
		if(lang=="fr"){Msg=Msg+"- Ville\n";}
		if(lang=="en"){Msg=Msg+"- Town\n";}
		}
		
	if (!pays)
		{
		if(lang=="fr"){Msg=Msg+"- Pays\n";}
		if(lang=="en"){Msg=Msg+"- Country\n";}
		}
	if(pays==46)
		{
		if(!etat)
			{
			if(lang=="fr"){Msg=Msg+"- L'Etat\n";}
			if(lang=="en"){Msg=Msg+"- State\n";}
			}
		}
		else
		{
		etat = true;	
		}
		
	if (!tel)
		{
		if(lang=="fr"){Msg=Msg+"- Téléphone\n";}
		if(lang=="en"){Msg=Msg+"- Phone number\n";}
		}

	if ( (document.forms['FLiv'].elements['choix1'].checked && document.forms['FLiv'].elements['choix2'].checked) || !nom || !prenom || !ad || !cp || !ville || !pays || !etat || !tel)
		{alert(Msg);return false;}else{return true;}
}





//-- Verif des champs du Formulaire inscription nouveau client
function f_verif_customer() {
	lang  = getElt("langue").value;
	titre = getElt("civil").value;
	nom   = getElt("nom").value;
	prenom= getElt("prenom").value;
	ad    = getElt("adresse").value;
	cp    = getElt("cp").value;
	ville = getElt("ville").value;
	pays  = getElt("pays").value;
	etat  = getElt("state").value;
	tel   = getElt("tel").value;
	email = getElt("mail").value;
	
	if(lang=="fr"){Msg="Le formulaire ne peut pas être validé car il manque les informations suivantes :\n";}
	if(lang=="en"){Msg="This form can not be sent. The following informations are not present :\n";}
	
	var email2 = true;
	var verif  = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,4}$/;
	if (verif.exec(email) == null){email2 = false;}else{email2 = true;}
	
	if (!titre)
		{
		if(lang=="fr"){Msg=Msg+"- Titre\n";}
		if(lang=="en"){Msg=Msg+"- Title\n";}
		}
	
	if (!nom)
		{
		if(lang=="fr"){Msg=Msg+"- Nom\n";}
		if(lang=="en"){Msg=Msg+"- Name\n";}
		}
		
	if (!prenom)
		{
		if(lang=="fr"){Msg=Msg+"- Prénom\n";}
		if(lang=="en"){Msg=Msg+"- First Name\n";}
		}
	
	if (!ad)
		{
		if(lang=="fr"){Msg=Msg+"- Adresse\n";}
		if(lang=="en"){Msg=Msg+"- Address\n";}
		}
		
	if (cp.length != 5) {
		if(lang=="fr"){Msg=Msg+"- Code postal (Code postal français uniquement, 5 chiffres)\n";}
		if(lang=="en"){Msg=Msg+"- ZIP code (French ZIP code only, must be 5 characters long)\n";}
	}
		
	if (!ville)
		{
		if(lang=="fr"){Msg=Msg+"- Ville\n";}
		if(lang=="en"){Msg=Msg+"- Town\n";}
		}
		
	if (!pays)
		{
		if(lang=="fr"){Msg=Msg+"- Pays\n";}
		if(lang=="en"){Msg=Msg+"- Country\n";}
		}
		
	if(pays==46)
		{
		if(!etat)
			{
			if(lang=="fr"){Msg=Msg+"- L'Etat\n";}
			if(lang=="en"){Msg=Msg+"- State\n";}
			}
		}
		else
		{
		etat = true;	
		}
		
	if (!tel)
		{
		if(lang=="fr"){Msg=Msg+"- Téléphone\n";}
		if(lang=="en"){Msg=Msg+"- Phone number\n";}
		}
		
	if (!email)
		{
		Msg=Msg+"- Email\n";
		}
		else
		{
		if(!email2)
			{
			if(lang=="fr"){Msg=Msg+"- Adresse Email incorrecte!\n";}
			if(lang=="en"){Msg=Msg+"- Error in your Email!\n";}
			}
		}
	
	if (!titre || !nom || !prenom || !email2 || !ad || !cp || !ville || !pays ||!etat || !tel){alert(Msg); return false;}else{return true;}
}





//-- Verif champs pour renvoi des identifiants
function f_verif_envoiMDP(){
	lang  = getElt("langue").value;
	email = getElt("mail").value;
	
	if(lang=="fr"){Msg="Le formulaire ne peut pas être validé :\n";}
	if(lang=="en"){Msg="This form can not be sent :\n";}
	
	var email2 = true;
	var verif = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,4}$/;
	if (verif.exec(email) == null){email2 = false;}else{email2 = true;}
		
	if (!email)
		{
		if(lang=="fr"){Msg=Msg+"- Adresse email absente\n";}
		if(lang=="en"){Msg=Msg+"- Your Email is not present\n";}
		}
		else
		{
		if(!email2)
			{
			if(lang=="fr"){Msg=Msg+"- Adresse Email incorrecte!\n";}
			if(lang=="en"){Msg=Msg+"- Error in your Email!\n";}
			}
		}
		
	if (!email || !email2) {alert(Msg);return false;}else{return true;}
}





//-- Verif Quantité entière PANIER
function f_verif_qte(){
	nb_row= getElt("nb_row").value;
	lang  = getElt("langue").value;
	var verif = /^[0-9]{1,5}$/;
	
	if(lang=="fr"){Msg="Merci d'insérer des quantités entières !\n";}
	if(lang=="en"){Msg="Thanks to insert whole quantities !\n";}
	
	cond = true;
	for(j=0;j<nb_row;j++)
		{
		if( verif.exec(getElt("qte"+j).value) == null )
			{
			cond = false;
			}
		}

	if( cond==false ){alert(Msg);return false;}else{return true;}
}





//-- Verif Code CHEQUE CADEAU
function f_verif_cheque_credit(){
	code = getElt("code").value;
	lang = getElt("langue").value;

	if(lang=="fr"){Msg="Merci d'insérer votre code !\n";}
	if(lang=="en"){Msg="Thanks to insert your code !\n";}

	if(!code){alert(Msg);return false;}else{return true;}
}





//-- Verif Code CHEQUE CADEAU
function f_cgvok(){
	code = getElt("cgv_ok").checked;
	lang = getElt("langue").value; 

	if(lang=="fr"){Msg="Merci de prendre connaissance des conditions générales de vente!\n";}
	if(lang=="en"){Msg="Thanks to read and to agree our general terms of sales!\n";}

	if(!code){alert(Msg);return false;}else{return true;}
}









//-----------------------------------------------------------------------------------------------------------------------------
//-- Changement de la vignette FICHE PRODUIT
function f_chg_img(tmp){
	document.images['previewImg0'].src = 'media/images/produits/'+tmp;
	//document.getElementById("previewImg0").innerHTML = '<img src="media/images/produits/'+tmp+'" class="img_detail" />';
}