﻿
function popup_foot()
{
    window.open('/common/code/b2c/mail_b2c.asp?mail_Model=invitationfoot20081206','foot','height=780,width=390,status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=yes');
}

function submitenter(e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
	if (keycode == 13) 
	{
		document.frmprdsearch.submit();
		return false;
	}
else
return true;
}





	
function format(valeur,decimal,separateur) {
// formate un chiffre avec 'decimal' chiffres après la virgule et un separateur
	var deci=Math.round( Math.pow(10,decimal)*(Math.abs(valeur)-Math.floor(Math.abs(valeur)))) ; 
	var val=Math.floor(Math.abs(valeur));
	if ((decimal==0)||(deci==Math.pow(10,decimal))) {val=Math.floor(Math.abs(valeur)); deci=0;}
	var val_format=val+"";
	var nb=val_format.length;
	for (var i=1;i<4;i++) {
		if (val>=Math.pow(10,(3*i))) {
			val_format=val_format.substring(0,nb-(3*i))+separateur+val_format.substring(nb-(3*i));
		}
	}
	if (decimal>0) {
		var decim=""; 
		for (var j=0;j<(decimal-deci.toString().length);j++) {decim+="0";}
		deci=decim+deci.toString();
		val_format=val_format+"."+deci;
	}
	if (parseFloat(valeur)<0) {val_format="-"+val_format;}
	return val_format;
}


function numbersonly(e, decimal) {
                                var key;
                                var keychar;

                                if (window.event) {
                                key = window.event.keyCode;
                                }
                                else if (e) {
                                key = e.which;
                                }
                                else {
                                return true;
                                }
                                keychar = String.fromCharCode(key);

                                if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) ) {
                                return true;
                                }
                                else if ((("0123456789").indexOf(keychar) > -1)) {
                                return true;
                                }
                                else if (decimal && (keychar == ".")) {
                                return true;
                                }
                                else
                                return false;
                                }



function popupFav()
{
    document.frmfavorites.action='/common/code/b2c/fav_b2c.asp?fav_Model=ajout';
    document.frmfavorites.target="popfav";
    window.open('','popfav','height=200,width=400,status=yes,toolbar=no,menubar=no,resizable=yes,scrollbars=yes');
}

function checkForm(type) 
{
	var frm = document.frmsendmail;
	var myVarSiSelected = false;

	if (type=='pass-visite' || type=='eReservation')
	{
		if (frm._situationprofessionnelle.selectedIndex==0)
		{
			alert('Veuillez renseigner le champ "Situation professionnelle".');
			frm._situationprofessionnelle.focus();
			return;
		}
	}
	
	if (type=='recherchev')
	{
		if (frm._demande_type.selectedIndex==0)
		{
			alert('Veuillez renseigner le type de produit recherché.');
			frm._demande_type.focus();
			return;
		}
		
		if ((frm.SelectLocalisation[0].selectedIndex==0 || frm.SelectLocalisation[0].selectedIndex==-1) && (frm.SelectLocalisation[1].selectedIndex==0 || frm.SelectLocalisation[1].selectedIndex==-1) && (frm.SelectLocalisation[2].selectedIndex==0 || frm.SelectLocalisation[2].selectedIndex==-1))
		{
			alert("Veuillez renseigner le secteur recherché.");
			frm.SelectLocalisation[0].focus();
			return;
		}
		if (frm._demande_pieces_min.selectedIndex==0 && frm._demande_pieces_max.selectedIndex==0)
		{
			alert('Veuillez renseigner le nombre de pièces souhaité.');
			frm._demande_pieces_min.focus();
			return;
		}
		if (frm._demande_prix_min.value=='' && frm._demande_prix_max.value=='')
		{
			alert('Veuillez renseigner le prix souhaité.');
			frm._demande_prix_min.focus();
			return;
		}

		var reg1 = frm.SelectLocalisation[0].options[frm.SelectLocalisation[0].selectedIndex].value;
		var reg2 = frm.SelectLocalisation[1].options[frm.SelectLocalisation[1].selectedIndex].value;
		var reg3 = frm.SelectLocalisation[2].options[frm.SelectLocalisation[2].selectedIndex].value;

		var localisation = '';

		if (reg1 != '' && reg1 != 0)
		{
			localisation=reg1;
		}
		if (reg2 != '' && reg2 != 0)
		{
			if (localisation != '')
			{
				localisation=localisation + ',' + reg2;
			}
			else localisation=reg2;
		}
		if (reg3 != '' && reg3 != 0)
		{
			if (localisation != '')
			{
				localisation=localisation + ',' + reg3;
			}
			else localisation=reg3;
		}
		frm._demande_localisation.value=localisation;

	}
	
	if (type=='recherchels')
	{
		if (frm.champ_localisation1.selectedIndex==0) // && frm.champ_localisation2.selectedIndex==0 && frm.champ_localisation3.selectedIndex==0
		{
			alert('Veuillez renseigner le secteur recherché.');
			frm.champ_localisation1.focus();
			return;
		}

		/*var locls = '';
		if ((frm.champ_localisation1.selectedIndex>=4) ||(frm.champ_localisation2.selectedIndex>=4)||(frm.champ_localisation3.selectedIndex>=4))
		{
			locls='711|0';
		}
		
		if (((frm.champ_localisation1.selectedIndex>=1)&&(frm.champ_localisation1.selectedIndex<4)) || 	((frm.champ_localisation2.selectedIndex>=1)&&(frm.champ_localisation2.selectedIndex<4)) || ((frm.champ_localisation3.selectedIndex>=1)&&(frm.champ_localisation3.selectedIndex<4)) )
		{
			locls=locls+',714|0';
		}
		
		frm._demande_localisation.value=locls;*/
		
		var destinataire1 = '';
		var destinataire2 = '';
		var destinataire3 = '';
		var demandeloc1 = '';
		var demandeloc2 = '';
		var demandeloc3 = '';

		if (frm.champ_localisation1.selectedIndex==2) 
		{
		    destinataire1='location.touquet@sergic.com';
		    frm._agy.value='404';
		    frm._evenement_code_destinataire.value='A-404';
		    //frm._target_id.value='2021';
		    demandeloc1='714|2125,714|2126,714|2127,714|2128,714|2160,714|2161,714|2162,714|2163';
		}
		if (frm.champ_localisation1.selectedIndex==3)
		{
		    destinataire1='location.berck@sergic.com';
		    frm._agy.value='403';
		    frm._evenement_code_destinataire.value='A-403';
		    //frm._target_id.value='1919';
		    demandeloc1='714|2136,714|2137,714|2138';
		}
		if (frm.champ_localisation1.selectedIndex==4)
		{
		    destinataire1='location.hardelot@sergic.com';
		    frm._agy.value='2617';
		    frm._evenement_code_destinataire.value='A-2617';
		    demandeloc1='714|2122,714|2227'; //Hardelot Plage, HARDELOT et environs
		}
		if (frm.champ_localisation1.selectedIndex==6)
		{
		    destinataire1='location.lecrotoy@sergic.com';
		    frm._agy.value='407';
		    frm._evenement_code_destinataire.value='A-407';
		    //frm._target_id.value='2110';
		    demandeloc1='711|2199,711|2200,711|2201';
		}
		if (frm.champ_localisation1.selectedIndex==7)
		{
		    destinataire1='location.fortmahon@sergic.com';
		    frm._agy.value='409';
		    frm._evenement_code_destinataire.value='A-409';
		    //frm._target_id.value='2111';
		    demandeloc1='711|2113,711|2114,711|2115';
		}
		frm._target_email.value=destinataire1;//+';'+destinataire2+';'+destinataire3
		frm._demande_localisation.value=demandeloc1;//+';'+demandeloc2+';'+demandeloc3
		//frm._target_type.value=3;
	}
	if (type=='proprio')
	{
		/*for (i=0;i<frm.champ_localisationbien.options.length;i++)
		{
			if (frm.champ_localisationbien.options[i].selected)
			{
				myVarSiSelected = true;
				break; 
			}
		}
		if (!myVarSiSelected)
		{
			alert('Veuillez renseigner le secteur géographique du bien.');
			return;
		}*/

		if (frm.champ_localisationbienchoix.selectedIndex==0 || frm.champ_localisationbienchoix.selectedIndex==-1)
		{
			alert('Veuillez renseigner le secteur géographique du bien.');
			frm.champ_localisationbienchoix.focus();
			return;
		}
		frm.champ_localisationbien.value = frm.champ_localisationbienchoix.options[frm.champ_localisationbienchoix.selectedIndex].value;
		
		if (frm.champ_villebien.value=='')
		{
			alert('Veuillez renseigner la ville du bien.');
			frm.champ_villebien.focus();
			return;
		}
		
		
	}
	if (type=='mandats') // || type=='syndic'
	{
		if (frm.champ_typebien.selectedIndex==0)
		{
			alert('Veuillez renseigner le type du bien');
			frm.champ_typebien.focus();
			return;
		}
		if (frm.champ_piecesbien.selectedIndex==0)
		{
			alert('Veuillez renseigner le champ Nombre de pièces');
			frm.champ_piecesbien.focus();
			return;
		}	
		if (frm.champ_adressebien.value=='' || frm.champ_villebien.value=='' || frm.champ_cpbien.value=='')
		{
			alert('Veuillez renseigner l\'adresse du bien (adresse précise, ville, code postal)');
			frm.champ_adressebien.focus();
			return;
		}
		if (frm._target_localisation.selectedIndex==0 || frm._target_localisation.selectedIndex==-1)
		{
			alert('Veuillez renseigner le secteur géographique.');
			frm._target_localisation.focus();
			return;
		}
		frm.champ_localisationbien.value = frm._target_localisation.options[frm._target_localisation.selectedIndex].value;
	}
	if (type=='syndic') // || type=='syndic'
	{
		if (frm.champ_localisationbien.selectedIndex==0 || frm.champ_localisationbien.selectedIndex==-1)
		{
			alert('Veuillez renseigner le secteur géographique.');
			frm.champ_localisationbien.focus();
			return;
		}
	}

	if (type == 'ami')
	{
		if (frm._email_ami.value == '')
		{
			alert('Veuillez renseigner l\'addresse e-mail du destinataire.');
			frm._email_ami.focus();
			return;
		}
		if (frm._email.value == '')
		{
			alert('Veuillez renseigner votre addresse e-mail personnelle.');
			frm._email.focus();
			return;
		}
	}
	else 
	{

		if (type == 'syndic')
		{
			if (frm.champ_typesyndic.selectedIndex==0 || frm.champ_typesyndic.selectedIndex==-1)
			{
				alert('Veuillez renseigner votre position dans le CS.');
				frm.champ_typesyndic.focus();
				return;
			}
		}
		
		if (frm._nom.value == '')
		{
			alert('Veuillez renseigner votre nom.');
			frm._nom.focus();
			return;
		}
		
		if (type == 'eReservation')
		{
			if (frm._adresse.value=='' || frm._ville.value=='' || frm._codepostal.value=='')
			{
				alert('Veuillez renseigner votre adresse, ville et code postal.');
				frm._adresse.focus();
				return;
			}
		}

		if (frm._telephone.value == '' && frm._mobile.value == '')
		{
			alert('Veuillez renseigner votre téléphone fixe ou mobile.');
			frm._telephone.focus();
			return;
		}

		if (frm._email.value == '')
		{
			alert('Veuillez renseigner votre adresse e-mail.');
			frm._email.focus();
			return;
		}
		
		

		
		
	}
	
	if (type == 'pass-visite')
	{
		if (frm.champ_resadisponibilites.value=='')
		{
			alert("Veuillez renseigner vos disponibilités pour un rendez-vous.");
			frm.champ_resadisponibilites.focus();
			return;
		}
	}
	if (type == 'pass-visite' || type == 'eReservation')
	{
		if (!frm.resa_conditions.checked)
		{
			if (type == 'pass-visite') alert("Vous devez certifier l'exactitude des renseignements fournis pour procéder à la demande de PASS-VISITE.");
			//if (type=='eReservation') alert("Vous devez accepter les conditions de réservation pour procéder à la réservation en ligne.");
			if (type=='eReservation') alert("Vous devez certifier l'exactitude des renseignements fournis pour procéder à la réservation en ligne.");
			frm.resa_conditions.focus();
			return;
		}
	}
	/* GRL_SUSPENDU : 
	if (type == 'eReservation')
	{
		if (frm.resa_garant[1].checked && frm.champ_grl.value=='')
		{
			alert("Veuillez renseignez votre numéro de PASS-GRL.");
			frm.champ_grl.focus();
			return;
		}
	}*/

	var numerosok = true;
	
	if (frm._nom != null) frm._nom.value=frm._nom.value.toUpperCase();
	if (numerosok && frm._telephone != null && frm._telephone.value != '') numerosok=numeros(frm._telephone,'téléphone');
	if (numerosok && frm._mobile != null && frm._mobile.value != '') numerosok=numeros(frm._mobile,'mobile');
	if (numerosok && frm._fax != null && frm._fax.value != '') numerosok=numeros(frm._fax,'fax');

	if (numerosok)
	{
	
		//alert('frm._target_email.value : '+frm._target_email.value);
		//alert('frm._demande_localisation.value : '+frm._demande_localisation.value);
		//alert('frm._target_type.value : '+frm._target_type.value);
		//alert('frm._target_id.value '+frm._target_id.value);
		//alert('frm._agy.value '+frm._agy.value);
		
		frm.submit();
		document.getElementById('div_frm').style.display='none';
		document.getElementById('div_frm_wait').style.display='';
	}
	else return;
}

// TRAITEMENT NUMEROS TEL MOBILE FAX : 

function numeros(champ,numero)
{
	var no = champ;
	var nos=/^\d{10}$/; // si 10 chiffres exactement
	var espace=/\s+/g; // espaces vides
	var point=/\.+/g; // points
	var lettres=/[a-z]|[A-Z]/g; // si contient des lettres
	
	if (champ.value.length<10 || lettres.test(champ.value))
	{
		alert("Veuillez vérifier la saisie du numéro de " + numero + ".");
		champ.focus();
		return false;
	}
	
	var initial = champ.value.replace(espace,""); 
	initial = initial.replace(point,"");

	if (initial.length==10) // tester combien de caractères après suppression des points et espaces, si 10 on espace par 2
	{
		champ.value=champ.value.replace(espace,""); // supprimer espaces
		champ.value=champ.value.replace(point,""); // supprimer points
	
		if (nos.test(champ.value))
		{
			var NoFin = "";
			for (var i = 0; i< champ.value.length; i++)
			{
				NoFin += champ.value.charAt(i);
				if (((i % 2) == 1) && (i!=champ.value.length-1)) 
					NoFin += " ";
			}
			champ.value=NoFin;
		}
	}
return true;
}

function geolocsai(champ)
{
	var frm = document.frmsendmail;
	var v;
	if (champ.value=="")
	{
		alert("Veuillez sélectionner un secteur précis à l'intérieur d'une région.");
		champ.selectedIndex=0;
	}
}


function populate(objForm,selectIndex)
{
	var frm = document.frmsendmail;
	timeA = new Date(objForm.champ_anneedu.options[objForm.champ_anneedu.selectedIndex].text, objForm.champ_moisdu.options[objForm.champ_moisdu.selectedIndex].value,1);
	timeDifference = timeA - 86400000;
	timeB = new Date(timeDifference);
	var daysInMonth = timeB.getDate();
	for (var i = 0; i < objForm.champ_jourdu.length; i++)
	{
		objForm.champ_jourdu.options[0] = null;
	}
	for (var i = 0; i < daysInMonth; i++)
	{
		objForm.champ_jourdu.options[i] = new Option(i+1);
	}
	frm.champ_jourdu.options[0].selected = true;
}


function populate2(objForm,selectIndex)
{
	var frm = document.frmsendmail;
	timeA = new Date(objForm.champ_anneeau.options[objForm.champ_anneeau.selectedIndex].text, objForm.champ_moisau.options[objForm.champ_moisau.selectedIndex].value,1);
	timeDifference = timeA - 86400000;
	timeB = new Date(timeDifference);
	var daysInMonth = timeB.getDate();
	for (var i = 0; i < objForm.champ_jourau.length; i++)
	{
		objForm.champ_jourau.options[0] = null;
	}
	for (var i = 0; i < daysInMonth; i++)
	{
		objForm.champ_jourau.options[i] = new Option(i+1);
	}
	frm.champ_jourau.options[0].selected = true;
}

function getYears()
{
	var frm = document.frmsendmail;
	var years = new Array(2008,2009)
	for (var i = 0; i < frm.champ_anneeau.length; i++)
	{
		frm.champ_anneeau.options[0] = null;
	}
	timeC = new Date();
	currYear = timeC.getFullYear();
	for (var i = 0; i < years.length; i++)
	{
		frm.champ_anneeau.options[i] = new Option(years[i]);
	}
	frm.champ_anneeau.options[2].selected=true;
}
window.onLoad = getYears;



function getYears2()
{
	var frm = document.frmsendmail;
	var years = new Array(2008,2009)
	for (var i = 0; i < frm.champ_anneedu.length; i++)
	{
		frm.champ_anneedu.options[0] = null;
	}
	timeC = new Date();
	currYear = timeC.getFullYear();
	for (var i = 0; i < years.length; i++)
	{
		frm.champ_anneedu.options[i] = new Option(years[i]);
	}
	frm.champ_anneedu.options[2].selected=true;
}
window.onLoad = getYears2;



function resa_situation(typefrm) // choix de la situation professionnelle
{
	var frm = document.frmsendmail;
	var choix = frm._situationprofessionnelle.selectedIndex;
	/*
	0=vide
	1=salarié cdd
	2=salarié cdi
	3=étudiant
	4=retraité
	5=indépendant
	6=sans emploi
	*/

    // Ajouté 04/08/2008 SED: pas de contrôle sur situation pour eResa car mise en place GRL	
	if (typefrm=='eReservation') {
		ressources_div('show');
		garant_div('hide');
		ressourcesgarant_div('hide');
		validation_div('hide'); // cacher validation
		document.getElementById('selection_biens').style.display='none'; // cacher selection biens
        return;	    
	}
	
	if (choix==0 || choix==3)// si vide, aucun div affiché
	{
		ressources_div('hide');
		garant_div('hide');
		ressourcesgarant_div('hide');
		dispos_div('hide');
		document.getElementById('selection_biens').style.display='none';
		validation_div('hide');
		if (choix==3) garant_div('show'); // si étudiant, afficher question garant
	}
	if (choix!=0 && choix!=3 && choix!=6) // si autre que vide ou étudiant, afficher question sur les revenus -  && choix!=5 supprimé pour indépendant && choix!=6 ajouté pour sans emploi 08/12/2006 LJN
	{
		ressources_div('show');
		garant_div('hide');
		ressourcesgarant_div('hide');
		validation_div('hide'); // cacher validation
		document.getElementById('selection_biens').style.display='none'; // cacher selection biens
	}
	// Ajouté 08/12/2006 LJN : si sans emploi, alerte, aucun div affiché
	if (choix==6)
	{
		frm._situationprofessionnelle.options[0].selected=true;
		ressources_div('hide');
		garant_div('hide');
		ressourcesgarant_div('hide');
		dispos_div('hide');
		document.getElementById('selection_biens').style.display='none';
		validation_div('hide');
		//if (typefrm=='eReservation') alert('Compte tenu de votre situation professionnelle et/ou de la nature de vos revenus,\nnous vous invitons à contacter directement votre agence SERGIC.');
		if (typefrm=='pass-visite') alert('Compte tenu de votre situation professionnelle et/ou de la nature de vos revenus,\nnous vous invitons à contacter directement votre agence SERGIC.');
	}
	frm.champ_resarevenus.value=''; // initialiser les revenus éventuellement renseignés sur une autre situation
	if (choix!=3) document.getElementById('disponibilites').style.display='none'; // cacher dispo si different d'etudiant : pour etudiant, affichage directement de l'intro garant et dispos et validation
	frm.champ_resadisponibilites.value=''; // initialiser la dispo éventuellement renseignée sur une autre situation
	
	
 }
 

function resa_solvabilite(loyer,revenus,qui,typefrm) {
 	var frm = document.frmsendmail;
 	var choix = frm._situationprofessionnelle.selectedIndex;
	var vloyer = parseInt(loyer);
	var vrevenus = parseInt(revenus);
	var solvalibilite = revenus/loyer;
	// qui == 1 --> client
	// qui == 2 --> garant
	
	if (typefrm=='eReservation') {
    	
	    if (vrevenus > 10 && qui==1) // client sans garant : 3 cas possibles
	    {
		    if (solvalibilite>=3) // OK si différent de cdd et revenus >= 3
		    {
		        //alert('3');
			    validation_div('show'); // afficher validation
			    garant_div('hide');
			    ressourcesgarant_div('hide');
			    document.getElementById('selection_biens').style.display='none'; // cacher selection biens
			    if (typefrm=='pass-visite') dispos_div('show');
		    }
		    else if (solvalibilite>=2 && solvalibilite<3) // GARANT si pas assez de revenus ou si cdd avec revenus >= 3
		    {
    		    //alert('2 et 3');
    		    dispos_div('hide');
    		    ressourcesgarant_div('hide');
    		    garant_div('show');
    		    document.getElementById('selection_biens').style.display='none';
			    validation_div('hide'); // cacher validation
		    }
		    else if (solvalibilite<2) // INVALIDE
		    {
		        //alert('2');
			    resa_invalide();
			    if (qui==1) // si client
			    {
				    garant_div('hide');
				    ressourcesgarant_div('hide');
			    }
		    }
	    }
	    else if (qui==1) alert('Le montant des ressources est invalide.');

	    if (qui==2) // garant
	    {
		    if (frm.champ_situationprogarant.selectedIndex==0)
		    {
			    alert("Veuillez renseigner la situation professionnelle du garant.");
			    validation_div('hide'); // afficher validation
			    return;
		    }
		    else
		    {
			    validation_div('show'); // afficher validation
			    document.getElementById('selection_biens').style.display='none'; // cacher selection biens
		    }
	    }	
	    return;
	}
	
	if (vrevenus > 10 && qui==1) // client sans garant : 3 cas possibles
	{
		if (solvalibilite>=3 && choix!=1) // OK si différent de cdd et revenus >= 3
		{
			validation_div('show'); // afficher validation
			garant_div('hide');
			ressourcesgarant_div('hide');
			document.getElementById('selection_biens').style.display='none'; // cacher selection biens
			if (typefrm=='pass-visite') dispos_div('show');
		}
		else if ((solvalibilite>=2 && solvalibilite<3) || (choix==1 && solvalibilite>=3)) // GARANT si pas assez de revenus ou si cdd avec revenus >= 3
		{
    		dispos_div('hide');
    		ressourcesgarant_div('hide');
    		garant_div('show');
    		document.getElementById('selection_biens').style.display='none';
			if (typefrm=='eReservation') validation_div('hide'); // cacher validation
		}
		else if (solvalibilite<2) // INVALIDE
		{
			resa_invalide();
			if (qui==1) // si client
			{
				garant_div('hide');
				ressourcesgarant_div('hide');
			}
		}
	}
	else if (qui==1) alert('Le montant des ressources est invalide.');

	if (qui==2) // garant
	{
		if (frm.champ_situationprogarant.selectedIndex==0)
		{
			alert("Veuillez renseigner la situation professionnelle du garant.");
			validation_div('hide'); // afficher validation
			return;
		}
		else
		{
			validation_div('show'); // afficher validation
			document.getElementById('selection_biens').style.display='none'; // cacher selection biens
		}
	}

}
 
function fresa_garant(action) {
	var frm = document.frmsendmail;
	
	//alert(frm.resa_garant[0].value);
	//alert(frm.resa_garant[1].value);
	
	if (action=='show' || frm.resa_garant.checked) //GRL_SUSPENDU : frm.resa_garant[0].checked
	{
		ressourcesgarant_div('show');
		document.getElementById('grl_questions').style.display='none';
		document.getElementById('selection_biens').style.display='none'; // cacher selection biens
	}
	else //GRL_SUSPENDU :  else if (action=='hide' || frm.resa_garant[1].checked)
	{
		ressourcesgarant_div('hide');
	    dispos_div('hide'); //GRL_SUSPENDU : si pas de garant, ne pas avancer
	    validation_div('hide'); //GRL_SUSPENDU : si pas de garant, ne pas avancer
		//GRL_SUSPENDU : if (typeformulaire == 'eReservation') document.getElementById('grl_questions').style.display=''; 
		//GRL_SUSPENDU : INCOHERENT SI PAS DE GARANT ? validation_div('show');
		//resa_invalide();
	}
}

function getProducts()
{
	var frm = document.frmsendmail;
	var prixprd = (Math.round(frm.champ_resarevenus.value/2));
	//var prixprd = (Math.round(frm.champ_resarevenus.value/2)-1);
	var url = "/common/code/b2c/prd_b2c.asp?s_prd_Type=2&s_prd_Nature=1,2&s_prd_Price1_max="+prixprd;//+"&s_prd_CodePostal="+deptprd ? à ajouter ?
	//alert(prixprd);
	window.location.href=url;
}

function resa_invalide() {
	var frm = document.frmsendmail;
	dispos_div('hide');
	validation_div('hide'); // cacher validation
	document.getElementById('selection_biens').style.display=''; // afficher selection biens
	// texte validé 08/12/2006 LJN pour pass-visite et e-resa : cdd, cdi, retraité, indépendant
	var prixMax = Math.round(frm.champ_resarevenus.value/2);
	if (prixMax>0)
	{
	 document.getElementById("div_alerteprd").innerHTML="<strong>Compte tenu de vos ressources, nous vous invitons à rechercher dans nos disponibilités un logement dont le loyer + charges n'excède pas " + prixMax + " euros.</strong>";//(Math.round(frm.champ_resarevenus.value/2)-1)
	 document.getElementById("div_alerteprd_lienprd").style.display='';
	}
	else 
	{
	document.getElementById("div_alerteprd").innerHTML="<strong>Compte tenu de votre situation professionnelle et/ou de la nature de vos revenus, nous vous invitons à contacter directement votre agence SERGIC.</strong>";//(Math.round(frm.champ_resarevenus.value/2)-1)
	document.getElementById("div_alerteprd_lienprd").style.display='none';
	}
	
}

function ressources_div(action) {
	var frm = document.frmsendmail;
	if (action=='hide')
	{
		document.getElementById('ressources').style.display='none';
		frm.champ_resarevenus.value='';
	}
	if (action=='show') document.getElementById('ressources').style.display=''; }

function ressourcesgarant_div(action) {
	var frm = document.frmsendmail;
	if (action=='hide')
	{
		document.getElementById('ressources_garant').style.display='none';
		//frm.champ_resarevenusgarant.value='';  champ supprimé 03/01/2007 - mail de SED - LJN
		frm.champ_situationprogarant.selectedIndex=0;
	}
	if (action=='show' && typeformulaire == 'eReservation') //questions sur garant uniquement pour resa et non passvisite : 29/12/2006 LJN
	{
		 document.getElementById('ressources_garant').style.display='';  
	}
	if (action=='show' && typeformulaire == 'pass-visite') //dispos direct pour passvisite (avec message garant) : 29/12/2006 LJN
	{
		dispos_div('show');
		validation_div('show'); // afficher validation
	}
}

function dispos_div(action) {
	var frm = document.frmsendmail;
	if (action=='hide')
	{
		document.getElementById('disponibilites').style.display='none';
		frm.champ_resadisponibilites.value='';
	}
	if (action=='show') document.getElementById('disponibilites').style.display='';
}
	
	
function validation_div(action) {
	var frm = document.frmsendmail;
	if (action=='hide')
	{
		document.getElementById('validation').style.display='none';
		document.getElementById('bt_valider').style.display='none';
		frm.resa_conditions.checked=false;
	}
	if (action=='show') 
	{
		document.getElementById('validation').style.display='';
		document.getElementById('bt_valider').style.display='';
	}
}

function garant_div(action) 
{
	var frm = document.frmsendmail;
	var choix = frm._situationprofessionnelle.selectedIndex;
	//alert('garant_div: ' + action); 
	if (action=='hide')
	{
		document.getElementById('garant').style.display='none';
		document.getElementById('garant_intro').style.display='none';
		document.getElementById('garant_questions').style.display='none';	
		frm.resa_garant.checked=false; //GRL_SUSPENDU : frm.resa_garant[0].checked=false;
		//GRL_SUSPENDU : frm.resa_garant[1].checked=false;
	}
	if (action=='show') 
	{
    	document.getElementById('garant').style.display='';
		if ((choix==1 || choix==2 || choix==4 || choix==5) && (typeformulaire == 'pass-visite'))
		{
		    document.getElementById('garant_intro').style.display='';
	
		    fresa_garant('show');

    		document.getElementById('garant_questions').style.display='none';

		    dispos_div('show');
		    validation_div('show'); // afficher validation
		}
        else if (typeformulaire == 'eReservation') document.getElementById('garant_questions').style.display='';
		else document.getElementById('garant_questions').style.display='';
    }
}

function checkDateFormat(dateLabel, oInput) {
	if ( oInput.value.length > 0){
		if ( !isDate(oInput.value) ) {
			alert(dateLabel + ' n\'est pas valide');
			oInput.value = '';
			oInput.focus();
		}
	}
}

function isDate(myDateStr){
	var myDate = DateFromSting(myDateStr)
	if ( myDate <= 0 ) return false; /* ex. on pourrait saisir 31/04/2005 ce qui donnerait 01/05/2005 */
	return true;
}

function DateFromSting(myDateStr){
	var aArryDate = myDateStr.split('/');
	if ( aArryDate.length != 3 ) return false;
	var myDayStr = aArryDate[0];
	if ( myDayStr.length > 1 && myDayStr.substr(0,1) == '0' ) myDayStr = myDayStr.substr(1,1);
	var myMonthStr = aArryDate[1];
	if ( myMonthStr.length > 1 && myMonthStr.substr(0,1) == '0' ) myMonthStr = myMonthStr.substr(1,1);
	var myYearStr = aArryDate[2];
	if ( myYearStr.length > 1 && myYearStr.substr(0,1) == '0' ) myYearStr = myYearStr.substr(1,1);

	intDay = parseInt(myDayStr);
	intMonth = parseInt(myMonthStr);
	intYear = parseInt(myYearStr);

	if ( isNaN(intDay) || isNaN(intMonth) || isNaN(intYear) ) return false;

	intMonth --; /*mois de 0 a 11*/
	if ( intYear < 1970 )
	   intYear = 2000 + (intYear % 4);
	var myDate = new Date(intYear, intMonth, intDay);
	if ( myDate.getMonth() != intMonth ) /* ex. on pourrait saisir 31/04/2005 ce qui donnerait 01/05/2005 */
		return 0;
	else
		return myDate;
	
}
function verifier_form_robien(){
	if (isNaN(document.Form_robien.Apport.value)) alert ("Votre apport doit être un nombre.");
	else{
		if (isNaN(document.Form_robien.RevenuMensuel.value) || document.Form_robien.RevenuMensuel.value == "") alert ("Merci de préciser votre revenu mensuel.");
		else{
			if (isNaN(document.Form_robien.impot_revenu.value) || document.Form_robien.impot_revenu.value == "") alert ("Merci de préciser votre impôt sur le revenu.");
			else{
				if (document.Form_robien.Nom.value == "") alert ("Votre nom n'est pas valide.");
				else{
					if (!verif(document.Form_robien.Email.value)) alert ("L'adresse email saisie n'est pas valide.");
					else{
						if (!CheckCP(document.Form_robien.Cpostal.value)) alert ("Le code postal n'est pas valide.");
						else{ 
							if (!CheckPhoneNumber(document.Form_robien.Telephone.value)) alert ("Le numéro de téléphone saisi n'est pas valide.");
							else{
								if (document.Form_robien.Apport.value=="") document.Form_robien.Apport.value = 0;
								document.Form_robien.UrlRetour.value += document.Form_robien.Email.value;//envoi mail lors du retour
								document.Form_robien.submit();
							}
						}
					}
				}
			}
		}
	}
}
function valeurSimul(){
	var radio = document.Form_robien.Simul;
	for (var i=0; i<radio.length;i++) {
         if (radio[i].checked) {
            return radio[i].value;
         }
    }
}

function CheckPhoneNumber(TheNumber) {
	 var reg = /^0\d{1}\.?\ ?(\d{2}\.?\ ?){4}$/ //numéro commençant par un zero sur 10 chiffres avec ou sans point séparateur ou espace
	 return (reg.exec(TheNumber)!=null)
}

function CheckCP(TheNumber) {
	 var reg = /^\d{5}$/ //numéro sur 5 chiffres
	 return (reg.exec(TheNumber)!=null)
}

function verif(email) { // vérif validité email par REGEXP
	 var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/
	 return (reg.exec(email)!=null)
}


var blnNSX	= (navigator.appName == "Netscape");
var blnIE	= (document.all) ? true : false;


function getKeyCode(e)
{
	if ( blnIE )
	{
		return window.event.keyCode;
	}
	else
	{
		return e.keyCode;
	}
}
function setKeyCode(e, intKey)
{
	if ( blnIE )
	{
		window.event.keyCode = intKey;
	}
	else
	{
		var oInput = e.currentTarget;
		if (  oInput != null)
		{
			//oInput.value = oInput.value.replace('.',',');
			//if ( intKey > 0 )	oInput.value += String.fromCharCode(intKey);
			//alert(oInput.value);
		}
	}
}

function AcceptOnlyNumbersNsIe(e, BoolDecimal) 
{
	if( !e ) 
	{
		if( window.event ) 
		{
			e = window.event;
		}
		else 
		{
			return;
		}
	}
	var intKeyCode = getKeyCode(e);
	if (intKeyCode == 45)
	{
		return true; //c'est pour -
	}
	if (intKeyCode == 44)
	{
		if (BoolDecimal!='False')
		{	
			return true; //c'est pour ,
		}
		else
		{
			setKeyCode(e, 0);
		}
	}
	if(intKeyCode == 46)
	{
		if (BoolDecimal!='False')
		{
			setKeyCode(e, 44);
		}
		else
		{
			setKeyCode(e, 0);
		}
	}	
	else
	{
		if(intKeyCode < 48 || intKeyCode > 57)
		{
			setKeyCode(e, 0);
		}
	}
}


function formatting(o,BoolDecimal){
	// o must have property value
	o.value=formattingNumber(o.value,BoolDecimal);
}


function formattingNumber(s,BoolDecimal){
	var blnBefore = true;
	s=String(s);
	
	strBefore = '';
	strAfter = '';
	strSep = '';
	
	s = s.replace(/\./g,',');
	// si vide
	if (s.length==0){
		if (BoolDecimal!='False'){			
			return '0,00';
		}else{
			return '0';
		}
	}
		
		
	for(var i = 0; i < s.length; i++)
	{
		if(s.charAt(i) == ',')
		{
			blnBefore=false;
			strSep = ',';
		}
		if(blnBefore)
			strBefore = strBefore + s.charAt(i);
		else
			if(s.charAt(i) != ',')
				strAfter = strAfter + s.charAt(i);
				// si plus de 2 decimale sortie
				if (strAfter.length == 2)
				{
					i = s.length;
				}
	}
	
	if(strBefore == '')
		strBefore = s;
		
	if(strSep == ',' && strAfter.length == 0){
			strAfter = '00';
	}
	
	if(strSep == ',' && strAfter.length == 1)
		strAfter = strAfter + '0' ;

	if(strSep == ''){
		strSep = ','
		strAfter = '00';
	}	
	
	if (BoolDecimal=='False'){
		strSep = ''
		strAfter = '';	
	}
	
	strBefore = AddSpaces(strBefore);
	
	return strBefore + strSep + strAfter;
	strBefore = trim(strBefore);

}

function AddSpaces(strIn)
{
	var strOut = '';
	strIn=strIn.toString(10);
	strIn = trim(strIn);

	for(var i = strIn.length-1; i >= 0; i--)
	{
		if((strIn.length-i)%3 == 0 && i != 0)
			strOut = ' ' + strIn.charAt(i) + strOut;
		else
			if(strIn.charAt(i) != '')
				strOut = strIn.charAt(i) + strOut;
	}
	return strOut;

}

function trim(argStr)
{
	var ex=/\s+/;
	var bool = true;
	var str = argStr;
			
	while(bool)
	{
		str=str.replace(ex,'');
		if (str.length == str.replace(ex,'').length) 
			bool = false ;
	}
	return str;
}

function geoSelect(champ)
{
	var finValue=/\|0$/;
	var tester=finValue.test(champ.value);

	if (tester){
		alert("Veuillez sélectionner un secteur précis à l'intérieur de cette région.");
		champ.selectedIndex=0;
	}
	
	var oInput = document.frmsendmail._target_localisation;
	if ( oInput != null && oInput.tagName == 'INPUT'){
		var strTemp = '';
		for ( i=0; i < 3; i++){
			var oSelect = document.frmsendmail.SelectLocalisation[i];
			if ( oSelect != null ){
				if ( oSelect.options[oSelect.selectedIndex].value.length > 0 && !finValue.test(oSelect.options[oSelect.selectedIndex].value) ){
					if ( strTemp.length > 0 ) strTemp += ',';
					strTemp += oSelect.options[oSelect.selectedIndex].value;
				}
			}
		}
		oInput.value = strTemp;
	}
	
	
}

var wnd;
function imagedetail_submit(before,mediaid,height,width) {
if (before) {
document.frmmedia.target="_mediapopup";
document.frmmedia.media_Model.value="imageseule";
wnd=window.open('', '_mediapopup', 'menubar=no,resizable=no,status=no,titlebar=no,scrollbars=no,width='+width+',height='+height);
}
else wnd.focus(); 
}



function postuler()
{
var frm = document.frmsendmail;
var cvfield = frm.champ_cv.value;

if (frm.champ_name.value == '')
{
	alert('Veuillez renseigner votre nom.');
	frm.champ_name.focus();
	return;
}
if (frm.champ_firstname.value == '')
{
	alert('Veuillez renseigner votre prénom.');
	frm.champ_firstname.focus();
	return;
}
if (frm.champ_birthday.value == '')
{
	alert('Veuillez renseigner votre date de naissance.');
	frm.champ_birthday.focus();
	return;
}


if (!isDate(frm.champ_birthday.value))
{
	alert('Veuillez vérifier la saisie de votre date de naissance.');
	frm.champ_birthday.focus();
	return;
}

/*
var testdatenaissance = /^([0-9]){2}(\/){1}([0-9]){2}(\/)([0-9]){4}$/;
if (!testdatenaissance.test(frm.champ_birthday.value))
{
	alert('Veuillez saisir votre date de naissance au format jj/mm/aaaa.');
	frm.champ_birthday.focus();
	return;
}
*/

if (frm.champ_address.value == '')
{
	alert('Veuillez renseigner votre adresse.');
	frm.champ_address.focus();
	return;
}
if (frm.champ_zipcode.value == '')
{
	alert('Veuillez renseigner votre code postal.');
	frm.champ_zipcode.focus();
	return;
}
if (frm.champ_city.value == '')
{
	alert('Veuillez renseigner votre ville.');
	frm.champ_city.focus();
	return;
}
if (frm.champ_mail.value == '')
{
	alert('Veuillez renseigner votre adresse e-mail.');
	frm.champ_mail.focus();
	return;
}
if (frm.champ_phone.value == '' || frm.champ_mobilphone.value == '')
{
	alert('Veuillez renseigner votre numéro de téléphone fixe\n ainsi que votre numéro de téléphone portable.');
	frm.champ_phone.focus();
	return;
}


// type de contrat
if (!document.frmsendmail.champ_contrat[0].checked && !document.frmsendmail.champ_contrat[1].checked && !document.frmsendmail.champ_contrat[2].checked)
{
	alert('Veuillez renseigner le type de contrat souhaité.')
	frm.champ_contrat[0].focus();
	return;
}
// si cdi ou cdd
if (document.frmsendmail.champ_contrat[0].checked || document.frmsendmail.champ_contrat[1].checked)
{
	//temps de travail
	if (!document.frmsendmail.champ_worktimechoix[0].checked && !document.frmsendmail.champ_worktimechoix[1].checked)
	{
		alert('Veuillez choisir entre temps complet et temps partiel.')
		frm.champ_worktimechoix[0].focus();
		return;
	}
	//si temps partiel
	if (frm.champ_worktimechoix[1].checked && frm.champ_hourweeknbr.value=='')
	{
		alert('Veuillez renseigner le nombre d\'heures par semaine souhaité.');
		frm.champ_hourweeknbr.focus();
		return;
	}
}
//si stage
if (document.frmsendmail.champ_contrat[2].checked)
{
	//durée
	if (frm.champ_stagelength.selectedIndex==0)
	{
		alert('Veuillez renseigner la durée du stage.');
		frm.champ_stagelength.focus();
		return;	
	}
	//début
	if (frm.champ_stagestartdate.value=='' || !isDate(frm.champ_stagestartdate.value))
	{
		alert('Veuillez vérifier la saisie du champ Début du stage.');
		frm.champ_stagestartdate.focus();
		return;	
	}
}

//poste recherché
if (frm.champ_domain.selectedIndex==0 || (frm.champ_job1.selectedIndex==0 && frm.champ_job2.selectedIndex==0 && frm.champ_job3.selectedIndex==0 && frm.champ_job4.selectedIndex==0 && frm.champ_job5.selectedIndex==0 && frm.champ_job6.selectedIndex==0 && frm.champ_job7.selectedIndex==0 && frm.champ_job8.selectedIndex==0 && frm.champ_job9.selectedIndex==0 && frm.champ_job10.selectedIndex==0))
{
	alert('Veuillez renseigner le poste recherché.');
	frm.champ_domain.focus();
	return;	
}
//formation
if (frm.champ_formationchoix.selectedIndex==0)
{
	alert('Veuillez renseigner le type de formation.');
	frm.champ_formationchoix.focus();
	return;	
}
//si formation de type Autre
if (frm.champ_formationchoix.options[frm.champ_formationchoix.selectedIndex].value=='autre')
{
	if (frm.champ_formationautre.value=='')
	{
		alert('Veuillez renseigner le nom de la formation.');
		frm.champ_formationautre.focus();
		return;	
	}
}
//intitulé formation
if (frm.champ_formationname.value=='')
{
	alert('Veuillez renseigner l\'intitulé de la formation.');
	frm.champ_formationname.focus();
	return;	
}
//niveau formation
if (frm.champ_formationlevel.selectedIndex==0)
{
	alert('Veuillez renseigner le niveau de formation.');
	frm.champ_formationlevel.focus();
	return;	
}

//expérience
// si cdi ou cdd
if (document.frmsendmail.champ_contrat[0].checked || document.frmsendmail.champ_contrat[1].checked)
{
	//expérience en immobilier
	if (!frm.champ_experienceimmobilier[0].checked && !frm.champ_experienceimmobilier[1].checked)
	{
		alert('Veuillez indiquer si vous avez de l\'expérience en immobilier.')
		frm.champ_experienceimmobilier[0].focus();
		return;
	}
	//OUI expérience en immobilier
	if (frm.champ_experienceimmobilier[0].checked)
	{
		//niveau expérience immobilier
		if (frm.champ_experimentlevel.selectedIndex==0)
		{
			alert('Veuillez indiquer le niveau d\'expérience en immobilier.')
			frm.champ_experimentlevel.focus();
			return;		
		}
		//nature expérience immobilier
		if (frm.champ_experimentnature.value=='')
		{
			alert('Veuillez indiquer la nature d\'expérience en immobilier.')
			frm.champ_experimentnature.focus();
			return;		
		}
	}
	//NON expérience en immobilier
	if (frm.champ_experienceimmobilier[1].checked)
	{
		//niveau expérience hors immobilier
		if (frm.champ_experimentlevelnonimmo.selectedIndex==0)
		{
			alert('Veuillez indiquer le niveau de l\'expérience hors immobilier.')
			frm.champ_experimentlevelnonimmo.focus();
			return;		
		}
		//nature expérience hors immobilier
		if (frm.champ_experimentnaturenonimmo.value=='')
		{
			alert('Veuillez indiquer la nature de l\'expérience hors immobilier.')
			frm.champ_experimentnaturenonimmo.focus();
			return;		
		}
	}

}
//si stage
if (document.frmsendmail.champ_contrat[2].checked)
{
	//stage
	if (!frm.champ_experiencestage[0].checked && !frm.champ_experiencestage[1].checked)
	{
		alert('Veuillez indiquer si vous avez déjà effectué des stages en entreprise.')
		frm.champ_experiencestage[0].focus();
		return;
	}
	//oui stage
	if (frm.champ_experiencestage[0].checked)
	{
		//nature stage
		if (frm.champ_experiencestagedetail.value=='')
		{
			alert('Veuillez indiquer la nature de l\'expérience des stages.')
			frm.champ_experiencestagedetail.focus();
			return;		
		}
	}
}


//rémunération
// si cdi ou cdd
if (document.frmsendmail.champ_contrat[0].checked || document.frmsendmail.champ_contrat[1].checked)
{
	if (frm.champ_actualremuneration.selectedIndex==0 || frm.champ_whishremuneration.selectedIndex==0)
	{
		alert('Veuillez renseigner votre rémunération actuelle et la rémunération souhaitée.')
		frm.champ_actualremuneration.focus();
		return;		
	}
}

//disponibilité
// si cdi ou cdd
if (document.frmsendmail.champ_contrat[0].checked || document.frmsendmail.champ_contrat[1].checked)
{
	if (!frm.champ_availability[0].checked && !frm.champ_availability[1].checked)
	{
		alert('Veuillez renseigner votre disponibilité.')
		frm.champ_availability[0].focus();
		return;		
	}
	//si préavis
	if (frm.champ_availability[1].checked)
	{
		if (frm.champ_preavis.selectedIndex==0)
		{
			alert('Veuillez renseigner la durée de votre préavis.')
			frm.champ_preavis.focus();
			return;		
		}
	}
}


//mobilité
var mobilitycheck=false;
for (i=0;i<frm.champ_mobilitychoix.length;i++)
{
	if (frm.champ_mobilitychoix[i].checked)
	{
	mobilitycheck=true;
	break;
	}
}
if (!mobilitycheck)
{
	alert('Veuillez renseigner la région recherchée et votre mobilité.')
	frm.champ_mobilitychoix[0].focus();
	return;
}
//si stage
if (document.frmsendmail.champ_contrat[2].checked)
{
	if (!frm.champ_drivelicence[0].checked && !frm.champ_drivelicence[1].checked)
	{
		alert('Possédez-vous un permis de conduire?')
		frm.champ_drivelicence[0].focus();
		return;		
	}
	if (!frm.champ_transportmeans[0].checked && !frm.champ_transportmeans[1].checked)
	{
		alert('Possédez-vous un moyen de locomotion?')
		frm.champ_transportmeans[0].focus();
		return;
	}
}


if (frm.champ_motivation.value=='')
{
	alert('Veuillez renseigner vos motivations.')
	frm.champ_motivation.focus();
	return;
}

var testDoc = /(.doc|.pdf)$/i;
if (!(testDoc.test(cvfield)))
{
	alert('Veuillez joindre votre CV au format .doc ou .pdf');
	return;
}
//(cvfield.indexOf('.pdf')==-1 && cvfield.indexOf('.doc')==-1 && cvfield.indexOf('.PDF')==-1 && cvfield.indexOf('.DOC')==-1) && 



	
//type formation
	if (frm.champ_formationchoix.options[frm.champ_formationchoix.selectedIndex].value!='autre')
	{
		frm.champ_formation.value=frm.champ_formationchoix.options[frm.champ_formationchoix.selectedIndex].value;
	}
	if (frm.champ_formationchoix.options[frm.champ_formationchoix.selectedIndex].value=='autre')
	{
		frm.champ_formation.value=frm.champ_formationautre.value;
	}
//expérience
	if (frm.champ_experiencestagedetail.value != '')
	{
		frm.champ_experimentnature.value=frm.champ_experiencestagedetail.value;
	}
//temps de travail
	for (i=0;i<frm.champ_worktimechoix.length;i++)
	{
		if (frm.champ_worktimechoix[i].checked) frm.champ_worktime.value=frm.champ_worktimechoix[i].value; 
	}
//poste
	if (frm.champ_job1.selectedIndex != 0) frm.champ_job.value=frm.champ_job1.options[frm.champ_job1.selectedIndex].value;
	if (frm.champ_job2.selectedIndex != 0) frm.champ_job.value=frm.champ_job2.options[frm.champ_job2.selectedIndex].value;
	if (frm.champ_job3.selectedIndex != 0) frm.champ_job.value=frm.champ_job3.options[frm.champ_job3.selectedIndex].value;
	if (frm.champ_job4.selectedIndex != 0) frm.champ_job.value=frm.champ_job4.options[frm.champ_job4.selectedIndex].value;
	if (frm.champ_job5.selectedIndex != 0) frm.champ_job.value=frm.champ_job5.options[frm.champ_job5.selectedIndex].value;
	if (frm.champ_job6.selectedIndex != 0) frm.champ_job.value=frm.champ_job6.options[frm.champ_job6.selectedIndex].value;
	if (frm.champ_job7.selectedIndex != 0) frm.champ_job.value=frm.champ_job7.options[frm.champ_job7.selectedIndex].value;
	if (frm.champ_job8.selectedIndex != 0) frm.champ_job.value=frm.champ_job8.options[frm.champ_job8.selectedIndex].value;
	if (frm.champ_job9.selectedIndex != 0) frm.champ_job.value=frm.champ_job9.options[frm.champ_job9.selectedIndex].value;
	if (frm.champ_job10.selectedIndex != 0) frm.champ_job.value=frm.champ_job10.options[frm.champ_job10.selectedIndex].value;
	
//mobilité
	var mobility = "";
	for (i=0;i<frm.champ_mobilitychoix.length;i++)
	{
		if (frm.champ_mobilitychoix[i].checked)
		{
			if (mobility == '') mobility=frm.champ_mobilitychoix[i].value;
			else mobility=mobility+", "+frm.champ_mobilitychoix[i].value;
		}
	}
	frm.champ_mobility.value=mobility;

//frm._target_email.value='recrutement@sergic.com';
    var sujet = "";
    sujet = 'Formulaire recrutement - ' + frm.champ_job.value;
    if (frm.champ_refannonce.value!='') sujet = sujet + ' (' + frm.champ_refannonce.value + ')'
    sujet = sujet + ' - ' + frm.champ_name.value + ' ' + frm.champ_firstname.value;
    frm._sujet.value=sujet;

frm.submit();
document.getElementById('div_frm').style.display='none';
document.getElementById('div_frm_wait').style.display='';
}
			
			
function griser(act)
{   
    document.getElementById("mask").style.display=act;
    var htmlElement = document.getElementsByTagName('html')[0];
    if (act=='inline') htmlElement.style.overflow = 'hidden';
    else htmlElement.style.overflow = 'scroll';
}


function display_suivi(act)
{
    document.getElementById("suivi_resa").style.display=act;
}


function printposte() {
window.open('','winPrint','width=570,height=600,scrollbars=yes');
document.frmEmploiPrint.target='winPrint';
document.frmEmploiPrint.submit();
}
function emploi(ref,domain,job)
{
var frm = document.frmEmploi;
frm.mail_special.value=ref+'|'+domain+'§'+job;
frm.submit();
}


function findPosX(obj) {
                    var curleft = 0;
                    if (obj.offsetParent) {
                    while (1) {
                    curleft+=obj.offsetLeft;
                    if (!obj.offsetParent) {
                    break;
                    }
                    obj=obj.offsetParent;
                    }
                    } else if (obj.x) {
                    curleft+=obj.x;
                    }
                    return curleft;
                    }
                    function findPosY(obj) {
                    var curtop = 0;
                    if (obj.offsetParent) {
                    while (1) {
                    curtop+=obj.offsetTop;
                    if (!obj.offsetParent) {
                    break;
                    }
                    obj=obj.offsetParent;
                    }
                    } else if (obj.y) {
                    curtop+=obj.y;
                    }
                    return curtop;
                    }
                    
function check_radio()
{
    for (i=0;i<document.frmprdsearch.elements.length;i++)
    {
        if(document.frmprdsearch.elements[i].type=='checkbox')
        {
            if (document.frmprdsearch.all_check.checked) document.frmprdsearch.elements[i].checked=true;
            else document.frmprdsearch.elements[i].checked=false;
        }
    }
}

function favoris()
{
	browserName = navigator.appName;
	browserVer = parseInt(navigator.appVersion);
	if (browserName == "Microsoft Internet Explorer" & browserVer >= 4) 
	{
		window.external.AddFavorite('http://www.sergic.com/', 'sergic.com');
	}
} 


function coordonnees()
{
	var frm = document.frmsendmail;
	if (document.frmsendmail._nom.value == '')
	{
		alert('Veuillez renseignez votre nom');
		document.frmsendmail._nom.focus();
		return;
	}
	if (document.frmsendmail._prenom.value == '')
	{
		alert('Veuillez renseignez votre prénom');
		document.frmsendmail._prenom.focus();
		return;
	}
	if (frm._telephone.value != '')
	{
		if (isNaN(frm._telephone.value))
		{
			alert('Veuillez vérifier le format de votre numéro de téléphone (numérique, maximum 10 caractères)');
			frm._telephone.focus();
			return;
		}
	}
	if (frm._mobile.value != '')
	{
		if (isNaN(frm._mobile.value))
		{
			alert('Veuillez vérifier le format de votre numéro de mobile (numérique, maximum 10 caractères)');
			frm._mobile.focus();
			return;
		}
	}
	if (frm._fax.value != '')
	{
		if (isNaN(frm._fax.value))
		{
			alert('Veuillez vérifier le format de votre numéro de fax (numérique, maximum 10 caractères)');
			frm._fax.focus();
			return;
		}
	}
	if (!verif(document.frmsendmail._email.value))
	{
		alert('Veuillez renseignez votre adresse e-mail');
		document.frmsendmail._email.focus();
		return;
	}
	
	frm.submit();
}

function modifier()
{
    var oDivRO = document.getElementById('div_frm');
    var oDivRW = document.getElementById('div_frm_edit');

    if (oDivRO && oDivRW)
    {
        if (oDivRO.style.display != 'none')
        {
            oDivRO.style.display = 'none';
            oDivRW.style.display = 'inline';
        }
        else
        {
            oDivRO.style.display = 'inline';
            oDivRW.style.display = 'none';
        }        
    }
}

                                function rechRapide(formu)
                                {
                                var frm = formu;
                                
                                frm.s_prd_CodePostal.value = '';
                                frm.s_prd_Ville.value = '';
                                
                                var reg75000=new RegExp("(75000)", "g");
                                var lieu = (frm.lieu.value).replace(reg75000,'75');
                                var reg = new RegExp("[,;]+", "g");
                                var stock_lieu = lieu.split(reg);
                                for (i=0;i<stock_lieu.length;i++)
                                {
                                if (isNaN(stock_lieu[i]))
                                {
                                stock_lieu[i] = getFilterValueIgnoreLine(stock_lieu[i]);
                                if (frm.s_prd_Ville.value != '') frm.s_prd_Ville.value=frm.s_prd_Ville.value+','+stock_lieu[i];
                                else frm.s_prd_Ville.value=stock_lieu[i];
                                }

                                if (!isNaN(stock_lieu[i]))
                                {
                                //stock_lieu[i] = getFilterValueCodePostal(stock_lieu[i]);
                                if (frm.s_prd_CodePostal.value != '') frm.s_prd_CodePostal.value=frm.s_prd_CodePostal.value+','+stock_lieu[i];
                                else frm.s_prd_CodePostal.value=stock_lieu[i];
                                }
                                }

                                //alert(frm.s_prd_Ville.value);
                                //alert(frm.s_prd_CodePostal.value);
                                frm.submit();
                                }

                                function getFilterValueIgnoreLine(str)
                                {
                                var ret;
                                if (str.indexOf('-') != -1)
                                {
                                ret = str.replace(/-/g, ' ');
                                }
                                else
                                {
                                ret = str;
                                }

                                return ret;
                                }

function setSearchVille(str)
{
   if (document.agy_menu_search)
    document.agy_menu_search.searchAgyVille.value = str; 
}
                                
function get_city(v,cont){
var strType;
var hintfile = '/common/code/all/hint_all.asp';
var strAspFile = window.location.href;
if (document.agy_menu_search && ((strAspFile.indexOf('agy_b2c') > 0) || (strAspFile.indexOf('agences-immobilieres') > 0) || (document.agy_menu_search.searchAgyVille.value == "agy")))
{
	strType = 'agy0';
}
else
{
    if (document.frmprdsearchrapide && document.frmprdsearchrapide.s_prd_Type)
    {
        strType = 'prd0' + document.frmprdsearchrapide.s_prd_Type.value;
	}    
    else
        strType = 'prd';	    
}
$.get(hintfile,{v:v,t:strType},
			function(obj){
				var res = [];
				var query = obj[0];
				var suggests = obj[1];
				var infos = obj[2];
				var urls = obj[3];
				for(var i=0;i<suggests.length;i++){
					res.push({ id:urls[0] , value:suggests[i] , info:infos[i] , extra:"query for "+query});
				}
				cont(res);
			},
			'json')
}

function hideSearchDiv(){
	var oSuggMenu;
	var oSuggestion, oSuggestion2;
	var menuId;
	menuId = document.agy_menu_search.searchAgyVille.value;
	oSuggMenu = eval('document.getElementById("suggMenu' + menuId + '")');
	oSuggestion = document.getElementById('suggestion');
	oSuggestion2 = document.getElementById('suggestion2');
	oAgySuggestion = document.getElementById('agy_suggestion');
	if (menuId != 'agy'){
		if (oSuggMenu){
			oSuggMenu.style.display = 'none';
			if(oSuggestion){
				oSuggestion.style.display = 'none';
			}
			if(oSuggestion2){
				oSuggestion2.style.display = 'none';
			}
		}
	}
	else{
		if (oSuggMenu){
			oSuggMenu.style.display = 'none';
		}
		if (oAgySuggestion){
			oAgySuggestion.style.display = 'none';
		}		
	}
}

function getCursorPos(textElement) {
 //save off the current value to restore it later,
 var sOldText = textElement.value;

//create a range object and save off it's text
 var objRange = document.selection.createRange();
 var sOldRange = objRange.text;

//set this string to a small string that will not normally be encountered
 var sWeirdString = '#%~';

//insert the weirdstring where the cursor is at
 objRange.text = sOldRange + sWeirdString; objRange.moveStart('character', (0 - sOldRange.length - sWeirdString.length));

//save off the new string with the weirdstring in it
 var sNewText = textElement.value;

//set the actual text value back to how it was
 objRange.text = sOldRange;

//look through the new string we saved off and find the location of
//the weirdstring that was inserted and return that value
 for (i=0; i <= sNewText.length; i++) {
   var sTemp = sNewText.substring(i, i + sWeirdString.length);
   if (sTemp == sWeirdString) {
     var cursorPos = (i - sOldRange.length);
     return cursorPos;
   }
 }
}

function setCursorPos(obj) {
    var menuId;
    if (document.agy_menu_search)
        menuId = document.agy_menu_search.searchAgyVille.value;
    else
        menuId = 'prd';    
    var oCursorPos = eval('document.getElementById("cursorPos_' + menuId + '")');
    if (oCursorPos) {
        oCursorPos.value = getCursorPos(obj);
    }
}                                