﻿reseau = "/z/portail/svx/bellesdemeures/img/";
if(navigator.appName=='Netscape') var navigateur='firefox';
else if(navigator.appName=='Microsoft Internet Explorer') var navigateur='IE';
else var navigateur='autre';

/* old code */
/*var diaporama vertical - préliste */
var diapo_margin = 1;
var curScroll = 0;
var declencheur = 0;
var depart = 0;
var vignette_height = 52;

var TnbImg = new Array();
var TdiapoHeight = new Array();
var Tscrollmax = new Array();

var TcurScroll = new Array();
/* fin old code */

function id3_go(u) {document.location.href=u;}
TidLieu = new Array("petite_france", "paris", "alsace","aquitaine","auvergne","bassenormandie","bourgogne","bretagne","centre","champagneardenne","franchecomte","hautenormandie","languedocroussillon","limousin","lorraine","midipyrenees","nordpasdecalais","paysdelaloire","picardie","poitoucharentes","provencealpescotedazur","rhonealpes", "corse", "domtom");
TdivLieu = new Array("", "2238", "2228", "2229", "2230", "2231", "2232", "2233", "2234", "2235", "2237", "2236", "2239", "2240", "2241", "2242", "2243", "2247", "2244", "2245", "2246", "2251", "", "");
Tdepartement = new Array("", "75", "68", "33", "15", "76", "58", "29", "18", "52", "90", "02", "48", "87", "88", "65", "59", "44", "02", "17", "00", "07", "20", "974,973,972,971,987");
Tcarto = new Array(TidLieu,TdivLieu,Tdepartement);
var iDcurCarto = 0;
var idMap = "default";
var idtt="8";
var cp="";
var argloca = "";
TableauCP = new Array();
//newTableauCP = new Array(); 
var div="";
var iddepartement="";
var query="";
var trancheprix="";
var surfacemin="";
var surfacemax="";
var pxmin="";
var pxmax="";
var si_piscine="";
var nb_balconsmin="";
var si_terrasse="";
var si_entretien="";
var si_cuisine="";
var si_securite="";
var si_bien_etre="";
var si_proche_golf="";
var idtypebien = "";
var idsituation = "";

idtypebien = new Array();
iddepartement = new Array();
var opaciteShow = 400;
var opaciteHide = 300;
var tri="&tri=d_px";


function affLieu(idMap) {
	if (idMap == "default"){
		$j("#intitule").text("Choisissez une région");
	}else{
		var libelle = document.getElementById(TidLieu[iDcurCarto]).title;
		var phrase = document.getElementById("intitule");
		phrase.innerHTML = "Votre sélection : "+libelle;
	}
}

function init() {
	cp="";
	div="";
	iddepartement="";
}

function defautCarte (mode) {
	affLieu("default");
	$j("#listepays2 div").remove();
	$j("#ville").val("");
	iDcurCarto = 0;
	argloca = "";
	
	if (mode == 0){
		$j("#carte_monde, .autosuggest").show();
		$j("#petite_france, #listepays2, .jScrollPaneContainer, #"+idMap).hide();
	}else{
		$j("#carte_monde").animate({ opacity: 'show' }, opaciteShow);
		$j("#petite_france, #listepays2, .jScrollPaneContainer, #"+idMap).animate({ opacity: 'hide' }, opaciteHide);
	}
	idMap = "default";
}

$j().ready(function() {
		init();
		$j("#carte_monde").animate({ opacity: 'show' });
		$j(".jScrollPanelContaine").animate({ opacity: 'show' });
		var elt_carte_monde = document.getElementById("carte_france");
		var elt_petite_france = document.getElementById("petite_france");
});

$j(function(){
	
		//onmouseOver sur une région
		$j("#France > area").mouseover(function (){
				if ( !$j("#intitule").hasClass("focus") ) $j("#intitule").text($j(this).attr('title'));
		});
		
		//onmouseOut sur une région
		$j("#France > area").mouseout(function (){
				if(iDcurCarto == 0)	affLieu("default");
		});
		
		//swap onglet achat
		$j("#oglachat").click(function (){
				resetCriteres();
				//$j("#engine_ogl").css({backgroundImage:"url('"+reseau+"bgengineachat.gif')"});
				$j("#engine_ogl").css({backgroundImage:"url('"+reseau+"bgengineachat2.gif')"});
				$j("#engine_tblocation div, #engine_pxlocation div").attr("class", "");
				$j("#engine_ogl span").css({ visibility: 'hidden' });
				$j("#engine_tblocation, #engine_pxlocation").animate({ opacity: 'hide' }, 0);
				$j("#engine_tbachat, #engine_pxachat").animate({ opacity: 'show' }, 0);
				defautCarte (0);
				idtt=8;
				tri="&tri=d_px";
		});
		
		//swap onglet location
		$j("#oglloc").click(function (){
				resetCriteres();
				//$j("#engine_ogl").css({backgroundImage:"url('"+reseau+"bgengineloc.gif')"});
				$j("#engine_ogl").css({backgroundImage:"url('"+reseau+"bgengineloc2.gif')"});
				$j("#engine_ogl span").css({ visibility: 'hidden' });
				$j("#engine_tblocation, #engine_pxlocation").animate({ opacity: 'show' }, 0);
				$j("#engine_tbachat, #engine_pxachat").animate({ opacity: 'hide' }, 0);
				$j("#engine_tbachat div").attr("class", "");
				defautCarte (0);
				trancheprix = "&pxmin=5000";
				idtt=1;
				tri="&tri=d_px_loyer";
		});
		
		//swap onglet location saisonnière
		$j("#ogllocsais").click(function (){
				idtt=4;
				id3_go("/annonces.htm?idtt=4");
		});
		
		//swap du background sur les types de biens
		$j("#engine_tbachat div, #engine_tblocation div, #thematique div").click(function(){
				if ( $j(this).attr("class") == "choixtype" )
				{
					$j(this).removeClass();
				}else{
					$j(this).toggleClass("choixtype");
				}				
		});
		
		//swap du background sur les types de biens achat
		$j("#tbachat2, #tbachat14, #tbachat13, #tbachat228, #tbachat1, #tbachat9, #tbachat266, #tbachat252").click(function(){
				idtypebien = "";
				var id="";
				$j("#engine_tbachat div").each( function () {
						if ($j(this).hasClass('choixtype'))
						{

						    	if(idtypebien == "")
						    		virgule="";
						       else
						       	virgule = ",";
						      
									id = $j(this).attr("id").substring(7);
									//test si c'est un sous type de bien pour mettre le '.'
									if ( id.length == 3 ) id = id.charAt(0)+"."+id.charAt(1)+id.charAt(2);
						      
						      idtypebien = idtypebien+virgule+id;
						}
				});
				idtypebien = "&idtypebien="+idtypebien;
		});
		
		//swap du background sur les types de biens location et location saisonnières
		$j("#tblocat1, #tblocat2, #tblocat227, #tblocat13, #tblocat468").click(function(){
				idtypebien = "";
				var id="";
				$j("#engine_tblocation div").each( function () {
						if ($j(this).hasClass('choixtype'))
						{

						    	if(idtypebien == "")
						    		virgule="";
						       else
						       	virgule = ",";
						      
									id = $j(this).attr("id").substring(7);
									
									//test si c'est un sous type de bien pour mettre le '.'
									if ( id.length == 3 ) id = id.charAt(0)+"."+id.charAt(1)+id.charAt(2);
						      
						      idtypebien = idtypebien+virgule+id;
						}
				});

				if (idtypebien) idtypebien = "&idtypebien="+idtypebien;
				
		});
		
		//swap du background sur les prix achats
		$j("#engine_pxachat div").click(function(){
				$j("#engine_pxachat div").removeClass();
				$j(this).toggleClass("choixtype");
				if ( $j(this).attr("id") == "px10plus" ){
					trancheprix = "&pxmin=10000000";
				}else if( $j(this).attr("id") == "px3a10" ){
					trancheprix = "&pxmin=3000000&pxmax=10000000";
				}else if( $j(this).attr("id") == "px17a3" ){
					trancheprix = "&pxmin=1700000&pxmax=3000000";
				}else if( $j(this).attr("id") == "px11a17" ){
					trancheprix = "&pxmin=1100000&pxmax=1700000";
				}else if( $j(this).attr("id") == "pxmoins11" ){
					trancheprix = "&pxmax=1100000";
				}else{
					trancheprix = "";
				}
		});
		
		//swap du background sur les prix locations (vacances)
		$j("#engine_pxlocation div").click(function(){
				$j("#engine_pxlocation div").removeClass();
				$j(this).toggleClass("choixtype");
				if ( $j(this).attr("id") == "px15plus" ){
					trancheprix = "&pxmin=15000";
				}else if( $j(this).attr("id") == "px10a15" ){
					trancheprix = "&pxmin=10000&pxmax=15000";
				}else if( $j(this).attr("id") == "px75a10" ){
					trancheprix = "&pxmin=7500&pxmax=10000";
				}else if( $j(this).attr("id") == "px5a75" ){
					trancheprix = "&pxmin=5000&pxmax=7500";
				}else{
					trancheprix = "&pxmin=5000";
				}
		});
		
		//clic sur une région / département / pays
		$j("#engine_carte map > area").click(function (){

				//clic sur région
				if ($j(this).attr('id').substring(0, 4) == "area" && $j(this).attr('id') != "area_petite_france"  && $j(this).attr('id') != "area_international" && $j(this).attr('id') != "area_corse" && $j(this).attr('id') != "area_domtom" && $j(this).attr('id') != "area_idf")
				{
						$j("#carte_monde").animate({ opacity: 'hide' }, opaciteHide);
						
						//on supprime le prefixe 'area_' pour récupérer l'id
						idMap = $j(this).attr('id').substring(5);
						$j("#petite_france, #"+idMap).animate({ opacity: 'show' }, opaciteShow);
						$j("#ville").text($j(this).attr('title'));
						iDcurCarto = setCurrentLieu(idMap);
						div = TdivLieu[iDcurCarto];
						argloca = "&div="+div;
				
				}else if( $j(this).attr('id') == 'area_international' ){

					var qry="idtt="+idtt;
					
					$j.ajax({
										url: "js,ajax,getannpays.htm",
										data: qry,
										type: 'GET', 
								 		dataType: "html", 
								    timeout: 5000,
								    async: false,
										success: function(data) {
											
											idMap = 0;
											var qry="idtt="+idtt;
											iDcurCarto = "international";
											$j("#carte_monde").hide();
											$j("#petite_france").animate({ opacity: 'show' }, 900);
											
											$j("#listepays2").append(data);
											$j(".jScrollPaneContainer").show();
											$j('#listepays2').jScrollPane();
											$j("#listepays2").animate({ opacity: 'show' }, opaciteShow);
											$j("#intitule").text("Sélectionnez un pays pour lancer la recherche");
											
											$j("#listepays2 div").mouseover(function (){
													$j(this).css("border-bottom" , "1px solid #fff");
											});
											$j("#listepays2 div").mouseout(function (){
													$j(this).css("border-bottom" , "1px solid transparent");
											});
											
											//clic sur un pays
											$j("#listepays2 div").click(function (){
													id3_go("/recherche.htm?"+qry+"&tri=d_px&idpays="+$j(this).attr('id').substring(5, 8));
											});	
										},
										error: function() {   
								    	alert("error");
								    }
					});
					
				}else if( $j(this).attr('id') == 'area_idf' ){
					
					iDcurCarto = "idf";
					idMap = $j(this).attr('id').substring(5);
					
					$j("#petite_france, #"+idMap).animate({ opacity: 'show' }, opaciteShow);
					$j("#carte_monde").animate({ opacity: 'hide' }, opaciteHide);
					argloca = "&div=2238";
					$j("#ville").attr('value', 'Île-de-France');
					
				}else if( $j(this).attr('id') == 'area_corse' ){

					iDcurCarto = "corse";
					idMap = $j(this).attr('id').substring(5);
					
					$j("#petite_france, #"+idMap).animate({ opacity: 'show' }, opaciteShow);
					$j("#carte_monde").animate({ opacity: 'hide' }, opaciteHide);
					argloca = "&cp=2A,2B";
					
				}else if( $j(this).attr('id') == 'area_domtom' ){

					iDcurCarto = "domtom";
					idMap = $j(this).attr('id').substring(5);
					
					$j("#petite_france, #"+idMap).animate({ opacity: 'show' }, opaciteShow);
					$j("#carte_monde").animate({ opacity: 'hide' }, opaciteHide);
					argloca = "&cp=974,973,972,971,987";
					$j("#intitule").attr('value', 'Départements d\'Outre-Mer');

				}else if ( $j(this).attr('id') == "area_petite_france" ) {
						
					defautCarte(1);

				}else{
					//clic sur département
					$j("#ville").attr('value', '');
					qry = "&ville="+$j(this).attr("id");
					
					$j.ajax({
										url: "js,ajax,getvillequery.htm",
										data: qry,
										type: 'GET', 
								 		dataType: "html", 
								    timeout: 5000,
								    async: false,
										success: function(data) {
											$j("#intitule").text(data);
											var decoupe1 = data.length-1;
											var decoupe2 = data.length-3;
											//alert(decoupe);
											argloca = "&cp="+data.substring(decoupe1, decoupe2);
										},
										error: function() {   
								    	alert("le serveur est momentanement indisponible");
								    }
					});
				}
		});
		
		//clic sur petite france
		$j("#smallfrance").click(function (){
				defautCarte(1);
		});
    
    //bouton du moteur
		$j("#btn_rechercher").click(function (){
				
				idtt = "idtt="+idtt;
				query = idtt+cp+pxmin+pxmax+argloca+idtypebien+trancheprix+tri;
				//alert(query);
				id3_go("/recherche.htm?"+query);
		});

});

function resetCriteres() {
	idtypebien="";
	trancheprix="";
	surfacemin="";
	surfacemax="";
	si_piscine="";
	nb_balconsmin="";
	si_terrasse="";
	si_entretien="";
	si_cuisine="";
	si_securite="";
	si_bien_etre="";
	si_proche_golf="";
	idsituation = "";
	$j("#surfacemin, #surfacemax").val("");
	$j("#si_piscine, #nb_balconsmin, #si_terrasse, #si_entretien, #si_cuisine, #si_securite, #si_bien_etre, #si_proche_golf").attr("checked", "");
}

function setCurrentLieu(idMap) {
	var i = 0;
	var max = TidLieu.length;
	while (TidLieu[i]!= idMap && i <= max)
	{
		i++;
	}	
	return i;
}

function setDepartement(iddep){
	
	//test si le département est présent
	if(($j.inArray(iddep, iddepartement) != -1) && (iddepartement != ""))
	{
		iddepartementTMP = new Array ();
		var j = 0;
		$j.each( iddepartement, function(i, val){
			if (val != iddep)
			{
				iddepartementTMP[j] = val;
				j++;
			}
		});
		iddepartement = iddepartementTMP;
	
	//sinon on l'ajoute à la suite
	}else{
		max = iddepartement.length;
		iddepartement[max] = iddep;
	}
}

function setPX(choix) {
	switch (choix){		
		case "achat1":
			pxmin = "";
			pxmax = "1100000";
		break;
		case "achat2":
			pxmin = "1100000";
			pxmax = "1700000";
		break;
		case "achat3":
			pxmin = "1700000";
			pxmax = "3000000";
		break;
		case "achat4":
			pxmin = "3000000";
			pxmax = "10000000";
		break;
		case "achat5":
 			pxmin = "10000000";
			pxmax = "";
 		break;
		case "location1":
			pxmin = "";
			pxmax = "5000";
		break;
		case "location2":
			pxmin = "7500";
			pxmax = "5000";
		break;
		case "location3":
			pxmin = "10000";
			pxmax = "7500";
		break;
		case "location4":
			pxmin = "15000";
			pxmax = "10000";
		break;
		case "location5":
 			pxmin = "15000";
			pxmax = "";
 		break;
 		default:
 			pxmin = "";
			pxmax = "";
 		break;
	}
}

function insertPrix (choix){
	o = document.getElementById("engine_prix");
	o1 = document.getElementById("pxmin");
	o2 = document.getElementById("pxmax");
	
	oDiv = o.getElementsByTagName("DIV");		
	for (var i = 0; i < 5; i++) {
    oDiv[i].className = "lib_prix";
  }
	switch (choix){		
		case "1":
			o1.value = "";
			o2.value = "1100000";
		break;
		case "2":
			o1.value = "1100000";
			o2.value = "1700000";
		break;
		case "3":
			o1.value = "1700000";
			o2.value = "3000000";
		break;
		case "4":
			o1.value = "3000000";
			o2.value = "";
		break;
		default:
 			o1.value = "";
			o2.value = "";
 		break;
	}

}

function getElementsByClassName(node, classname)
{
    var tbl = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
        if(re.test(els[i].className))tbl.push(els[i]);
    return tbl;
}<!-- ID3x v4.60 - X20 - static - 30/07/2010 15:28:02 - js\engine3.js -->