﻿//-- TOUT COCHER : DEMANDE SPECIFIQUE

function GereChkbox(nb_box) {
for(i=0;i<nb_box;i++)
	{
	document.getElementById('box'+i).checked=true;
	}
}
function GereChkbox2(nb_box) {
for(i=0;i<nb_box;i++)
	{
	document.getElementById('box'+i).checked=false;
	}
}





//-- 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();
}




//-- Verif des champs du Formulaire de Contact
function f_verif_contact() {
	titre = getElt("titre").value;
	nom   = getElt("nom").value;
	prenom= getElt("prenom").value;
	email = getElt("email").value;
	pays  = getElt("pays").value;
	tel   = getElt("tel").value;
	mess  = getElt("message").value;
	
	Msg="Le formulaire ne peut pas être validé car il manque les informations suivantes :\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)
		Msg=Msg+"- Titre\n";
	if (!nom)
		Msg=Msg+"- Nom\n";
	if (!prenom)
		Msg=Msg+"- Prénom\n";

	if (!pays)
		Msg=Msg+"- Pays\n";
	if (!tel)
		Msg=Msg+"- Tel.\n";
	if (!email)
		{
		Msg=Msg+"- Email\n";
		}
		else
		{
		if(!email2)
			{
			Msg=Msg+"- Adresse Email incorrecte!\n";
			}
		}
	if (!mess)
		Msg=Msg+"- Message\n";

	
	if (!titre || !nom || !prenom || !email2 || !pays || !tel || !mess) {
		alert(Msg);
		return false;
		}
		else
		return true;
}




//-- Verif des champs du Formulaire ENVOYER A UN AMI
function f_verif_ami(captchaValue) {
	nom   = getElt("nom").value;
	prenom= getElt("prenom").value;
	mess  = getElt("message").value;
	email = getElt("mail").value;
	langue= getElt("langue").value;
	captcha = getElt("captcha").value;	
	if(captcha){
		captcha = captcha.toUpperCase();
		captcha = md5(captcha);
	}
	if(captcha && captcha != captchaValue) captcha = false;
	
	if(langue=="fr"){Msg="Le formulaire ne peut pas être validé car il manque les informations suivantes :\n";}
	if(langue=="en"){Msg="Your form can not be sent. The following informations are not present :\n";}
	
		
	if (!nom)
		{
		if(langue=="fr"){Msg=Msg+"- Nom!\n";}
		if(langue=="en"){Msg=Msg+"- Name!\n";}
		}
	
	if (!prenom)
		{
		if(langue=="fr"){Msg=Msg+"- Prénom!\n";}
		if(langue=="en"){Msg=Msg+"- First name!\n";}
		}
		
	if (!mess)
		{
		if(langue=="fr"){Msg=Msg+"- Votre message!\n";}
		if(langue=="en"){Msg=Msg+"- Your message!\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(langue=="fr"){Msg=Msg+"- L\'adresse Email du destinatire!\n";}
		if(langue=="en"){Msg=Msg+"- Your friend\'s Email!\n";}
		}
		else
		{
		if(!email2)
			{
			if(langue=="fr"){Msg=Msg+"- Adresse Email incorrecte!\n";}
			if(langue=="en"){Msg=Msg+"- Error in Email!\n";}
			}
		}
	
	if(!captcha)
		{
		if(langue=="fr"){Msg=Msg+"- Code de vérification!\n";}
		if(langue=="en"){Msg=Msg+"- Verification code!\n";}
		}

	
	if (!nom || !prenom || !mess || !email || !email2 || !captcha)
		{
		alert(Msg);
		return false;
		}
		else{return true;}
}




//-- Verif des champs du Formulaire CALLBACK
function f_verif_callback(captchaValue) {
	phone  = getElt("phone").value;
	langue = getElt("langue").value;
	captcha = getElt("captcha").value;	
	if(captcha){
		captcha = captcha.toUpperCase();
		captcha = md5(captcha);
	}
	if(captcha && captcha != captchaValue) captcha = false;
	
	if(langue=="fr"){Msg="Le formulaire ne peut pas être validé car il manque les informations suivantes :\n";}
	if(langue=="en"){Msg="Your form can not be sent. The following informations are not present :\n";}
	
	if(!phone)
		{
		if(langue=="fr"){Msg=Msg+"- Téléphone!\n";}
		if(langue=="en"){Msg=Msg+"- Phone number!\n";}
		}
	
	if(!captcha)
		{
		if(langue=="fr"){Msg=Msg+"- Code de vérification!\n";}
		if(langue=="en"){Msg=Msg+"- Verification code!\n";}
		}
	
	
	if(!phone || !captcha)
		{
		alert(Msg);
		return false;
		}
		else{return true;}
}




//-- Verif des champs du Formulaire RDV
function f_verif_rdv(captchaValue) {
	nom   = getElt("nom").value;
	prenom= getElt("prenom").value;
	email = getElt("mail").value;
	tel   = getElt("tel").value;
	langue= getElt("langue").value;
	captcha = getElt("captcha").value;	
	if(captcha){
		captcha = captcha.toUpperCase();
		captcha = md5(captcha);
	}
	if(captcha && captcha != captchaValue) captcha = false;
	
	if(langue=="fr"){Msg="Le formulaire ne peut pas être validé car il manque les informations suivantes :\n";}
	if(langue=="en"){Msg="Your form can not be sent. The following informations are not present :\n";}
		
	if (!nom)
		{
		if(langue=="fr"){Msg=Msg+"- Nom!\n";}
		if(langue=="en"){Msg=Msg+"- Name!\n";}
		}
	
	if (!prenom)
		{
		if(langue=="fr"){Msg=Msg+"- Prénom!\n";}
		if(langue=="en"){Msg=Msg+"- First name!\n";}
		}
		
	if (!tel)
		{
		if(langue=="fr"){Msg=Msg+"- Votre numéro de téléphone!\n";}
		if(langue=="en"){Msg=Msg+"- Your phone number!\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(langue=="fr"){Msg=Msg+"- Votre Email !\n";}
		if(langue=="en"){Msg=Msg+"- Your Email!\n";}
		}
		else
		{
		if(!email2)
			{
			if(langue=="fr"){Msg=Msg+"- Adresse Email incorrecte!\n";}
			if(langue=="en"){Msg=Msg+"- Error in Email!\n";}
			}
		}
	
	if(!captcha)
		{
		if(langue=="fr"){Msg=Msg+"- Code de vérification!\n";}
		if(langue=="en"){Msg=Msg+"- Verification code!\n";}
		}

	if (!nom || !prenom || !tel || !email || !email2 || !captcha)
		{
		alert(Msg);
		return false;
		}
		else{return true;}
}

//-- Verif des champs du Formulaire RDV
function f_verif_rdv2() {
	nom   = getElt("nom").value;
	prenom= getElt("prenom").value;
	email = getElt("mail").value;
	tel   = getElt("tel").value;
	langue= getElt("langue").value;
	
	if(langue=="fr"){Msg="Le formulaire ne peut pas être validé car il manque les informations suivantes :\n";}
	if(langue=="en"){Msg="Your form can not be sent. The following informations are not present :\n";}
		
	if (!nom)
		{
		if(langue=="fr"){Msg=Msg+"- Nom!\n";}
		if(langue=="en"){Msg=Msg+"- Name!\n";}
		}
	
	if (!prenom)
		{
		if(langue=="fr"){Msg=Msg+"- Prénom!\n";}
		if(langue=="en"){Msg=Msg+"- First name!\n";}
		}
		
	if (!tel)
		{
		if(langue=="fr"){Msg=Msg+"- Votre numéro de téléphone!\n";}
		if(langue=="en"){Msg=Msg+"- Your phone number!\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(langue=="fr"){Msg=Msg+"- Votre Email !\n";}
		if(langue=="en"){Msg=Msg+"- Your Email!\n";}
		}
		else
		{
		if(!email2)
			{
			if(langue=="fr"){Msg=Msg+"- Adresse Email incorrecte!\n";}
			if(langue=="en"){Msg=Msg+"- Error in Email!\n";}
			}
		}
	

	if (!nom || !prenom || !tel || !email || !email2)
		{
		alert(Msg);
		return false;
		}
		else{return true;}
}




//-- Changement de la vignette
function f_chg_img(tmp)
	{
	document.getElementById("previewImg0").innerHTML = '<img src="media/photo_annonces/'+tmp+'" width="373" height="278">';
}



//----------------------------------------------------------
//--Fonction pour l'ouverture en POP-UP pour abonnement NEWSLETTER
function PopPage(mypage)
   {
      // Largeur et hauteur préconisées de la fenêtre SPPLUS
   	var PopupSpplus_largeur	= 380;
   	var PopupSpplus_hauteur	= 280;

      // 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,top="+PopupSpplus_top+",left="+PopupSpplus_left+",width="+PopupSpplus_largeur+",height="+PopupSpplus_hauteur);
   	win.focus();
}


function openPopup(url,name,w,h,o)
	{
	window.open(url,name,'width='+w+',height='+h+',resizable=0,'+o);
}