/* Javascript - Laforet Immobilier */

/***** Sommaire *****/
// 01 - Variables
// 02 - Methodes
// 05 - Affichage / Masquage layer information
// 10 - Debloquage liste secondaire
// 15 - Diaporama
// 18 - Comparer
// 20 - Navigation
// 25 - Popup
// 30 - Selection region
// 50 - Ajax
// 55 - Module "Trouver une agence"
// 60 - Espace Laforet
// 65 - Controle des formulaires
// 80 - Google Maps
// 99 - onLoad
/***** ******** *****/

/***** 01 - Variables *****/
var actURL  = document.location.href;
var isOpera = (navigator.userAgent.indexOf('Opera') == 55 || navigator.userAgent.indexOf('Opera') == 36 || navigator.userAgent.indexOf('Opera') == 0)? true : false ;

var Xpos;
var Ypos;
var decalY;
var offsetAdd;

var timeInfo;

var tabSearchVilles	= new Array();

/***** 02 - Methodes *****/

// Ajoute la fonction trim comme mÃ©thode de l'objet String.
String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

/***** 05 - Affichage / Masquage layer information *****/
function showInfo(){
	
	var layerInfo = document.getElementById('infoLayer');
	layerInfo.style.left = (Xpos+50)+'px';
	if(document.all && !isOpera){
		document.getElementById('flayerinfo').style.left = (Xpos+50)+'px';
		document.getElementById('flayerinfo').style.height = document.getElementById('infoLayer').offsetHeight;
	}
	
	if((document.getElementById('infoLayer').offsetHeight+(Ypos-150)) > document.getElementsByTagName('div')[0].offsetHeight){
		Ypos = document.getElementsByTagName('div')[0].offsetHeight-document.getElementById('infoLayer').offsetHeight;
	} else {
		Ypos = (Ypos-150);
	}
	
	layerInfo.style.top = Ypos+'px';
	if(document.all && !isOpera){
		document.getElementById('flayerinfo').style.top = Ypos+'px';
	}
}

function hideInfo(){
	var layerInfo = document.getElementById('infoLayer');
	layerInfo.style.top = '-999px';
	layerInfo.style.left = '-999px';
	if(document.all && !isOpera){
		document.getElementById('flayerinfo').style.left = '-999px';
		document.getElementById('flayerinfo').style.top = '-999px';
	}
}

/***** 10 - Debloquage liste secondaire *****/
function unlockListeElargir(){
	document.FormMaRecherche.large[0].disabled = (document.FormMaRecherche.villeBiens.value != '' && document.FormMaRecherche.villeBiens.value != '00')? '' : 'disabled';
	document.FormMaRecherche.large[1].disabled = (document.FormMaRecherche.villeBiens.value != '' && document.FormMaRecherche.villeBiens.value != '00')? '' : 'disabled';
	document.FormMaRecherche.large[2].disabled = (document.FormMaRecherche.villeBiens.value != '' && document.FormMaRecherche.villeBiens.value != '00')? '' : 'disabled';
	document.FormMaRecherche.large[3].disabled = (document.FormMaRecherche.villeBiens.value != '' && document.FormMaRecherche.villeBiens.value != '00')? '' : 'disabled';
}

function unlockListeElargir_alertes(){
	document.FormMonAlerte.large[0].disabled = (document.FormMonAlerte.villeBiens.value != '' && document.FormMonAlerte.villeBiens.value != '00')? '' : 'disabled';
	document.FormMonAlerte.large[1].disabled = (document.FormMonAlerte.villeBiens.value != '' && document.FormMonAlerte.villeBiens.value != '00')? '' : 'disabled';
	document.FormMonAlerte.large[2].disabled = (document.FormMonAlerte.villeBiens.value != '' && document.FormMonAlerte.villeBiens.value != '00')? '' : 'disabled';
	document.FormMonAlerte.large[3].disabled = (document.FormMonAlerte.villeBiens.value != '' && document.FormMonAlerte.villeBiens.value != '00')? '' : 'disabled';
}

function checkResults_alertes() {
	// TODO : après un Timeout, rafraichir le nb. de résultats en fct. des critères d'alerte choisis
}

function unlockSList(obj){

	if(obj == "citiesBiens")
	{
		document.FormMaRecherche.villeBiens.selectedIndex = 0;
		document.FormMaRecherche.villeBiens.disabled = (document.FormMaRecherche.regBiens.value != '')? '' : 'disabled' ;
	
		//document.FormMaRecherche.large[0].checked = true;
		
		
		document.FormMaRecherche.large[0].disabled = 'disabled';
		document.FormMaRecherche.large[1].disabled = 'disabled';
		document.FormMaRecherche.large[2].disabled = 'disabled';
		document.FormMaRecherche.large[3].disabled = 'disabled';
	}
	else if(obj == "agences")
	{
		document.FormTrouverAgence.villeAgences.selectedIndex = 0;
		document.FormTrouverAgence.villeAgences.disabled = (document.FormTrouverAgence.dptAgences.value != '')? '' : 'disabled' ;
	}
	if(obj == "large" || obj == "largeLoad")
	{	
		if (obj != "largeLoad" && document.FormMaRecherche.villeBiens.selectedIndex <= 0)
		{
			//document.FormMaRecherche.large[0].checked = true;
		}

		if(document.FormMaRecherche.libre.value != "") {
			document.FormMaRecherche.large[0].disabled = '';
			document.FormMaRecherche.large[1].disabled = '';
			document.FormMaRecherche.large[2].disabled = '';
			document.FormMaRecherche.large[3].disabled = '';
		}
		else {
			document.FormMaRecherche.large[0].disabled = (document.FormMaRecherche.villeBiens.value != '')? '' : 'disabled';
			document.FormMaRecherche.large[1].disabled = (document.FormMaRecherche.villeBiens.value != '')? '' : 'disabled';
			document.FormMaRecherche.large[2].disabled = (document.FormMaRecherche.villeBiens.value != '')? '' : 'disabled';
			document.FormMaRecherche.large[3].disabled = (document.FormMaRecherche.villeBiens.value != '')? '' : 'disabled';
		}
	}
	else if(obj == "largePop")
	{	
		//opener.document.FormMaRecherche.large[0].checked = true;
		
		opener.document.FormMaRecherche.large[0].disabled = (opener.document.FormMaRecherche.villeBiens.value != '')? '' : 'disabled';
		opener.document.FormMaRecherche.large[1].disabled = (opener.document.FormMaRecherche.villeBiens.value != '')? '' : 'disabled';
		opener.document.FormMaRecherche.large[2].disabled = (opener.document.FormMaRecherche.villeBiens.value != '')? '' : 'disabled';
		opener.document.FormMaRecherche.large[3].disabled = (opener.document.FormMaRecherche.villeBiens.value != '')? '' : 'disabled';
	}
}

/***** 15 - Diaporama *****/
var curPos = 0;

function scrollUp(id){
	var realID = id.substr(9);
	eval('var curPos = thumbPos'+realID);
	if(curPos < 0){
		curPos += 10;
		document.getElementById('scroll'+realID).getElementsByTagName('div')[0].style.top = curPos+'px';
		eval('thumbPos'+realID+' = '+curPos+';');
	} else {
		document.getElementById('scroll'+realID).getElementsByTagName('div')[0].style.top = '0px';
	}
}

function scrollDown(id){
	var realID = id.substr(9);
	eval('var curPos = thumbPos'+realID);
	if(document.getElementById('scroll'+realID).getElementsByTagName('div')[0].offsetHeight + curPos - document.getElementById('scroll'+realID).offsetHeight > 0){
		curPos -= 10;
		document.getElementById('scroll'+realID).getElementsByTagName('div')[0].style.top = curPos+'px';
		eval('thumbPos'+realID+' = '+curPos+';');
	}
}

function showPreview(monImg,id){
	reg = new RegExp("(/50/)", "g");
	document.getElementById('previewImg'+id).getElementsByTagName('img')[0].src = monImg.src.replace(reg, "/370/");
}

/*

ORIGINAL :

function showPreview(monImg,id){
	document.getElementById('previewImg'+id).getElementsByTagName('img')[0].src = monImg.src;
}
*/

function buildDiapo(){

	// Scan des DIV
	var divTable = document.getElementsByTagName('div');
	var diapoTable = new Array();
	for(i=0; i<divTable.length; i++){
		// Div resultats
		if(divTable[i].className == 'diapo'){ diapoTable[diapoTable.length] = divTable[i]; }
	}
	// 15 - Diaporama
	var timeScroll;
	
	if(diapoTable.length > 0){
		for(i=0; i<diapoTable.length; i++){
			var divDiapoChilds = diapoTable[i].getElementsByTagName('div');
			for(j=0; j<divDiapoChilds.length; j++){
				if(divDiapoChilds[j].className.indexOf('previewImg') != -1){
					divDiapoChilds[j].id = 'previewImg'+i;
				} else if(divDiapoChilds[j].className.indexOf('scrollTop') != -1){
					divDiapoChilds[j].id = 'scrollTop'+i;
					divDiapoChilds[j].onmouseover = function(){ timeScroll = setInterval("scrollUp(\""+this.id+"\");", 100); }
					divDiapoChilds[j].onmouseout = function(){ clearInterval(timeScroll); }
				} else if(divDiapoChilds[j].className.indexOf('thumbs') != -1){
					eval('thumbPos'+i+' = 0;');
					divDiapoChilds[j].id = 'scroll'+i;
					var thumbTab;
					thumbTab = divDiapoChilds[j].getElementsByTagName('img');
					for(k=0; k<thumbTab.length; k++){
						thumbTab[k].id = i;
						thumbTab[k].onmouseover = function(){ showPreview(this,this.id); }
					}
				} else if(divDiapoChilds[j].className.indexOf('scrollBot') != -1){
					divDiapoChilds[j].id = 'scrollBot'+i;
					divDiapoChilds[j].onmouseover = function(){ timeScroll = setInterval("scrollDown(\""+this.id+"\");", 100); }
					divDiapoChilds[j].onmouseout = function(){ clearInterval(timeScroll); }
				}
			}
		}
	}
}

/***** 18 - Comparer *****/
function buildVoletComp(){

	var tempTab = document.getElementById('compar').getElementsByTagName('div');
	var tempCount = 0;
	for(i=0; i<tempTab.length; i++){
		if(tempTab[i].className == 'link'){ 
			tempTab[i].getElementsByTagName('a')[0].id = 'link'+tempCount;
			tempTab[i].getElementsByTagName('a')[0].href = 'javascript:showDetail('+tempCount+');';
			tempCount ++;
		}
	}
	var tempTab = document.getElementById('compar').getElementsByTagName('td');
	var tempCount = 0;
	for(i=0; i<tempTab.length; i++){
		if(tempTab[i].className == 'detail'){
			tempTab[i].id = 'detail'+tempCount;
			tempTab[i].getElementsByTagName('a')[0].href = 'javascript:hideDetail('+tempCount+');';
			tempCount ++;
		}
	}
		
}

function showDetail(id){

	if(id != "" && (texte = file("/immobilier/mon-espace-laforet/popup/getFicheBien.php?propertyId="+escape(id))))
	{
		if(texte != "")
		{
			tabSearchFiche 		= texte.split("|");
			agencyId 		= tabSearchFiche[0];
			transactionBien 	= tabSearchFiche[1];
			propertyId 		= tabSearchFiche[2];
			propertyBien		= tabSearchFiche[3];
			roomsQuantity 		= tabSearchFiche[4];
			city 			= tabSearchFiche[5];
			departementId 		= tabSearchFiche[6];
			description_bien 	= tabSearchFiche[7];
			constructionYear 	= tabSearchFiche[8];
			bathroomsQuantity 	= tabSearchFiche[9];
			waterClosetsQuantity 	= tabSearchFiche[10];
			waterRoomsQuantity 	= tabSearchFiche[11];
			kitchenType 		= tabSearchFiche[12];
			heatingNature		= tabSearchFiche[13];
			cellar			= tabSearchFiche[14];
			parkingInsidesQuantity	= tabSearchFiche[15];
			parkingOutsidesQuantity	= tabSearchFiche[16];
			garagesQuantity		= tabSearchFiche[17];
			surface			= tabSearchFiche[18];
			livingroomSurface	= tabSearchFiche[19];
			groundSurface		= tabSearchFiche[20];
			surfaceUnit		= tabSearchFiche[21];
			sellingPrice		= tabSearchFiche[22];
			privilege		= tabSearchFiche[23];
			fees			= tabSearchFiche[24];
			mainVisu		= tabSearchFiche[25];
			subVisus		= tabSearchFiche[26];
			contratPrivilege2	= tabSearchFiche[27];
			agencyName		= tabSearchFiche[28];
			address1		= tabSearchFiche[29];
			postalCode		= tabSearchFiche[30];
			agencyCity		= tabSearchFiche[31];
			phoneNumber		= tabSearchFiche[32];
			faxNumber		= tabSearchFiche[33];
			mailAddress		= tabSearchFiche[34];
			webURL			= tabSearchFiche[35];
			nbVisus			= tabSearchFiche[36];
			
			document.getElementById("propertyId_"+id).innerHTML = propertyId;
			
			var infosfiche = "<strong>"+sellingPrice+" &euro;</strong> * <strong>   - "+propertyBien;
			if (roomsQuantity != "" && roomsQuantity > 0) infosfiche += " "+roomsQuantity+" pi&egrave;ce(s)";
			if (surface != "") infosfiche +=  " / "+surface+" "+surfaceUnit;
			infosfiche += "</strong><br />"+city+" ("+departementId+")";
			document.getElementById("infosFiche_"+id).innerHTML = infosfiche;
			if (fees != "" && fees != 0)
			{	
				document.getElementById("fees1_"+id).innerHTML = fees;
				document.getElementById("fees_"+id).style.display = "block";
			}
			document.getElementById("descFiche_"+id).innerHTML = description_bien;

			if (contratPrivilege2 == 1) document.getElementById("contratPrivilege_"+id).style.display = "block";
			else document.getElementById("contratPrivilege_"+id).style.display = "none"
			
			document.getElementById("surface_"+id).innerHTML 			= surface;
			document.getElementById("livingroomSurface_"+id).innerHTML 		= livingroomSurface;
			document.getElementById("constructionYear_"+id).innerHTML 		= constructionYear;
			document.getElementById("bathroomsQuantity_"+id).innerHTML 		= bathroomsQuantity;
			document.getElementById("waterClosetsQuantity_"+id).innerHTML 	= waterClosetsQuantity;
			document.getElementById("kitchenType_"+id).innerHTML 		= kitchenType;
			document.getElementById("waterRoomsQuantity_"+id).innerHTML 	= waterRoomsQuantity;
			document.getElementById("heatingNature_"+id).innerHTML 		= heatingNature;
			document.getElementById("cellar_"+id).innerHTML 			= cellar;
			document.getElementById("parkingInsidesQuantity_"+id).innerHTML 	= parkingInsidesQuantity;
			document.getElementById("parkingOutsidesQuantity_"+id).innerHTML 	= parkingOutsidesQuantity;
			document.getElementById("groundSurface_"+id).innerHTML 		= groundSurface;
			document.getElementById("garagesQuantity_"+id).innerHTML 		= garagesQuantity;
			
			/* Visuels */
			if(mainVisu != "") document.getElementById("mainVisu_"+id).innerHTML = mainVisu;
			if(subVisus != "") document.getElementById("subVisus_"+id).innerHTML = subVisus;
			
			if(nbVisus > 4)
			{
				document.getElementById("infosScrollTop_"+id).style.display = "block";
				document.getElementById("infosScrollBot_"+id).style.display = "block";
			}
			
			agenceInfos = agencyName+"<br />"+address1+"<br />"+postalCode+" "+agencyCity;
			document.getElementById("agenceInfos_"+id).innerHTML = agenceInfos;
			document.getElementById("agenceGoogle_"+id).href = "javascript:openWin('/maps/geoZoom.php?agencyId="+agencyId+"')";
			
			if (phoneNumber != "") phoneNumber += "<br />";
			else phoneNumber = "-<br />";
			
			if (faxNumber != "") faxNumber += "<br />";
			else faxNumber = "-<br />";
			
			if (mailAddress != "") mailAddress = "<a href=\"mailto:"+mailAddress+"\">"+mailAddress+"</a><br />";
			else mailAddress = "-<br />";
			
			if (webURL != "") webURL = "<a href=\"http://"+webURL+"\" target=\"_blank\">"+webURL+"</a><br />";
			else webURL = "-<br />";
			
			document.getElementById("phoneNumber_"+id).innerHTML 	= phoneNumber;
			document.getElementById("faxNumber_"+id).innerHTML 		= faxNumber;
			document.getElementById("mailAddress_"+id).innerHTML 	= mailAddress;
			document.getElementById("webURL_"+id).innerHTML 		= webURL;		
			
			document.getElementById("agenceRdv_"+id).href = "javascript:openPopup('/immobilier/popup/rendez-vous.php?agence="+agencyId+"&bien="+propertyId+"','form',560,620,'scrollbars=yes');";
			document.getElementById("agenceEcrire_"+id).href = "javascript:openPopup('/immobilier/popup/ecrire-agence.php?agence="+agencyId+"&bien="+propertyId+"','form',560,600,'scrollbars=yes');";
			
			document.getElementById("agenceSelect_"+id).href = "javascript: openPopup('/immobilier/popup/selection.php?id="+propertyId+"&type="+transactionBien+"','selection',330,370);";
			document.getElementById("agenceAmi_"+id).href = "javascript:openPopup('/immobilier/popup/envoi-ami.php?id="+propertyId+"','ami',560,400,'scrollbars=yes');";
			
			document.getElementById('detail'+id).style.display = '';
			document.getElementById('link'+id).style.display = 'none';
		}
	}
	
}

function hideDetail(id){
	document.getElementById('detail'+id).style.display = 'none';
	document.getElementById('link'+id).style.display = '';
}


/***** 20 - Navigation *****/
var lastNav = '';
function showMenu(id){
	if(lastNav != ''){
		hideMenu(lastNav);
	}
	document.getElementById(id).className += ' hover';
	lastNav = id;
}

function hideMenu(id){
	document.getElementById(id).className = document.getElementById(id).className.substring(0,document.getElementById(id).className.length-6);
	lastNav = '';
}

/***** 25 - Popup *****/
function openPopup(url,name,w,h,o){
	window.open(url,name,'width='+w+',height='+h+',resizable=0,'+o);
}

/***** 30 - Selection region *****/
var regionFind = false;
function selectRegion(id,n){
	var optionTab = opener.document.getElementById(id).getElementsByTagName('option');
	for(i=0; i<optionTab.length; i++){
		if(optionTab[i].value == n){
			optionTab[i].selected = true;
			opener.unlockSList();
			regionFind = true;
			region = optionTab[i].value;
		}
	}

	if(regionFind == true && (id == "mySearchList" || id == "advancedSearchList"))
	{
		getVille(region,'citiesBiensPop');
		window.close();
	}
	else if(regionFind == true && id == "cibleSearchList")
	{
		window.close();
	}
	else
	{
		if (!confirm("Aucun bien n'a Ã©tÃ© trouvÃ© dans cette rÃ©gion. Voulez-vous chercher dans une autre ?")) {
			window.close();
		}
	}
}

function selectList (obj,loc)
{
	var arrOptions = document.getElementById(obj).getElementsByTagName('option');
	for(i=0; i<arrOptions.length; i++){
		if(arrOptions[i].value == loc){
			arrOptions[i].selected = true;
		}
	}
}

/***** 50 - Ajax *****/
function file(fichier)
{
	if(window.XMLHttpRequest) { // FIREFOX
		xhr_object = new XMLHttpRequest();
	} else if(window.ActiveXObject) { // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		return(false);
	}
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	if(xhr_object.readyState == 4) {
		return(xhr_object.responseText);
	} else {
		return(false);
	}
}

function writediv(texte,obj) {
	if(obj == "agences") document.getElementById("citiesAgences").innerHTML = texte;
	else if(obj == "citiesBiens" || obj == "citiesBiensLoad") {
		document.getElementById("citiesBiens").innerHTML = texte;
		if (obj != "citiesBiensLoad") unlockSList("large");
	}
	else if(obj == "citiesBiensPop") {
		opener.document.getElementById("citiesBiens").innerHTML = texte;
		unlockSList("largePop");
	}
	else if(obj == "regionsBiens" || obj == "regionsBiensLoad" || obj == "regionsBiensAvance" || obj == "regionsBiensAvanceLoad") {
		document.getElementById("regionsBiens").innerHTML = texte;
		if(obj != "regionsBiensLoad" && obj != "regionsBiensAvanceLoad") unlockSList("citiesBiens");
	}
	else if(obj == "search") {
		/*if(document.getElementById("mySearch")) {
			document.getElementById("searchbox").style.left = (document.getElementById("mySearch").offsetLeft+10) +'px';
			document.getElementById("searchbox").style.top = (document.getElementById("mySearch").offsetTop+172) +'px';
		}
		else if(document.getElementById("advancedSearch")) {
			document.getElementById("searchbox").style.left = (document.getElementById("advancedSearch").offsetLeft+208) +'px';
			document.getElementById("searchbox").style.top = (document.getElementById("advancedSearch").offsetTop+135) +'px';
		}*/	
		document.getElementById("searchbox").style.visibility = "visible";
		document.getElementById("searchbox").style.display = "block";
		document.getElementById("searchbox").innerHTML = texte;
		var helpDiv = document.getElementById('searchbox');
		if(!isOpera && document.all){
			if(!document.getElementById('helpSyntax')){
				document.getElementById('autosearch').innerHTML = '\n<iframe id="helpSyntax" frameborder="0" style="display:none;z-index:15;position:absolute;width:'+helpDiv.offsetWidth+'px;height:'+helpDiv.offsetHeight+'px;"></iframe>\n';
			}
			document.getElementById('helpSyntax').style.display = '';
			document.getElementById('helpSyntax').style.visibility = 'visible';
		}
	}
}

function getReg(obj) {

	if(document.FormMaRecherche.transactionType[0].checked) transaction_type = document.FormMaRecherche.transactionType[0].value;
	else if(document.FormMaRecherche.transactionType[1].checked) transaction_type = document.FormMaRecherche.transactionType[1].value;
	
	if (obj == "regionsBiensAvance" || obj == "regionsBiensAvanceLoad")
	{	
		arr_property = new Array();
		if(document.FormMaRecherche.maison.checked) arr_property.push("Maison");
		if(document.FormMaRecherche.appartement.checked) arr_property.push("Appartement");
		if(document.FormMaRecherche.terrain.checked) arr_property.push("Terrain");
		if(document.FormMaRecherche.immeuble.checked) arr_property.push("Immeuble");
		if(document.FormMaRecherche.local.checked) arr_property.push("Local");
		if(document.FormMaRecherche.commerce.checked) arr_property.push("Fond de commerce");
		if(document.FormMaRecherche.parking_garage_box.checked) arr_property.push("Parking");
		property_type = arr_property.join();
		urlReg = "/includes/modules/rechercheBiens/getRegionsBiens.php?type="+transaction_type+"&property="+property_type+"&recherche=avance";
	}
	else
	{
		if(document.FormMaRecherche.propertyType[0].checked) property_type = document.FormMaRecherche.propertyType[0].value;
		else if(document.FormMaRecherche.propertyType[1].checked) property_type = document.FormMaRecherche.propertyType[1].value;
		urlReg = "/includes/modules/rechercheBiens/getRegionsBiens.php?type="+transaction_type+"&property="+property_type+"&recherche=normal";
	}
	
	if(texte = file(urlReg)) {
		if(texte != "")	{
			writediv(texte,obj);
		}
	}
}

function getVille(loc,obj) {
	if(loc != "") {
		if(obj == "agences") {
			url  = "trouverAgence/getVillesAgences.php";
			url2 = "";
		}
		else if(obj == "citiesBiens" || obj == "citiesBiensLoad") {
			if(obj != "citiesBiensLoad") {
				document.FormMaRecherche.libreCP.value = "";
				document.FormMaRecherche.libre.value = "";
			}
			
			if(document.FormMaRecherche.transactionType[0].checked) transaction_type = document.FormMaRecherche.transactionType[0].value;
			else if(document.FormMaRecherche.transactionType[1].checked) transaction_type = document.FormMaRecherche.transactionType[1].value;
			
			if (document.FormMaRecherche.propertyType)
			{
				if(document.FormMaRecherche.propertyType[0].checked) property_type = document.FormMaRecherche.propertyType[0].value;
				else if(document.FormMaRecherche.propertyType[1].checked) property_type = document.FormMaRecherche.propertyType[1].value;
			}
			else
			{
				arr_property = new Array();
				if(document.FormMaRecherche.maison.checked) arr_property.push("Maison");
				if(document.FormMaRecherche.appartement.checked) arr_property.push("Appartement");
				if(document.FormMaRecherche.terrain.checked) arr_property.push("Terrain");
				if(document.FormMaRecherche.immeuble.checked) arr_property.push("Immeuble");
				if(document.FormMaRecherche.local.checked) arr_property.push("Local");
				if(document.FormMaRecherche.commerce.checked) arr_property.push("Fond de commerce");
				if(document.FormMaRecherche.parking_garage_box.checked) arr_property.push("Parking");
				property_type = arr_property.join();
			}
			
			url  = "rechercheBiens/getVillesBiens.php";
			url2 = "&type="+transaction_type+"&property="+property_type;
		}
		else if(obj == "citiesBiensPop") {
			opener.document.FormMaRecherche.libreCP.value = "";
			opener.document.FormMaRecherche.libre.value = "";
		
			if(opener.document.FormMaRecherche.transactionType[0].checked) transaction_type = opener.document.FormMaRecherche.transactionType[0].value;
			else if(opener.document.FormMaRecherche.transactionType[1].checked) transaction_type = opener.document.FormMaRecherche.transactionType[1].value;
			
			if (opener.document.FormMaRecherche.propertyType)
			{
				if(opener.document.FormMaRecherche.propertyType[0].checked) property_type = opener.document.FormMaRecherche.propertyType[0].value;
				else if(opener.document.FormMaRecherche.propertyType[1].checked) property_type = opener.document.FormMaRecherche.propertyType[1].value;
			}
			else
			{
				arr_property = new Array();
				if(opener.document.FormMaRecherche.maison.checked) arr_property.push("Maison");
				if(opener.document.FormMaRecherche.appartement.checked) arr_property.push("Appartement");
				if(opener.document.FormMaRecherche.terrain.checked) arr_property.push("Terrain");
				if(opener.document.FormMaRecherche.immeuble.checked) arr_property.push("Immeuble");
				if(opener.document.FormMaRecherche.local.checked) arr_property.push("Local");
				if(opener.document.FormMaRecherche.commerce.checked) arr_property.push("Fond de commerce");
				if(opener.document.FormMaRecherche.parking_garage_box.checked) arr_property.push("Parking");
				property_type = arr_property.join();
			}
			
			url  = "rechercheBiens/getVillesBiens.php";
			url2 = "&type="+transaction_type+"&property="+property_type;
		}
		if(texte = file("/includes/modules/"+url+"?loc="+escape(loc)+url2)) {
			if(texte != "")	{
				writediv(texte,obj);
			}
		}
	}
	else {
		unlockSList(obj);
	}
}

function searchPreview(like,nbCaracteresMin) {

	document.FormMaRecherche.regBiens.value = "";
	unlockSList("citiesBiens");
	document.FormMaRecherche.large[0].disabled = (document.FormMaRecherche.libre.value != '')? '' : 'disabled';
	document.FormMaRecherche.large[1].disabled = (document.FormMaRecherche.libre.value != '')? '' : 'disabled';
	document.FormMaRecherche.large[2].disabled = (document.FormMaRecherche.libre.value != '')? '' : 'disabled';
	document.FormMaRecherche.large[3].disabled = (document.FormMaRecherche.libre.value != '')? '' : 'disabled';

	if(like != "" && isNaN(like.substring(0,1)) && like.length >= nbCaracteresMin) {
		
		like = like.toLowerCase();
		
		document.getElementById("searchbox").style.visibility = "hidden";
		document.getElementById("searchbox").style.display = "none";	
		document.getElementById("searchbox").innerHTML = "";
		
		/* On cherche la chaine dans le tableau javascript s'il existe */
		if(tabSearchVilles != "" && like.length > nbCaracteresMin) {
			if(tabSearchVilles[0].indexOf("::") == -1) {
				
				if(like.indexOf("(") > 0) like = like.substring(0,like.indexOf("(")-1)
				like = like.trim ();
				
				cpt = 0;
				texthtml  = "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
				var trouve = false;
				for(keyVar in tabSearchVilles) {
				
					tmp = tabSearchVilles[keyVar].split("_");
					if(tmp[1].substring(0,like.length) == getNormalizedCity(like)) {
					   	dpt 	= tmp[0];
					   	city 	= tmp[1];
					   
						if ((cpt%2) == 0) rowcls = "gris";
						else rowcls = "blanc";
						
						texthtml += "<tr class='txt11 "+rowcls+"'><td style='padding-left:5px;'><a href=\"#0\" onclick=\"setSearch('"+dpt+"','"+city+"');unlockSList('large');\" class='txt11'>"+city+" ("+dpt+")</a></td></tr>";
						trouve = true;
						cpt++;
					}
				}
				if(trouve == false) texthtml = "<a href=\"#0\" onclick=\"setSearch('','')\" class='txt11'>Aucun element ne correspond a la demande.</a>";
				texthtml += "</table>\n";
			}
			else {
				texthtml = "<a href=\"#0\" onclick=\"setSearch('','')\" class='txt11'>"+tabSearchVilles[0].replace("::","")+"</a>";
			}
			writediv(texthtml,"search");
		}
		else if(texte = file("/includes/modules/rechercheBiens/getVillesSearch.php?search="+escape(like))) {
		/* On execute sinon le script pour recuperer un tableau des villes commencant par la chaine recherchee */
			if(texte != "")	{
				if(texte.indexOf("::") == -1) {
					cpt = 0;
					tabSearchVilles = texte.split(",");
					
					texthtml  = "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
					for(keyVar in tabSearchVilles) {
						
						tmp 	= tabSearchVilles[keyVar].split("_");
					   	dpt	= tmp[0];
					   	city 	= tmp[1];
					   
						if ((cpt%2) == 0) rowcls = "gris";
						else rowcls = "blanc";
						
						texthtml += "<tr class='txt11 "+rowcls+"'><td style='padding-left:5px;'><a href=\"#0\" onclick=\"setSearch('"+dpt+"','"+city+"');unlockSList('large');\" class='txt11'>"+city+" ("+dpt+")</a></td></tr>";
						cpt++;
					}
					texthtml += "</table>\n";
				}
				else {
					tabSearchVilles = texte.split(",");
					texthtml = "<a href=\"#0\" onclick=\"setSearch('','')\" class='txt11'>"+texte.replace("::","")+"</a>";
				}
				writediv(texthtml,"search");
			}}
		
	}
	else if(like.length < nbCaracteresMin) {
		document.getElementById("searchbox").style.visibility = "hidden";
		document.getElementById("searchbox").style.display = "none";	
		document.getElementById("searchbox").innerHTML = "";
		if(!isOpera && document.all){
			if(document.getElementById('helpSyntax')){
				document.getElementById('helpSyntax').style.display = 'none';
				document.getElementById('helpSyntax').style.visibility = 'hidden';
			}
		}
	}

}

function reg_replace(chaine,char1,char2) {
	var reg = new RegExp(char1, "ig");
	nouv_chaine  = chaine.replace(reg,char2);
	return nouv_chaine;
}

function getNormalizedCity(chaine) {
	/* Remplacement des apostrophes par des espaces */
	chaine = reg_replace(chaine,"'"," ");
	
	/* Remplacement des tirets par des espaces */
	chaine = reg_replace(chaine,"-"," ");
	
	/* Convertion des caracteres accentues en leur equivalent ASCII */
	chaine = reg_replace(chaine,"['Ã Ã¢Ã¤']","a");
	chaine = reg_replace(chaine,"['Ã©Ã¨ÃªÃ«']","e");
	chaine = reg_replace(chaine,"['Ã®Ã¯']","i");
	chaine = reg_replace(chaine,"['Ã´Ã¶']","o");
	chaine = reg_replace(chaine,"['Ã¹Ã»Ã¼']","u");
	
	/* Mise en majuscule de toutes les premieres lettres de la chaine */
	var elements 	= chaine.split(" ");
	for(key in elements) {
		elements[key] = elements[key].substring(0,1).toUpperCase() + elements[key].substring(1,elements[key].length);
	}
	chaine = elements.join(" ");
	return chaine;
}

function setSearch(str1,str2) {
	
	if(str1 != "" && str2 != "")
	{
		document.FormMaRecherche.regBiens.value = "";
		
	}
	unlockSList("citiesBiens");

	document.forms.FormMaRecherche.libreCP.value = str1;
	document.forms.FormMaRecherche.libre.value   = str2;
	if(str1 != "") document.forms.FormMaRecherche.libre.value += " ("+str1.substring(0,2)+")";

	document.getElementById("searchbox").style.visibility = "hidden";
	document.getElementById("searchbox").style.display = "none";	
	document.getElementById("searchbox").innerHTML = "";
	if(!isOpera && document.all){
		document.getElementById('helpSyntax').style.display = 'none';
		document.getElementById('helpSyntax').style.visibility = 'hidden';
	}
}

function showFiche(obj,propertyId,nav,cpt)
{
	if(document.all && !isOpera && document.getElementById('flayerinfo') || !document.all || isOpera){
		hideInfo();
		
		Xpos = obj.offsetParent.offsetLeft;
		Ypos = obj.offsetParent.offsetTop;
		
		if(propertyId != "" && (texte = file("/immobilier/annonces-immobilieres/getFicheSearch.php?search="+escape(propertyId)+"&nav="+nav+"&cpt="+cpt)))
		{
			if(texte != "")
			{
				tabSearchFiche 		= texte.split("|");
				transactionType 	= tabSearchFiche[0];
				propertyType 		= tabSearchFiche[1];
				city 			= tabSearchFiche[2];
				contratPrivilege2	= tabSearchFiche[3];
				sellingPrice 		= tabSearchFiche[4];
				roomsQuantity 		= tabSearchFiche[5];
				surface 		= tabSearchFiche[6];
				surfaceUnit 		= tabSearchFiche[7];
				departementId 		= tabSearchFiche[8];
				desc 			= tabSearchFiche[9];
				groundSurface 		= tabSearchFiche[10];
				bedroomsQuantity 	= tabSearchFiche[11];
				floorsQuantity 		= tabSearchFiche[12];
				mainVisu		= tabSearchFiche[13];
				subVisus		= tabSearchFiche[14];
				
				var infosfiche = "<strong>"+sellingPrice+" &euro;</strong> * <strong>   - "+propertyType;
				if (roomsQuantity != "" && roomsQuantity > 0) infosfiche += " "+roomsQuantity+" pi&egrave;ce(s)";
				if (surface != "") infosfiche +=  " / "+surface+" "+surfaceUnit;
				infosfiche += "</strong><br />"+city+" ("+departementId+")";
				document.getElementById("infosFiche").innerHTML = infosfiche;
				document.getElementById("descFiche").innerHTML = desc;

				if (contratPrivilege2 == 1) document.getElementById("contratPrivilege").style.display = "block";
				else document.getElementById("contratPrivilege").style.display = "none";

				if (groundSurface != "") document.getElementById("surfaceFiche").innerHTML = groundSurface+" "+surfaceUnit;
				else document.getElementById("surfaceFiche").innerHTML = "-";
				document.getElementById("nbChambresFiche").innerHTML = bedroomsQuantity;
				
				if(floorsQuantity > 0) nbEtages = floorsQuantity;
				else nbEtages = "-";
				document.getElementById("nbEtagesFiche").innerHTML = nbEtages;
				
				/* Visuels */
				if(mainVisu != "") document.getElementById("visuFiche").innerHTML = mainVisu;
				if(subVisus != "") document.getElementById("thumbFiche").innerHTML = subVisus+"\n<div class=\"clear\"></div>\n";
				
				// Clear & appel
				clearTimeout(timeInfo);
				timeInfo = setTimeout("showInfo('',"+obj.offsetTop+","+obj.offsetLeft+");",500);
			}
		}
	}
}

function getForm(nb)
{
	document.getElementById("err").innerHTML = "";

	var cnom = document.FormSubscribtion.cnom.value;
	var ccp  = document.FormSubscribtion.cCP.value;
	var cnum = document.FormSubscribtion.cnum.value;
	var show = 1;

	if((ccp != "" || cnum != "") && (texte = file("/immobilier/mon-espace-laforet/getForm.php?cnom="+cnom+"&ccp="+ccp+"&cnum="+cnum)))
	{
		if(texte != "")
		{
			if(texte.indexOf("::") == -1)
			{
				tabForm 		= texte.split("|");
				
				civ			= tabForm[0];
				prenom			= tabForm[1];
				ccp2			= tabForm[2];
				cnum2 			= tabForm[3];
				adresse1 		= tabForm[4];
				adresse2 		= tabForm[5];
				cp	 		= tabForm[6];
				ville	 		= tabForm[7];
				tel	 		= tabForm[8];
				
				if (nb == 1)
				{
					if (civ == "m") document.FormSubscribtion.civilite[0].checked = true;
					else if (civ == "Mme") document.FormSubscribtion.civilite[1].checked = true;
					else if (civ == "mlle") document.FormSubscribtion.civilite[2].checked = true;
					document.FormSubscribtion.cprenom.value 	= prenom;
					
					if(ccp == "" && cnum != "" && ccp2 != "")
					{
						show = 0;
						openPopup('/immobilier/mon-espace-laforet/popup/profil-contrat-privilege.php','contrat',541,300);
					}
					else document.FormSubscribtion.cCP.value = ccp2;
					
					document.FormSubscribtion.cnum.value 		= cnum2;
					document.FormSubscribtion.cadrs.value 		= adresse1;
					document.FormSubscribtion.cadrs2.value 		= adresse2;
					document.FormSubscribtion.cp.value 		= cp;
					document.FormSubscribtion.cville.value 		= ville;
					document.FormSubscribtion.ctel.value 		= tel;
				}
				
				var arrDisabledFields 		= new Array ();
				arrDisabledFields['civilite'] 	= 1;
				arrDisabledFields['cprenom'] 	= 1;
				arrDisabledFields['cnom'] 	= 1;
				arrDisabledFields['cCP'] 	= 1;
				arrDisabledFields['cnum'] 	= 1;
				arrDisabledFields['cadrs'] 	= 1;
				arrDisabledFields['cadrs2'] 	= 1;
				arrDisabledFields['cp'] 	= 1;
				arrDisabledFields['cville'] 	= 1;
				arrDisabledFields['ctel'] 	= 1;
				
				if (nb == 2)
				{
					var arrPericlesFields 	= new Array ();					
					periclesFields 		= document.FormSubscribtion.periclesFields.value;
					arrPericlesFields 	= periclesFields.split(',');
					
					arrDisabledFields['civilite'] 	= 0;
					arrDisabledFields['cprenom'] 	= 0;
					arrDisabledFields['cnom'] 	= 0;
					arrDisabledFields['cCP'] 	= 0;
					arrDisabledFields['cnum'] 	= 0;
					arrDisabledFields['cadrs'] 	= 0;
					arrDisabledFields['cadrs2'] 	= 0;
					arrDisabledFields['cp'] 	= 0;
					arrDisabledFields['cville'] 	= 0;
					arrDisabledFields['ctel'] 	= 0;
					
					for (i = 0; i < arrPericlesFields.length; i++)
					{
						if (arrPericlesFields[i] == "civilite") arrDisabledFields['civilite'] 	= 1;
						if (arrPericlesFields[i] == "cprenom") 	arrDisabledFields['cprenom'] 	= 1;
						if (arrPericlesFields[i] == "cnom") 	arrDisabledFields['cnom'] 	= 1;
						if (arrPericlesFields[i] == "cCP") 	arrDisabledFields['cCP'] 	= 1;
						if (arrPericlesFields[i] == "cnum") 	arrDisabledFields['cnum'] 	= 1;
						if (arrPericlesFields[i] == "cadrs") 	arrDisabledFields['cadrs'] 	= 1;
						if (arrPericlesFields[i] == "cadrs2") 	arrDisabledFields['cadrs2'] 	= 1;
						if (arrPericlesFields[i] == "cp") 	arrDisabledFields['cp'] 	= 1;
						if (arrPericlesFields[i] == "cville") 	arrDisabledFields['cville'] 	= 1;
						if (arrPericlesFields[i] == "ctel") 	arrDisabledFields['ctel'] 	= 1;
					}
				}
				
				if ((document.FormSubscribtion.civilite[0].checked || document.FormSubscribtion.civilite[1].checked || document.FormSubscribtion.civilite[2].checked)  && arrDisabledFields['civilite'] == 1)
				{
					document.FormSubscribtion.civilite[0].disabled = "disabled";
					document.FormSubscribtion.civilite[1].disabled = "disabled";
					document.FormSubscribtion.civilite[2].disabled = "disabled";
				}
				if (document.FormSubscribtion.cprenom.value != '' && arrDisabledFields['cprenom'] == 1) document.FormSubscribtion.cprenom.disabled 	= "disabled";
				if (document.FormSubscribtion.cnom.value != '' && arrDisabledFields['cnom'] == 1) 	document.FormSubscribtion.cnom.disabled 	= "disabled";
				if (document.FormSubscribtion.cCP.value != '' && arrDisabledFields['cCP'] == 1) 	document.FormSubscribtion.cCP.disabled 		= "disabled";
				if (document.FormSubscribtion.cnum.value != '' && arrDisabledFields['cnum'] == 1) 	document.FormSubscribtion.cnum.disabled 	= "disabled";
				if (document.FormSubscribtion.cadrs.value != '' && arrDisabledFields['cadrs'] == 1) 	document.FormSubscribtion.cadrs.disabled 	= "disabled";
				if (document.FormSubscribtion.cadrs2.value != '' && arrDisabledFields['cadrs2'] == 1) 	document.FormSubscribtion.cadrs2.disabled 	= "disabled";
				if (document.FormSubscribtion.cp.value != '' && arrDisabledFields['cp'] == 1) 		document.FormSubscribtion.cp.disabled 		= "disabled";
				if (document.FormSubscribtion.cville.value != '' && arrDisabledFields['cville'] == 1) 	document.FormSubscribtion.cville.disabled 	= "disabled";
				if (document.FormSubscribtion.ctel.value != '' && arrDisabledFields['ctel'] == 1) 	document.FormSubscribtion.ctel.disabled 	= "disabled";
			}
			else
			{
				show = 0;
				document.getElementById("err").innerHTML = texte.replace("::","");
				document.getElementById("errLine").style.display = "";
			}
		}
	}
	if(show == 1)
	{
		for(i=0;i<=12;i++){
			document.getElementById('formLine'+i).style.display = "";
		}
		document.getElementById("btn2").style.visibility  = "hidden";
	}
}

function alerteMail(recherche,val)
{
	if(val == 0 || val == 1)
	{
		texte = file("/immobilier/mon-espace-laforet/getFonctions.php?fonction=alerteMail&recherche="+recherche+"&val="+val);
		
		if (val == 0)
		{
			document.getElementById('alerte'+recherche+'_1').style.display = "none";
			document.getElementById('alerte'+recherche+'_0').style.display = "";
		}
		else
		{
			document.getElementById('alerte'+recherche+'_0').style.display = "none";
			document.getElementById('alerte'+recherche+'_1').style.display = "";
		}
	}
}

/***** 60 - Espace Laforet *****/
function afficheForm(val)
{
	if(val == 1)
	{
		for(i=0;i<=12;i++){
			opener.document.getElementById('formLine'+i).style.display = "";
		}
		opener.document.getElementById("btn2").style.visibility = "hidden";
	}
	window.close();	
}

function submitIdentification (obj)
{
	// Scan des INPUT
	var inputTable = document.getElementsByTagName('input');
	var resultTable = new Array();
	j = 0;
	for(i=0; i<inputTable.length; i++){
	
		// Inputs resultats
		if (inputTable[i].name != "" && eval("obj."+(inputTable[i].name)))
		{
			if(inputTable[i].disabled){ 
				inputTable[i].disabled = '';
				resultTable[j] = inputTable[i].name;
				j++;
			}
		}
	}
	document.FormSubscribtion.periclesFields.value = resultTable.join ();
	obj.submit();
}

function saisiePassword (obj,action)
{
	if (action == 1 && obj.value == "****") obj.value = "";
	else if (action == 2 && obj.value == "") obj.value = "****";
}

/***** 55 - Module "Trouver une agence" *****/
function testListeAgences()
{
	if(document.FormTrouverAgence.dptAgences.selectedIndex <= 0) return;
	else {
		indexDpt   = document.FormTrouverAgence.dptAgences.selectedIndex;
		indexVille = document.FormTrouverAgence.villeAgences.selectedIndex;
		dpt	   = document.FormTrouverAgence.dptAgences[document.FormTrouverAgence.dptAgences.selectedIndex].value;
		ville	   = document.FormTrouverAgence.villeAgences[document.FormTrouverAgence.villeAgences.selectedIndex].value;

		url = document.FormTrouverAgence.action+"?dpt="+dpt+"&indexDpt="+indexDpt;
		if(indexVille > 0) {
			url += "&ville="+ville+"&indexVille="+indexVille;
		}
		document.location = url;
	}
}

function changePage(objForm,currentpage)
{
	eval("document."+objForm+".currentpage.value = "+currentpage+";");
	eval("document."+objForm+".submit();");
}

function chargeFiche(agence)
{
	document.FormFicheAgence.agence.value = agence;
	document.FormFicheAgence.submit();
}

/***** 65 - Controle des formulaires *****/
function checkEmail(email)
{
	var re = new RegExp("^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,3}");
	var test = email.search(re);
	if(test != -1) return true;
	else {
		alert("Adresse email incorrecte");
		return false;
	}
}

function testFormHeader()
{
	var cp 	= document.FormHeaderTrouverAgence.ville.value;
	var reg = /^\d{0,5}$/;
	if(!reg.test(cp))
	{
		document.location = document.FormHeaderTrouverAgence.action + "?search=nok";
		return false;
	}
	else return true;
}

function testReference()
{
	if(document.FormReference.id.value == "") return false;
}

function testMaRecherche()
{
	if(!document.FormMaRecherche.maison.checked && !document.FormMaRecherche.appartement.checked && !document.FormMaRecherche.terrain.checked && !document.FormMaRecherche.immeuble.checked && !document.FormMaRecherche.local.checked && !document.FormMaRecherche.commerce.checked && !document.FormMaRecherche.parking_garage_box.checked)
	{
		document.getElementById('alertForm').innerHTML = "Veuillez choisir au moins un type de bien pour votre recherche.";
		document.getElementById('alertForm').style.display = "block";
		return false;
	}
	else
	{
		document.getElementById('alertForm').innerHTML = "";
		document.getElementById('alertForm').style.display = "none";
	}
}

function testTri (page,query,tri)
{
	if (tri != 00)
	{
		var pos = query.indexOf('&tri=');
		if (pos > -1) location.href = page + "?" + query.substr(0,pos) + "&tri=" + tri;
		else location.href = page + "?" + query + "&tri=" + tri;
		
	}
}

function plusCriteres (obj)
{
	if (obj == "FormMaRecherche") {
		document.FormMaRecherche.action = "/immobilier/annonces-immobilieres/annonce-immobilier.php";
		document.FormMaRecherche.submit ();
	} 
	else if (obj == "FormRechercheCiblee") {
		document.FormRechercheCiblee.action = "/immobilier/annonces-immobilieres/annonce-immobilier.php";
		document.FormRechercheCiblee.submit ();
	}
}

/***** 80- Google Maps *****/
function openWin(url)   
{     
	googlemap = window.open(url,'googlemap','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=650,height=450');
}

/***** 99 - onLoad *****/
window.onload = function(){
	
	// 05 - Affichage / Masquage layer information
	if(document.getElementById('infoLayer')){
		document.getElementById('infoLayer').onmouseover = function(){ clearTimeout(timeInfo); }
		document.getElementById('infoLayer').onmousemove = function(){ clearTimeout(timeInfo); }
		document.getElementById('infoLayer').onmouseout = function(){ clearTimeout(timeInfo);  timeInfo = setTimeout("hideInfo();",500); }
		//ajout de l'iframe pour IE
		if(document.all && !isOpera){
			document.getElementById('resultats').innerHTML += '\n<iframe frameborder="0" id="flayerinfo" style="z-index:40;position:absolute;top:-999px;left:-999px;width:210px;height:150px;"></iframe>\n';
		}
	}
	
	// Scan des DIV
	var divTable = document.getElementsByTagName('div');
	var resultTable = new Array();
	diapoTable = new Array();
	for(i=0; i<divTable.length; i++){
		// Div resultats
		if(divTable[i].className == 'result'){ resultTable[resultTable.length] = divTable[i]; }
		if(divTable[i].className == 'diapo'){ diapoTable[diapoTable.length] = divTable[i]; }
	}
	
	var eventElem;
	for(i=0; i<resultTable.length; i++){
		eventElem = (resultTable[i].getElementsByTagName('div')[0].className == 'visu')? resultTable[i].getElementsByTagName('div')[0] : resultTable[i].getElementsByTagName('div')[1] ;
		eventElem.onmouseout = function(){ clearTimeout(timeInfo);  timeInfo = setTimeout("hideInfo();",500); }
	}
	
	// 15 - Diaporama
	buildDiapo();
	
	// 20 - Navigation
	var listTab = new Array();
	var sMenuTab = new Array();
	var timeMenu;
	if(document.getElementById('navtop')){
		listTab = document.getElementById('navtop').getElementsByTagName('li');
		for(i=0; i<listTab.length; i++){
			if(listTab[i].getElementsByTagName('div').length != 0){
				sMenuTab[sMenuTab.length] = listTab[i];
			}
		}
		
		for(i=0; i<sMenuTab.length; i++){
			//Attribution des ID
			sMenuTab[i].id = 'menu'+i;
			//Evenement
			sMenuTab[i].onmouseover = function(){ showMenu(this.id); }
			sMenuTab[i].onmouseout = function(){ timeMenu = setTimeout('hideMenu(\''+this.id+'\');',50); }
			sMenuTab[i].onmousemove = function(){ clearTimeout(timeMenu); }
		}
		//ajout de l'iframe pour IE
		if(document.all && !isOpera){
			for(i=0; i<sMenuTab.length; i++){
				reactDiv = sMenuTab[i].getElementsByTagName('div')[0];
				document.getElementById('menu'+i).innerHTML += '\n<iframe frameborder="0" id="fmen'+i+'" style="z-index:50;position:absolute;top:'+(reactDiv.offsetTop)+'px;left:'+reactDiv.offsetLeft+'px;width:'+reactDiv.offsetWidth+'px;height:'+(reactDiv.offsetHeight)+'px;"></iframe>\n';
			}
		}
	}
	
}
