﻿reseau = "/z/portail/svx/basetestbd/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", "idf", "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="";
var cp="";
var ci = "";
TableauCP = new Array();
var div="";
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 si_ismh="";
var idtypebien = "";
var idsituation = "";
var idpays = "";
var tri="";

//idtypebien = new Array();
var opaciteShow = 400;
var opaciteHide = 300;

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() {
	
	idtt = $j("#idtt").attr('value');
	if ( $j("#idtypebien").attr('value') ) idtypebien = "&idtypebien="+$j("#idtypebien").attr('value');	
	pxmin = $j("#pxmin").attr('value');
	pxmax = $j("#pxmax").attr('value');
	if ( $j("#idsituation").attr('value') != "" )
	{
		idsituation = $j("#idsituation").attr('value');
	}else{
		idsituation = "";
	}
	
	if ($j("#si_piscine").is(":checked")) si_piscine = "&si_piscine=1";
	if ($j("#si_terrasse").is(":checked")) si_terrasse = "&si_terrasse=1";
	if ($j("#nb_balconsmin").is(":checked")) nb_balconsmin = "&nb_balconsmin=1";
	if ($j("#si_entretien").is(":checked")) si_entretien = "&si_entretien=1";
	if ($j("#si_cuisine").is(":checked")) si_cuisine = "&si_cuisine=1";
	if ($j("#si_securite").is(":checked")) si_securite = "&si_securite=1";
	if ($j("#si_bien_etre").is(":checked")) si_bien_etre = "&si_bien_etre=1";
	if ($j("#si_proche_golf").is(":checked")) si_proche_golf = "&si_proche_golf=1";
	if ($j("#si_ismh").is(":checked")) si_ismh = "&si_ismh=1";

	if(pxmin != "") trancheprix = "&pxmin="+pxmin;
	if(pxmax != "") trancheprix = trancheprix+"&pxmax="+pxmax;

	cp = $j("#cp").attr('value');
	div="";
	
	if ( $j("#idpays").attr('value') != "" ) idpays = "&idpays="+$j("#idpays").attr('value');
	
	tri = "&tri="+$j("#tri").attr('value');
	
	if (idtt == 1){
		$j("#engine_critav").css('background-image', 'url("/z/portail/svx/bellesdemeures/img/bg_engine_critavloc.gif")');
		$j("#engine_critav").css('height', '270px');
		
	}else if (idtt == 4){
			$j("#engine_critav").css('background-image', 'url("/z/portail/svx/bellesdemeures/img/bg_engine_critavlocvac.gif")');
			$j("#engine_critav").css('height', '250px');
	}
	
}

function defautCarte (mode) {
	affLieu("default");
	$j("#listepays2 div").remove();
	$j("#ville").val("");
	iDcurCarto = 0;
	argloca = "";
	idpays = "";
	
	if (mode == 0){
		$j("#carte_monde, .autosuggest").show();
		$j("#petite_france, #listepays2, #"+idMap).hide();
	}else{
		$j("#carte_monde, .autosuggest").animate({ opacity: 'show' }, opaciteShow);
		$j("#petite_france, #listepays2, .jScrollPaneContainer, #"+idMap).animate({ opacity: 'hide' }, opaciteHide);
	}
}

$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(){
		
		//debug
		$j().click(function(){
			//query = "idtt="+idtt+idtypebien+trancheprix+argloca+idsituation+surfacemin+surfacemax+si_piscine+nb_balconsmin+si_terrasse+si_entretien+si_cuisine+si_securite+si_bien_etre+si_proche_golf+si_ismh+tri;
			//console.info(query);
		});
		
		//onmouseOver sur une région
		$j("#France > area").mouseover(function (){
				$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 (){
			
			if ( $j(this).attr("class") != "choixtype" )
			{
					resetCriteres();
					$j(this).toggleClass("choixtype");
					$j("#oglloc, #ogllocsais, #engine_tbachat div, #engine_tblocation div, #engine_tblocvac div, #thematique div, #engine_pxlocation div").removeClass();
					
					$j("#engine_tblocation, #engine_tblocvac, #engine_pxlocation, #critav_loc, #critav_locvac, #thematique, #engine_lib_thematique, #btn_submit_thematique, #engine_pxlocation").hide();
					$j("#engine_tbachat, #engine_pxachat, #ismh").show();
					
					$j("#engine_critav").css('background-image', 'url("/z/portail/svx/bellesdemeures/img/bg_engine_critav2.gif")');
					$j("#engine_critav").css('height', '220px');
					defautCarte(0);
					
					idtt=8;
					tri="&tri=d_px";
			}
			
		});
		
		//swap onglet location
		$j("#oglloc").click(function (){
			if ( $j(this).attr("class") != "choixtype" )
			{
					resetCriteres();
					$j("#oglachat, #ogllocsais, #engine_tbachat div, #engine_tblocation div, #engine_tblocvac div, #thematique div, #engine_pxlocation div").removeClass();
					$j(this).toggleClass("choixtype");
					
					$j("#engine_tblocation, #engine_pxlocation, #critav_loc").show();
					$j("#engine_tbachat, #engine_tblocvac, #engine_pxachat, #critav_locvac, #thematique, #engine_lib_thematique, #btn_submit_thematique, #ismh").hide();
					$j("#ismh").hide();
					$j("#engine_critav").css('background-image', 'url("/z/portail/svx/bellesdemeures/img/bg_engine_critavloc.gif")');
					$j("#engine_critav").css('height', '270px');
					
					defautCarte(0);
					
					idtt=1;
					tri="&tri=d_px_loyer";
			}
		});
		
		//swap onglet location saisonnière
		$j("#ogllocsais").click(function (){
			
			if ( $j(this).attr("class") != "choixtype" )
			{
					resetCriteres();
					$j("#oglachat, #oglloc, #engine_tbachat div, #engine_tblocation div, #engine_tblocvac div, #engine_pxlocation div").removeClass();
					$j(this).toggleClass("choixtype");
					
					$j("#engine_tblocvac, #engine_pxlocation, #critav_locvac, #thematique, #engine_lib_thematique, #btn_submit_thematique").show();
					$j("#engine_tbachat, #engine_tblocation, #engine_pxachat, #critav_loc, #ismh").hide();
					
					$j("#engine_critav").css('background-image', 'url("/z/portail/svx/bellesdemeures/img/bg_engine_critavlocvac.gif")');
					$j("#engine_critav").css('height', '250px');
					
					defautCarte(0);
					
					idtt=4;
			}
		});
		
		//swap du background sur les types de biens
		$j("#engine_tbachat div, #engine_tblocation div, #engine_tblocvac 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
		$j("#tblocat2, #tblocat14, #tblocat13, #tblocat228, #tblocat1, #tblocat9").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 types de biens location saisonnières
		$j("#tblocvac1, #tblocvac2, #tblocvac227, #tblocvac13, #tblocvac468").click(function(){
				idtypebien = "";
				var id="";
				
				$j("#engine_tblocvac div").each( function () {
						if ($j(this).hasClass('choixtype'))
						{

						    	if(idtypebien == "")
						    		virgule="";
						       else
						       	virgule = ",";
						      
									id = $j(this).attr("id").substring(8);
									//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 thématiques
		$j("#them_mer2, #them_montagne1, #them_campagne3, #them_ville4").click(function(){
				idsituation = "";
				var id="";

				var lastchar = "";
				
				$j("#thematique div").each( function () {
						if ($j(this).hasClass('choixtype'))
						{

						    	if(idsituation == "")
						    		virgule="";
						       else
						       	virgule = ",";
						      
									var lastchar = $j(this).attr("id").length-1;
									id = $j(this).attr("id").substring(lastchar);
						      
						      idsituation = idsituation+virgule+id;
						}
				});
				if ( idsituation != "")
				{
					idsituation = "&idsituation="+idsituation;
				}else{
					idsituation = "";
				}
				
				
		});
		
		//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")
				{
						
						idpays = "";
						
						$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").attr('value', $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;
					iDcurCarto = "international";
					$j("#carte_monde, .autosuggest").animate({ opacity: 'hide' }, opaciteHide);
					$j("#petite_france").animate({ opacity: 'show' }, opaciteShow);
					$j.ajax({
										url: "js,ajax,getannpays.htm",
										data: qry,
										type: 'GET', 
								 		dataType: "html", 
								    timeout: 5000,
								    async: false,
										success: function(data) {
											$j("#listepays2").append(data);
											
											$j('#listepays2').jScrollPane();
											$j(".jScrollPaneContainer").show();
											$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";
					$j("#ville").attr('value', 'Corse');
					
				}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("#ville").attr('value', 'Départements d\'Outre-Mer');
					
				}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;
											argloca = "&cp=" + data.substring(decoupe1, decoupe2);
											$j("#ville").attr('value', data);
										},
										error: function() {   
								    	alert("error");
								    }
					});
				}
		});
		
		//clic sur petite france
		$j("#smallfrance").click(function (){
				defautCarte(1);
		});
	
		

		//click sur un critère avancé
		$j("#si_piscine").click(function () {
			si_piscine = "";
			if ( $j(this).is(":checked") ) si_piscine = "&si_piscine=1";
			//$j('#si_piscine input[type="checkbox"]')
			//$j(this).children('input[type="checkbox"]')[0].checked = !$j(this).children('input[type="checkbox"]')[0].checked;
			//$j(this).children('input[type="checkbox"]')[0].checked.triggerHandler("click");
		});
		
		$j("#nb_balconsmin").click(function (){
			nb_balconsmin = "";
			if ( $j(this).is(":checked") )
			{
				$j("#si_terrasse").attr("checked", "");
				si_terrasse = "";
			}
			if ( $j(this).is(":checked") ) nb_balconsmin = "&nb_balconsmin=1";
		});
		
		$j("#si_terrasse").click(function (){
			si_terrasse = "";
			if ( $j(this).is(":checked") )
			{
				$j("#nb_balconsmin").attr("checked", "");
				nb_balconsmin = "";
			}
			if ( $j(this).is(":checked") ) si_terrasse = "&si_terrasse=1";
		});
		
		$j("#si_entretien").click(function (){
			si_entretien = "";
			if ( $j(this).is(":checked") ) si_entretien = "&si_entretien=1";
		});
		$j("#si_cuisine").click(function (){
			si_cuisine = "";
			if ( $j(this).is(":checked") ) si_cuisine = "&si_cuisine=1";
		});
		$j("#si_securite").click(function (){
			si_securite = "";
			if ( $j(this).is(":checked") ) si_securite = "&si_securite=1";
		});
		$j("#si_bien_etre").click(function (){
			si_bien_etre = "";
			if ( $j(this).is(":checked") ) si_bien_etre = "&si_bien_etre=1";
		});
		$j("#si_proche_golf").click(function (){
			si_proche_golf = "";
			if ( $j(this).is(":checked") ) si_proche_golf = "&si_proche_golf=1";
		});
		$j("#si_ismh").click(function (){
			si_ismh = "";
			if ( $j(this).is(":checked") ) si_ismh = "&si_ismh=1";
		});
    
    //bouton du moteur
		$j(".btn_submit").click(function (){
				if ( $j("#surfacemin").attr('value') ) surfacemin = "&surfacemin="+$j("#surfacemin").attr('value');
				if ( $j("#surfacemax").attr('value') ) surfacemax = "&surfacemax="+$j("#surfacemax").attr('value');
				if ( $j("#ville").attr('value') == "" ) argloca = "";
				
				if (idpays == "") {
					query = "idtt="+idtt+idtypebien+trancheprix+argloca+idsituation+surfacemin+surfacemax+si_piscine+nb_balconsmin+si_terrasse+si_entretien+si_cuisine+si_securite+si_bien_etre+si_proche_golf+si_ismh+tri;
				}else{
					query = "idtt="+idtt+idtypebien+trancheprix+idpays+idsituation+surfacemin+surfacemax+si_piscine+nb_balconsmin+si_terrasse+si_entretien+si_cuisine+si_securite+si_bien_etre+si_proche_golf+si_ismh+tri;
				}
				console.info(query);
				//alert(query);
				id3_go("/recherche.htm?"+query);
		});
    	
		// this initialises the demo scollpanes on the page.
				$j('#listepays').jScrollPane({showArrows:true});
            
		// this allows you to click a link to add content to #pane4 and shows how to reinitialise the scrollbars when you have done this.
		$j('#add-content').bind('click', function(){
				$j('#pane4').append($j('<p></p>').html($j('#intro').html())).jScrollPane({scrollbarWidth:20, scrollbarMargin:10});
		});
		
		// and this allows you to click the link to reduce the amount of content in #pane4 and reinitialise the scrollbars.
		$j('#remove-content').bind('click', function(){
				$j('#pane4').empty().append($j('<p></p>').html($j('#intro').html())).jScrollPane({scrollbarWidth:20, scrollbarMargin:10});
		});
			
});

function resetCriteres() {
	idtypebien="";
	trancheprix = "&pxmin=5000";
	surfacemin="";
	surfacemax="";
	si_piscine="";
	nb_balconsmin="";
	si_terrasse="";
	si_entretien="";
	si_cuisine="";
	si_securite="";
	si_bien_etre="";
	si_ismh="";
	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, #si_ismh").attr("checked", "");
}

function setCurrentLieu(idMap) {
	var i = 0;
	var max = TidLieu.length;
	while (TidLieu[i]!= idMap && i <= max)
	{
		i++;
	}	
	return i;
}

function DispImgs(o, id, idimg) {	
	oInit = document.getElementById("rech_img"+id);
	if (o == "init") {
		oImg = document.getElementById(idimg);
		oInit.src = oImg.src;
	}else{
		oInit.src = o.src;
	}	
}<!-- ID3x v4.60 - X8 - static - 30/07/2010 15:50:52 - js\new\refine.js -->