/*
	// author: Tommy L
	// company: Goes & Roos
	// versie 0.1.16
*/
var smartSelect={sort:"",pageNum:0,latlng:null,straal:0,plaats:[],provincies:[],types:[],prijs:[],prijs_holder:[],perceelopp:[],perceelopp_holder:[],woonopp:[],woonopp_holder:[],kamers:[],kamers_holder:0,openHuis:0,zoekterm:null,adres:null,info_check:function(c){return((c.indexOf("?")!=-1)?"&":"?")}};smartSelect.getMinMax=function(c){a=b=c[0];d=0;while(d<c.length){b=Math.max(b,c[d]);a=Math.min(a,c[d]);d++}return[a,b]};smartSelect.getMax=function(c){max=c[0];d=0;while(d<c.length){max=Math.max(max,c[d]);d++}return max};smartSelect.getMin=function(c){min=c[0];d=0;while(d<c.length){min=Math.min(min,c[d]);d++}return min};Filter_search=function(){smartSelect.pageNum=0;if(document.getElementById("GoogleContainer").style.display!="none"){$(".lijst").click()}$("#SearchContainer div").removeClass("ddactive");$("#SearchContainer ul").parent().find("ul").slideUp();ssmartSelect.send()};Filter_update=function(f,c){this.smart_info=document.getElementById("smart_info");smartSelect.pageNum=0;ssmartSelect.update(f,c);if(c=="page"){if(document.getElementById("GoogleContainer").style.display!="none"){$(".lijst").click()}$("#SearchContainer div").removeClass("ddactive");$("#SearchContainer ul").parent().find("ul").slideUp();ssmartSelect.send()}};Filter_clear=function(f,c){ssmartSelect.clear(f,c)};Filter_adv_search=function(g){var f;var h;try{f=document.getElementById("attrSearchContainer")}catch(c){f=null}try{h=document.getElementById("ExtensiveSearch")}catch(c){h=null}if(f!=null){f.style.display=(f.style.display=="none")?"block":"none"}};function RequestClass(c,e,g){this.container=c;try{this.search=e}catch(f){this.search=null}this.opts=g;this.update_search=function(){if(this.container.length<=0){return}var h=this;$.ajax({url:"http://www.mastermakelaars.nl/huizen/smartselect.aspx"+this.search.value,dataType:"html",context:this,beforeSend:function(j,i){if(typeof h.opts.preloader=="undefined"){return}if(!h.opts.preloader){return}h.container.html('<div class="dyn_loader"></div>')},success:function(i){this.container.html(i);this.successHandler()}})};this.successHandler=function(){var k=$("#elementCount");if(k.length>0){if(k.val()>0){setTimeout("myGR_Tooltip._setup()",200);setTimeout("grSmartFav.set_items()",100);var j=$("#num");if(k.val()==1){j.text("Er is "+k.val()+" object gevonden.")}else{j.text("Er zijn "+k.val()+" objecten gevonden.")}var i=j.text();j.html(i+' <span id="range">'+$("#elementRange").val()+" wordt nu getoond.</span>")}else{$("#num").text("Er zijn geen objecten gevonden.")}if(this.opts.debug){this.opts.debugHandler("Request handler(count):"+k.value)}}else{$("#num").html("")}var h=this.container.find("ul");$("#pageNav").html("");$("#pageNavBottom").html("");if(h.length>0){$("#pageNav").append(h[0]);$("#pageNavBottom").html($("#pageNav").html())}}}function cookieManager(f,e){var c;var h=/^([a-zA-Z]+)[=]([\w\d~-]+)$/;var g="smartSelector"+f;this.opts=e||{FILTER_SELECTED:"filter_sel"};this.save=function(i){setCookieMin(g,i,5);if(this.opts.debug){this.opts.debugHandler("CookieManager save<"+g+">: Done.")}};this.isset=function(){return(!!c)};this.parse=function(){c=getCookie(g);if(!c){if(this.opts.debug){this.opts.debugHandler("CookieManager load<"+g+">: Not found.")}return}list=(c).split(/[?|&]/);for(var l=0;l<list.length;++l){var k=h.exec(list[l]);if(k){if(smartSelect[k[1]]||smartSelect[k[1]]==0){if(k[2].indexOf("~")<0){if(typeof smartSelect[k[1]+"_holder"]=="object"){smartSelect[k[1]+"_holder"].push(k[2])}else{if(typeof smartSelect[k[1]]=="object"){smartSelect[k[1]].push(k[2]);if(typeof smartSelect[k[1]+"_holder"]=="number"){smartSelect[k[1]+"_holder"]=k[2]}}else{smartSelect[k[1]]=k[2]}}}else{if(typeof smartSelect[k[1]]=="string"){smartSelect[k[1]]=k[2];continue}matches=k[2].split("~");for(var j=0;j<matches.length;j++){if(typeof smartSelect[k[1]]=="object"){smartSelect[k[1]].push(matches[j])}}}}else{if(typeof smartSelect[k[1]]!="undefined"){if(smartSelect[k[1]]==null){smartSelect[k[1]]=k[2]}}}}}this.select_filters()};this.highlight=function(j,i){lis=j.getElementsByTagName("li");for(var k=0;k<lis.length;++k){li=lis[k];if(smartSelect[i].indexOf(li.title)!=-1){li.className=this.opts.FILTER_SELECTED}}};this.m_highlight=function(j,i){lis=j.getElementsByTagName("li");if(!smartSelect[i+"_holder"]||typeof smartSelect[i+"_holder"][0]=="undefined"){return}parts=smartSelect[i+"_holder"][0].split("-");highlight=false;for(var k=0;k<lis.length;++k){li=lis[k];if(!li.title){continue}if(li.title.split("-")[1]==parts[1]){highlight=false;li.className=this.opts.FILTER_SELECTED;smartSelect[i].push(li.title);break}if(li.title.split("-")[0]==parts[0]||highlight){highlight=true;li.className=this.opts.FILTER_SELECTED;smartSelect[i].push(li.title)}}};this.select_filters=function(){var m=null;var k=["ssFilterId_Kamers","ssFilterId_Wijk","ssFilterId_Provincies","ssFilterId_Perceel","ssFilterId_Woonopp","ssFilterId_PlaatsWijk","ssFilterId_Plaats","ssFilterId_Type","ssFilterId_Prijs"];var j=["kamers","plaats","provincies","perceelopp","woonopp","plaats","plaats","types","prijs"];var l=k.length-1;if(smartSelect.sort!=""){document.getElementById("sort_order").value=smartSelect.sort}while(l>=0){try{m=document.getElementById(k[l])}catch(n){m=null}if(m!=null){if(j[l]=="plaats"||j[l]=="types"||j[l]=="kamers"||j[l]=="provincies"){this.highlight(m,j[l])}else{this.m_highlight(m,j[l])}}--l}if(smartSelect.woonopp.length>0||smartSelect.perceelopp.length>0||smartSelect.kamers.length>0){try{extSearch=document.getElementById("ExtensiveSearch")}catch(n){extSearch=null}if(extSearch!=null){Filter_adv_search(extSearch)}}for(var q in smartSelect){if($("#"+q).length>0){$("#"+q).val(smartSelect[q])}}}}var ssmartSelect=(function(){var c={};c.request=null;c.prefilter=null;c.info=null;c.cookie=null;c.options={selectFirst:null};c.defaults={debug:false,FILTER_NONE:"filter_norm",FILTER_SELECTED:"filter_sel",FILTER_CLOSE:"filter_close"};c.crit={types:[]};c.setDebug=function(f){var g;try{g=document.getElementById("smartDebug")}catch(e){g=null}if(g==null){g=document.createElement("div");g.setAttribute("id","smartDebug");g.innerHTML="[ smartDebug ] geinitialiseerd.<br/>";document.getElementsByTagName("body")[0].appendChild(g)}if(f){g.innerHTML+="[ smartDebug ] "+f+"<br/>"}};c.clear=function(g,f){if(f=="plaats"){smartSelect.plaats=[]}else{if(f=="provincies"){smartSelect.provincies=[]}else{if(f=="type"){smartSelect.types=[]}else{if(f=="prijs"){smartSelect.prijs=[];smartSelect.prijs_holder=[]}else{if(f=="perceelopp"){smartSelect.perceelopp=[];smartSelect.perceelopp_holder=[]}else{if(f=="woonopp"){smartSelect.woonopp=[];smartSelect.woonopp_holder=[]}else{if(f=="kamers"){smartSelect.kamers=[]}}}}}}}c.update(g,null);if(g.parentNode.tagName.toLowerCase()=="ul"){options=g.parentNode.getElementsByTagName("li");o=options.length-2;while(o>=0){option=options[o];if(option!=g){if(option.className==c.defaults.FILTER_CLOSE){--o}else{option.className=c.defaults.FILTER_NONE}}--o}}};c.update=function(g,f){c.setup(g,f);if(c.info==null){return}c.info.value="";if(smartSelect.plaats.length>0){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="plaats="+smartSelect.plaats.join("~")}if(smartSelect.provincies.length>0){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="provincies="+smartSelect.provincies.join("~")}if(smartSelect.types.length>0){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="types="+smartSelect.types.join("~")}if(smartSelect.prijs.length>0){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="prijs="+smartSelect.prijs_holder.join("-")}if(smartSelect.perceelopp.length>0){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="perceelopp="+smartSelect.perceelopp_holder.join("-")}if(smartSelect.woonopp.length>0){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="woonopp="+smartSelect.woonopp_holder.join("-")}if(smartSelect.kamers.length>0){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="kamers="+smartSelect.kamers_holder}if(smartSelect.openHuis>0){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="openhuis="+smartSelect.openHuis}if(smartSelect.zoekterm!=null){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="zoekterm="+smartSelect.zoekterm}if(smartSelect.adres!=null){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="adres="+smartSelect.adres}if(gr_objExists(document.getElementById("straal"))){if(smartSelect.straal==0&&document.getElementById("straal")!=null){if(document.getElementById("straal").value.length>0){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="plaats="+document.getElementById("straal").value}}}if(smartSelect.latlng!=null&&smartSelect.straal>0){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="latlng="+smartSelect.latlng;c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="st="+smartSelect.straal}if(c.prefilter!=null){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="prefilter="+c.prefilter.value}if(smartSelect.pageNum>=0){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="pageNum="+smartSelect.pageNum}if(smartSelect.sort!=""){c.info.value+=smartSelect.info_check(c.info.value);c.info.value+="sort="+smartSelect.sort}if(c.defaults.debug){c.setDebug("Update string<info>: "+c.info.value)}};c.setup=function(g,f){if(f=="plaats"){if((pos=smartSelect.plaats.indexOf(g.title))!==-1){smartSelect.plaats.splice(pos,1);g.className=c.defaults.FILTER_NONE}else{smartSelect.plaats.push(g.title);g.className=c.defaults.FILTER_SELECTED}}else{if(f=="type"){if((pos=smartSelect.types.indexOf(g.title))!==-1){smartSelect.types.splice(pos,1);g.className=c.defaults.FILTER_NONE}else{smartSelect.types.push(g.title);g.className=c.defaults.FILTER_SELECTED}}else{if(f=="provincies"){if((pos=smartSelect.provincies.indexOf(g.title))!==-1){smartSelect.provincies.splice(pos,1);g.className=c.defaults.FILTER_NONE}else{smartSelect.provincies.push(g.title);g.className=c.defaults.FILTER_SELECTED}}else{if(f=="prijs"){if((pos=smartSelect.prijs.indexOf(g.title))!==-1){smartSelect.prijs.splice(pos,1);g.className=c.defaults.FILTER_NONE}else{smartSelect.prijs.push(g.title);g.className=c.defaults.FILTER_SELECTED}smartSelect.prijs_holder=[];if(smartSelect.prijs.length>0){for(p=0;p<smartSelect.prijs.length;++p){s_prijs=smartSelect.prijs[p].split("-");smartSelect.prijs_holder.push(s_prijs[0]);smartSelect.prijs_holder.push(s_prijs[1])}smartSelect.prijs_holder=smartSelect.getMinMax(smartSelect.prijs_holder)}}else{if(f=="perceelopp"){if((pos=smartSelect.perceelopp.indexOf(g.title))!==-1){smartSelect.perceelopp.splice(pos,1);g.className=c.defaults.FILTER_NONE}else{smartSelect.perceelopp.push(g.title);g.className=c.defaults.FILTER_SELECTED}smartSelect.perceelopp_holder=[];if(smartSelect.perceelopp.length>0){for(p=0;p<smartSelect.perceelopp.length;++p){s_perceel=smartSelect.perceelopp[p].split("-");smartSelect.perceelopp_holder.push(s_perceel[0]);smartSelect.perceelopp_holder.push(s_perceel[1])}smartSelect.perceelopp_holder=smartSelect.getMinMax(smartSelect.perceelopp_holder)}}else{if(f=="woonopp"){if((pos=smartSelect.woonopp.indexOf(g.title))!==-1){smartSelect.woonopp.splice(pos,1);g.className=c.defaults.FILTER_NONE}else{smartSelect.woonopp.push(g.title);g.className=c.defaults.FILTER_SELECTED}smartSelect.woonopp_holder=[];if(smartSelect.woonopp.length>0){for(p=0;p<smartSelect.woonopp.length;++p){s_perceel=smartSelect.woonopp[p].split("-");smartSelect.woonopp_holder.push(s_perceel[0]);smartSelect.woonopp_holder.push(s_perceel[1])}smartSelect.woonopp_holder=smartSelect.getMinMax(smartSelect.woonopp_holder)}}else{if(f=="kamers"){if((pos=smartSelect.kamers.indexOf(g.title))!==-1){smartSelect.kamers.splice(pos,1);g.className=c.defaults.FILTER_NONE}else{smartSelect.kamers.push(g.title);g.className=c.defaults.FILTER_SELECTED}smartSelect.kamers_holder=0;if(smartSelect.kamers.length>0){smartSelect.kamers_holder=smartSelect.getMin(smartSelect.kamers)}}else{if(f=="page"){smartSelect.pageNum=g.title}else{if(f=="sort"){smartSelect.sort=g.value}else{if(f=="openhuis"){smartSelect.openHuis=(g.checked?1:0)}else{if(f=="zoekterm"){if(g.value.length>0){smartSelect.zoekterm=g.value}else{smartSelect.zoekterm=null}}else{if(f=="adres"){if(typeof jQuery!="undefined"){if($(g).val().length>1){smartSelect.adres=$(g).val()}else{smartSelect.adres=null}}else{smartSelect.adres=null}}else{if(f=="latlng"){if(typeof jQuery!="undefined"){if($(g).val().length>1){smartSelect.latlng=$(g).val()}else{smartSelect.latlng=null}}else{smartSelect.latlng=null}}else{if(f=="straal"){smartSelect.straal=g.value}}}}}}}}}}}}}}};c.send=function(){c.cookie.save(c.info.value);smartSelect.pageNum=0;c.build_criteria();c.request.update_search()};c.build_criteria=function(){var h=document.getElementById("SearchContainer");var g='&nbsp;<span class="search_sep">&raquo;</span>&nbsp;';var i=0;var f=null;try{f=document.getElementById("SearchCriteria")}catch(j){f=null}if(f==null){f=document.createElement("div");f.setAttribute("id","SearchCriteria");h.appendChild(f)}var k="U heeft gezocht op: ";var e=k.length;f.innerHTML=k;if(smartSelect.plaats.length>0){f.innerHTML+=smartSelect.plaats.join(", ");i=1}c.crit.types=[];$("#ssFilterId_Type > li").each(function(){var l=$(this).attr("title");if(smartSelect.types.indexOf(l)!=-1){c.crit.types.push($(this).text())}delete l});if(c.crit.types.length>0){if(i==1){f.innerHTML+=g}f.innerHTML+=c.crit.types.join(", ");i=1}if(smartSelect.prijs.length>0){if(i==1){f.innerHTML+=g}f.innerHTML+="Prijsklasse: &euro; "+smartSelect.prijs_holder.join(" tot ");i=1}if(smartSelect.perceelopp.length>0){if(i==1){f.innerHTML+=g}f.innerHTML+="Perceel opp: "+smartSelect.perceelopp_holder.join(" tot ")+"m&sup2;";i=1}if(smartSelect.woonopp.length>0){if(i==1){f.innerHTML+=g}f.innerHTML+="Woon opp: "+smartSelect.woonopp_holder.join(" tot ")+"m&sup2;";i=1}if(smartSelect.kamers.length>0){if(i==1){f.innerHTML+=g}f.innerHTML+="Kamers: "+smartSelect.kamers_holder;i=1}if(smartSelect.zoekterm!==null){if(i==1){f.innerHTML+=g}f.innerHTML+="Vrije zoekterm: "+smartSelect.zoekterm;i=1}if(smartSelect.adres!==null){if(i==1){f.innerHTML+=g}f.innerHTML+="Adres: "+smartSelect.adres;i=1}if(f.innerHTML.length==e){f.innerHTML=""}delete k;delete e};c.load=function(){try{c.info=document.getElementById("filter_search")}catch(f){c.info=null}try{c.prefilter=document.getElementById("filter_prefilter")}catch(f){c.prefilter=null}if(c.info==null){alert("Er ontbreekt een veld.");return}var e={debug:c.defaults.debug,debugHandler:c.setDebug,timeout:100,preloader:true};c.request=new RequestClass($("#ObjectsContainer"),c.info,e);var g={debug:c.defaults.debug,debugHandler:c.setDebug,FILTER_SELECTED:c.defaults.FILTER_SELECTED};c.cookie=new cookieManager(c.prefilter.value,g);if(c.defaults.debug){c.setDebug("SmartSelect geinitialiseerd.")}try{c.options.selectFirst=parseInt(document.getElementById("filter_selectfirst").value)}catch(f){c.options.selectFirst=null}if(c.prefilter!=null){c.update(null,null)}c.cookie.parse();if(c.cookie.isset()){c.update(null,null);if(c.defaults.debug){c.setDebug("SmartSelect search:"+c.info.value)}c.build_criteria();c.request.update_search()}else{if(c.options.selectFirst!=null){c.update(null,null);c.request.update_search()}}};if(window.addEventListener){window.addEventListener("load",c.load,false)}else{if(window.attachEvent){window.attachEvent("onload",c.load)}}return c})();function toggleSmartGMap(f,g,i){var k;var c={objects:null,maps:null};var h={on:null,off:null};try{k=document.getElementById("mgmMarkerIDs")}catch(j){k=null}if(k==null){if(typeof Shadowbox!="undefined"){Shadowbox.open({content:'<div id="ssDialog">Er is geen selectie gemaakt.</div>',player:"html",title:"Googlemaps",height:100,width:300})}return}try{c.objects=document.getElementById("ObjectsContainer");c.maps=document.getElementById("GoogleContainer")}catch(j){c.objects=null;c.maps=null}if(c.objects==null||c.maps==null){return}try{h.on=document.getElementById(g);h.off=document.getElementById(i)}catch(j){h.on=null;h.off=null}if(h.on==null||h.off==null||h.on.className=="TabOn"){return}h.on.className="TabOn";h.off.className="TabOff";if(c.maps.style.display=="none"){c.maps.style.display="block";c.objects.style.display="none";smartMaps.update()}else{c.maps.style.display="none";c.objects.style.display="block"}};
