function  mapOver(className)
{
	$('searchMapImg').className = className; 
}
function mapOut()
{
	$('searchMapImg').className = "";
}


function callOpenXBanners()
{
	
	
	var openx_timeout = 1, // limit the time we wait for openx
	oZones = OA_zones, // list of [div_id] => zoneID
	displayBannerAds; // function.


	// oZones.<divID> = <zoneID>
	// eg: oZones.banner_below_job2 = 100;
	// (generated on the server side with PHP)
	//oZones.banner_homepage = 4;
	//oZones.banner_bottom = 34;
	
	

	
	displayBannerAds = function()
	{
		
		if( typeof(OA_output)!='undefined' && OA_output.constructor == Array )
		{
			
		  // OpenX SinglePageCall ready!
			
	    		for (var zone_div_id in oZones)
		    	{
	    			
	      			zoneid = zone_div_id;

	     	 		if(typeof(OA_output[zoneid])!='undefined' && OA_output[zoneid]!='') 
		     	 	{
	        			var flashCode,
	          			oDIV = document.getElementById( zone_div_id );

	        			if (oDIV) 
		        		{
	        				
	          				// if it's a flash banner..
	          				if(OA_output[zoneid].indexOf("ox_swf.write")!=-1)
	          				{
	            				// extract javascript code
	            				var pre_code_wrap = "<script type='text/javascript'><!--// <![CDATA[",
	              				post_code_wrap = "// ]]> -->";
	            				flashCode = OA_output[zoneid].substr(OA_output[zoneid].indexOf(pre_code_wrap)+pre_code_wrap.length);
	            				flashCode = flashCode.substr(0, flashCode.indexOf(post_code_wrap));

								// replace destination for the SWFObject
	            				flashCode = flashCode.replace(/ox\_swf\.write\(\'(.*)'\)/, "ox_swf.write('"+ oDIV.id +"')");


	            				// insert SWFObject
	            				if( flashCode.indexOf("ox_swf.write")!=-1 )
		            			{
	              					eval(flashCode);
	              					
	            				}// else: the code was not as expected; don't show it
	          				}
	          				else
		          			{
					            // normal image banner; just set the contents of the DIV
					            oDIV.innerHTML = OA_output[zoneid];
					            //oDIV.removeClass('hidden');
	          				}
	          				oDIV.style.display = 'block';
	        			}
	      			}
	    		} // end of loop
	    		
	  		//else: no banners on this page
		}
		else
		{
	  	// not ready, let's wait a bit
	  		if (openx_timeout>80) 
		  	{
	    	return; // we waited too long; abort
	  		}
	  	setTimeout( displayBannerAds, 10*openx_timeout );
	   	openx_timeout+=4;
		}
	};
	displayBannerAds();
};


function googleAnalyticsTrackPageView( pageToTrack , multipleCall )
{
	if(frenchRegion != '')	
    {
		pageToTrack = '/' + frenchRegion + pageToTrack;
    }
	if(typeof(multipleCall) == 'undefined')
	{
		multipleCall = 1;
	}
	
	for(var m = 0 ; m < multipleCall ; m++)
	{
		_gaq.push(function()
				{
					_gat._getTrackerByName('globalTracker')._trackPageview(pageToTrack);
					
				}
			);
	}
		
}



// Event tracker send async stats to googleAnalytics using globalTrackerinmplemented in google-analytics_default.php class
// These stats are used by Vendor report module
// category : view , callcack , share    |    action : viewDetail , viewPhone , viewPropOnListing , facebook , friend .... ,  label :   propId:id;agentId:agentId

function googleAnalyticsTrackEvent(category,action,label)
{

	for(i=0; i < label.length; i++)
	{
		_gaq.push(function()
			{
				_gat._getTrackerByName('globalTracker')._trackEvent(category , action , label[i]);
			})
	}
}

function refreshCaptcha()
{
	if(typeof(ajaxRequestCaptchaReference) != 'undefined' && ajaxRequestCaptchaReference != '' && callInProgress(ajaxRequestCaptchaReference.transport))
	{
		ajaxRequestCaptchaReference.transport.abort();
	}

    ajaxUrl ='/agent/generate-captcha';

    if(frenchRegion != '')
    {
    	ajaxUrl = '/' + frenchRegion + ajaxUrl;
    }

	ajaxRequestCaptchaReference = new Ajax.Request(
			ajaxUrl,
			{
				method: 'post',
				onSuccess: function(transport)
				{

					updateCaptcha(transport.responseJSON);
				}
			}
	);


}
function reportErrorToSupport(id,lang)
{
	if(typeof(ajaxRequestSupportReference) != 'undefined' && ajaxRequestSupportReference != '' && callInProgress(ajaxRequestSupportReference.transport))
	{
		ajaxRequestSupportReference.transport.abort();
	}
	
	ajaxUrl ='/support/message';

    if(frenchRegion != '')
    {
    	ajaxUrl = '/' + frenchRegion + ajaxUrl;
    }
	
	if(typeof(id) != 'undefined' && typeof(lang) != 'undefined')
	{
		propId = id;
		var ajaxMethod = 'get';
		formDatas = "";
		ajaxUrl += "?lang="+lang;
		globalLang = lang;
	}
	else
	{
		var ajaxMethod = 'post';
		formDatas = $('supportcontact').serialize();
		ajaxUrl += "?lang="+globalLang;
	}
	
    ajaxRequestSupportReference = new Ajax.Request(
			ajaxUrl,
			{
				method: ajaxMethod,
				parameters: formDatas,
				onSuccess: function(transport)
				{
					$('msgBox').innerHTML = transport.responseText;
					if(typeof($('supportcontact')) != 'undefined')
					{
						$('supportcontact').elements['propId'].value = propId;
					}
				}
			}
	);
	
	
}

function updateCaptcha(json)
{
	$('captchaContainer').firstChild.nextSibling.src = '' + json.url.toString() + json.id.toString() + json.suffix.toString() + '';
	document.forms['contact'].elements['contact[captcha][id]'].value = '' +json.id.toString() + '';
}



// able or disable form inputs 
function changeStateElementsInForm(form) {
	/*
	if($('spiner-search') != null && $('spiner-search').style.display == 'none')
	{
		$('spiner-search').style.display = 'block';
		$('grey-page').style.display = 'block';
	}
	else if($('spiner-search') != null)
	{
		$('spiner-search').style.display = 'none';
		$('grey-page').style.display = 'none';
	}*/
	for(i=0;i<form.elements.length;i++)
	{
		if(form.elements[i].getAttribute('disabled')==true || form.elements[i].getAttribute('disabled')=='disabled')
		{
			form.elements[i].removeAttribute('disabled');			
			if(form.elements[i].className=='bt-submit grayed') {
				form.elements[i].className='bt-submit';
			}
		}
		else
		{
			form.elements[i].setAttribute('disabled','disabled');
			if(form.elements[i].className=='bt-submit') {
				form.elements[i].className='bt-submit grayed';
			}
		}
	}	
}

// return true if ajax request past is in progress
function callInProgress (xmlhttp) {  
	switch (xmlhttp.readyState) {  
		case 1: case 2: case 3:  
			return true;  
		break;  
		// Case 4 and 0  
		default:  
			return false;  
		break;  
	}  
} 

function StopBubble(e)
{
    /* http://www.quirksmode.org/js/events_order.html */
    if (!e)
        e = window.event;

    e.cancelBubble = true; /* Microsoft */
    if (e.stopPropagation)
        e.stopPropagation(); /* W3C */
}

function recupSelectedForGoogleTrackEvent(recup){		
	pageTracker._trackEvent('Tri des resultats', recup, '', '');
}


function openList(id) {
	var obj=document.getElementById(id);
	if(obj!=null) {
		if(obj.style.display=='' || obj.style.display=='none') 
		{
			obj.style.display='block'; 
		}
		else 
		{
			obj.style.display='none'; 
		}
	}
}
function checkOpenedMenu()
{
	// International site menu
	if($('togglerSitesList').className == 'opened')
	{
		openList('sites-list');
		$('togglerSitesList').className = 'closed';
	}
	
	// User Account rapid access menu
	if( $('linkToggler')!= null &&  $('linkToggler').className == 'opened')
	{
		openList('userAcountRapidAccessList');
		$('linkToggler').className = 'closed';
	}
}


/************************************fonctions utilisées pour l'affichage du bloc modification d'une partie de la recherche (fonctions auparavent utilisé dans l'ancien lightbox..) ********/
function showSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

function hideSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}
function showFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "visible";
	}
	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "visible";
	}
}

function hideFlash(){
	var flashObjects = document.getElementsByTagName("object");
	for (i = 0; i < flashObjects.length; i++) {
		flashObjects[i].style.visibility = "hidden";
	}
	var flashEmbeds = document.getElementsByTagName("embed");
	for (i = 0; i < flashEmbeds.length; i++) {
		flashEmbeds[i].style.visibility = "hidden";
	}
}

function writeCookie(name,value) {
	document.cookie=name+'='+escape(value)+';path=/';
}

function readCookie(name) {
	var chaine=document.cookie;
	var reg=new RegExp("[ ]", "g");
	chaine=chaine.replace(reg,'');
	var total=chaine.length;
	tab1=chaine.split(";");

	for(i=0;i<tab1.length;i++)
	{
		sous_chaine=tab1[i];
		tab1[i]=sous_chaine.split('=');	
	}
	
	for(i=0;i<tab1.length;i++)
	{
		if(name==tab1[i][0]) return tab1[i][1];
	}
	return null;
}


function Lien() {
        i = document.encode.elements['bien[country]'].options[document.encode.elements['bien[country]'].selectedIndex].value;
        if (i == 0) return;
	   if (i== 'Belgique') {showstuff('ocity'); hidestuff('master');}
	   if (i== 'Allemagne') {showstuff('ocity'); hidestuff('master');}
	   if (i== 'France') {showstuff('ocity'); hidestuff('master');}
	   if (i== 'Luxembourg') {hidestuff('ocity');showstuff('master'); }
       }
	  
function Lien2() {
        i = document.encode.transaction.options[document.encode.transaction.selectedIndex].value;
	   if (i == 0) return;
        if  ((i != 'location') || (i != 'vente') || (i != 'both')) { hidestuff('divPrixloyer');showstuff('divMsg');}
	   if (i== 'location') {showstuff('divPrixloyer'); showstuff('divLoyer'); hidestuff('divPrix'); hidestuff('divMsg');}
	   if (i== 'vente') {showstuff('divPrixloyer'); showstuff('divPrix'); hidestuff('divLoyer'); hidestuff('divMsg');}
	   if (i== 'both') {showstuff('divPrixloyer'); showstuff('divLoyer'); showstuff('divPrix'); hidestuff('divMsg');}
       }
function Lien3() {
        i = document.encode.elements['bien[disponib]'].options[document.encode.elements['bien[disponib]'].selectedIndex].value;
	   if (i == 0) return;
        if (i == 'autre') { showstuff('divDispo1');}
	if (i == 'autre') { showstuff('divDispo2');}
	   if ( i!= 'autre') {hidestuff('divDispo1'); }
	   if ( i!= 'autre') {hidestuff('divDispo2'); }
       }
function Lien4() {
        i = document.encode.elements['bien[disponib]'].options[document.encode.elements['bien[disponib]'].selectedIndex].value;
	   if (i == 0) return;
        if (i == 'autre') { showstuff('divDispo');}
	   if ( i!= 'autre') {hidestuff('divDispo'); }
}       
function LienDispo(disponib){	
	if(disponib=="autre"){
		showstuff('divDispo');
	}
}   

function updateStatsClick( clickEvent , propId , agentId , contactId )
	{		
		switch (clickEvent)
		{
			case 'linkPhone' :
				var url = "/stats_appeler.php";
				var pars="offerid="+propId+"&agence="+agentId+"&idcont="+contactId;
			break;
			
			case 'linkWebsite' :
			
				var url = "/stats_linkToAgentWebsite.php";			
				var pars="fromWhere=detail&agence="+agentId;
			break;
			
		}
		var myAjax = new Ajax.Request(
				url, 
        	{method: 'get', parameters: pars }
		);
		return false;
}


function updateStatsRech(from_link,urlsite){		
	var url = urlsite+"/stats_recherche.php";
		
	var pars; 
	pars = "flk="+from_link;	
	var myAjax = new Ajax.Request(
		url, 
	{method: 'get', parameters: pars, onComplete: showFunctionStat }
	);
}

function updateStatsBrand(agence,urlsite){		
	var url = urlsite+"/stats_brandbooster.php";
		
	var pars; 
	pars = "agence="+agence;	
	var myAjax = new Ajax.Request(
		url, 
	{method: 'get', parameters: pars, onComplete: showFunctionStat }
	);
}


function showFunctionStat(){
	
}
function flvFTL1(){// v1.0
var v1=arguments,v2,v3,v4,v5,v7;
for (v3=0;v3<v1.length;v3++){
v2=MM_findObj(v1[v3]);
if (v2){
	if (document.layers){
		v4=v2;
		v5="show";
		v7="block";
	}else {
		v4=v2.style;
		v5="visible";
		v7="block";
		}
v4.visibility=(v4.visibility==v5)?"hidden":"visible";
v4.display=(v4.display==v7)?"none":"block";
}}}


//function qui permet de selectionner les champs soit de type location ou de vente
function LienTransaction(val){
	if (val==0){ //vente
		showstuff("divVente");
		hidestuff("divLocation");	
		showstuff("divNeuf");
	}else if (val==1){ //location
		showstuff("divLocation");
		hidestuff("divVente");
		showstuff("divNeuf");
	}else if (val==2){ //location vente
		
	}else {
		showstuff("divVente");
		hidestuff("divLocation");
	}
}

function showstuff(elem){ 
document.getElementById(elem).style.visibility="visible"; 
document.getElementById(elem).style.display="block"; 
}
function hidestuff(elem){ 
document.getElementById(elem).style.visibility="hidden";
document.getElementById(elem).style.display="none"; 

}
//function qui permet de selectionner la bonne liste de pays
function SelectPays(obj,pays){	
	if(pays!=""){
		var trouve=false;
		for (var i=0; i<obj.options.length; i++) {			
			if(pays==obj.options[i].text){	
				trouve=true;
				obj.options[i].selected="selected";
			}
		}
		if(trouve==false){			
			obj.options[obj.options.length-1].selected="selected";
		}
	}	
	
	LienPays(obj.value);	
}




function MM_findObj(n, d) { //modified 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

//fonction qui permet qui garde l'url en fonction du choix du tri
function choixTri(liste,catPrincipale,sousCat,chemin,localite){			
	var lienLocalite="";
	if(localite!=""){
			var lienLocalite="/recherche/"+localite;
		}
		
	if(liste.value==0){			
			document.location.href=""+chemin+"/annuaire/services/"+catPrincipale+"/"+sousCat+"/tri/nom"+lienLocalite;
		}
		
	if(liste.value==1){
			document.location.href=""+chemin+"/annuaire/services/"+catPrincipale+"/"+sousCat+"/tri/localite"+lienLocalite;
		}			
}

//fonction qui permet de garder l'url en fonction du choix du tri sur une recherche globale
function choixTriRechercheGlobale(liste,region,ville,cat,occurence,chemin)
{
  	tableau = cat.split("t") ;
  	if(tableau[0]=="sousca"){
		cat="souscat"+tableau[1];
	}else{
		if(tableau[0]=="ca"){
			cat="cat"+tableau[1];
		}else{
			cat=tableau[0];
		}
	}
	if(liste.value==0){			
			document.location.href=""+chemin+"/annuaire/recherches/"+region+"/"+ville+"/"+cat+"/"+occurence+"/tri/nom";
		}
		
	if(liste.value==1){
			document.location.href=""+chemin+"/annuaire/recherches/"+region+"/"+ville+"/"+cat+"/"+occurence+"/tri/localite";
		}		
}


function controleRechercheGlobale(){  
  if(document.search.localite.value=='' && document.search.ville.value=='' && document.search.categorie.value=='' && document.search.occurence.value==''){
	  alert("Veuillez choisir ou saisir au minimum un critère de recherche");
  }else{
	  document.search.submit();
  }
}

function ValiderInscription(formulaire){
	if(formulaire.elements['userAdress[firstname]'].value!="" && formulaire.elements['userAdress[lastname]'].value!="" && formulaire.elements['jourNaiss'].value!="" && formulaire.elements['moisNaiss'].value!="" && formulaire.elements['anneeNaiss'].value!="" && formulaire.elements['userAdress[country]'].value!="" && formulaire.elements['userAdress[zipcode]'].value!="" && formulaire.elements['userAdress[street]'].value!="" && formulaire.elements['userAdress[firstbesttimetocall]'].value!="" && formulaire.elements['userAdress[firstbestperiodtocall]'].value!="" && formulaire.elements['user[email]'].value!="" && formulaire.elements['user[password]'].value!="" && formulaire.elements['confirmation'].value!="" && formulaire.elements['userAdress[connu]'].value!="" && formulaire.elements['disclaimer'].value!=""){
		formulaire.submit();
	}else{
		alert('Veuillez remplir tous les champs obligatoires');
	}
}


//fonction qui selectionne tous les cases de la recherches par types
function checkAllCaseCochee(nbInput,numInput,caseAll){	
	for(i=numInput;i<(nbInput+numInput);i++){	
		if(caseAll.checked==true)
			document.encode.elements['immotype[]'][i].checked=true;
		else
			document.encode.elements['immotype[]'][i].checked=false;
	}
	
}

//fonction qui fait apparaitre des autres lien
function lienFantome(element){
	if(document.getallElementById(element).className == "cacher"){
		document.getElementById(element).className = "afficher";
	}
	if(document.getElementById(element).className == "afficher"){
		document.getElementById(element).className = "cacher";
	}
	if(document.getElementById(element).className == ""){
		document.getElementById(element).className = "cacher";
	}
}

function popupEdit(idChildren , id){
	window.open ('/agadmin/agadminAction/popupEdit/'+idChildren+'/'+id+'', '', config='height=700, width=900, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no')
}

var dhtmlgoodies_menuObj;	// Reference to the menu div
	var currentZIndex = 1000;
	var liIndex = 0;
	var visibleMenus = new Array();
	var activeMenuItem = false;
	var timeBeforeAutoHide = 1200; // Microseconds from mouse leaves menu to auto hide.
	var dhtmlgoodies_menu_arrow = 'images/arrow.gif';
	
	var MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;
	var navigatorVersion = navigator.appVersion.replace(/.*?MSIE ([0-9]\.[0-9]).*/g,'$1')/1;
	var menuBlockArray = new Array();
	var menuParentOffsetLeft = false;	
	function getTopPos(inputObj)
	{
		
	  var returnValue = inputObj.offsetTop;
	  if(inputObj.tagName=='LI' && inputObj.parentNode.className=='menuBlock1'){
	  	var aTag = inputObj.getElementsByTagName('A')[0];
	  	if(aTag)returnValue += aTag.parentNode.offsetHeight;

	  }	  
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;

	  return returnValue;
	}
	
	function getLeftPos(inputObj)
	{
	  var returnValue = inputObj.offsetLeft;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
	  return returnValue;
	}
	
	function showHideSub()
	{

		var attr = this.parentNode.getAttribute('currentDepth');
		if(navigator.userAgent.indexOf('Opera')>=0){
			attr = this.parentNode.currentDepth;
		}
		
		this.className = 'currentDepth' + attr + 'over';
		
		if(activeMenuItem && activeMenuItem!=this){
			activeMenuItem.className=activeMenuItem.className.replace(/over/,'');
		}
		activeMenuItem = this;
	
		var numericIdThis = this.id.replace(/[^0-9]/g,'');
		var exceptionArray = new Array();
		// Showing sub item of this LI
		var sub = document.getElementById('subOf' + numericIdThis);
		if(sub){
			visibleMenus.push(sub);
			sub.style.display='';
			sub.parentNode.className = sub.parentNode.className + 'over';
			exceptionArray[sub.id] = true;
		}	
		
		// Showing parent items of this one
		
		var parent = this.parentNode;
		while(parent && parent.id && parent.tagName=='UL'){
			visibleMenus.push(parent);
			exceptionArray[parent.id] = true;
			parent.style.display='';
			
			var li = document.getElementById('dhtmlgoodies_listItem' + parent.id.replace(/[^0-9]/g,''));
			if(li.className.indexOf('over')<0)li.className = li.className + 'over';
			parent = li.parentNode;
			
		}

			
		hideMenuItems(exceptionArray);



	}

	function hideMenuItems(exceptionArray)
	{
		/*
		Hiding visible menu items
		*/
		var newVisibleMenuArray = new Array();
		for(var no=0;no<visibleMenus.length;no++){
			if(visibleMenus[no].className!='menuBlock1' && visibleMenus[no].id){
				if(!exceptionArray[visibleMenus[no].id]){
					var el = visibleMenus[no].getElementsByTagName('A')[0];
					visibleMenus[no].style.display = 'none';
					var li = document.getElementById('dhtmlgoodies_listItem' + visibleMenus[no].id.replace(/[^0-9]/g,''));
					if(li.className.indexOf('over')>0)li.className = li.className.replace(/over/,'');
				}else{				
					newVisibleMenuArray.push(visibleMenus[no]);
				}
			}
		}		
		visibleMenus = newVisibleMenuArray;		
	}
	
	
	
	var menuActive = true;
	var hideTimer = 0;
	function mouseOverMenu()
	{
		menuActive = true;		
	}
	
	function mouseOutMenu()
	{
		menuActive = false;
		timerAutoHide();	
	}
	
	function timerAutoHide()
	{
		if(menuActive){
			hideTimer = 0;
			return;
		}
		
		if(hideTimer<timeBeforeAutoHide){
			hideTimer+=100;
			setTimeout('timerAutoHide()',99);
		}else{
			hideTimer = 0;
			autohideMenuItems();	
		}
	}
	
	function autohideMenuItems()
	{
		if(!menuActive){
			hideMenuItems(new Array());	
			if(activeMenuItem)activeMenuItem.className=activeMenuItem.className.replace(/over/,'');		
		}
	}
	
	
	function initSubMenus(inputObj,initOffsetLeft,currentDepth)
	{	
		var subUl = inputObj.getElementsByTagName('UL');
		if(subUl.length>0){
			var ul = subUl[0];
			
			ul.id = 'subOf' + inputObj.id.replace(/[^0-9]/g,'');
			ul.setAttribute('currentDepth' ,currentDepth);
			ul.currentDepth = currentDepth;
			ul.className='menuBlock' + currentDepth;
			ul.onmouseover = mouseOverMenu;
			ul.onmouseout = mouseOutMenu;
			currentZIndex+=1;
			ul.style.zIndex = currentZIndex;
			menuBlockArray.push(ul);
			var topPos = getTopPos(inputObj);
			var leftPos = getLeftPos(inputObj)/1 + initOffsetLeft/1;			
			ul = dhtmlgoodies_menuObj.appendChild(ul);
			ul.style.position = 'absolute';
			ul.style.left = leftPos + 'px';
			ul.style.top = topPos + 'px';
			var li = ul.getElementsByTagName('LI')[0];

			while(li){
				if(li.tagName=='LI'){	
					li.className='currentDepth' + currentDepth;					
					li.id = 'dhtmlgoodies_listItem' + liIndex;
					liIndex++;				
					var uls = li.getElementsByTagName('UL');
					li.onmouseover = showHideSub;

					if(uls.length>0){
						var offsetToFunction = li.getElementsByTagName('A')[0].offsetWidth+2;
						if(navigatorVersion<6 && MSIE)offsetToFunction+=15;	// MSIE 5.x fix
						initSubMenus(li,offsetToFunction,(currentDepth+1));
					}	
					if(MSIE){
						var a = li.getElementsByTagName('A')[0];
						a.style.width=li.offsetWidth+'px';
						a.style.display='block';
					}					
				}
				li = li.nextSibling;
			}
			ul.style.display = 'none';	
			if(!document.all){
				//dhtmlgoodies_menuObj.appendChild(ul);
			}
		}	
	}


	function resizeMenu()
	{
		var offsetParent = getLeftPos(dhtmlgoodies_menuObj);
		
		for(var no=0;no<menuBlockArray.length;no++){
			var leftPos = menuBlockArray[no].style.left.replace('px','')/1;
			menuBlockArray[no].style.left = leftPos + offsetParent - menuParentOffsetLeft + 'px';
		}
		menuParentOffsetLeft = offsetParent;
	}
	
	/* 
	Initializing menu 
	*/
	function initDhtmlGoodiesMenu()
	{
		dhtmlgoodies_menuObj = document.getElementById('dhtmlgoodies_menu');
		
		
		var aTags = dhtmlgoodies_menuObj.getElementsByTagName('A');
		for(var no=0;no<aTags.length;no++){			

			var subUl = aTags[no].parentNode.getElementsByTagName('UL');
			if(subUl.length>0 && aTags[no].parentNode.parentNode.parentNode.id != 'dhtmlgoodies_menu'){
				var img = document.createElement('IMG');
				img.src = dhtmlgoodies_menu_arrow;
				aTags[no].appendChild(img);				

			}

		}
				
		var mainMenu = dhtmlgoodies_menuObj.getElementsByTagName('UL')[0];
		mainMenu.className='menuBlock1';
		mainMenu.style.zIndex = currentZIndex;
		mainMenu.setAttribute('currentDepth' ,1);
		mainMenu.currentDepth = '1';
		mainMenu.onmouseover = mouseOverMenu;
		mainMenu.onmouseout = mouseOutMenu;		

		var mainMenuItemsArray = new Array();
		var mainMenuItem = mainMenu.getElementsByTagName('LI')[0];
		mainMenu.style.height = mainMenuItem.offsetHeight + 2 + 'px';
		while(mainMenuItem){
			
			mainMenuItem.className='currentDepth1';
			mainMenuItem.id = 'dhtmlgoodies_listItem' + liIndex;
			mainMenuItem.onmouseover = showHideSub;
			liIndex++;				
			if(mainMenuItem.tagName=='LI'){
				mainMenuItem.style.cssText = 'float:left;';	
				mainMenuItem.style.styleFloat = 'left';
				mainMenuItemsArray[mainMenuItemsArray.length] = mainMenuItem;
				initSubMenus(mainMenuItem,0,2);
			}			
			
			mainMenuItem = mainMenuItem.nextSibling;
			
		}

		for(var no=0;no<mainMenuItemsArray.length;no++){
			initSubMenus(mainMenuItemsArray[no],0,2);			
		}
		
		menuParentOffsetLeft = getLeftPos(dhtmlgoodies_menuObj);	
		window.onresize = resizeMenu;	
		dhtmlgoodies_menuObj.style.visibility = 'visible';	
	}
	
	//window.onload = initDhtmlGoodiesMenu;
	
function selectCommunes(indexCommune){	
	if(document.encode.elements['communeGeo[]'][indexCommune].selected==true){
		document.encode.elements['communeGeo[]'][indexCommune].selected=false;
	}else{		
		document.encode.elements['communeGeo[]'][indexCommune].selected=true;
	}
}

function selectOtherCommunes(index){
	
	if(document.encode.elements['otherCommune[]'][index].selected==true){
		document.encode.elements['otherCommune[]'][index].selected=false;
	}else{		
		document.encode.elements['otherCommune[]'][index].selected=true;
	}
}


//tableau qui redirige vers le site régionalisé en fonction de la region
function verifSiteRegion(region){
	var url="";
	var idRegion;
	for (idRegion in tabRegionRegional){		
		if(region==idRegion){
   			url = tabRegionRegional[idRegion];   
		}
	}
	if(url!=""){
		//window.location.replace(url);
		document.encode.action.value=url;
		document.encode.submit();		
	}
}


//function de vérification pour le formulaire de recherche en home page
function validHomeSearch(urlsite){		
	if(isNaN(document.formHomeSearch.prixMax.value)){				
		document.formHomeSearch.prixMax.value='';		
	}
	if(isNaN(document.formHomeSearch.prixMini.value) && document.formHomeSearch.prixMini.value!=0){				
		document.formHomeSearch.prixMini.value='';
	}
	//alert(urlsite);
	if (urlsite=='http://www.athome.lu' || urlsite=='http://www.athomev3.dev'){
		updateStatsRech('rapide',urlsite);
	}
	
	//redirection vers le site régionalisé
	/*var url="";
	var idRegion;
	var region=document.formHomeSearch.region.value;	
	for (idRegion in tabRegionRegional){				
		if(region==idRegion){
   			url = tabRegionRegional[idRegion];      			
		}
	}
	if(url!=""){
		//window.location.replace(url);		
		document.formHomeSearch.action=url+'/action/home_search';		
		document.formHomeSearch.submit();		
	}*/
}


//fonction qui verifie si on veut garder les critères de recherches avant de changer de cartes
function redirectSearchSession(keepInSession,url){	
	var urlRedirect="";
	if(keepInSession==1){		
		var chaine=""+url+"";
		var reg=new RegExp("[ /]+", "g");		
		var tableau=chaine.split(reg);		
		var encodeUrl="";
		for (var i=0; i<tableau.length; i++) {
 			//document.write("tableau[" + i + "] = " + tableau[i] + "<BR>");
 			
 			if(tableau[i]=="action"){
 				encodeUrl=1;
 			}
 			if(encodeUrl==1){
 				urlRedirect+='/'+tableau[i];
 			} 
		}									
	}else{
		urlRedirect=url;
	}			
	document.formHomeSearch.method="GET";
	document.formHomeSearch.action=urlRedirect;
	alert(urlRedirect);
	document.formHomeSearch.submit();
	//document.formHomeSearch.method="GET";
	
}

//fonction qui cache les champs à ne pas afficher selon l'immotype
function hiddenFields(immotype){
	document.getElementById("numchamb").style.visibility="visible";	
	document.getElementById("numpiece").style.visibility="visible";
	document.getElementById("surface").style.visibility="visible";
	if(fieldsHidden['numchamb'][immotype]==1){
		document.getElementById("numchamb").style.visibility="hidden";
	}
	if(fieldsHidden['numpiece'][immotype]==1){
		document.getElementById("numpiece").style.visibility="hidden";
	}
	if(fieldsHidden['surface'][immotype]==1){		
		document.getElementById("surface").style.visibility="hidden";
	}
    if(immotype=='11'){
        document.getElementById("terrainAvecContrat_1").style.display="block";
        document.getElementById("terrainAvecContrat_2").style.display="block";
}else{
        document.getElementById("terrainAvecContrat_1").style.display="none";
        document.getElementById("terrainAvecContrat_2").style.display="none";
        
}

}
function hiddenFieldsResidencies(immotype){		
	document.getElementById("numchamb").style.visibility="visible";	
	document.getElementById("surface").style.visibility="visible";
	if(fieldsHidden['numchamb'][immotype]==1){
		document.getElementById("numchamb").style.visibility="hidden";
	}	
	if(fieldsHidden['surface'][immotype]==1){		
		document.getElementById("surface").style.visibility="hidden";
	}
}

//HttpRequest, table programmation :
	
	var httpRequestForm = false;
	
	function formSearchLocaliteBlock(regionMap){
		hideSelectBoxes();
		hideFlash();
		var urlMap="";
		if(regionMap>0){
			urlMap='&region[]='+regionMap;
		}		
		httpRequestForm = new MyHttpRequest(null,'get','/action/modifSearchBlock?form=geo&keepInSession=1&filtre=1'+urlMap+'');
		
		var functionOnReadyStateChange = " var http=httpRequestForm.http; \
					\
					if(http.readyState == 4  &&  http.status == 200)	\
					{	document.getElementById('searchBlock').innerHTML = http.responseText; \
					}	\
					else	\
					{	var noeud = document.getElementById('searchBlock'); \
						while(noeud.childNodes.length>0) noeud.removeChild(noeud.firstChild); \
						var img = document.createElement('img'); \
						img.alt = 'KO'; \
						img.src = '/images/no.gif'; \
						noeud.appendChild(img); \
					} ";
				
		httpRequestForm.onReadyStateChange = new Function(functionOnReadyStateChange);
		
		var functionWait = " if(httpRequestForm.waitOK == false){ \
						var noeud = document.getElementById('searchBlock'); \
						while(noeud.childNodes.length>0) noeud.removeChild(noeud.firstChild); \
						var img = document.createElement('img'); \
						img.src = '/images/wait.gif'; \
						noeud.appendChild(img); \
						httpRequestForm.waitOK = true; \
					} ";
					
		httpRequestForm.wait = new Function(functionWait);
		httpRequestForm.send();
		document.getElementById('searchBlock').style.visibility="visible";
		document.getElementById('searchBlock').style.display="block";
		/*document.getElementById('container').style.setProperty("-moz-opacity", 0.2, "");
	    document.getElementById('container').style.setProperty("-khtml-opacity", 0.2, "");
	    document.getElementById('container').style.setProperty("opacity", 0.2, "");	 */
		
	}
	httpRequestForm= false;
	function formSearchTypeBlock(){
		hideSelectBoxes();		
		hideFlash();
		httpRequestForm = new MyHttpRequest(null,'get','/action/modifSearchBlock?form=critere&keepInSession=1');
		
		var functionOnReadyStateChange = " var http=httpRequestForm.http; \
					\
					if(http.readyState == 4  &&  http.status == 200)	\
					{	document.getElementById('searchBlock').innerHTML = http.responseText; \
					}	\
					else	\
					{	var noeud = document.getElementById('searchBlock'); \
						while(noeud.childNodes.length>0) noeud.removeChild(noeud.firstChild); \
						var img = document.createElement('img'); \
						img.alt = 'KO'; \
						img.src = '/images/no.gif'; \
						noeud.appendChild(img); \
					} ";
				
		httpRequestForm.onReadyStateChange = new Function(functionOnReadyStateChange);
		
		var functionWait = " if(httpRequestForm.waitOK == false){ \
						var noeud = document.getElementById('searchBlock'); \
						while(noeud.childNodes.length>0) noeud.removeChild(noeud.firstChild); \
						var img = document.createElement('img'); \
						img.src = '/images/wait.gif'; \
						noeud.appendChild(img); \
						httpRequestForm.waitOK = true; \
					} ";
					
		httpRequestForm.wait = new Function(functionWait);
		httpRequestForm.send();
		document.getElementById('searchBlock').style.visibility="visible";
		document.getElementById('searchBlock').style.display="block";
		/*document.getElementById('container').style.setProperty("-moz-opacity", 0.2, "");
	    document.getElementById('container').style.setProperty("-khtml-opacity", 0.2, "");
	    document.getElementById('container').style.setProperty("opacity", 0.2, "");*/		 
	}
	httpRequestForm= false;
	function formSearchCaractBlock(){
		hideSelectBoxes();		
		hideFlash();
		httpRequestForm = new MyHttpRequest(null,'get','/action/modifSearchBlock?form=carac&keepInSession=1');
		
		var functionOnReadyStateChange = " var http=httpRequestForm.http; \
					\
					if(http.readyState == 4  &&  http.status == 200)	\
					{	document.getElementById('searchBlock').innerHTML = http.responseText; \
					}	\
					else	\
					{	var noeud = document.getElementById('searchBlock'); \
						while(noeud.childNodes.length>0) noeud.removeChild(noeud.firstChild); \
						var img = document.createElement('img'); \
						img.alt = 'KO'; \
						img.src = '/images/no.gif'; \
						noeud.appendChild(img); \
					} ";
				
		httpRequestForm.onReadyStateChange = new Function(functionOnReadyStateChange);
		
		var functionWait = " if(httpRequestForm.waitOK == false){ \
						var noeud = document.getElementById('searchBlock'); \
						while(noeud.childNodes.length>0) noeud.removeChild(noeud.firstChild); \
						var img = document.createElement('img'); \
						img.src = '/images/wait.gif'; \
						noeud.appendChild(img); \
						httpRequestForm.waitOK = true; \
					} ";
					
		httpRequestForm.wait = new Function(functionWait);
		httpRequestForm.send();
		document.getElementById('searchBlock').style.visibility="visible";
		document.getElementById('searchBlock').style.display="block";
		/*document.getElementById('container').style.setProperty("-moz-opacity", 0.2, "");
	    document.getElementById('container').style.setProperty("-khtml-opacity", 0.2, "");
	    document.getElementById('container').style.setProperty("opacity", 0.2, "");*/		
	}
/*******************************fin des fonctions utilisées pour l'affichage du bloc modification d'une partie de la recherche*/



	function cancelLink(link)
	{
		
		if(link.cancel == 1)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
