﻿                //AFFICHER LA REGION EN FONCTION DU PAYS :
                function selectRegion(idregion)
                {
                    var frm = document.frmprdsearch;

                    document.getElementById('labelRegion').style.display='none';
                    document.getElementById('regions').style.display='none';
                    frm.select_regions.selectedIndex=0;
	                document.getElementById('labelSituation').style.display='none';
		            document.getElementById('situation').style.display='none';
				    frm.select_situation.selectedIndex=0;
				    frm.s_prd_Localisation.value='';

                    //AUTRE QUE MONACO ET NON VIDE
                    if (idregion != 'MO' && idregion != '')
                    {
                        change_options(idregion);
                        document.getElementById('labelRegion').style.display='';
                        document.getElementById('regions').style.display='';
                    }
                }


                //CHOISIR UNE REGION ET POUR LA FRANCE, AFFICHER LA SITUATION (= sous régions)
                function changeSituation(idregion)
                {
				    var frm = document.frmprdsearch;
					if (frm.pays[frm.pays.selectedIndex].value == 'FR')
				    {
						//RENSEIGNER LES OPTIONS DANS LES SOUS REGIONS POUR LA FRANCE (VARIABLE : ID DE LA REGION PRINCIPALE)
						changeOptionsSituation(idregion.substring(0,idregion.indexOf('|')));
	                }
                }



                function rechercher()
                {

	                var frm = document.frmprdsearch;

		            //PAYS SELECTIONNE
	                var selectPays = frm.pays[frm.pays.selectedIndex].value;
			        //REGION SELECTIONNEE
				    var selectRegion = frm.select_regions[frm.select_regions.selectedIndex].value;
				   //SOUS REGION SELECTIONNEE
					var selectSousRegion = frm.select_situation[frm.select_situation.selectedIndex].value;

	                //SI SOUS REGION SELECTIONNEE
		            if (selectSousRegion != '') 
		            {
						frm.s_prd_Localisation.value=selectSousRegion;
						frm.s_prd_Pays.value='';
					}

					//SI UNE REGION SELECTIONNEE
		            else if (selectRegion != '')
		            {
						frm.s_prd_Localisation.value=selectRegion;
						frm.s_prd_Pays.value='';
					}

					//SI PAYS MAIS PAS DE REGION, VIDER LE CHAMP REGION ET PRENDRE EN COMPTE LE PAYS
					else if (selectPays != '')
					{
						frm.s_prd_Localisation.value='';
						if (selectPays == 'FR') frm.s_prd_Pays.value='France';
				        else if (selectPays == 'MO') frm.s_prd_Pays.value='Monaco';
				        else if (selectPays == 'ES') frm.s_prd_Pays.value='Espagne';
				        else if (selectPays == 'IT') frm.s_prd_Pays.value='Italie';
				        else if (selectPays == 'RO') frm.s_prd_Pays.value='Roumanie';
					}
					
					//SI PAS DE PAYS, ET PAS DE REGION
					else 
					{
						frm.s_prd_Localisation.value='';
						frm.s_prd_Pays.value='';
					}



					
					if (frm.prices[frm.prices.selectedIndex].value==1)
					{
						frm.s_prd_Price1_min.value='';
						frm.s_prd_Price1_max.value=1500000;
					}
					if (frm.prices[frm.prices.selectedIndex].value==2)
					{
						frm.s_prd_Price1_min.value=1500000;
						frm.s_prd_Price1_max.value=3000000;
					}
					if (frm.prices[frm.prices.selectedIndex].value==3)
					{
						frm.s_prd_Price1_min.value=3000000;
						frm.s_prd_Price1_max.value=5000000;
					}
					if (frm.prices[frm.prices.selectedIndex].value==4)
					{
						frm.s_prd_Price1_min.value=5000000;
						frm.s_prd_Price1_max.value=10000000;
					}
					if (frm.prices[frm.prices.selectedIndex].value==5)
					{
						frm.s_prd_Price1_min.value=10000000;
						frm.s_prd_Price1_max.value='';
					}
					try{dispo();}catch(e){}
					if (document.frmrefsearch.s_prd_Reference.value != '')
					{
					    if (document.frmrefsearch.idprd.value != '') 
					    {
					        var forceaction = document.frmforceref.action.replace('11111',document.frmrefsearch.idprd.value);
					        document.frmforceref.action = forceaction;
					        document.frmforceref.submit();
					    }
					    else
					        document.frmrefsearch.submit();
					}    
					
					//alert('loc = ' + frm.s_prd_Localisation.value);
					//alert('pays = ' + frm.s_prd_Pays.value);	
					//alert(frm.s_prd_Price1_min.value);
					//alert(frm.s_prd_Price1_max.value);

					else frm.submit();
                }


                    function selectBudget(transac)
                    {
                    var frm = document.frmprdsearch;
                    if (transac==1)
                    {
                    document.getElementById('labelBudget').style.display='';
                    document.getElementById('divBudget').style.display='';
                    }
                    if (transac==3)
                    {
                    document.getElementById('labelBudget').style.display='none';
                    document.getElementById('divBudget').style.display='none';
                    frm.s_prd_Price1_min.value='';
                    frm.s_prd_Price1_max.value='';
                    frm.prices.selectedIndex=0;
                    }
                    }

                function showdiv(div)
                {
                if (document.getElementById('div_owner') != null && document.getElementById('div_agy') != null && document.getElementById('div_jt') != null)
                {
	                if (div == 'div_owner')
		            {
			        document.getElementById('div_agy').style.display='none';
				    document.getElementById('div_jt').style.display='none';
					}
	                if (div == 'div_agy')
		            {
			        document.getElementById('div_jt').style.display='none';
				    document.getElementById('div_owner').style.display='none';
	                }
			        if (div == 'div_jt')
		            {
						document.getElementById('div_owner').style.display='none';
						document.getElementById('div_agy').style.display='none';
		            }
	                document.getElementById(div).style.display='';
			    }
			    }
			    
                function hidediv()
                {
                if (document.getElementById('div_owner') != null && document.getElementById('div_agy') != null && document.getElementById('div_jt') != null)
                {
                document.getElementById('div_owner').style.display='none';
                document.getElementById('div_agy').style.display='none';
                document.getElementById('div_jt').style.display='none';
                }
                }
                
                
function check_simple(frm,langue)
{
	if (frm._prenom.value == '')
	{
		if (langue == 'fr') alert('Veuillez renseigner votre prénom');
		if (langue == 'us') alert('Please fill in your first name');
		if (langue == 'it') alert('Inserire il nome');
		if (langue == 'ro') alert('Introduceţi prenumele dvs.');
		if (langue == 'es') alert('Por favor, indique su nombre');
		frm._prenom.focus();
		return;
	}
	if (frm._nom.value == '')
	{
		if (langue == 'fr') alert('Veuillez renseigner votre nom');
		if (langue == 'us') alert('Please fill in your last name');
		if (langue == 'it') alert('Inserire il cognome');
		if (langue == 'ro') alert('Introduceţi numele dvs.');
		if (langue == 'es') alert('Por favor, indique sus apellidos');
		frm._nom.focus();
		return;
	}
	if (!verif(frm._email.value))
	{
		if (langue == 'fr') alert('Veuillez vérifier le format de votre adresse e-mail');
		if (langue == 'us') alert('Please check the format of your e-mail address');
		if (langue == 'it') alert('Verificare il formato del vostro indirizzo email');
		if (langue == 'ro') alert('Verificaţi formatul adresei dvs. de e-mail');
		if (langue == 'es') alert('Por favor, compruebe el formato de su dirección de email');
		frm._email.focus();
		return;
	}
	if (frm == document.frmnewsletter)
	{
		if (!(frm.champ_etreinforme.checked))
		{
			if (langue == 'fr') alert('Veuillez cocher la case "Je souhaite être informé de l\'actualité de John Taylor par e-mail"');
			if (langue == 'us') alert('Please check the "I would like to receive the latest news at John Taylor by e-mail" box');
			if (langue == 'it') alert('Selezionare la casella "Desidero essere informato(a) sull\'attualità di John Taylor tramite e-mail"');
			if (langue == 'ro') alert('Bifaţi căsuţa "Doresc să primesc anunţurile actuale John Taylor prin e-mail"');
			if (langue == 'es') alert('Por favor, marque con una cruz la casilla "Quisiera ser informado por e-mail de la actualidad de John Taylor"');
			return;
		}
	}
	if (frm == document.frmalertes)
	{
		if (frm.champ_etreinforme.checked)
		{
			frm._mailinglist.value='156';
		}
		else frm._mailinglist.value='';
	}
	frm.submit();
}


function check_doc(langue)
{
var frm = document.frmsendmail;
	if (frm._prenom.value == '')
	{
		if (langue == 'fr') alert('Veuillez renseigner votre prénom');
		if (langue == 'us') alert('Please fill in your first name');
		if (langue == 'it') alert('Inserire il nome');
		if (langue == 'ro') alert('Introduceţi prenumele dvs.');
		if (langue == 'es') alert('Por favor, indique su nombre');
		frm._prenom.focus();
		return;
	}
	if (frm._nom.value == '')
	{
		if (langue == 'fr') alert('Veuillez renseigner votre nom');
		if (langue == 'us') alert('Please fill in your last name');
		if (langue == 'it') alert('Inserire il cognome');
		if (langue == 'ro') alert('Introduceţi numele dvs.');
		if (langue == 'es') alert('Por favor, indique sus apellidos');
		frm._nom.focus();
		return;
	}
	if (frm._telephone.value == '')
	{
		if (langue == 'fr') alert('Veuillez renseigner votre numéro de téléphone');
		if (langue == 'us') alert('Please fill in your telephone number');
		if (langue == 'it') alert('Inserire il vostro numero di telefono');
		if (langue == 'ro') alert('Por favor, indique su número de teléfono');
		if (langue == 'es') alert('Introduceţi numărul dvs. de telefon');
		frm._telephone.focus();
		return;
	}
	if (!verif(frm._email.value))
	{
		if (langue == 'fr') alert('Veuillez vérifier le format de votre adresse e-mail');
		if (langue == 'us') alert('Please check the format of your e-mail address');
		if (langue == 'it') alert('Verificare il formato del vostro indirizzo email');
		if (langue == 'ro') alert('Verificaţi formatul adresei dvs. de e-mail');
		if (langue == 'es') alert('Por favor, compruebe el formato de su dirección de email');
		frm._email.focus();
		return;
	}
	document.getElementById('layfrm').style.display='none';
	document.getElementById('laywait').style.display='';
	frm.submit();
}

function check_ami(langue)
{
var frm = document.frmsendmail;
	if (!verif(frm._email_ami.value))
	{
		if (langue == 'fr') alert('Veuillez vérifier le format de l\'adresse e-mail du destinataire');
		if (langue == 'us') alert('Please check the format of the recipient\'s e-mail address');
		if (langue == 'it') alert('Verificare il formato dell\'indirizzo email del destinatario');
		if (langue == 'ro') alert('Verificaţi formatul adresei de e-mail a destinatarului');
		if (langue == 'es') alert('Por favor, compruebe el formato de la dirección de email del destinatario');
		frm._email_ami.focus();
		return;
	}
	if (!verif(frm._email.value))
	{
		if (langue == 'fr') alert('Veuillez vérifier le format de votre adresse e-mail');
		if (langue == 'us') alert('Please check the format of your e-mail address');
		if (langue == 'it') alert('Verificare il formato del vostro indirizzo email');
		if (langue == 'ro') alert('Verificaţi formatul adresei dvs. de e-mail');
		if (langue == 'es') alert('Por favor, compruebe el formato de su dirección de email');
		frm._email.focus();
		return;
	}
	if (frm._nom.value == '')
	{
		if (langue == 'fr') alert('Veuillez renseigner votre nom');
		if (langue == 'us') alert('Please fill in your last name');
		if (langue == 'it') alert('Inserire il cognome');
		if (langue == 'ro') alert('Introduceţi numele dvs.');
		if (langue == 'es') alert('Por favor, indique sus apellidos');
		frm._nom.focus();
		return;
	}
	document.getElementById('layfrm').style.display='none';
	document.getElementById('laywait').style.display='';
	frm.submit();
}


function check_zone_contact(langue)
{
var frm = document.frmsendmail;
	if (frm._agy[frm.champ_metier.selectedIndex].value == '')
	{
		if (langue == 'fr') alert('Veuillez préciser le service concerné par votre demande');
		if (langue == 'us') alert('Please specify which department is concerned by your request');
		if (langue == 'it') alert('Precisare il servizio interessato dalla vostra richiesta');
		if (langue == 'ro') alert('Precizaţi serviciul pe care îl solicitaţi');
		if (langue == 'es') alert('Por favor, señale el servicio correspondiente a su petición');
		frm.champ_metier.focus();
		return false;
	}
	if (frm._agy[frm._agy.selectedIndex].value == '')
	{
		if (langue == 'fr') alert('Veuillez choisir une agence');
		if (langue == 'us') alert('Please choose an agency');
		if (langue == 'it') alert('Scegliere un\'agenzia');
		if (langue == 'ro') alert('Alegeţi o agenţie');
		if (langue == 'es') alert('Por favor, seleccione una agencia');
		frm._agy.focus();
		return false;
	}
	if (frm._prenom.value == '')
	{
		if (langue == 'fr') alert('Veuillez renseigner votre prénom');
		if (langue == 'us') alert('Please fill in your first name');
		if (langue == 'it') alert('Inserire il nome');
		if (langue == 'ro') alert('Introduceţi prenumele dvs.');
		if (langue == 'es') alert('Por favor, indique su nombre');
		frm._prenom.focus();
		return false;
	}
	if (frm._nom.value == '')
	{
		if (langue == 'fr') alert('Veuillez renseigner votre nom');
		if (langue == 'us') alert('Please fill in your last name');
		if (langue == 'it') alert('Inserire il cognome');
		if (langue == 'ro') alert('Introduceţi numele dvs.');
		if (langue == 'es') alert('Por favor, indique sus apellidos');
		frm._nom.focus();
		return false;
	}
	if (frm._telephone.value == '')
	{
		if (langue == 'fr') alert('Veuillez renseigner votre numéro de téléphone');
		if (langue == 'us') alert('Please fill in your telephone number');
		if (langue == 'it') alert('Inserire il vostro numero di telefono');
		if (langue == 'ro') alert('Por favor, indique su número de teléfono');
		if (langue == 'es') alert('Introduceţi numărul dvs. de telefon');
		frm._telephone.focus();
		return false;
	}
	if (!verif(frm._email.value))
	{
		if (langue == 'fr') alert('Veuillez vérifier le format de votre adresse e-mail');
		if (langue == 'us') alert('Please check the format of your e-mail address');
		if (langue == 'it') alert('Verificare il formato del vostro indirizzo email');
		if (langue == 'ro') alert('Verificaţi formatul adresei dvs. de e-mail');
		if (langue == 'es') alert('Por favor, compruebe el formato de su dirección de email');
		frm._email.focus();
		return false;
    }
    setAgency(frm._agy[frm._agy.selectedIndex].value);
	return submitToHighslide(frm);
	return true;
}


function verif(email) { // vérif validité email par REGEXP
	 var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,4}$/
	 return (reg.exec(email)!=null)
}

function changeLanguage(strCode) {
    var frmL = document.frmLangue;
    var frm = document.frmprdsearch;
    var vRef = '';
    frmL._LanguageCode.value = strCode;
    
    if (document.frmrefsearch && document.frmrefsearch.s_prd_Reference)
        vRef = document.frmrefsearch.s_prd_Reference.value;
							
	if (vRef == '') 
	{
		if (frm)
		{
		            //PAYS SELECTIONNE
	                var selectPays = frm.pays[frm.pays.selectedIndex].value;
			        //REGION SELECTIONNEE
				    var selectRegion = frm.select_regions[frm.select_regions.selectedIndex].value;
				   //SOUS REGION SELECTIONNEE
					var selectSousRegion = frm.select_situation[frm.select_situation.selectedIndex].value;

	                //SI SOUS REGION SELECTIONNEE
		            if (selectSousRegion != '') 
		            {
						frm.s_prd_Localisation.value=selectSousRegion;
						frm.s_prd_Pays.value='';
					}

					//SI UNE REGION SELECTIONNEE
		            else if (selectRegion != '')
		            {
						frm.s_prd_Localisation.value=selectRegion;
						frm.s_prd_Pays.value='';
					}

					//SI PAYS MAIS PAS DE REGION, VIDER LE CHAMP REGION ET PRENDRE EN COMPTE LE PAYS
					else if (selectPays != '')
					{
						frm.s_prd_Localisation.value='';
						if (selectPays == 'FR') frm.s_prd_Pays.value='France';
				        else if (selectPays == 'MO') frm.s_prd_Pays.value='Monaco';
				        else if (selectPays == 'ES') frm.s_prd_Pays.value='Espagne';
				        else if (selectPays == 'IT') frm.s_prd_Pays.value='Italie';
				        else if (selectPays == 'RO') frm.s_prd_Pays.value='Roumanie';
					}
					
					//SI PAS DE PAYS, ET PAS DE REGION
					else 
					{
						frm.s_prd_Localisation.value='';
						frm.s_prd_Pays.value='';
					}

			if (frm.prices[frm.prices.selectedIndex].value==1)
			{
				frm.s_prd_Price1_min.value='';
				frm.s_prd_Price1_max.value=1500000;
			}
			if (frm.prices[frm.prices.selectedIndex].value==2)
			{
				frm.s_prd_Price1_min.value=1500000;
				frm.s_prd_Price1_max.value=3000000;
			}
			if (frm.prices[frm.prices.selectedIndex].value==3)
			{
				frm.s_prd_Price1_min.value=3000000;
				frm.s_prd_Price1_max.value=5000000;
			}
			if (frm.prices[frm.prices.selectedIndex].value==4)
			{
				frm.s_prd_Price1_min.value=5000000;
				frm.s_prd_Price1_max.value=10000000;
			}
			if (frm.prices[frm.prices.selectedIndex].value==5)
			{
				frm.s_prd_Price1_min.value=10000000;
				frm.s_prd_Price1_max.value='';
			}

		    if (frm.s_prd_Localisation) frmL.s_prd_Localisation.value = frm.s_prd_Localisation.value;
		    if (frm.s_prd_Pays) frmL.s_prd_Pays.value = frm.s_prd_Pays.value;
		    if (frm.s_prd_Price1_min) frmL.s_prd_Price1_min.value = frm.s_prd_Price1_min.value;
		    if (frm.s_prd_Price1_max) frmL.s_prd_Price1_max.value = frm.s_prd_Price1_max.value;
		    if (frm.s_prd_Type) 
		    {
		        if (frm.s_prd_Type.value)
		            frmL.s_prd_Type.value = frm.s_prd_Type.value;
		        else
		        {
		            for (var i=0;i<frm.s_prd_Type.length;i++)
		                if (frm.s_prd_Type[i].checked)
		                    frmL.s_prd_Type.value = frm.s_prd_Type[i].value;
		        }
		    }
		    if (frm.s_prd_Nature) frmL.s_prd_Nature.value = frm.s_prd_Nature.value;
		    if (frm.s_prd_Chambres_min) frmL.s_prd_Chambres_min.value = frm.s_prd_Chambres_min.value;
		    if (frm.s_prd_Chambres_max) frmL.s_prd_Chambres_max.value = frm.s_prd_Chambres_max.value;		    
		    if (frm.prd_CurrentSort) frmL.prd_CurrentSort.value = frm.prd_CurrentSort.value;
		    frmL.s_prd_Reference.value = "";
		}
	}
	else
	{
		frmL.s_prd_Reference.value = vRef;
	}
	
	frmL.submit();
}

function hideBudgetOnLocation() {
    document.frmprdsearch.prices.selectedIndex = 0;
    document.getElementById('labelBudget').style.display = "none";
    document.getElementById('divBudget').style.display = "none";
}