Booli.AdToolbox={getLivingCostAd:function(b,a){if(a===1){return'<iframe scrolling="no" frameborder="0" src="/ad/livingCost?pos=LivingCost_Popup_320x16&id='+b+'" allowtransparency="true" id="popupAd'+b+'"></iframe>'}else{return'<iframe scrolling="no" frameborder="0" src="/ad/livingCost?pos=LivingCost_Hitlist_539x16&id='+b+'" allowtransparency="true" id="hitlistAd'+b+'"></iframe>'}}};var Toolbox=function(){var b=function(p){return p.charAt(0).toUpperCase()+p.substr(1)};var k=function(p){if(parseInt(p,10)===0){p="+/-"+p}else{if(parseInt(p,10)>0){p="+"+p}}return""+p};var h=function(q,p){var s=q;for(var r=0;r<p-(""+q).length;r++){s="0"+s}return s};var c=function(q,p){p=p||32;if(q.length>p){q=q.replace("vägen","v.");q=q.replace("gatan","g.")}if(q.length>p){q=q.replace(/,.*/,"")}if(q.length>p){q=q.substring(0,p-3)+"..."}return q};var n=function(q){var p=Math.floor(q);if(p<q){return(p+"&frac12;")}else{return p}};var m=function(q,r){var u=parseInt(r,10);var s=(""+q);if(!u){s=Math.abs(parseInt(s.replace(/[^\d\-\.]/g,""),10));var t="";if(s<1000){return parseInt(q,10)<0?"-"+s:""+s}if(s>=1000000){t=t+Math.floor(s/1000000)+" ";t=t+h(Math.floor((s%1000000)/1000),3)+" "}else{if(s>=1000){t=Math.floor((s%1000000)/1000)+" "}}t=t+h(s%1000,3);return parseInt(q,10)<0?"-"+t:t}else{var p=s.replace(/[^\d\-\.]/g,"");p=Math.abs(parseFloat(p,10));p=Math.round(p*Math.pow(10,u))/Math.pow(10,u);return parseInt(q,10)<0?"-"+p:""+p}};var l=function(p){return p.replace(/ /g,"")};var d=function(q,y,w,x){var p=w||{},s=p.posFudge||{top:0,left:0},v=p.zIndex||100,u=$(q),r=$(y);if(!u||!r){return}var t=r.cumulativeOffset();u.setStyle({top:t.top+s.top+"px",left:t.left+s.left+"px",zIndex:v});if(x){return}o(u,r,p.sizeFudge)};var o=function(p,q,s){var r=s||{x:0,y:0};q.style.height=document.documentElement.clientHeight-186+"px";p.setStyle({width:q.clientWidth+r.x+"px",height:q.clientHeight+r.y+"px"})};var a=function(s,u,t,v,r){var q=$(s),p=$(u);if(!q||!p){return}q.style.position="absolute";if(!(Booli.ie<7)){q.style.position=p.up(".modalBox")?"fixed":"absolute"}d(s,p,t,v);if(q.up()!==document.body){Element.insert(document.body,q)}if(r){return}Event.observe(window,"resize",function(){d(s,p,t,v)})};var e=function(q,p,x,u,A,w){var q=$(q),w=(w||240),r=document.viewport.getHeight()-x/2-w;if(p){var z=$(p).getHeight();if(totalHeight>z){r=z-toSave-w}}if(A){r=Math.max(r,A)}q.setStyle({height:r+"px"});if(p==="leftContainer"){var s=$(p);var v=364;var y=q.getHeight()+v;s.setStyle({minHeight:y+"px"})}var t=q.up();if(q===$("searchMapContainer")&&t.getStyle("position")=="fixed"){left=$("leftContainer").cumulativeOffset().left+$("leftContainer").getWidth();t.setStyle({left:left+5+"px"});if(!t.hasClassName("nonliquid")){t.setStyle({width:(document.viewport.getWidth()-$("leftContainer").getWidth())-17+"px"})}tableHeader=$("tableHeader");if(tableHeader){left=$("leftContainer").cumulativeOffset().left;tableHeader.setStyle({left:left+1+"px"})}}return r};var g=function(p){if(p.getStyle("display")==="none"||p.getStyle("visibility")==="hidden"){return false}return true};function i(u,w){if(!u){return""}var q=w||"+";var v=u.toLowerCase(),t=[/Á/g,/É/g,/Í/g,/Ó/g,/Ú/g,/À/g,/È/g,/Ì/g,/Ò/g,/Ù/g,/á/g,/é/g,/í/g,/ó/g,/ú/g,/ý/g,/à/g,/è/g,/ì/g,/ò/g,/ù/g,/â/g,/ê/g,/î/g,/ô/g,/û/g,/Â/g,/Ê/g,/Î/g,/Ô/g,/Û/g,/ä/g,/ë/g,/ï/g,/ö/g,/ü/g,/ÿ/g,/Ä/g,/Ë/g,/Ï/g,/Ö/g,/Ü/g,/Ÿ/g,/ã/g,/õ/g,/ñ/g,/å/g,/ø/g,/š/g,/Ã/g,/Õ/g,/Ñ/g,/Å/g,/Ø/g,/Š/g,/ç/g,/&#287;/g,/&#305;/g,/ö/g,/&#351;/g,/ü/g,/ /g,/\_/g,/\?/g],s=["a","e","i","o","u","a","e","i","o","u","a","e","i","o","u","y","a","e","i","o","u","a","e","i","o","u","a","e","i","o","u","a","e","i","o","u","y","a","e","i","o","u","y","a","o","n","a","q","s","a","o","n","a","q","s","c","g","i","o","s","u",q,q,""],r=0,p=t.length;for(r;r<p;r++){v=v.replace(t[r],s[r])}return v}function f(q){var p=Math.ceil(Math.random()*q);return p===q?true:false}return{getChangeSign:k,readableNumber:m,removeThousandSeparators:l,readableRooms:n,stringLength:c,absTop:a,maximizeHeight:e,setPositionAndSize:d,cloneSize:o,isVisible:g,ucFirst:b,standardizeUrl:i,oneIn:f}}();Booli.Controller.Api={init:function(a){if(typeof this[a]==="function"){this[a]()}},explorer:function(){this._addListeners();var a=this;Booli.Hash.init(function(b){a._fillForm(b);a._request(b)},new Element("iframe",{style:"display:none;"}))},_request:function(d){var b=d||document.location.hash.match(/#(.*)/)[1],c=this;var a="";if($("sandbox").checked===false&&$("callerId").value!==""&&$("privateKey").value!==""){a="&callerId="+$("callerId").value+"&privateKey="+$("privateKey").value}Booli.Effect.run("response_pre","Fade",{duration:0.2,afterFinish:function(){var e=new Ajax.Request("/api/proxy?url="+encodeURIComponent(b)+a,{method:"get",onSuccess:function(h){var f=h.responseText.evalJSON();if(f.body.isJSON()){var g=JSON.stringify(f.body.evalJSON(),undefined,4)}else{var g=f.body}c._output(g,f.headers)}})}});if(b!==""){$("path").value=decodeURIComponent(b);$("req_path").update(b);$("request_pre").show()}},_addListeners:function(){var a=this;$("update_url").observe("click",function(f){f.stop();var c=$("description").getElements(),d={};for(var b=c.length-1;b>=0;b--){if(c[b].value!==""&&!c[b].disabled){d[c[b].name]=c[b].value}}if(d.booliId){$("path").value="/listings/"+d.booliId}else{$("path").value="/listings?"+decodeURIComponent(Object.toQueryString(d))}});$("submit").observe("click",function(b){b.stop();if("#"+$("path").value===document.location.hash){a._request()}else{Booli.Hash.set($("path").value)}});$("sandbox").observe("click",function(){if(this.checked){$("callerId").value="";$("privateKey").value="";$("own_keys_control").hide();$("limit").disabled="disabled";$("offset").disabled="disabled";a._request()}else{$("own_keys_control").show();$("limit").disabled="";$("offset").disabled=""}});$("optional_list_parameters_container_toggle").observe("click",function(){this.update(this.innerHTML==="Visa färre"?"Visa fler":"Visa färre");$("optional_list_parameters_container").toggle()});$$("a.hash").each(function(b){b.observe("click",function(c){c.stop();Booli.Hash.set(this.href.match(/#(.*)/)[1])})})},_fillForm:function(e){var d;if(e.match(/.*?\/\d+/)){d={booliId:e.match(/.*?\/(\d+)/)[1]};$("show_parameters_container").show();$("list_parameters_container").hide();$("optional_list_parameters_container").hide();$("optional_list_parameters_container_toggle").hide();$$("#action_container p")[0].update("Hämta information om en enskild bostad");$("update_url").addClassName("first")}else{d=e.toQueryParams();$("show_parameters_container").hide();$("list_parameters_container").show();$("optional_list_parameters_container").hide();$("optional_list_parameters_container_toggle").update("Visa fler");$("optional_list_parameters_container_toggle").show();$$("#action_container p")[0].update("Hämta bostäder baserat på valda parametrar");$("update_url").removeClassName("first")}var c=$("description").getElements();for(var b=c.length-1;b>=0;b--){if(d[c[b].name]){c[b].value=d[c[b].name]}else{if(!c[b].disabled){c[b].value=""}}}if(document.location.search){var a=document.location.search.toQueryParams();if(a.callerId&&a.privateKey){$("sandbox").checked="";$("callerId").value=a.callerId;$("privateKey").value=a.privateKey;$("own_keys_control").show();$("limit").disabled="";$("offset").disabled=""}}},_output:function(b,a){b=b.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,function(d){var c="number",e=d;if(/http/.test(d)!==false){c="url";e="<a href="+d+" target='_blank'>"+d+"</a>"}else{if(/^"/.test(d)){c="string"}else{if(/true|false/.test(d)){c="boolean"}else{if(/null/.test(d)){c="null"}}}}return'<span class="'+c+'">'+e+"</span>"});b=b.replace(/(<span class=\"(string)\">\".*?\"<\/span>:)/g,function(c){return c.replace("string","property")});$("response_headers").update(a);$("response_body").update(b);Booli.Effect.run("response_pre","Appear",{duration:0.5})}};Booli.Controller.Areastatistics={init:function(b){Booli.Location.init();Booli.TopMenu.init();Booli.Tabs.Transaction();this.search=new Booli.Search.AreaStatistics();Booli.RefineLoader(this.search);Booli.Search.History.init(this.search);var a=new InterestForm()}};Booli.Controller.Auth={init:function(a){Booli.AuthLoader.load(function(){Booli.Auth.Static.init(a)})}};Booli.Map={};if(!Booli.Auth){Booli.Auth={}}Booli.Bootstrap=function(){if(window.Survey){}if(Booli.Config.isTouch){Booli.askIPhone()}Booli.Pageview.init();var c=Toolbox.ucFirst(Booli.Server.controller);if(Booli.Controller[c]){Booli.Controller.current=Booli.Controller[c];Booli.Controller[c].init(Booli.Server.action)}var b=function(){var g=new Element("div",{id:"globalMsg"});g.update("Ett fel i indexeringen gör att vissa objekt för närvarande saknas. Vi jobbar för fullt på problemet.");Element.insert($("content"),g);Event.observe(window,"load",function(){setTimeout(g.addClassName("show"),500)})};var f=[],e="38,38,40,40,37,39,37,39,66,65",a,d='<img src="'+Booli.Config.imagesUrl+'/logo_iloob.png" id="logo" />';Event.observe(document,"keydown",function(g){f.push(g.keyCode);if(f.toString().indexOf(e)>=0){if(Booli.Controller.Search.map){LazyLoad.js([Booli.Config.scriptUrl+"/application/MapModules/TileMarker.js"],function(){var h=new Booli.Map.TileMarker(Booli.Controller.Search.map.map);h.bindEvents()})}if(!$("logoContainer")){return}f=[];a=$("logoContainer").innerHTML;$("logoContainer").innerHTML=d;d=a;$("content").scrollTo()}})};Booli.ie=(function(){var b,a=3,c=document.createElement("div");while(c.innerHTML="<!--[if gt IE "+(++a)+"]><i></i><![endif]-->",c.getElementsByTagName("i")[0]){}return a>4?a:b}());Booli.Controller.Dashboard={init:function(a){if(typeof this[a]==="function"){this[a]()}LazyLoad.js(Booli.Config.scriptUrl+"/application/Dashboard/dashboard"+Booli.Config.jsRev+".js",function(){},null)}};Booli.Controller.Index={init:function(a){Booli.Location.init();Booli.Tabs.Transaction();Booli.Inspiration.Toggle.init();Booli.Search.History.addIndexHtml();Booli.Auth.isLoggedInAsync(this.addSavedListings);if(this[a]){this[a]()}this.graphs()},index:function(){this.search=new Booli.Search.Index.Listings();this.refine_()},transactions:function(){this.search=new Booli.Search.Index.Transactions();this.refine_()},statistics:function(){this.search=new Booli.Search.Index.AreaStatistics();this.refine_()},graphs:function(){Event.observe(window,"load",function(){setTimeout(function(){new Ajax.Updater($$(".statisticsContainer")[0],"/index/graphs",{insertion:"top",method:"get"})},10)})},refine_:function(){var b=this,a=0;$("searchForm").observe("mouseover",function(){if(!a){Booli.RefineLoader(b.search);a=1}})},addSavedListings:function(a){if(a){new Ajax.Request("/search/update?sparade=1&type=listings&areaId=77104&format=simple",{method:"GET",onSuccess:function(c){var b=$("latestSearches");if(!b){$("indexLeftContainer").insert({top:'<div class="module" id="latestSearches"><div style="float:left; width:59%;"><h2>Mina senaste sökningar</h2><ul><li><i>Inga sökningar gjorda</i></li></ul></div></div>'});b=$("latestSearches")}b.insert(c.responseText.evalJSON().hitsHtml)}})}}};Booli.Controller.Inspiration={init:function(a){if(typeof this[a]==="function"){this[a]()}},index:function(){Booli.Inspiration.Toggle.init()},images:function(){Booli.Inspiration.init()},tagger:function(){LazyLoad.js(Booli.Config.scriptUrl+"/application/InspirationModules/Tagger"+Booli.Config.jsRev+".js",function(){Booli.Inspiration.init()},null)},widget:function(){LazyLoad.js(Booli.Config.scriptUrl+"/application/InspirationModules/Widget"+Booli.Config.jsRev+".js",function(){Booli.Inspiration.Widget.init()},null)}};Booli.Controller.Iphone={init:function(a){Booli.AuthLoader.load(function(){Booli.Auth.Static.init(a)})}};Booli.Controller.Listing={searchBox:null,init:function(b){Booli.Location.init();var a=Booli.Server.hit;Booli.Server.type=a.transactionDate?"transactions":"listings";this.hit=a;Booli.TopBar.init({SaveRemove:a.id,Share:{post:"/share/sendShareEmail",params:{shareId:a.id,tab:b,shareType:(!a.link?"t":"l")}},ErrorReport:null});if(typeof this[b]==="function"){this[b]()}if(b!=="priceGuess"){this.showPriceGuessHint()}this.addListeners();if(Booli.Server.type==="listings"){var c=this.hit.id;c+=this.hit.basicObjectType?"|"+this.hit.basicObjectType:"";c+=this.hit.postAddress?"|"+this.hit.postAddress:"";c+=this.hit.price?"|"+this.hit.price:"";c+=this.hit.rooms?"|"+this.hit.rooms:"";c+=this.hit.livingArea?"|"+this.hit.livingArea:"";c+=this.hit.municipality&&this.hit.municipality.areaName?"|"+this.hit.municipality.areaName:"";Cookies.set("latest_listing",c,30,"/ad/")}},index:function(){this.initSharedComponents()},transaction:function(){this.initSharedComponents()},images:function(){LazyLoad.js(Booli.Config.scriptUrl+"application/InspirationModules/Vote"+Booli.Config.jsRev+".js",function(){Booli.InspirationModules.Vote.init()},null)},aerial:function(){var a=function(){if(window.overviewMap&&window.VEMap&&$("map").attachEvent){overviewMap.init.call(overviewMap)}else{setTimeout(a,10)}};LazyLoad.js([Booli.Config.scriptUrl+"application/MapModules/VE"+Booli.Config.jsRev+".js","http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2"],function(){a()},10)},map:function(){this.Map=new Booli.Map.ListingLarge()},priceGuess:function(){var a=this;LazyLoad.js([Booli.Config.auth,Booli.Config.scriptUrl+"application/PriceGuess/priceguess"+Booli.Config.jsRev+".js"],function(){Booli.PriceGuess.init(a.hit.id)},null);Booli.activateSourceGuesses()},source:function(){if(navigator.userAgent.indexOf("Safari")!=-1){$("listingBar").style.WebkitBoxShadow="none"}},initSharedComponents:function(){this.Map=new Booli.Map.Listing()},showPriceGuessHint:function(){return},addListeners:function(){$$("a.broker").each(function(B){B.observe("click",function(){if(!this.href.match(/booli\.se|localhost/i)){Booli.Pageview.add("adress")}})});var i,o,b,y,z,a,k,m,h,p,s,g,c,t,x,d,l,w,e,r,f,q,n,v;if((c=$("mapButton"))&&(t=$("mapButtonPopup"))){if(Booli.ie===6){c.update("Karta");return}c.observe("click",function(B){if(B.element().id==="aerialLink"||B.element().up().id==="aerialLink"){B.stop();window.location=$("aerialLinkHref").value}});c.observe("mouseover",function(){t.show()}).observe("mouseout",function(){t.hide()})}if(i=$("closeFrame")){i.observe("click",function(){Booli.Pageview.add("close-bar",{noAd:1})})}if(v=$("broadbandLink")){v.observe("click",function(){Booli.Pageview.add("bredbandsbolaget-featured-topbar-link",{noAd:1})})}if(n=$("broadbandLinkData")){n.observe("click",function(){Booli.Pageview.add("bredbandsbolaget_mer_info-featured-topbar-link",{noAd:1})})}if(f=$("livingCostLinkData")){f.observe("click",function(){Booli.Pageview.add("boendekostnad_mer_info-featured-data-link",{noAd:1})})}if(q=$("insuranceLinkData")){q.observe("click",function(){Booli.Pageview.add("forsakring_mer_info-featured-data-link",{noAd:1})})}if(r=$("listingAdCont")){r.className=r.className}if(b=$("externalFrame")){Event.observe(window,"resize",function(B){b.style.height=(document.documentElement.clientHeight-68)+"px"})}if(y=$("changeSearch")){this.search=new Booli.Search.Object(this.hit.transactionDate?"transactions":"listings");Booli.RefineLoader(this.search);var u=this;y.observe("click",function(){CustomEvents.notify({},"Topbar:changeSearch");Booli.Pageview.add("forfina/dialog",{noAd:1})})}if(z=$("socialShare")){z.observe("click",function(C){var B=C.element();if(B.tagName.toLowerCase()==="a"){Booli.Pageview.add("social",{noAd:1})}})}if(a=$("random")){a.observe("click",function(B){Booli.Pageview.add("random",{noAd:1})})}if(m=$("birdsEye")){m.observe("click",function(){Booli.Pageview.add("flygfoto",{noAd:1})})}if(h=$("listingImage")){h.observe("click",function(){CustomEvents.notify({},"images:click")})}if(p=$("brguiden")){p.observe("click",function(){Booli.Pageview.add("brguiden",{noAd:1})})}var A=$("showAllParts");if(s=$("showAllSellers")){s.observe("mouseover",function(){A.show()}).observe("mouseout",function(){A.hide()})}if(g=$("showAllBuyers")){g.observe("mouseover",function(){A.show()}).observe("mouseout",function(){A.hide()})}if($("Listing_Panorama_980x240")&&$("listingAdCont")){$("listingAdCont").addClassName("superpanorama")}if(d=$$(".sourceExpToggle")){d.each(function(B){B.observe("click",function(C){C.stop();l=$("sourceExpanded");l.toggle()})})}if(w=$$(".statExpToggle")){w.each(function(B){B.observe("click",function(C){C.stop();e=$("statExpanded");e.toggle()})})}}};Booli.Controller.Map={init:function(a){Booli.Location.init();if(this[a]){this[a]()}Booli.RefineLoader(this.search);$("changeSearch").observe("click",function(){CustomEvents.notify({},"Topbar:changeSearch")})},searchListings:function(){this.map=new Booli.Map.MapSearch();this.search=new Booli.Search.Map.Listings()},searchTransactions:function(){this.map=new Booli.Map.MapSearch();this.search=new Booli.Search.Map.Transactions()}};Booli.Controller.Polygon={init:function(a){LazyLoad.js(Booli.Config.scriptUrl+"application/MapModules/Polygon/Controller.js",function(){Booli.Map.Polygon.Controller.init(a)})}};Booli.Controller.Priceguesssource={init:function(a){LazyLoad.js(Booli.Config.scriptUrl+"/application/PriceGuessSource/Controller"+Booli.Config.jsRev+".js",function(){Booli.PriceGuessSource.init(a)},null)}};Booli.Controller.Search={init:function(b){Booli.Location.init();Booli.TopMenu.init();Booli.Tabs.Transaction();if(this[b]){this[b]()}Booli.RefineLoader(this.search);Booli.Search.History.init(this.search);var a=new InterestForm()},index:function(){this.map=new Booli.Map.Search();this.search=new Booli.Search.Listings()},transactions:function(){this.map=new Booli.Map.Search();this.search=new Booli.Search.Transactions()}};Booli.Controller.Source={init:function(a){Booli.Location.init();if(typeof this[a]==="function"){this[a]()}Booli.RefineLoader(this.search);this.setupOffertAdTracking()},list:function(){Booli.Source.List.init()},listing:function(){this.search=new Booli.Search.Source.Listings();this.map=new Booli.Map.Search()},transaction:function(){this.search=new Booli.Search.Source.Transactions();this.map=new Booli.Map.Search()},setupOffertAdTracking:function(){if(($("offertAd")||$("topBar"))&&$("offertSubmit")){Booli.Pageview.add("offert-ad-imp",{noAd:1});$("offertSubmit").observe("click",function(){Booli.Pageview.add("offert-ad-click",{noAd:1})})}}};Booli.Controller.User={init:function(a){if(this[a]){this[a]()}},editSearch:function(){$("remove").observe("click",function(){Booli.Pageview.add("ta-bort",{noAd:1})});$("save").observe("click",function(){Booli.Pageview.add("spara",{noAd:1})})}};Booli.AuthLoader={_loginCheckInited:false,_loginCheckDone:false,load:function(a){if(a){Booli.AuthLoader._loadScripts(a)}},run:function(b,a,c){this._loadScripts(function(){Booli.Auth.Popup[b](a,c)}.bind(this))},_loadScripts:function(a){var b=typeof a==="function"?a:function(){};if(this._loaded){b()}else{if(this._inProgress){setTimeout(this._load.bind(this,b),10)}else{this._inProgress=1;LazyLoad.js(Booli.Config.auth,function(){this._loaded=true;b()},null,this)}}},_loginCheck:function(){if(this._loginCheckInited){return}this._loginCheckInited=1;var d=this,c,b,a=function(){c=new Ajax.Request("/auth/isLoggedIn",{method:"get",parameters:{fbConnected:$.bjStorage.get("fb.connected"),format:"json"},onSuccess:function(e){if(e&&e.responseText&&e.responseText!==""&&e.responseText.isJSON()){b=e.responseText.evalJSON().auth;if(Booli.Auth.Static&&!$("auth")){Booli.Auth.Static.setLoggedIn(b.status,true)}else{var f=$("login"),g=$("logout");if(f){f[!!b.status?"hide":"show"]()}if(g){g[!!b.status?"show":"hide"]()}}Booli.Auth.loggedIn=!!b.status;d._loginCheckDone=true;if(Booli.Auth.loggedIn){_gaq.push(["_setCustomVar",1,"user","registered",2])}}}})};setTimeout(a,100)}};Event.observe(window,"load",function(){setTimeout(Booli.AuthLoader._loginCheck.bind(Booli.AuthLoader),30)});Booli.Auth.loggedIn=false;Booli.Auth.isLoggedIn=function(){return Booli.Auth.loggedIn};Booli.Auth.isLoggedInAsync=function(a){if(Booli.AuthLoader._loginCheckDone){a(Booli.Auth.loggedIn)}else{setTimeout(function(){Booli.Auth.isLoggedInAsync(a)},10)}};Booli.Auth.LoginAsync=function(b,a){if(Booli.Auth.loggedIn){b()}else{Booli.AuthLoader.run("login",b,a)}};Booli.FB={init:function(a){LazyLoad.js(Booli.Config.scriptUrl+"application/Facebook/Wrapper"+Booli.Config.jsRev+".js",function(){Booli.FB.init(a)})}};Booli.RefineLoader=(function(){var a=function(d,b,c){if(!d.refine){LazyLoad.js(Booli.Config.scriptUrl+"application/Refine/Refine"+Booli.Config.jsRev+".js",function(){d.refine=new Booli.Refine(d,b,c)},null)}else{d.refine.show()}};return function(c){var d,b=$("searchBox");if(b){a(c,b,true)}else{CustomEvents.observe(this,"Topbar:changeSearch",function(){d=new Element("div",{id:"searchBox",style:"display:none;","class":c.name}).update(Booli.Server.load);Element.insert(document.body,d);b=new Booli.Widgets.ModalBox(d);b.show();a(c,b)});var e=$$(".active")[0];if(e){e.observe("click",function(f){f.stop();d=new Element("div",{id:"searchBox",style:"display:none;","class":c.name}).update(Booli.Server.load);Element.insert(document.body,d);b=new Booli.Widgets.ModalBox(d);b.show();a(c,b)})}}}}());var FormField={DefaultInputText:function(){var d=$H({});var c="#595959";var b="#000000";function a(i,e){var l=$(i);var f=e;var m="";var h=this;var g=function(){if($F(l)===""){l.value=f;if(!l.hasClassName("FixedColor")){l.setStyle({color:c})}}};var k=function(){if($F(l)===f){l.value="";l.setStyle({color:b})}};this.reset=function(){var n=$F(l.identify());if(n===""){g()}else{if(n!==f){l.setStyle({color:b})}else{if(!l.hasClassName("FixedColor")){l.setStyle({color:c})}}}};this.onBlur=function(){l.stopObserving("blur",h.onBlur);l.observe("focus",h.onFocus);g()};this.onFocus=function(){l.stopObserving("focus",h.onFocus);l.observe("blur",h.onBlur);k()};this.destroy=function(){l.stopObserving("blur",h.onBlur);l.stopObserving("focus",h.onFocus);d.unset(l.identify());l=null;h=null};if(!l){throw"Argument 1 for DefaultFormText constructor must be a form field or a form field id!"}if(a.isRegistered(l)){d.get(l.identify()).destroy()}d.set(l.identify(),this);l.observe("focus",h.onFocus);h.reset()}a.isRegistered=function(f){var e=$(f);return !!e&&!!d.get(e.identify())};a.createDefaultInputTexts=function(){$$(".DefaultInputText").each(function(g){var e=$(g).readAttribute("alt");if(!e){e=$F(g)}var f=new FormField.DefaultInputText(g,e)})};return a}(),initialize:function(){this.DefaultInputText.createDefaultInputTexts()}};if(!Booli.Widgets){Booli.Widgets={}}Booli.Widgets.ModalBox=function(){var b={},i={overlay:null,closeButton:null},n=null,c=function h(){i.overlay=new Element("div",{"class":"overlay",id:"modal_overlay"}).setStyle({display:"none"});i.closeButton=new Element("div",{"class":"closePopup closeIcon",title:"Stäng"})},m=function(o){var p=o.content.identify();b[p]=o},k=function(o){var p=o.content.identify();b[p]=null;o.hide()},g=function(){if(i.overlay){if(!i.overlay.up()){Element.insert(document.body,i.overlay)}i.overlay.show()}},e=function(){if(i.overlay){i.overlay.hide()}},a=function(o){if(o.hasCloseButton){o.wrapper.insert({top:i.closeButton})}},f=function(o){var q=o.hide.bind(o);i.closeButton.stopObserving();i.closeButton.observe("click",q);var p=$("cancel_"+o.content.identify());if(p){p.stopObserving();p.observe("click",q)}Event.observe(window,"resize",o.preventHiddenTop.bind(o))},l=function(o){this.content=$(o);this.hasCloseButton=!this.content.hasClassName("noCloseButton");this.wrapper=this.content.wrap("div",{id:this.content.identify()+"Wrapper","class":"modalBox modalBoxWrapper"}).hide();this.content.removeClassName("modalBox").removeClassName("noCloseButton").addClassName("content").show();Element.insert(document.body,this.wrapper);m(this)};l.prototype={preventHiddenTop:function(){if(!(Booli.ie<7)){var p=this.wrapper.getHeight();var o=document.documentElement.clientHeight;if(p>o){this.wrapper.setStyle({top:"0px",marginTop:"0px"})}else{if(this.wrapper===$("popupConnectWrapper")){this.wrapper.setStyle({top:"50%",marginTop:"-200px"})}else{if(this.wrapper===$("popup_registerWrapper")){this.wrapper.setStyle({top:"50%",marginTop:"-194px"})}else{this.wrapper.setStyle({top:"50%",marginTop:Math.floor(-p/2)+"px"})}}}}},show:function(){if(n===null){c()}if(n&&n!==this){n.hide()}n=this;a(this);f(this);g();this.wrapper.show();this.preventHiddenTop();if(Prototype.Browser.IE){this.wrapper.hide().show()}CustomEvents.notify(this,"modal_box:show_"+this.content.id);return this},hide:function(){e();this.wrapper.hide();CustomEvents.notify(this,"modal_box:hide_"+this.content.id);return this},visible:function d(){return this.wrapper.visible()}};l.get=function(p){var o=$(p);if(!o){return false}return b[o.identify()]};l.getActive=function(){return(n&&n.visible())?n:null};l.lazy=function(t,s,o,w,r){var q,u,p,v;u=l.get(t.id);if(u){u.show();return u}q=new Element("div",t).update(Booli.Server.load);Element.insert(document.body,q);u=new Booli.Widgets.ModalBox(q);u.show();if(r){$("modal_overlay").observe("click",function(){u.hide()})}setTimeout(function(){p=new Ajax.Request(s,{parameters:o,method:"get",onComplete:function(y){if(y.responseText.isJSON()){q.update(y.responseText.evalJSON())}else{q.update(y.responseText)}var x=$("cancel_"+t.id);if(x){x.stopObserving();x.observe("click",u.hide.bind(u))}w()}})},200);return u};return l}();if(!Booli.Widgets){Booli.Widgets={}}Booli.Widgets.SlidingBox=(function(){var b={},a=function(c,d){this.element=$(c);this.offset=d||0;this.container=this.element.up();this.checkBoundaries();this.addListeners();b[this.element.identify()]=this};a.prototype={container:null,element:null,currentEffect:null,isScrolling:false,scrollLimitTop:0,scrollLimitBottom:0,scrollHandler:null,checkBoundaries:function(){var c=this.container.cumulativeOffset();var d=parseInt(this.element.getStyle("marginTop"),10);this.scrollLimitTop=c.top+d;this.scrollLimitBottom=this.scrollLimitTop+this.container.getHeight()-this.element.getHeight()-d;return this.scrollLimitBottom>this.scrollLimitTop},addListeners:function(){this.scrollHandler=this.onScroll.bind(this);Event.observe(window,"scroll",this.scrollHandler)},onScroll:function(d){if(this.currentEffect){this.currentEffect.cancel()}var c=false;if(!(c=this.calculateScrollDistance())){this.checkBoundaries();return}var e=this;Booli.Effect.run(this.element,"Move",{x:c.x,y:c.y,delay:4},function(f){e.currentEffect=f})},calculateScrollDistance:function(){var d=document.viewport.getScrollOffsets();var f=this.element.cumulativeOffset();var c=d.top-f.top+this.offset;var e=f.top+c;if(e<this.scrollLimitTop){c=this.scrollLimitTop-f.top}if(e>this.scrollLimitBottom){c=this.scrollLimitBottom-f.top}if(c===0){return false}return{x:0,y:c}}};return a}());$$(".sliding").each(function(a){var b=new Booli.Widgets.SlidingBox(a,60)});Booli.Pageview={opts:{},attr:{},time:5000,positions:[],init:function(){this.positions=$$(".adunit")||[];var a=this;Event.observe(window,"load",function(){setTimeout(a._ads.bind(a),1500)})},add:function(b,d,a){this.opts=d||{};this.attr=a||{};this.showAd=(this.opts.forceAd||!this.timer)&&!this.opts.noAd;var c=false;if(this.showAd){c=this._ads(b)}this._track(b,c)},domchange:function(){this.positions=$$(".adunit")},setAttr:function(a){this.attr=Object.extend(this.attr,a)},_ads:function(){if(this.opts&&!this.opts.forceAd){var d=this;this.timer=setTimeout(function(){d.timer=null},this.time)}var c,f,e=Object.toQueryString(this.attr),h=0;if(this.opts&&this.opts.imageViewAd){this.positions=[$("Inspiration_Slideshow_768x512")]}else{this.positions=$$(".adunit")}if(this.opts&&this.opts.domchange){this.positions=$$(".adunit")}for(var b=0,a=this.positions.length;b<a;b+=1){c=this.positions[b];if(c&&Toolbox.isVisible(c)){j=0;var g=c.id+(e!==""?"&"+e:"");c.innerHTML="<iframe scrolling='no' allowTransparency='true' frameborder='0' src='/ad/render?pos="+g+"' style='z-index: 0;'></iframe>";h++}}return h>0},_track:function(a,c){var b="/_ga/"+(c?"":"xpv/"),b=b+Booli.Tracking.resource,b=b+"/"+(this.legacyMapper[a]||this.legacyMapper[a]==""?this.legacyMapper[a]:a),b=b.toLowerCase(),b=b+Booli.Tracking.area,b=b.replace(/\/\/\/?/g,"/");if(window._gaq){_gaq.push(["_trackPageview",b])}},legacyMapper:{changeSearch:"forfina/dialog",sort:"sortera/dialog/oppna",monitor:"bevaka/dialog/oppna",adjustMap:"karta/storlek",transactionsTab:"slutpriser",listingsTab:"",statisticsTab:"bomarknad"}};if(!Booli.Map){Booli.Map={}}Booli.Map.Abstract={map:null,elements:{},loaded:false,bounds:{},currentHits:{},cache:{},active:1,control_opts:{scaleControl:true,navigationControl:true,mapTypeControl:true,streetViewControl:true},_DEFAULT_ZOOM:5,_LOW_ACC_ZOOM:12,_SET_ZOOM_MAX:15,MIN_ZOOM:5,MAX_ZOOM:18,centerLat:62.875188,centerLng:18.720703,create:function(){this.map=new google.maps.Map($(this.elements.map),Object.extend({zoom:this._getZoom(),center:new google.maps.LatLng(this.centerLat,this.centerLng),mapTypeId:google.maps.MapTypeId.ROADMAP},this.control_opts));this._setMaxAndMinZoomLevel();Booli.Map.Marker=Booli.Map.MarkerCreator();var b=this;this.map.getBMapInstance=function(){return b};this.map.infoBox=new Booli.Map.Info(this.map);var a=function(c){this.setMap(c)};a.prototype=new google.maps.OverlayView();a.prototype.draw=function(){};a.prototype.getProjectionMap=function(d,c){return this.getProjection()[d](c)};this.OverlayView=new a(this.map);this.setupSubClasses();this.bindCustomListeners();this.loaded=true},setupSubClasses:function(){},bindCustomListeners:function(){},processHits:function(b){this.currentHits={};this.validNrOfHits=0;this.nrOfHits=b.length;for(var a=0;a<this.nrOfHits;a=a+1){this.currentHits[b[a].id]=b[a];if(b[a].showInMap){this.validNrOfHits=this.validNrOfHits+1}}},getHit:function(d){if(this.currentHits&&this.currentHits[d]){return this.currentHits[d]}else{if(this.cache&&this.cache[d]){return this.cache[d]}else{var f=window["booli_meta_"+d],g,b,e={},a;if(f){e=f;e.id=d}this.cache[d]=e;return e}}},getNrOfHitsOnMap:function(){return this.nrOfHits},isOnlyLowAccMarkers:function(){return(this.validNrOfHits===0&&this.nrOfHits!==0)},_getZoom:function(){if(this.isOnlyLowAccMarkers()){return this._LOW_ACC_ZOOM}if(this.getNrOfHitsOnMap()===0){return this._DEFAULT_ZOOM}return this.zoom||this._DEFAULT_ZOOM},setBoundsZoom:function(){this.map.fitBounds(Booli.Map.Toolbox.getGBounds(new google.maps.LatLng(this.bounds.maxLat,this.bounds.maxLng),new google.maps.LatLng(this.bounds.minLat,this.bounds.minLng)));if(this.map.getZoom()>this._SET_ZOOM_MAX){this.map.setZoom(this._getZoom())}},_setMaxAndMinZoomLevel:function(){var a=this;google.maps.event.addListener(this.map,"zoom_changed",function(){if(a.map.getZoom()<a.MIN_ZOOM){a.map.setZoom(a.MIN_ZOOM)}})},isMapLarge:function(){return true},setupActivateMap:function(){var a=this,b=this.control_opts;google.maps.event.addListener(this.map,"mouseover",function(c){if(a.active){return}a.active=1;a.map.setOptions({streetViewControl:true});setTimeout(function(){a.map.setOptions({navigationControl:true,mapTypeControl:true,scaleControl:true})},10)});google.maps.event.addListener(this.map,"mouseout",function(d){if(!a.active){return}var c=a.map.getDiv().getDimensions();if((d.pixel.x>0&&d.pixel.x<c.width)&&(d.pixel.y>0&&d.pixel.y<c.height)){return}a.active=0;a.map.setOptions({streetViewControl:false});a.map.setOptions({navigationControl:false,mapTypeControl:false,scaleControl:false})})}};Booli.Map.Listing=function(){this.parent=Booli.Map.Abstract;this.create()};Booli.Map.Listing.prototype=Object.extend({},Booli.Map.Abstract);Object.extend(Booli.Map.Listing.prototype,{active:0,disallow_tiles:1,control_opts:{scaleControl:false,navigationControl:false,mapTypeControl:false,streetViewControl:false},elements:{map:"listingMap"},create:function(){this.hit=Booli.Server.hit;this.centerLat=this.hit.latitude;this.centerLng=this.hit.longitude;this.zoom=14;this.type=Booli.Server.type;this.parent.create.call(this);this.hit.noClick=true;this.processHits([this.hit]);var a=this;setTimeout(function(){a.mc.add(a.currentHits)},500);this.setupActivateMap()},setupSubClasses:function(){if(this.hit.showInMap){this._setupDistanceControl()}this.mc=new Booli.Map.MarkerWrapper.Ajax(this.map)},_setupDistanceControl:function(){var b=$("distanceSection"),a=this;if(b){FormField.initialize();b.observe("mouseover",function(){a._loadDistance();b.stopObserving()})}},_loadDistance:function(){var b=this,a;LazyLoad.js(Booli.Config.scriptUrl+"application/MapModules/DrivingDirection"+Booli.Config.jsRev+".js",function(){a=new Direction(b.map,new google.maps.LatLng(b.hit.latitude,b.hit.longitude));if(Booli.Server.storedAddressesJson){}},null)}});Booli.Map.ListingLarge=function(){this.parent=Booli.Map.Abstract;this.create()};Booli.Map.ListingLarge.prototype=Object.extend({},Booli.Map.Abstract);Object.extend(Booli.Map.ListingLarge.prototype,{elements:{map:"map"},create:function(){this.hit=Booli.Server.hit;this.centerLat=this.hit.latitude;this.centerLng=this.hit.longitude;this.zoom=14;this.type=Booli.Server.type;this.parent.create.call(this);this.processHits([this.hit]);this.resize();Event.observe(window,"resize",this.resize.bind(this));var a=this;setTimeout(function(){a.mc.add(a.currentHits)},500)},resize:function(){$(this.elements.map).style.height=(document.documentElement.clientHeight-61)+"px"},setupSubClasses:function(){var a=new Booli.Map.Tooltip(this.map);this.mc=new Booli.Map.MarkerWrapper.Ajax(this.map)}});if(!Booli.Map.MapSearch){Booli.Map.MapSearch={}}Booli.Map.MapSearch=function(a){this.mapHeightHandler=this.mapHeightResizer.bind(this);this.parent=Booli.Map.Abstract;this.create(a)};Booli.Map.MapSearch.prototype=Object.extend({},Booli.Map.Abstract);Object.extend(Booli.Map.MapSearch.prototype,{_tileLayer:null,elements:{map:"mapSearch",mapContainer:"mapSearchContainer",loading:"mapLoading"},create:function(b){var a=$.bjStorage.get("map_search");this.bounds=Booli.Server.bounds;this.centerLat=a?a.lat:(this.bounds.maxLat+this.bounds.minLat)/2;this.centerLng=a?a.lng:(this.bounds.maxLng+this.bounds.minLng)/2;this.zoom=a?a.z:5;this.uniqueSearchKey=Booli.Server.uniqueSearchKey;this.type=b||Booli.Server.type;this.parent.create.call(this);this.mapHeightResizer();$("topBar").show();this._setupDragZoom();var c=this;setTimeout(function(){c._searchViewPort()},500)},setupSubClasses:function(){Booli.Map.Loader("Popup",this.map);var a=new Booli.Map.Tooltip(this.map);this.mc=new Booli.Map.MarkerWrapper.Ajax(this.map)},bindCustomListeners:function(){var a=this;CustomEvents.observe(this,"search:update",function(b){a.mc.remove();a.uniqueSearchKey=b.source.uniqueSearchKey;a._searchViewPort(true,b)});CustomEvents.observe(this,"search:no_hits",function(){a._hideLoading()});google.maps.event.addListener(this.map,"idle",this._searchViewPort.bind(this));Event.observe(window,"resize",this.mapHeightHandler)},processHits:function(b){this.currentHits=null;this.validNrOfHits=0;this.ids=null;if(!b){return}this.currentHits={};this.ids=[];this.nrOfHits=b.length;for(var a=0;a<this.nrOfHits;a=a+1){this.currentHits[b[a][0]]={latitude:b[a][2],longitude:b[a][1],tooltip:"",id:parseInt(b[a][0],10),showInMap:parseInt(b[a][3],10)};this.ids.push(parseInt(b[a][0],10))}},_getFlatBounds:function(){var b=this.map.getBounds(),a=b.getSouthWest(),c=b.getNorthEast();return{maxLat:c.lat(),minLat:a.lat(),maxLng:c.lng(),minLng:a.lng()}},_hideLoading:function(){var a=$(this.elements.loading);if(a.style.display==="none"){return}a.hide()},_searchViewPort:(function(){var a,b,c,e,d;function f(h){a._hideLoading();a._saveState();var g;if(h.responseText===""||parseInt(h.responseText,10)===0){g=[]}else{g=h.responseText.evalJSON()}a.processHits(g);a.mc.add(a.currentHits,a.ids);if(a.savedZoom){a.setBoundsZoom();a.savedZoom=null}}return function(g){a=this;try{d=this._getFlatBounds()}catch(h){setTimeout(a._searchViewPort.bind(a),20);return}d.hash=this.uniqueSearchKey;d.maxNr=this.mc.getMarkerLimit();d.type=this.type;e=Object.toQueryString(d);if(e===c&&g!==true){return}c=e;this.map.infoBox.load("Lägger till bostäder");if(b){b.transport.abort()}b=new Ajax.Request("/map/searchViewport?"+e,{method:"get",onSuccess:f})}}()),mapHeightResizer:function(){Toolbox.maximizeHeight(this.elements.map,null,1,null,300,1);google.maps.event.trigger(this.map,"resize")},_setupDragZoom:function(){LazyLoad.js(Booli.Config.scriptUrl+"/application/MapModules/keydragzoom"+Booli.Config.jsRev+".js",function(){Booli.Map.DragZoom();this.map.enableKeyDragZoom({visualEnabled:true,visualPosition:google.maps.ControlPosition.LEFT,visualPositionOffset:new google.maps.Size(35,0),visualPositionIndex:null,visualSprite:"http://maps.gstatic.com/mapfiles/ftr/controls/dragzoom_btn.png",visualSize:new google.maps.Size(20,20),visualTips:{on:"Klicka för att avaktivera zoomhjälp",off:"Klicka för att aktivera zoomhjälp"}})},null,this)},_saveState:function(){$.bjStorage.set("map_search",{lat:this.map.getCenter().lat(),lng:this.map.getCenter().lng(),z:this.map.getZoom()})}});Booli.Map.Info=function(a){this.map=a};Booli.Map.Info.prototype={_infoDiv:null,_create:function(){this._infoDiv=new Element("div",{"class":"infoBox",style:"display:none"});this.map.getDiv().appendChild(this._infoDiv)},show:function(a){if(!this._infoDiv){this._create()}if(this.text!==a){this._infoDiv.update(a);this.text=a}this._infoDiv.show()},warn:function(a){this.show(a);this._infoDiv.className="errorBox"},load:function(a){this.show('<img title="Laddar" alt="" src="'+Booli.Config.imagesUrl+'/map/ajax-loader.gif" />'+a)},hide:function(){if(!this._infoDiv){return}this._infoDiv.hide();this._infoDiv.className="infoBox"}};Booli.Map.ListInteraction=function(c){this.map=c;this.BMap=c.getBMapInstance();this.interactionDiv=new Element("div",{style:"display:none;position:relative;"});var a=new Element("div",{"class":"interactionMarker"}),b=this;this.interactionDiv.appendChild(a);CustomEvents.observe(b,"hitlist:mouseover",b._show);CustomEvents.observe(b,"hitlist:mouseout",b._hide);CustomEvents.observe(b,"map:showing_tiles",b.allow);CustomEvents.observe(b,"map:showing_markers",b.disallow);CustomEvents.observe(b,"hitlist:showInMap",b._hide);CustomEvents.observe(b,"hit:remove",b._hide);google.maps.event.addListener(c,"bounds_changed",b._hide.bind(b))};Booli.Map.ListInteraction.prototype={isAllowed:true,allow:function(){this.isAllowed=true},disallow:function(){this._hide();this.isAllowed=false},_showCalled:0,_show:function(a){if(!this._showCalled){this.BMap.OverlayView.getPanes().floatPane.appendChild(this.interactionDiv);this._showCalled=1}if(!this.isAllowed){return}var f=a.source.id,b=this.BMap.getHit(f),e=new google.maps.LatLng(b.latitude,b.longitude),c,d;if(!this.map.getBounds().contains(e)){return}c=this.BMap.OverlayView.getProjectionMap("fromLatLngToDivPixel",e);d=new google.maps.Size(c.x-9,c.y-32);this.interactionDiv.style.top=d.height+"px";this.interactionDiv.style.left=d.width+"px";this.interactionDiv.show()},_hide:function(){if(this.interactionDiv){this.interactionDiv.hide()}this.map.infoBox.hide()}};Booli.Map.MarkerCreator=function(){var a=function(b){google.maps.Marker.apply(this,arguments);if(this.get("clickable")){google.maps.event.addListener(this,"click",this.onClick);google.maps.event.addListener(this,"mouseover",this.mouseOverHandler);google.maps.event.addListener(this,"mouseout",this.mouseOutHandler)}};a.prototype=new google.maps.Marker();a.prototype=Object.extend(a.prototype,{onClick:function(b){var d=this.get("clicked");this.setIcon(d?this.get("icons").hover:this.get("icons").def);this.set("clicked",!d);CustomEvents.notify({id:this.get("id")},"marker:click")},mouseOverHandler:function(c){this.onMouseOver();for(var b=0;b<this.get("multipleMarker").length;b=b+1){CustomEvents.notify({id:this.get("multipleMarker")[b]},"marker:mouseover")}},onMouseOver:function(){if(!this.get("clicked")){this.setIcon(this.get("icons").hover)}},mouseOutHandler:function(){this.onMouseOut();for(var b=0;b<this.get("multipleMarker").length;b=b+1){CustomEvents.notify({id:this.get("multipleMarker")[b]},"marker:mouseout")}},onMouseOut:function(b){if(!this.get("clicked")){this.setIcon(this.isSaved?this.get("icons").saved:this.get("icons").def)}},saved:function(){this.isSaved=1;this.setIcon(this.get("icons").saved)},unsaved:function(){this.isSaved=0;this.setIcon(this.get("icons").def)}});return a};Booli.Map.Polygon={_polygons:[],_color:"#000000",_transparency:1,_borderSize:1,visible:false,map:null,lazy:function(c,b){if(!Booli.Server.params||!Booli.Server.params.areaId){return}var a=Object.isArray(Booli.Server.params.areaId)?Booli.Server.params.areaId.join(","):Booli.Server.params.areaId;setTimeout(function(){new Ajax.Request("/map/polygon?id="+a,{method:"get",onComplete:function(d){Booli.Map.Polygon.add(d.responseText.evalJSON(),c,b)}})},2000)},add:function(l,b,h){if(Booli.Map.Polygon.exists()||!l){return}var a,k,c,f,e,g=l.length,d;this.map=b;this.visible=true;for(f=0;f<g;f=f+1){a=l[f];k=new google.maps.MVCArray();d=a.length;for(e=0;e<d;e=e+1){k.push(new google.maps.LatLng(parseFloat(a[e][0]),parseFloat(a[e][1])))}c=new google.maps.Polygon({paths:k,strokeColor:this._color,strokeOpacity:this._transparency,strokeWeight:this._borderSize,map:!h?this.map:null,clickable:false,fillOpacity:0});this._polygons.push(c)}},remove:function(){this.hide();this._polygons=[]},exists:function(){return this._polygons.length!==0},hide:function(){if(!Booli.Map.Polygon.exists()||!this.visible){return}for(var b=0,a=this._polygons.length;b<a;b=b+1){this._polygons[b].setMap()}this.visible=false},show:function(){if(!Booli.Map.Polygon.exists()||this.visible){return}for(var b=0,a=this._polygons.length;b<a;b=b+1){this._polygons[b].setMap(this.map)}this.visible=true}};Booli.Map.TileLayer={_TILE_BASE_URL:"/map/getTile/",tilelayer:null,_map:null,_added:false,uniqueSearchKey:null,create:function(c){this._map=c;this.uniqueSearchKey=this.BMap.uniqueSearchKey;var d=Booli.Map.Toolbox.getGBounds(new google.maps.LatLng(this.BMap.bounds.maxLat,this.BMap.bounds.maxLng),new google.maps.LatLng(this.BMap.bounds.minLat,this.BMap.bounds.minLng)),a=this,b={};b.isPng=true;b.tileSize=new google.maps.Size(256,256);b.getTileUrl=function(e,h){var g=Booli.Config.tilesMultipleHosts?window.location.protocol+"//mt"+(e.x+e.y)%4+".booli.se":"",i={zoom:h,x:e.x,y:e.y,type:a.BMap.type,hash:a.uniqueSearchKey},f=g+a._TILE_BASE_URL+"?"+Object.toQueryString(i);return f};this.tilelayer=new google.maps.ImageMapType(b)},add:function(a){this.BMap=a.getBMapInstance();if(this.uniqueSearchKey!==this.BMap.uniqueSearchKey){this.remove()}if(!this.tilelayer){this.create(a)}if(!this._added){this._added=true;this._map.overlayMapTypes.insertAt(0,this.tilelayer)}},hide:function(){if(this.tilelayer&&this._added){this._added=false;this._map.overlayMapTypes.removeAt(0)}},remove:function(){this.hide();this.tilelayer=null}};Booli.Map.Tooltip=function(d){this.map=d;this.BMap=d.getBMapInstance();this._tooltip=new Element("div",{id:"tooltip",style:"display:none;position:absolute;"});this._markerOutsideHolder=$("markerOutsideHolder");var b=$("tooltipTemplate"),a=$("markerOutsideHolderTemplate");this._template=new Template(b?b.innerHTML:"");this._markerOutsideHolderTemplate=new Template(a?a.innerHTML:"",/(^|.|\r|\n)(\--(\w+)--)/);var c=this;CustomEvents.observe(c,"marker:mouseover",c._showTimed.bind(c,false));CustomEvents.observe(c,"marker:mouseout",c._hide);CustomEvents.observe(c,"hitlist:mouseover",c._showTimed.bind(c,true));CustomEvents.observe(c,"hitlist:mouseout",c._hide);CustomEvents.observe(c,"marker:click",c._toggle);CustomEvents.observe(c,"hit:remove",c._hide);CustomEvents.observe(c,"map:resize",c._hide);CustomEvents.observe(c,"hitlist:showInMap",c._hide);CustomEvents.observe(c,"listing_map:show_tooltip",c._showTimed.bind(c,true));google.maps.event.addListener(d,"idle",this._hide.bind(this));google.maps.event.addListener(d,"mouseover",this._hide.bind(this));CustomEvents.observe(c,"marker:open",c._disallow);CustomEvents.observe(c,"marker:close",c._allow);CustomEvents.observe(c,"popup:show",c._disallow);CustomEvents.observe(c,"popup:hide",c._allow)};Booli.Map.Tooltip.prototype={_timer:null,allowed:true,_allow:function(){this.allowed=true},_disallow:function(){this.allowed=false},_hide:function(a){clearTimeout(this._timer);this._tooltip.hide();this._hideOutsideBounds();this._visible=false},_showTimed:function(c,a){if(!this.added){this.BMap.OverlayView.getPanes().floatPane.appendChild(this._tooltip);this.added=1}var b=this;clearTimeout(this._timer);this._timer=setTimeout(b._show.bind(b,c,a),300)},_show:function(c,a){if(!a){return}var d=a.source.id,b=Object.extend({},this.BMap.getHit(d));this.latlng=new google.maps.LatLng(b.latitude,b.longitude);b.imageUrl='<img src="'+Booli.Map.Toolbox.getImageUrl(d)+'" />';b.type=Booli.Server.type&&Booli.Server.type==="transactions"?"transaction":"listing";if(this.allowed&&!this.map.getBounds().contains(this.latlng)){this._showOutsideBounds(b)}else{if(!c){this._showInsideBounds(b)}}},_setPosition:function(b){var e,c,d;if(this.BMap.OverlayView.getProjectionMap("fromLatLngToDivPixel",this.map.getCenter()).y>this.BMap.OverlayView.getProjectionMap("fromLatLngToDivPixel",this.latlng).y){this._tooltip.addClassName("top");e=65+this._tooltip.getHeight()}else{this._tooltip.removeClassName("top")}var a=$("markerTooltip");if(Prototype.Browser.IE&&a&&a.style.width===""){a.style.width=(this._tooltip.getWidth()===4?140:this._tooltip.getWidth())+"px";if(Booli.ie<7){a.style.width="140px"}}c=this.BMap.OverlayView.getProjectionMap("fromLatLngToDivPixel",this.latlng);d=new google.maps.Size(c.x-(this._tooltip.getWidth()/2),c.y-48-(this._tooltip.getHeight())+(e||0));this._tooltip.style.top=(d.height+(!!b.showInMap?0:10))+"px";this._tooltip.style.left=d.width+"px"},_showInsideBounds:function(d){var a=this.BMap.mc.getMultipleMarkers(d.id),c,b=this;c=new Ajax.Request("/map/getPostAddress?id="+d.id+"&type="+this.BMap.type+"&multiple="+a.length,{method:"get",onComplete:function(e){b._evalTemplateAndSetPosition(d,e.responseText)}})},_evalTemplateAndSetPosition:function(b,a){b.postAddress=a;this._tooltip.update(this._template.evaluate(b));this._tooltip.down("img").src=Booli.Config.imagesUrl+"/map/tt_loader.gif";this._setPosition(b);this._tooltip.show();this._visible=true;if(Booli.ie<7&&$("thumb")&&$("markerTooltip")){$("thumb").style.width=$("markerTooltip").getWidth()-4+"px"}},_showOutsideBounds:function(a){if(!this._markerOutsideHolder||!$("searchMap")){return}this._markerOutsideHolder.update(this._markerOutsideHolderTemplate.evaluate(a));this._markerOutsideHolder.down("#mapImg").src="http://maps.google.com/maps/api/staticmap?center="+a.latitude+","+a.longitude+"&zoom=13&size=140x155&sensor=false";this._markerOutsideHolder.show();$("mapLoading").show();if(Booli.ie<7){$("markerShadImg").hide()}},_hideOutsideBounds:function(){if(!$("markerOutsideHolder")||!$("searchMap")){return}$("markerOutsideHolder").hide();$("mapLoading").hide()},_toggle:function(){if(this._visible){this._hide()}else{this._show()}}};Booli.Map.Search=function(){this.parent=Booli.Map.Abstract;this.largeMapResizeHandler=this.largeMapResizer.bind(this);this.smallMapResizeHandler=this.smallMapResizer.bind(this);this.create()};Booli.Map.Search.prototype=Object.extend({},Booli.Map.MapSearch.prototype);Object.extend(Booli.Map.Search.prototype,{_tileLayer:null,active:0,control_opts:{scaleControl:false,navigationControl:false,mapTypeControl:false,streetViewControl:false},savedZoom:null,elements:{map:"searchMap",mapContainer:"searchMapContainer",location:{largeMap:"largeMap",smallMap:"rightContainer"},loading:"mapLoading"},scrollOffsetTop:0,create:function(){this.bounds=Booli.Server.bounds;this.centerLat=(this.bounds.maxLat+this.bounds.minLat)/2;this.centerLng=(this.bounds.maxLng+this.bounds.minLng)/2;this.uniqueSearchKey=Booli.Server.uniqueSearchKey;this.type=Booli.Server.type;this.parent.create.call(this);if(this.bounds.maxLat!==this.bounds.minLat&&this.bounds.maxLng!==this.bounds.minLng){this.setBoundsZoom()}this._getResizeHandler().call(this);this.activateScroll();var a=new Booli.Map.ListInteraction(this.map);Booli.Map.Polygon.lazy(this.map,window.location.hash.match("sparade"))},bindCustomListeners:function(){var a=this;CustomEvents.observe(this,"search:update",function(b){if(a.uniqueSearchKey===b.source.uniqueSearchKey){return}a.mc.remove();a.uniqueSearchKey=b.source.uniqueSearchKey;a.bounds=b.source.bounds;a.centerLat=(a.bounds.maxLat+a.bounds.minLat)/2;a.centerLng=(a.bounds.maxLng+a.bounds.minLng)/2;a._searchViewPort(true)});CustomEvents.observe(this,"search:no_hits",function(){a._hideLoading()});CustomEvents.observe(this,"search:showing_saved",function(){Booli.Map.Polygon.hide();a.savedZoom=true});CustomEvents.observe(this,"search:hiding_saved",function(){Booli.Map.Polygon.show();a.savedZoom=true});google.maps.event.addListener(this.map,"idle",this._searchViewPort.bind(this));Event.observe(window,"resize",function(){var b=a._getResizeHandler();b.call(a)});CustomEvents.observe(this,"Topbar:adjustMap",this._toggleMapSize);this.setupActivateMap()},_hideLoading:function(){var a=$(this.elements.loading);if(a.style.display==="none"){return}a.hide();if($(this.elements.mapContainer).up().identify()===this.elements.location.largeMap){$("mapInfoSmall").show();CustomEvents.notify({size:"large"},"map:resize")}},isMapLarge:function(){return($(this.elements.mapContainer).up().identify()===this.elements.location.largeMap)},_getResizeHandler:function(){return this[this.isMapLarge()?"largeMapResizer":"smallMapResizer"]},mapHeightResizer:function(){Toolbox.maximizeHeight(this.elements.map,null,1,null,300,1);google.maps.event.trigger(this.map,"resize")},_maximizeMap:function(a){Event.stopObserving(window,"resize",this.smallMapResizeHandler);$(this.elements.location.largeMap).insert({top:a});$("minimizeMap").show();$("maximizeMap").hide();this.largeMapResizer();this.largeMap=true;Event.observe(window,"resize",this.largeMapResizeHandler)},largeMapResizer:function(){Toolbox.maximizeHeight(this.elements.mapContainer,null,90,"large",300);google.maps.event.trigger(this.map,"resize")},_minimizeMap:function(a){Event.stopObserving(window,"resize",this.largeMapResizeHandler);$(this.elements.location.smallMap).insert({top:a});$("maximizeMap").show();$("minimizeMap").hide();this.smallMapResizer();this.largeMap=false;Event.observe(window,"resize",this.smallMapResizeHandler)},smallMapResizer:function(){if(Booli.Config.isTouch){Toolbox.maximizeHeight(this.elements.mapContainer,"leftContainer",0,"small",145)}else{Toolbox.maximizeHeight(this.elements.mapContainer,"leftContainer",360,"small",145)}google.maps.event.trigger(this.map,"resize")},_toggleMapSize:function(){if(!this.mc.isMarkersAdded()){return}var a=this.map.getCenter(),b=$(this.elements.mapContainer);if(this.isMapLarge()){this._minimizeMap(b)}else{this._maximizeMap(b)}this.map.setCenter(a);CustomEvents.notify({size:this.isMapLarge()?"large":"small"},"map:resize")},activateScroll:function(){if(Booli.ie<7){return}var m=$("leftContainer"),v=$("rightContainer"),g=$("searchContainer"),o=m.cumulativeOffset().top-this.scrollOffsetTop-1,s,c=v.cumulativeOffset().left,r,l,h,u=!this.isMapLarge(),w="absolute",b=true,f=0,p=null,t,e,n,k,i,d,a=function(){c=v.hasClassName("nonliquid")?v.offsetLeft:c;if(!u){return}e=document.viewport.getScrollOffsets()[1]-o;p=m.getHeight()-v.getHeight();n=v.getStyle("width");if(h>o&&p>0){s=h-o;b=false;f=f+1;k=m.cumulativeOffset().left+m.getWidth()+5;d=document.viewport.getWidth()<996?k-(document.viewport.getScrollOffsets()[0]):k;v.setStyle({position:"fixed",top:"1px",width:n,left:d+"px"});g.setStyle({position:"static"});CustomEvents.notify({pos:"fixed"},"map:fixed")}else{if(!b){b=true;f=f+1;c=m.getWidth();v.setStyle({position:"absolute",left:c+5+"px",width:n});g.setStyle({position:"relative"});CustomEvents.notify({pos:"absolute"},"map:absolute")}}},q=function(){h=document.viewport.getScrollOffsets()[1];if(l===h&&!Booli.Config.isTouch){a()}i=v.getStyle("left");l=h};CustomEvents.observe(this,"map:resize",function(x){u=x.source.size==="small";o=m.cumulativeOffset().top-3});Event.observe(window,"scroll",function(x){l=document.viewport.getScrollOffsets()[1];q()})},_saveState:function(){}});Booli.Map.StaticMap=function(){this.parent=Booli.Map.Abstract;this.largeMapResizeHandler=this.largeMapResizer.bind(this);this.smallMapResizeHandler=this.smallMapResizer.bind(this);this.create()};Booli.Map.StaticMap.prototype=Object.extend({},Booli.Map.Search.prototype);Object.extend(Booli.Map.StaticMap.prototype,{bindCustomListeners:function(){var a=this;CustomEvents.observe(this,"search:update",function(c){a.mc.remove();a._searchViewPort(c)});var b=this;setTimeout(function(){b._searchViewPort()},500);Event.observe(window,"resize",function(){var c=a._getResizeHandler();c.call(a)})},_searchViewPort:function(b){var a=b?b.source.hits:Booli.Server.hits;this.processHits(a);this.mc.add(this.currentHits,this.ids);this._hideLoading()},processHits:function(b){this.currentHits={};this.validNrOfHits=0;this.nrOfHits=b.length;for(var a=0;a<this.nrOfHits;a=a+1){this.currentHits[b[a].id]=b[a];if(b[a].showInMap){this.validNrOfHits=this.validNrOfHits+1}}}});Booli.Map.Loader=function(b,d){if(b==="Popup"){var c,a=function(e){LazyLoad.js(Booli.Config.scriptUrl+"application/MapModules/Popup"+Booli.Config.jsRev+".js",function(){c=new Booli.Map.Popup(d);c.toggle(e)});CustomEvents.stopObserving(this,"marker:click",a)};CustomEvents.observe(this,"marker:click",a)}};Booli.Map.Toolbox={getGBounds:function(c,d){var a=new google.maps.LatLngBounds();a.extend(c);a.extend(d);return a},getImageUrl:function(a){return Booli.Config.imagesUrl+"/cache/primary_"+a+"_140x94.jpg"}};if(!Booli.Map.MarkerWrapper){Booli.Map.MarkerWrapper={}}Booli.Map.MarkerWrapper.Abstract={map:null,markers:{},markersOnMap:{},_icon:{},lowAcc:[],enabled:true,create:function(){this.BMap=this.map.getBMapInstance();this.createIcons();this.mgr=new MarkerManager(this.map);this.addListeners()},addListeners:function(){var a=this;CustomEvents.observe(a,"savedObject:removed",a.removeMarker);CustomEvents.observe(a,"hit:save",a._toggleSaved.bind(a,true));CustomEvents.observe(a,"hit:remove",a._toggleSaved.bind(a,false));CustomEvents.observe(a,"marker:close",function(c){try{a.markerCallback("onMouseOut",c)}catch(b){}})},add:function(){},remove:function(){if(this.mgr){if(this.mapMoveHandle){google.maps.Event.removeListener(this.mapMoveHandle);this.mapMoveHandle=null}this.markersOnMap={};this.hits=[];this.mgr.clearMarkers();this.lowAcc=[];Booli.Map.TileLayer.remove()}},getMarker:function(a){return this.markers[a]},getMultipleMarkers:function(d){var a=this.markers[d]||{},b=a.positionKey,c=this.visibleHits[b];return c||false},removeMarker:function(b){var a=this.getMarker(b.source.id);if(!a){return}this.BMap.validNrOfHits=this.BMap.validNrOfHits-1;this.mgr.removeMarker(a);CustomEvents.notify({id:a.id},"marker:removed")},isMarkersAdded:function(){return this.markersAdded},hideOverlays:function(){this.disableMarkers();Booli.Map.TileLayer.hide()},createIcons:(function(){var a=function(h,c,b,e,d,g,f){return{def:new google.maps.MarkerImage(Booli.Config.imagesUrl+"/map/"+h+".png",new google.maps.Size(c,b),new google.maps.Point(0,0),new google.maps.Point(g,f)),shadow:new google.maps.MarkerImage(Booli.Config.imagesUrl+"/map/"+h.replace("Transaction","")+"Shadow.png",new google.maps.Size(e,d),new google.maps.Point(0,0),new google.maps.Point(g,f)),saved:new google.maps.MarkerImage(Booli.Config.imagesUrl+"/map/"+h+"Saved.png",new google.maps.Size(c,b),new google.maps.Point(0,0),new google.maps.Point(g,f)),hover:new google.maps.MarkerImage(Booli.Config.imagesUrl+"/map/"+h+"h.png",new google.maps.Size(c,b),new google.maps.Point(0,0),new google.maps.Point(g,f)),hoverUrl:Booli.Config.imagesUrl+"/map/"+h+"h.png",defaultUrl:Booli.Config.imagesUrl+"/map/"+h+".png",savedUrl:Booli.Config.imagesUrl+"/map/"+h+"Saved.png",anchor:new google.maps.Point(g,f),size:new google.maps.Size(c,b)}};return function(){this._icon={};this._icon.la={};this._icon.mm={};this._icon.mm.la={};this._icon.normal=a("marker",17,35,26,36,8,35);this._icon.transaction=a("markerTransaction",17,35,26,36,8,35);this._icon.la.normal=a("markerLowAcc",17,26,28,27,8,13);this._icon.la.transaction=a("markerLowAccTransaction",17,26,28,27,8,13);this._icon.mm.normal=a("markerMultiple",21,37,31,37,10,37);this._icon.mm.transaction=a("markerMultipleTransaction",21,37,31,37,10,37);this._icon.mm.la.normal=a("markerLowAccMultiple",21,22,26,22,10,11);this._icon.mm.la.transaction=a("markerLowAccMultipleTransaction",21,22,26,22,10,11)}}()),_getIcon:function(c,a,d){var b=this._icon;if(a){b=this._icon.mm}if(d){b=b.la}if(c.transactionDate||this.BMap.type==="transactions"){b=b.transaction}else{b=b.normal}return b},markerCallback:function(c,b){var a=this.getMarker(b.source.id);if(a&&this.map.getBounds().contains(a.getPosition())){a[c]()}},_toggleSaved:function(b,d){var a=this.getMarker(d.source.id),c=this.BMap.getHit(d.source.id);if(!a){return}c.listingId=!!b;if(a.get("visible")&&this.map.getBounds().contains(a.getPosition())){if(b){a.saved()}else{a.unsaved()}}},_createMarker:function(l,h){var b=l[0],a=this.BMap.getHit(b),c=(l.length>1),k=!a.showInMap,e,d,g=this._getIcon(a,c,k);var f={icon:g.def,shadow:g.shadow,icons:g,hoverUrl:g.hoverUrl,defaultUrl:g.defaultUrl,id:b,clickable:!a.noClick,multipleMarker:l,positionKey:h,lowAcc:k,map:this.map,position:new google.maps.LatLng(a.latitude,a.longitude),anchor:g.anchor,size:g.size};e=new Booli.Map.Marker(f);for(d=0;d<l.length;d++){this.markers[l[d]]=e}return e},showTiles:function(){CustomEvents.notify({},"map:showing_tiles");this.disableMarkers();var a=this;setTimeout(function(){Booli.Map.TileLayer.add(a.map)},50);this.markersAdded=true},showMarkers:function(a){this.enableMarkers();Booli.Map.TileLayer.hide();this.addMarkers(this.visibleHits,a);CustomEvents.notify({},"map:showing_markers")},addMarkers:(function(){var f,h,i,b,a,k,g,d=function(){if(!f[h]){return}g=f[h];g=k._createMarker(g.ids,g.key);k.mgr.addMarker(g,0);k.markersOnMap[g.get("positionKey")]=1;if(g.get("lowAcc")){k.lowAcc.push(g)}if(g.get("id")===k.activeHit){g.onMouseOver();k.activeHit=null}h=h+1;if(h===i){k.map.infoBox.hide();clearInterval(b);k.markersAdded=true}},e=function(l,c){f=[];h=0;i=0;k=this;this.map.infoBox.load("Uppdaterar");if(l&&l.length!==0){for(var n in l){if(typeof l[n]!=="function"&&!this.markersOnMap[n]&&n!=="count"){i=i+1;f.push({ids:l[n],key:n})}}if(!c){if(b){clearInterval(b)}this.mgr.clearMarkers()}for(var m=f.length-1;m>=0;m--){d()}}if(i===0){this.map.infoBox.hide();this.markersAdded=true}};return e}()),enableMarkers:function(){if(!this.enabled){this.enabled=true;this.mgr.show()}},disableMarkers:function(){if(this.enabled){this.enabled=false;this.mgr.hide()}},getMarkerLimit:function(){if(Booli.Server.controller==="user"){return 30000}if(Booli.ie<7){return 50}if(Prototype.Browser.IE){return 75}return 100}};if(!Booli.Map.MarkerWrapper){Booli.Map.MarkerWrapper={}}Booli.Map.MarkerWrapper.Ajax=function(a){this.map=a;this.parent=Booli.Map.MarkerWrapper.Abstract;CustomEvents.observe(this,"hitlist:mouseover",this.markerCallback.bind(this,"onMouseOver"));CustomEvents.observe(this,"hitlist:mouseout",this.markerCallback.bind(this,"onMouseOut"));this.create()};Booli.Map.MarkerWrapper.Ajax.prototype=Object.extend({},Booli.Map.MarkerWrapper.Abstract);Object.extend(Booli.Map.MarkerWrapper.Ajax.prototype,{add:function(a,b){this.hits=a;this.visibleHits=this.getVisibleHits();if(this.visibleHits.count>0){this.showMarkers(true)}else{this.showTiles();this.mgr.clearMarkers();this.markersOnMap=[];setTimeout(this.map.infoBox.hide.bind(this.map.infoBox),800)}},getVisibleHits:function(){var a={},d,c,b;a.count=0;for(c in this.hits){d=this.hits[c];if(typeof d!=="function"){b=""+d.latitude+d.longitude;if(a[b]){a[b].push(d.id)}else{a[b]=[d.id]}a.count++}}return a}});function MarkerManager(b,c){var a=this;a.map_=b;a.mapZoom_=b.getZoom();a.projectionHelper_=ProjectionHelperOverlay(b);google.maps.event.addListener(a.projectionHelper_,"ready",function(){a.projection_=this.getProjection();a.initialize(b,c)})}MarkerManager.prototype.initialize=function(f,h){var d=this;h=h||{};d.tileSize_=MarkerManager.DEFAULT_TILE_SIZE_;var b=f.mapTypes;var a=1;for(var g in b){if(typeof f.mapTypes.get(g)==="object"&&typeof f.mapTypes.get(g).maxZoom==="number"){var c=f.mapTypes.get(g).maxZoom;if(c>a){a=c}}}d.maxZoom_=h.maxZoom||19;d.trackMarkers_=h.trackMarkers;d.show_=h.show||true;var e;if(typeof h.borderPadding==="number"){e=h.borderPadding}else{e=MarkerManager.DEFAULT_BORDER_PADDING_}d.swPadding_=new google.maps.Size(-e,e);d.nePadding_=new google.maps.Size(e,-e);d.borderPadding_=e;d.gridWidth_={};d.grid_={};d.grid_[d.maxZoom_]={};d.numMarkers_={};d.numMarkers_[d.maxZoom_]=0;google.maps.event.addListener(f,"bounds_changed",function(){d.onMapMoveEnd_()});d.removeOverlay_=function(i){i.setMap(null);d.shownMarkers_--};d.addOverlay_=function(i){if(d.show_){i.setMap(d.map_);d.shownMarkers_++}};d.resetManager_();d.shownMarkers_=0;d.shownBounds_=d.getMapGridBounds_();google.maps.event.trigger(d,"loaded")};MarkerManager.DEFAULT_TILE_SIZE_=1024;MarkerManager.DEFAULT_BORDER_PADDING_=100;MarkerManager.MERCATOR_ZOOM_LEVEL_ZERO_RANGE=256;MarkerManager.prototype.resetManager_=function(){var a=MarkerManager.MERCATOR_ZOOM_LEVEL_ZERO_RANGE;for(var b=0;b<=this.maxZoom_;++b){this.grid_[b]={};this.numMarkers_[b]=0;this.gridWidth_[b]=Math.ceil(a/this.tileSize_);a<<=1}};MarkerManager.prototype.clearMarkers=function(){if(!this.shownBounds_){return}this.processAll_(this.shownBounds_,this.removeOverlay_);this.resetManager_()};MarkerManager.prototype.getTilePoint_=function(e,c,d){var b=this.projectionHelper_.LatLngToPixel(e,c);var a=new google.maps.Point(Math.floor((b.x+d.width)/this.tileSize_),Math.floor((b.y+d.height)/this.tileSize_));return a};MarkerManager.prototype.addMarkerBatch_=function(c,h,b){var f=this;var g=c.getPosition();c.MarkerManager_minZoom=h;if(this.trackMarkers_){google.maps.event.addListener(c,"changed",function(k,i,l){f.onMarkerMoved_(k,i,l)})}var d=this.getTilePoint_(g,b,new google.maps.Size(0,0,0,0));for(var e=b;e>=h;e--){var a=this.getGridCellCreate_(d.x,d.y,e);a.push(c);d.x=d.x>>1;d.y=d.y>>1}};MarkerManager.prototype.isGridPointVisible_=function(b){var d=this.shownBounds_.minY<=b.y&&b.y<=this.shownBounds_.maxY;var a=this.shownBounds_.minX;var c=a<=b.x&&b.x<=this.shownBounds_.maxX;if(!c&&a<0){var e=this.gridWidth_[this.shownBounds_.z];c=a+e<=b.x&&b.x<=e-1}return d&&c};MarkerManager.prototype.onMarkerMoved_=function(c,g,b){var f=this.maxZoom_;var h=false;var e=this.getTilePoint_(g,f,new google.maps.Size(0,0,0,0));var d=this.getTilePoint_(b,f,new google.maps.Size(0,0,0,0));while(f>=0&&(e.x!==d.x||e.y!==d.y)){var a=this.getGridCellNoCreate_(e.x,e.y,f);if(a){if(this.removeFromArray_(a,c)){this.getGridCellCreate_(d.x,d.y,f).push(c)}}if(f===this.mapZoom_){if(this.isGridPointVisible_(e)){if(!this.isGridPointVisible_(d)){this.removeOverlay_(c);h=true}}else{if(this.isGridPointVisible_(d)){this.addOverlay_(c);h=true}}}e.x=e.x>>1;e.y=e.y>>1;d.x=d.x>>1;d.y=d.y>>1;--f}if(h){this.notifyListeners_()}};MarkerManager.prototype.removeMarker=function(c){var e=this.maxZoom_;var f=false;var b=c.getPosition();var d=this.getTilePoint_(b,e,new google.maps.Size(0,0,0,0));while(e>=0){var a=this.getGridCellNoCreate_(d.x,d.y,e);if(a){this.removeFromArray_(a,c)}if(e===this.mapZoom_){if(this.isGridPointVisible_(d)){this.removeOverlay_(c);f=true}}d.x=d.x>>1;d.y=d.y>>1;--e}if(f){this.notifyListeners_()}this.numMarkers_[c.MarkerManager_minZoom]--};MarkerManager.prototype.addMarkers=function(d,e,c){var a=this.getOptMaxZoom_(c);for(var b=d.length-1;b>=0;b--){this.addMarkerBatch_(d[b],e,a)}this.numMarkers_[e]+=d.length};MarkerManager.prototype.getOptMaxZoom_=function(a){return a||this.maxZoom_};MarkerManager.prototype.getMarkerCount=function(b){var a=0;for(var c=0;c<=b;c++){a+=this.numMarkers_[c]}return a};MarkerManager.prototype.getMarker=function(f,c,e){var g=new google.maps.LatLng(f,c);var b=this.getTilePoint_(g,e,new google.maps.Size(0,0,0,0));var a=new google.maps.Marker({position:g});var h=this.getGridCellNoCreate_(b.x,b.y,e);if(h!==undefined){for(var d=0;d<h.length;d++){if(f===h[d].getLatLng().lat()&&c===h[d].getLatLng().lng()){a=h[d]}}}return a};MarkerManager.prototype.addMarker=function(b,e,d){var a=this.getOptMaxZoom_(d);this.addMarkerBatch_(b,e,a);var c=this.getTilePoint_(b.getPosition(),this.mapZoom_,new google.maps.Size(0,0,0,0));if(this.isGridPointVisible_(c)&&e<=this.shownBounds_.z&&this.shownBounds_.z<=a){this.addOverlay_(b);this.notifyListeners_()}this.numMarkers_[e]++};function GridBounds(a){this.minX=Math.min(a[0].x,a[1].x);this.maxX=Math.max(a[0].x,a[1].x);this.minY=Math.min(a[0].y,a[1].y);this.maxY=Math.max(a[0].y,a[1].y)}GridBounds.prototype.equals=function(a){if(this.maxX===a.maxX&&this.maxY===a.maxY&&this.minX===a.minX&&this.minY===a.minY){return true}else{return false}};GridBounds.prototype.containsPoint=function(a){var b=this;return(b.minX<=a.x&&b.maxX>=a.x&&b.minY<=a.y&&b.maxY>=a.y)};MarkerManager.prototype.getGridCellCreate_=function(a,f,e){var c=this.grid_[e];if(a<0){a+=this.gridWidth_[e]}var b=c[a];if(!b){b=c[a]=[];return(b[f]=[])}var d=b[f];if(!d){return(b[f]=[])}return d};MarkerManager.prototype.getGridCellNoCreate_=function(a,e,d){var c=this.grid_[d];if(a<0){a+=this.gridWidth_[d]}var b=c[a];return b?b[e]:undefined};MarkerManager.prototype.getGridBounds_=function(a,i,h,f){i=Math.min(i,this.maxZoom_);var b=a.getSouthWest();var e=a.getNorthEast();var g=this.getTilePoint_(b,i,h);var d=this.getTilePoint_(e,i,f);var k=this.gridWidth_[i];if(e.lng()<b.lng()||d.x<g.x){g.x-=k}if(d.x-g.x+1>=k){g.x=0;d.x=k-1}var c=new GridBounds([g,d]);c.z=i;return c};MarkerManager.prototype.getMapGridBounds_=function(){return this.getGridBounds_(this.map_.getBounds(),this.mapZoom_,this.swPadding_,this.nePadding_)};MarkerManager.prototype.onMapMoveEnd_=function(){this.objectSetTimeout_(this,this.updateMarkers_,0)};MarkerManager.prototype.objectSetTimeout_=function(b,c,a){return window.setTimeout(function(){c.call(b)},a)};MarkerManager.prototype.visible=function(){return this.show_?true:false};MarkerManager.prototype.isHidden=function(){return !this.show_};MarkerManager.prototype.show=function(){this.show_=true;this.refresh()};MarkerManager.prototype.hide=function(){this.show_=false;this.refresh()};MarkerManager.prototype.toggle=function(){this.show_=!this.show_;this.refresh()};MarkerManager.prototype.refresh=function(){if(this.shownMarkers_>0){this.processAll_(this.shownBounds_,this.removeOverlay_)}if(this.show_){this.processAll_(this.shownBounds_,this.addOverlay_)}this.notifyListeners_()};MarkerManager.prototype.updateMarkers_=function(){this.mapZoom_=this.map_.getZoom();var a=this.getMapGridBounds_();if(a.equals(this.shownBounds_)&&a.z===this.shownBounds_.z){return}if(a.z!==this.shownBounds_.z){this.processAll_(this.shownBounds_,this.removeOverlay_);if(this.show_){this.processAll_(a,this.addOverlay_)}}else{this.rectangleDiff_(this.shownBounds_,a,this.removeCellMarkers_);if(this.show_){this.rectangleDiff_(a,this.shownBounds_,this.addCellMarkers_)}}this.shownBounds_=a;this.notifyListeners_()};MarkerManager.prototype.notifyListeners_=function(){google.maps.event.trigger(this,"changed",this.shownBounds_,this.shownMarkers_)};MarkerManager.prototype.processAll_=function(b,d){for(var a=b.minX;a<=b.maxX;a++){for(var c=b.minY;c<=b.maxY;c++){this.processCellMarkers_(a,c,b.z,d)}}};MarkerManager.prototype.processCellMarkers_=function(b,f,d,e){var a=this.getGridCellNoCreate_(b,f,d);if(a){for(var c=a.length-1;c>=0;c--){e(a[c])}}};MarkerManager.prototype.removeCellMarkers_=function(a,c,b){this.processCellMarkers_(a,c,b,this.removeOverlay_)};MarkerManager.prototype.addCellMarkers_=function(a,c,b){this.processCellMarkers_(a,c,b,this.addOverlay_)};MarkerManager.prototype.rectangleDiff_=function(b,a,d){var c=this;c.rectangleDiffCoords_(b,a,function(e,f){d.apply(c,[e,f,b.z])})};MarkerManager.prototype.rectangleDiffCoords_=function(b,a,m){var f=b.minX;var n=b.minY;var h=b.maxX;var d=b.maxY;var e=a.minX;var l=a.minY;var g=a.maxX;var c=a.maxY;var k,i;for(k=f;k<=h;k++){for(i=n;i<=d&&i<l;i++){m(k,i)}for(i=Math.max(c+1,n);i<=d;i++){m(k,i)}}for(i=Math.max(n,l);i<=Math.min(d,c);i++){for(k=Math.min(h+1,e)-1;k>=f;k--){m(k,i)}for(k=Math.max(f,g+1);k<=h;k++){m(k,i)}}};MarkerManager.prototype.removeFromArray_=function(e,c,d){var a=0;for(var b=0;b<e.length;++b){if(e[b]===c||(d&&e[b]===c)){e.splice(b--,1);a++}}return a};function ProjectionHelperOverlay(b){function a(e){this.setMap(e);var c=8;var d=1<<c;var f=7;this._map=e;this._zoom=-1;this._X0=this._Y0=this._X1=this._Y1=-1}a.prototype=new google.maps.OverlayView();a.prototype.LngToX_=function(c){return(1+c/180)};a.prototype.LatToY_=function(d){var c=Math.sin(d*Math.PI/180);return(1-0.5/Math.PI*Math.log((1+c)/(1-c)))};a.prototype.LatLngToPixel=function(g,d){var e=this._map;var f=this.getProjection().fromLatLngToDivPixel(g);var c={x:~~(0.5+this.LngToX_(g.lng())*(2<<(d+6))),y:~~(0.5+this.LatToY_(g.lat())*(2<<(d+6)))};return c};a.prototype.draw=function(){if(!this.ready){this.ready=true;google.maps.event.trigger(this,"ready")}};return new a(b)}var Navigation=function(){var g=40;var i=38;var h=13;var d=37;var a=39;var c=27;var b=9;var e=null;var k={changeValueOnRowChange:true};var f=function(r,m,v,n){var p=null;var o=null;var q=null;var w=function(x){var y=o.getSelectedRowNr()+x;o.setSelectedRowNr(y,q.changeValueOnRowChange);p.setCurrentSuggest(y)};var s=function(z){var x=z.keyCode?z.keyCode:z.charCode;if(x===g||x===i){z.stop()}else{if(x===h){var y=t();var A=(!p.getCurrentSuggest||(typeof p.getCurrentSuggest()!=="string"&&p.getCurrentSuggest()!==null));if(y&&A){z.stop()}else{if(Prototype.Browser.IE){CustomEvents.notify({},"Booli.Suggest.Navigation:stringSubmit")}}l(z)}}};var u=function(){var x=$$(".suggestMenu");var y=[];x.each(function(z){y.push(z.visible())});return(y.indexOf(true)>=0)};var t=function(){var x=$("suggestHits")?$("suggestHits").visible():false;return(x||u())};var l=function(y){var x=y.keyCode?y.keyCode:y.charCode;if(x===d||x===a){return}var z=this.value;switch(x){case h:p.selectSuggest(o.getSelectedRowNr());if(p.abortCurrentSuggest){p.abortCurrentSuggest()}break;case c:o.hideSuggests();break;case g:w(1);break;case i:w(-1);break;default:o.setSelectedRowNr(-1,false);p.updateSuggests(z)}};q=Object.extend(n||{},k);p=r;o=m;e=v;this.keyPress=l;$(e).observe("keypress",s);$(e).observe("keyup",l)};return f}();var PriceSuggest=function(){var b={className:"price"};var a=function(e){var d=null;var f=null;var g=null;var c=function(h){h=(""+h).replace(/[^\d]/g,"");var i=h+"0";if(h.length<4){return c(i)}else{if(h.length<8){return i}}return null};this.getSuggestions=function(){var k=d.getValue().replace(/[^\d]/g,"");var h=[];if(k>9999){h.push(k)}if(k!==""&&parseInt(k,10)!==0){var i=c(k);while(i!==null){h.push(i);i=c(i)}}return h};this.setField=function(h){d=h};this.getField=function(){return d};this.setMenu=function(h){g=h};this.getMenu=function(){return g};this.beforeSubmit=function(){if(this.getMenu().visible()){this.getMenu().chooseCurrent()}var h=d.getElement();if(h.value!=="Min"&&h.value!=="Max"){h.value=h.value.replace(/[^\d]/g,"")}return true};this.updateSuggests=function(i){var h=d.getElement();if(h.value.length>3){h.value=Toolbox.readableNumber(h.value)}g.show()};this.setCurrentSuggest=function(h,i){g.setSelectedRowNr(h,i)};this.selectSuggest=function(){g.chooseCurrent()};f=Object.extend(e||{},b)};return a}();Booli.Suggest=function(b,a){this.searchField=$(b);this.type=a||"hybrid";this.suggestHits=$("suggestHits");this.hintEl=$("hint");Toolbox.absTop("suggestHits","suggestsWrapper",{zIndex:200},true,true);this.addListeners()};Booli.Suggest.prototype={suggestString:"",suggestions:null,type:null,open:false,highlighted:null,elements:[],hintStr:"",hintActive:true,addListeners:function(){Event.observe(document,"keydown",this.documentKeydown.bind(this));Event.observe(document,"click",this.documentClick.bind(this));this.searchField.observe("keyup",this.keyup.bind(this))},documentKeydown:function(b){var a=b.keyCode?b.keyCode:b.charCode;if(!this.open){return}if(a===32){this.resetHint();this.hintActive=false}if(a===13&&this.open&&this.highlighted!==null&&this.suggestions[this.highlighted]){b.stop();this.suggested()}if(a===27){this.close()}if(a===40){this.move("down");b.stop()}if(a===38){this.move("up");b.stop()}},documentClick:function(b){var a=b.element();if(a.up("#suggestHits")){if(a.hasClassName("suggestHit")||a.up().hasClassName("suggestHit")){this.suggested()}else{return}}this.close()},keyup:function(b){var a=b.keyCode?b.keyCode:b.charCode,c=[13,27,40,38,37,39];if(c.indexOf(parseInt(a,10))===-1){this.update()}},suggested:function(){CustomEvents.notify(this.suggestions[this.highlighted],"suggest:suggested");this.highlighted=null;this.suggestString="";this.hintActive=true;this.close();this.updateHint(0,"Lägg till nytt område")},getSuggest:function(){return this.highlighted!==null?this.suggestions[this.highlighted]:null},update:function(){if(this.suggestString===this.searchField.value){return}if(this._request){this._request.transport.abort()}if(this.searchField.value===""){this.suggestString="";this.hintActive=true;this.close();return}this.suggestString=this.searchField.value;this.resetElements();var a={q:this.suggestString,listings:0,transactions:0};if(this.type==="hybrid"){a.listings=1;a.transactions=1}else{if(this.type==="listings"){a.listings=1}else{a.transactions=1}}this._request=new Ajax.Request("/suggest",{method:"get",parameters:a,onSuccess:this.newSuggests.bind(this)})},newSuggests:function(a){this.highlighted=null;this.suggestions=a.responseJSON.suggestions;this.updateHint(0);this.suggestHits.update(this.getHtml()).show();this.observe();this.toggleHighlight(0);this.open=true;Toolbox.absTop("suggestHits","suggestsWrapper",{zIndex:200},true,true)},move:function(a){var b=this.highlighted!==null?this.highlighted:-1;b=b+(a==="up"?-1:1);if(b===-1||b===this.suggestions.length){this.updateHint(b);this.toggleHighlight(b);CustomEvents.notify(this.suggestString,"suggest:highlighted");return}if(b>this.suggestions.length){b=0}if(b<0){b=this.suggestions.length-1}if(this.suggestions[b]){this.updateHint(b);this.toggleHighlight(b);CustomEvents.notify(this.suggestions[b].areaName,"suggest:highlighted")}},getHtml:function(){var f=new Element("div",{id:"suggestContent","class":"searchSuggest"}),c=this.suggestions,a=c.length,e=0,d=0;if(a>0){for(var b=0;b<a;b++){if(c[b].areaType=="postAddress"&&e===0){f.insert('<div class="suggestDiv"></div>');e=1}else{if(c[b].areaType=="county"&&d===0){f.insert('<div class="suggestDiv"></div>');d=1}}this.elements[b]=new Element("div",{"class":"suggestHit"}).update(c[b].areaName+'<span class="p">, '+c[b].parent+"</span>");f.insert(this.elements[b])}if(this.type!=="hybrid"){f.insert('<div class="t">Eller testa vår <a target="_blank" href="/kartsok/'+(this.type==="transactions"?"salda/":"")+'">kartsök</a>.</div>')}}else{if(this.type==="hybrid"){f.update('<div class="t">Hittade inga områden med information om bostadsmarknaden.</div>')}else{if(this.type==="listings"){f.update('<div class="t">Hittade inga områden med bostäder till salu. Testa vår <a target="_blank" href="/kartsok/">kartsök</a>.</div>')}else{f.update('<div class="t">Hittade inga områden med slutpriser. Testa vår <a target="_blank" href="/kartsok/salda/">kartsök</a>.</div>')}}}return f},observe:function(){var b=this,a=0;this.elements.each(function(c){c.id=a;a++;c.observe("mouseover",function(){var d=parseInt(this.id,10);b.updateHint(d);b.toggleHighlight(d)})})},resetElements:function(){this.elements.each(function(a){a.stopObserving()});this.elements=[]},close:function(){this.resetElements();this.resetHint();this.suggestHits.hide();this.open=false},toggleHighlight:function(a){this._highlight(this.highlighted,"remove");this._highlight(a,"add");this.highlighted=a},_highlight:function(a,c){var b=this.elements[a];if(b){b[c+"ClassName"]("highlight")}},updateHint:function(c,d){var a=d||"";if(a===""){if(!this.hintActive){return}if(!this.suggestions[c]){this.resetHint();return}var e=this.suggestions[c].areaName,b=this.searchField.value+e.substr(this.searchField.value.length);if(this.hintStr===b){return}}else{if(this.searchField.value===""){b=a}else{b=""}}this.resetHint();this.hintEl.update(b);this.hintStr=b},resetHint:function(){this.hintStr="";this.hintEl.update("")}};var SuggestElement=function(){var a=function(m,l,h,c){var f=null;var d=null;var r=m;var p=(Object.isUndefined(l)||l===null)?m:l;var e=h;var q={className:"suggestElement",hoverClass:"hover",selectedClass:"selected",style:""};var b=function(){e.getMenu().setSelectedValue(r,false,false)};var g=function(){};var n=function(){e.getMenu().setSelectedValue(r,true,true);e.getField().focus();e.getMenu().hide()};var o=function(){d.stopObserving("mouseover",b);d.stopObserving("click",n);d.stopObserving("mouseout",g)};var k=function(){d.observe("mouseover",b);d.observe("click",n);d.observe("mouseout",g)};var i=function(){d=new Element("div",{style:f.style,"class":f.className});d.update(p)};this.destroy=function(){if(!d){return}d.update();o();d=null};this.getElement=function(){return d};this.setLabel=function(s){p=s;d.update(p)};this.setValue=function(s){if(p===r){this.setLabel(s)}r=s};this.getValue=function(){return r};this.setSelected=function(s){if(!s&&d.hasClassName(f.selectedClass)){d.removeClassName(f.selectedClass)}else{if(!!s&&!d.hasClassName(f.selectedClass)){d.addClassName(f.selectedClass)}}};f=Object.extend(c||{},q);i();k()};return a}();var SuggestFactory=function(){var d={className:"suggest"};var f=null;var c=null;var e=function(){c=$$("."+f.className)};this.hideAll=function(){};var b=function(l){var q=c.length;var p=null;var k=null;var n=null;var h=null;var g={};var m=Array.from($$(".suggestMenu"));m.each(function(i){i.remove()});for(var o=0;o<q;o++){var r=c[o];if(!r.isCustomized){if(r.hasClassName("price")){if(l&&l.wrapper&&l.wrapper.hasClassName("modalBox")&&!(Booli.ie<7)){g={style:"position: fixed; display: none;"}}p=new PriceSuggest();n=new SuggestField(p,r);k=new SuggestMenu(p,r,g);h=new Navigation(p,k,r,{changeValueOnRowChange:false});p.setField(n);p.setMenu(k);r.isCustomized=true}}}};var a=function(h,g){f=Object.extend(h||{},d);e();b(g)};return a}();var SuggestField=function(){var b={className:"suggest"};var a=function(l,k,e){var f=k;var h=null;var d=null;var i=l;var m=function(q){var p=$(q).up("."+i.getMenu().getClassName());if(q.hasClassName(i.getMenu().getClassName())||q.hasClassName(h.className)){}else{if(!!p){q=p}else{q=q.up("."+h.className)}}return q};var g=function(p){return i.beforeSubmit()};var n=function(p){f.focus();f.select();if(p.type==="click"&&!i.getMenu().visible()){i.getMenu().show();p.stop()}};var c=function(p){var q=null;if(p.type==="blur"){if(!!p.explicitOriginalTarget){q=p.explicitOriginalTarget.parentNode;q=m(q);if(q===i||q===f||q===i.getMenu().getElement()){return}}else{return}}else{if(p.type==="click"){if(Prototype.Browser.IE&&p.target.tagName.toLowerCase()==="input"&&(p.target.type.toLowerCase()==="image"||p.target.type.toLowerCase()==="submit")){i.getMenu().chooseCurrent();return}if(!!p.target){q=p.target}else{q=p.srcElement}q=m(q);if(q===i||q===f||q===i.getMenu().getElement()){return}}else{if(p.type==="popupShow"){q=p.source;if(q===i){return}}else{return}}}if(i.getMenu().visible()){i.getMenu().hide();if(!!p&&!!p.stop){p.stop()}}};var o=function(){var p=f.up("form");if(!!p){p.observe("submit",g)}CustomEvents.observe(i,"popupShow",c)};this.setNavigation=function(p){d=p};this.getValue=function(){return $F(f)};this.setValue=function(p){f.value=p;if(typeof CustomEvents!=="undefined"){CustomEvents.notify(f,"pricechange")}};this.getElement=function(){return f};this.focus=function(){f.focus()};this.setHiddenListeners=function(){document.stopObserving("click",c);f.observe("click",n);f.stopObserving("blur",c)};this.setDisplayListeners=function(){f.stopObserving("click",n);f.observe("blur",c);document.observe("click",c)};h=Object.extend(e||{},b);this.setHiddenListeners();o()};return a}();var SuggestMenu=function(e,a,c){var b={style:"display:none; position:absolute;",className:"suggestMenu",topOffset:2,leftOffset:1,elementClass:SuggestElement};var d=a;this._element=null;this._menuElements=[];this._suggest=e;this.selectedRowNr=0;b.style=c.style||b.style;this._settings=Object.extend(c||{},b);this._position=function(){var f=d.cumulativeOffset();this._element.style.left=(f.left+this._settings.leftOffset)+"px";this._element.style.top=(f.top+d.getHeight()+this._settings.topOffset)+"px";this._element.style.width=(d.getWidth()*1.5)+"px";if(d===$("guess")){this._element.style.left=((f.left-6)+this._settings.leftOffset)+"px";this._element.style.width="396px"}};this._element=new Element("div",{"class":this._settings.className,style:this._settings.style});Element.insert(document.body,this._element)};SuggestMenu.prototype={hide:function(){if(this._element.visible()){this._element.hide();this._suggest.getField().setHiddenListeners();return true}return false},show:function(){var a=this.redraw();if(a&&!this._suggest.getMenu().visible()){this._element.show();CustomEvents.notify(this._suggest,"popupShow");this._suggest.getField().setDisplayListeners()}else{if(!a){this.hide()}}},redraw:function(){this._position();var d=null;while(this._menuElements.length>0){d=this._menuElements.pop();d.destroy();d=null}this._menuElements=[];this._element.update();this.selectedRowNr=0;var c=this._suggest.getSuggestions();var a=c.length;for(var b=0;b<a;b++){d=new this._settings.elementClass(c[b],this.getPrintUnit(Toolbox.readableNumber(c[b])),this._suggest);this._menuElements.push(d);this._element.insert(d.getElement())}this.setSelectedRowNr(this.selectedRowNr,false,true);return !!a},getPrintUnit:function(a){},getSelectedRowNr:function(){return this.selectedRowNr},setSelectedRowNr:function(a,c,b){if(a>this._menuElements.length-1||a<0||(!b&&!this._element.visible())){return false}if(this.selectedRowNr<this._menuElements.length&&this.selectedRowNr>=0){this._menuElements[this.selectedRowNr].setSelected(false)}this.selectedRowNr=a;this._menuElements[this.selectedRowNr].setSelected(true);if(!!c){this._suggest.getField().setValue(this.getSelectedValue())}return true},getSelectedValue:function(){return Toolbox.readableNumber(this._menuElements[this.selectedRowNr].getValue())},setSelectedValue:function(d,c){if(!this._element.visible()){return false}var a=this._menuElements.length;for(var b=0;b<a;b++){if(this._menuElements[b].getValue()===d){this.setSelectedRowNr(b,c);return true}}return false},chooseCurrent:function(){this.setSelectedRowNr(this.getSelectedRowNr(),true,true);this.hide()},visible:function(){return this._element.visible()},hideSuggests:function(){this.hide()},getElement:function(){return this._element},getClassName:function(){return this._settings.className},getPrintUnit:function(a){return a+" kr"}};Booli.Favorite=function(b,d,c){if(!Booli.Auth.isLoggedIn()){Booli.Auth.LoginAsync(Booli.Favorite.bind(this,b,d,c),b==="save"?"Du måste vara inloggad för att kunna spara ett objekt":null);return}var a=new Ajax.Request("/save/"+b+"Listing?id="+d,{method:"get",onComplete:function(){Booli.Pageview.add("favorit/"+(b==="save"?"spara":"radera"),{noAd:1})}});CustomEvents.notify({id:parseInt(d,10)},"hit:"+b);if(c){c()}};Booli.ListEstimate={leftContainer:null,init:function(){this.ceh=$("closeEstimateHelp");this.ae=$$(".activate");this.leftContainer=$("leftContainer");if(!this.leftContainer){return}this.showEstimates();this.showEstimateHelp();CustomEvents.observe(this,"sourceGuesses:activated",function(){this.leftContainer.removeClassName("na");this.closeEstimateHelp.call(this)});this.ae.each(function(a){a.observe("click",Booli.activateSourceGuesses)})},redraw:function(){this.showEstimates();this.showEstimateHelp()},showEstimateHelp:function(){var a=$("estimateHelp");if(a&&!$.bjStorage.get("estimateHelpShown")){this.leftContainer.addClassName("nu");a.show();if(this.ceh){this.ceh.stopObserving();this.ceh=$("closeEstimateHelp")}this.ceh.observe("click",this.closeEstimateHelp.bind(this))}},showEstimates:function(){if($.bjStorage.get("activatedSourceGuesses")){this.leftContainer.removeClassName("na")}},closeEstimateHelp:function(){var a=$("estimateHelp");if(a){a.hide();this.leftContainer.removeClassName("nu");$.bjStorage.set("estimateHelpShown",1)}}};Booli.List=function(a){this.setLatestVisit();if(!this.getContainer(true)){return}Booli.ListEstimate.init();this.type=a;this.listeners();this.addImages();CustomEvents.observe(this,"hit:save",this.savedRemoved.bind(this));CustomEvents.observe(this,"hit:remove",this.savedRemoved.bind(this));CustomEvents.observe(this,"search:update",this.newHits.bind(this));CustomEvents.observe(this,"marker:mouseover",this.markerMouseOverHandler);CustomEvents.observe(this,"marker:mouseout",this.markerMouseOutHandler);CustomEvents.observe(this,"marker:open",this.markerOpenHandler);CustomEvents.observe(this,"marker:close",this.markerCloseHandler)};Booli.List.prototype={_elementsCache:null,_container:null,_meta_cache:[],getElements:function(){if(!this._elementsCache){this._elementsCache=this.getContainer().childElements()}return this._elementsCache},getContainer:function(a){if(!this._container||a){this._container=$("hitsWrapper")}return this._container},newHits:function(a){$("hitlist").update(a.source.hitsHtml);if(!this.getContainer(true)){return}this.getContainer(true).removeClassName("update");Booli.ListEstimate.redraw();this.listeners(true);this._elementsCache=null;this._container=null;this.listeners();this.addImages()},listeners:function(b){var f=this.getElements(),d,c=0,a=f.length,e=this,g=function(k){var i=k.relatedTarget?k.relatedTarget:k.fromElement,h=k.element();if(!i){return}i=$(i);if(!i.descendantOf||i.descendantOf(this)){return}var l=e._id(this.id);if(!l){return}CustomEvents.notify({id:l},"hitlist:"+k.type);if(Booli.Server.controller=="search"){Booli.List.Popup.show(h,this,k.type,e._meta(l,"private"))}};for(c;c<a;c=c+1){d=f[c];if(b){d.stopObserving()}else{d.observe("mouseover",g);d.observe("mouseout",g)}}},clickDelegater:function(h){var i=h.element().className,g,d=h.element(),f=$("leftContainer"),a={map:"karta",aerial:"flygfoto",images:"bilder",info:"info",postAddress:"postAddress"};if(i==="saveIcon"||i==="removeIcon"){this.saveClickHandler.call(this,h)}if(i==="livingCostLink"&&this.type==="listings"&&Booli.Server.controller!=="user"){h.stop();this.showHitlistCampaign(d.up(".hit"))}if(i==="postAddress"||i==="info"||i==="images"){g=this;setTimeout(function(){g.showHitlistCampaign(d.up(".hit"));g.showInterstitial(d.up(".hit"))},700)}if(i!=="activate"&&d.up(".estimate")&&(f&&!$("leftContainer").hasClassName("na"))){var b=d.up(".hit").down(".info").href+"/vardeindikation/";window.open(b)}if(i==="activate"||(d.up(".blur")||i==="blur")){Booli.activateSourceGuesses()}if(a[i]){Booli.Pageview.add(a[i],{noAd:1})}},markerMouseOverHandler:function(b){var a=$("id_"+b.source.id);if(a){a.addClassName("highlight")}},markerMouseOutHandler:function(b){var a=$("id_"+b.source.id);if(a){a.removeClassName("highlight")}},markerOpenHandler:function(b){var a=$("id_"+b.source.id);if(a){a.addClassName("selected")}},markerCloseHandler:function(b){var a=$("id_"+b.source.id);if(a){a.removeClassName("selected").removeClassName("highlight")}},addImages:function(d){var a=this.getElements(),f,c,b,i,h=this,e,g=function(){b=a.shift();if(b&&b.id){c=h._id(b.id);if(h.type==="listings"){f=$("img_"+c);if(f){e=h._meta(c,"primaryImage");f.src=Booli.Config.imagesUrl+"/cache/"+(e?e:"primary_"+c)+"_65x43.jpg";setTimeout(g,100)}}i=h._meta(c,"added");if(i&&h.isNewToUser(i)&&$("new_"+c)){$("new_"+c).show()}}setTimeout(g,100)};setTimeout(g,50)},updateSavedElement:function(b,c){var a;if(c){b.addClassName("saved");a=b.down(".saveIcon");a.removeClassName("saveIcon").addClassName("removeIcon").update("Ta bort")}else{b.removeClassName("saved");a=b.down(".removeIcon");a.removeClassName("removeIcon").addClassName("saveIcon").update("Spara")}},savedRemoved:function(c){var a=$("id_"+c.source.id),b=c.type==="hit:save";if(a){this.updateSavedElement(a,b)}if(!b&&Booli.Server.controller==="user"){CustomEvents.notify({id:c.source.id},"savedObject:removed")}},saveClickHandler:function(b,c){b.stop();var a=b.element();if(a.tagName.toLowerCase()!=="a"){a=a.up("a")}Booli.Favorite(a.hasClassName("saveIcon")?"save":"remove",this._id(a.up(".hit").id))},showHitlistCampaign:function(d){if(Booli.Server.type!=="listings"){return}var b=$$(".hitlistAd")[0],a=this._id(d.id),c=new Element("div",{"class":"hitlistAd",id:"hitlistAd"+a});if(b){b.remove()}d.down("td").insert({bottom:c});c.update(Booli.AdToolbox.getLivingCostAd(a));Booli.Pageview.add("hitlist-ad");if($("hitlistAd"+a)){$("hitlistAd"+a).observe("click",function(){Booli.Pageview.add("hitlist-ad-click",{noAd:1})})}},showInterstitial:function(c){var a=Cookies.get("Interstitial_750x500");if(!a){var b=this._meta(this._id(c.id),"objectType");if(b==="Villa"){var d=Booli.Widgets.ModalBox.lazy({id:"interstitial750x500"},"/ad/getInterstitial",{format:"json",dim:"750x500"},function(){var e=function(){d.hide()};$("modal_overlay").observe("click",e)});Cookies.set("Interstitial_750x500","1",30,"/")}}},setLatestVisit:function(){var b=(new Date()).getTime(),d=Cookies.get("u_visits")||"",c,a;if(d){d=d.split("_");a=parseInt(d[0],10);c=parseInt(d[1],10);if(c<b-60*60*1000){a=c;c=b}}else{c=b;a=b}Cookies.set("u_visits",a+"_"+c,7,"/");this.latestVisit=a},isNewToUser:function(a){if(this.latestVisit&&(a*1000)>this.latestVisit){return true}return false},_meta:function(b,a){if(!this._meta_cache[b]){this._meta_cache[b]=window["booli_meta_"+b]||{}}return a?this._meta_cache[b][a]:this._meta_cache[b]},_id:function(b){var a=b.match(/id_(.*)/);return a?a[1]:false}};Booli.List.Popup={show:function(b,d,a,c){if(Booli.ie===6){return}if(!this.privatePopup){this._setupPrivate()}if(!this.estimatePopup){this._setupEstimate();CustomEvents.observe(this,"sourceGuesses:activated",this._setupEstimate)}if(a==="mouseover"){if(b.hasClassName("estimate")||b.up().hasClassName("estimate")){this.estimatePopup.setStyle({left:"630px",top:d.cumulativeOffset().top+"px",width:"210px"}).show()}else{if(c){this.privatePopup.setStyle({left:"630px",top:d.cumulativeOffset().top+"px"}).show()}}}else{this.privatePopup.hide();this.estimatePopup.hide()}},_setupPrivate:function(){this.privatePopup=new Element("span",{id:"privatePopup",style:"display:none;position:absolute;","class":"InfoPopupChild infoBox"}).update("Psst. Mig hittar du inte via Hemnet.");Element.insert(document.body,this.privatePopup)},_setupEstimate:function(){this.estimatePopup=new Element("span",{id:"estimatePopup",style:"display:none;position:absolute;","class":"InfoPopupChild infoBox"}).update($("leftContainer").hasClassName("na")?"Klicka för att aktivera Värderobot&trade; och Mäklarindikation.":"Klicka för mer information och möjligheten att kommentera.");Element.insert(document.body,this.estimatePopup)}};Booli.Tabs={};Booli.Tabs.Transaction=function(){var a=$("transactionsTab"),b=$("transactionsPopup");if(a&&b){a.observe("mouseover",function(){b.show()}).observe("mouseout",function(){b.hide()})}CustomEvents.observe(this,"TabManager:tabChanged",function(){b.hide()})};if(!Booli.TopBar){Booli.TopBar={}}Booli.TopBar.ErrorReport={init:function(){var a=$("errorReport"),d,c=this,b=function(e){if(!arguments.callee.called){c.setupForm()}Booli.TopBar.Slider.toggle("reportContainer",function(){if(d=$("shareMail")){d.removeClassName("active")}})};a.observe("click",b)},setupForm:function(){var e=$("reportContainer"),d=$("errorReportForm"),b=$("reportFeedback"),c,f=function(a){a.stop();b.update("");c=new Ajax.Request("/listing/error",{method:"get",parameters:d.serialize(true),onSuccess:function(g){b.update("Tack för hjälpen!")}});Booli.Pageview.add("felrapport",{noAd:1})};d.observe("submit",f)}};if(!Booli.TopBar){Booli.TopBar={}}Booli.TopBar.SaveRemove={init:function(e){var d=$("saveOrRemove"),b,a,c=function(f){f.stop();a=Booli.Auth.isLoggedIn();saved=function(){d.addClassName("active");d.down("span").removeClassName("save").addClassName("saved");d.innerHTML=d.innerHTML.replace("Spara","Sparad")},removed=function(){d.removeClassName("active");d.down("span").removeClassName("saved").addClassName("save");d.innerHTML=d.innerHTML.replace("Sparad","Spara")};if(!d.hasClassName("active")){Booli.Favorite("save",e,(a?null:saved));if(a){saved()}}else{Booli.Favorite("remove",e);removed()}};if(!d){return}d.observe("click",c)}};if(!Booli.TopBar){Booli.TopBar={}}Booli.TopBar.Share={init:function(c){var a=$("shareMail"),e,b,d=function(f){f&&f.stop();if(!arguments.callee.called){$("shareContainer").update(Booli.Server.load);e=new Ajax.Updater("shareContainer","/share/getMailHtml",{parameters:{post:c.post,id:c.params.shareId},onComplete:function(){b=new Booli.ShareEmail(d,c.params)}});arguments.callee.called=1}Booli.TopBar.Slider.toggle("shareContainer",function(){a.toggleClassName("active")});CustomEvents.observe({},"topbar:slide_up_shareContainer",function(){})};a.observe("click",d)}};Booli.TopBar.Slider={openOn:null,inProgress:0,toggle:function(b,a){this.cb=a;if(b!==this.openOn){this.show(b)}else{this.hide(b)}},show:function(a){if(this.openOn){this.effect(this.openOn,"SlideUp")}this.effect(a,"SlideDown")},hide:function(a){if(!this.openOn||(a&&a!==this.openOn)){return}this.effect(this.openOn,"SlideUp");CustomEvents.notify({},"topbar:slide_up_"+this.openOn)},effect:function(b,a){var c=this;if(this.inProgress){if(b!==this.inProgress){setTimeout(function(){c.effect(b,a)},10)}return}Booli.Effect.run(b,a,{duration:0.5,beforeStart:function(){c.inProgress=b},afterFinish:function(){c.inProgress=null;c.openOn=a!=="SlideUp"?b:null;if(c.cb){c.cb()}}})}};Booli.TopBar.init=function(b){var c=b||{},a,d;for(a in c){if((d=Booli.TopBar[a])&&typeof a!=="function"){d.init(c[a])}}};Booli.TopMenu={init:function(){var a=$("topBar");a&&a.observe("click",this.handleTopBarClick)},handleTopBarClick:function(a){var c=a.element(),b=null;c=c.match("li.action")?c:c.up("li.action");if(!c||c.hasClassName("disabled")){return}a.stop();b=c.identify();CustomEvents.notify({},"Topbar:"+b);Booli.Pageview.add(b,{noAd:1})}};"use strict";Booli.Inspiration={width:768,height:512,votes:[],init:function(){var a=this;this.imageInfo=Booli.Server.imageInfo[0];this.loaded={};this.setupElements();this.previewNavigation();this.init=1;Booli.Hash.init(this.locationHandler.bind(this),$("hidden-iframe"));this.addListeners();Booli.Pageview.setAttr({tag:this.getAdTag()});FormField.initialize();Booli.FB.init(function(){FB.Event.subscribe("edge.create",function(b){a.sendVote()});FB.Event.subscribe("comment.create",function(b){a.sendVote()});FB.XFBML.parse($("likeBox"));a.likeBox.show();FB.XFBML.parse($("commentBox"))})},setupElements:function(){this.next=$("next");this.back=$("back");this.image=$("image");this.info=$("info");this.cb=$("commentBoxWrap");this.ls=$("taggingBox");this.likeBox=$("likeBox");this.navi=$("navigation");this.naviHelp=$("naviHelp");this.yes=$("yes");this.no=$("no")},previewNavigation:function(){this.next.addClassName("nextActive");this.back.addClassName("prevActive");var a=this;setTimeout(function(){a.next.removeClassName("nextActive");a.back.removeClassName("prevActive")},4000)},locationHandler:function(a){if(parseInt(a,10)===this.id){return}this.setupIds(a);this.loadImage();this.getMeta();this.preLoadImages();if(!this.init){this.track()}this.init=0},changeDomForAdsCalled:0,changeDomForAds:function(){var b=Object.isString(this.id),a="hide",c="show",d;d=!!this.mode;if(b===d){return}this.mode=b;if(b){a="show";c="hide"}if(!this.changeDomForAdsCalled){this.changeDomForAdsCalled=1;this.ah=[$("adHide")];this.ads=$$(".toggleAd")}this.ah.each(function(f){f[c]()});this.image[c]();this.ads.each(function(f){f.update("");f[a]()})},posLike:function(){this.likeBox.setStyle({top:Math.floor((512-this.image.getHeight())/2+14)+"px",left:Math.floor((988-this.image.getWidth())/2)+"px"})},track:function(){Booli.Pageview.add(this.getTag(),{forceAd:this.getForceAd(),imageViewAd:this.mode},{tag:this.getAdTag()})},getForceAd:function(){if(Object.isString(this.id)||this.getTag()==="kok"||this.getTag()==="sovrum"){return 1}},setupIds:function(d){this.id=d;if(this.id===""){this.id=Booli.Server.imageId?Booli.Server.imageId:this.imageInfo[0].imageId}this.id=Object.isString(this.id)&&this.id.match(/annons_.*_(.*)/)?this.id:parseInt(this.id,10);this.changeDomForAds();this.index=null;var a=this.imageInfo.length,c=0,b;while(c<a){if(this.imageInfo[c].imageId===this.id){this.index=c;this.height=this.imageInfo[c].height;break}c=c+1}if(!this.index&&this.index!==0){window.location="/inspiration/removed?id="+this.id}if(this.index!==this.imageInfo.length-1){this.nextId=this.imageInfo[this.index+1].imageId;this.next.href="#"+this.nextId;this.yes.href="#"+this.nextId;this.no.href="#"+this.nextId;this.next.show()}else{this.nextId=null;this.next.hide()}if(this.index!==0){this.backId=this.imageInfo[this.index-1].imageId;this.back.href="#"+this.backId;this.back.show();this.naviHelp.hide();this.navi.removeClassName("first")}else{this.backId=null;this.back.hide();this.naviHelp.show();this.navi.addClassName("first")}if(Booli.Server.imageId&&Booli.Server.imageId===this.id){this.naviHelp.show();this.navi.addClassName("first")}},getTag:function(){if(Booli.Server.imageInfo){return Booli.Server.imageInfo[1]}},getAdTag:function(){var a=this.getTag();if(Object.isString(this.id)){var c=parseInt(this.id.match(/annons_.*_(.*)/)[1],10),b=null}return a},loadImage:function(){var b=(navigator.appVersion.indexOf("MSIE 7.")==-1)?false:true;if(b){this.image.style.top="50%";this.image.style.marginTop="-"+Math.floor(this.height/2)+"px"}var a=this;this.image.onload=function(){a.posLike()};this.image.src=this.getImageUrl(this.id)},getMeta:function(){if(this.request){this.request.abort()}this.request=new Ajax.Request("/inspiration/getMeta",{method:"get",parameters:{imageId:this.id,tag:this.getTag()},onSuccess:this.updateHtml.bind(this)})},updateHtml:function(c){var a=c.responseText.evalJSON(),d,b;for(d in a){if(typeof a[d]!=="function"&&$(d)){b=$(d);b.innerHTML=a[d]}}this.info.removeClassName("loading");if(this.ls){this.ls.removeClassName("loading")}if(this.cb){this.cb.removeClassName("loading")}FB.XFBML.parse($("likeBox"));this.likeBox.show();FB.XFBML.parse($("commentBox"));this.posLike()},preLoadImages:function(){var a=new Image(),b=this.index-1;while(b<this.index+4){if(this.imageInfo[b]&&this.imageInfo[b].imageId&&!this.loaded[this.imageInfo[b].imageId]&&b!==this.index&&!Object.isString(this.imageInfo[b].imageId)){a.src=this.getImageUrl(this.imageInfo[b].imageId);this.loaded[this.imageInfo[b].imageId]=1}b=b+1}},getImageUrl:function(a){if(Object.isString(this.id)){return""}if(this.imageInfo[this.index].width>this.width||this.imageInfo[this.index].height>this.height){return Booli.Config.imagesUrl+"/cache/"+a+"_"+this.width+"x"+this.height+".jpg"}else{return Booli.Config.imagesUrl+"/cache/"+a+"_"+this.imageInfo[this.index].width+"x"+this.imageInfo[this.index].height+".jpg"}},sendVote:function(c){if(this.votes[this.id]){return}this.votes[this.id]=1;var d,b;b=new Ajax.Request("/inspiration/vote",{method:"get",parameters:{imageId:this.id},onSuccess:function(){Booli.Pageview.add("vote",{noAd:1})}})},added:0,addListeners:function(){if(this.added){return}this.added=1;var m=this,q,e,p=[],d,i,f,h=function(s){var r=s.element();if(r.tagName.toLowerCase()!=="span"){return}if(r.hasClassName("active")){r.removeClassName("active")}else{r.addClassName("active")}f={};f["tags[]"]=[];$$(".active").each(function(t){f["tags[]"].push(t.innerHTML.toLowerCase())});f.imageId=m.id;s.stop();$("taggingBox").request({parameters:f,onComplete:function(){}})},k=function(r,s){m.likeBox.hide();m.info.addClassName("loading");if(m.ls){m.ls.addClassName("loading")}if(m.cb){m.cb.addClassName("loading")}r.stop();Booli.Hash.set(s)},n=function(r){var s=this.href.replace(/.*#/,"");k(r,s)},g=function(r){var s=this.href.replace(/.*#/,"");k(r,s);m.sendVote()},a=function(r){if(Booli.Widgets.ModalBox.getActive()){return}var s=$("subscriber").value===$("subscriber").defaultValue;if(r.keyCode===37&&m.backId&&s){k(r,m.backId)}else{if(r.keyCode===39&&m.nextId&&s){k(r,m.nextId)}}},c=function(r){if(q){q.show();return}q=Booli.Widgets.ModalBox.lazy({id:"shareMail","class":"postcardCont",style:"height: 273px"},"/share/getMailHtml",{post:"/share/sendInspirationShareEmail"},function(){i=new Booli.ShareEmail(function(){q.hide()},{imageId:m.id,tag:m.getTag()})})},l=function(r){if(q){q.show();return}q=Booli.Widgets.ModalBox.lazy({id:"commentCondition","class":"commentCondition",style:"height: 225px; width: 540px"},"/inspiration/getCommentConditions",{},function(){$("closeCommentCondition").observe("click",function(){q.hide()})})},b=function(r){window.location="/inspiration/"+this.value+"/"},o=function(v){v.stop();var s=$(this),u=$("mailLoader"),t=s.down(".errorMessage");if(t){t.remove()}u.update(Booli.Server.load);var r=new Ajax.Request("/inspiration/subscribe",{parameters:{subscriber:$F("subscriber")},onSuccess:function(x){var w=x.responseJSON,z=new Element("p",{"class":(w.success?"infoBox":"errorMessage")}).update(w.message);if(w.success){var y=s.up("#subscribe");s.remove();y.insert(z)}else{s.insert(z)}Booli.Pageview.add("prenumerera",{noAd:1})},onComplete:function(){u.update("")}})};if($("taggingBox")){$("taggingBox").observe("click",h)}$("next").observe("click",n);$("back").observe("click",n);$("no").observe("click",n);$("yes").observe("click",g);Event.observe(document,"keydown",a);$("subscription").observe("submit",o);$("commentInfoAnchor").observe("click",l);$("changeTag").observe("change",b)}};"use strict";Booli.Inspiration.Toggle={init:function(f,b){var m=$$("span.imgWrap"),h=new Image(),d=Booli.Server.imageInfo,p,c=f||2000,a=10000,o=b||0.5,e="",l,k,g,i=function(){if(!d){return}p=m[Math.floor(Math.random()*m.length)];k=p.down("img");if(!k){return}l=d[k.id][Math.floor(Math.random()*d[k.id].length)].imageId;if(l===e){setTimeout(i,c);return}e=l;Booli.Effect.run(p,"Fade",{duration:o,afterFinish:function(){h.src=k.src.replace(/[\d]+_/,l+"_");g=new Date()}})},n=function(){k.src=this.src;Booli.Effect.run(p,"Appear",{duration:o});setTimeout(i,c)};h.onload=n;Event.observe(window,"load",function(){setTimeout(i,a)})}};Booli.ShareEmail=function(b,a){FormField.initialize();this.closeCallback=b;this.submit=this.submit(this);$("shareForm").observe("submit",this.submit);$("shareForm").params=a||{};if(Booli.ie===6){setTimeout(function(){$("shareSubmit").style.border="1px solid";$("shareSubmit").style.border="none"},500)}};Booli.ShareEmail.prototype={submit:function(){var a=this;return function(b){var d=$("shareFeedback"),c=function(f){d.addClassName("red").removeClassName("green").update(f.responseText);d.style.visibility="visible"},e=function(f){d.style.visibility="visible";d.addClassName("green").removeClassName("red").update(f.responseText);$("shareToEmail").clear();setTimeout(function(){a.closeCallback()},2000)};b.stop();this.request({parameters:this.params,onFailure:c,onSuccess:e});Booli.Pageview.add("tipsa",{noAd:1})}}};Booli.activateSourceGuesses=function(){if(!$.bjStorage.get("activatedSourceGuesses")&&Cookies.isEnabled()){var a=Booli.Widgets.ModalBox.lazy({id:"activatedSourceGuesses"},"/priceguess/activateInList",{format:"json"},function(){var b=function(){$.bjStorage.set("activatedSourceGuesses",1);a.hide();CustomEvents.notify({},"sourceGuesses:activated")};$("activateSourceGuesses").observe("click",b)})}};var InterestForm=function(){var d=$("interestBox");if(!d||Booli.disablePopups){return}if(!Cookies.isEnabled()){return}var c=new Date(),a=d.innerHTML;if(Cookies.get("interestform"+a)){var e=Cookies.get("interestform"+a);if(e=="1"){return}var g=new Date(e);var b=(c-g)/1000/60/60/24;if(b>=2){return}else{d.addClassName(a.match(/T_(.*)/)[1]);d.update(Booli.Server.load);(new Booli.Widgets.ModalBox($("interestBox"))).show();var f=new Ajax.Updater("interestBox","/ad/getInterestForm",{onComplete:function(){if($("interestForm")){$("interestForm").observe("submit",function(h){Booli.Widgets.ModalBox.get("interestBox").hide()})}}});Cookies.set("interestform"+a,1,2,"/");return}}Cookies.set("intrestform"+a,c,4,"/")};Booli.askIPhone=function(){if(!Cookies.isEnabled()||Cookies.get("iPhone_askApp")){return}var a=function(){var b=confirm("Ladda ner vår nya iPhone-app för en bättre och snabbare upplevelse av Booli.se!");if(b==true){Cookies.set("iPhone_askApp","1",600,"/");window.location="http://bit.ly/booli-iphone"}else{Cookies.set("iPhone_askApp","1",14,"/")}};if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPod/i))){a()}};Booli.iPhone=function(){if(!$.bjStorage.get("iphone-push")){$.bjStorage.set("iphone-push",(new Date).getTime());Booli.disablePopups=1;var b=Booli.Widgets.ModalBox.lazy({id:"iphone-push"},"/mobile/iphonePromo",{format:"json"},function(){var c=function(){b.hide()};$("modal_overlay").observe("click",c)})}else{var a=$.bjStorage.get("iphone-push");if(a<(new Date).getTime()-1000*60*60*24*30){$.bjStorage.deleteKey("iphone-push")}}};"use strict";Booli.Source=Booli.Source||{};Booli.Source.List={params:{},prevHash:"",_SORT:"namn",_ORDER:"stigande",_ASC:"stigande",_DESC:"fallande",_URL_BASE:"/maklare/",init:function(){var e=this,b,d,f,a=$("municipality"),h=$("county"),g=$("sourceNameSearch");this.allEl=$("showAll");this.hitListTable=$("hitListTable");b=parseInt(window.location.pathname.replace(/.*\/([\d]+).*?/,"$1"),10);this.params.area=!isNaN(b)?b:77104;Booli.Hash.init(this.locationHandler.bind(this),$("hidden-iframe"));f=function(i){i.stop();var c=i.element();e.refineArea=this[this.selectedIndex].text;if(e.refineArea.match("Välj")&&c.value!=="77104"){e.refineArea=h[h.selectedIndex].text}e.updateLocation({areaId:c.value})};h.observe("change",f);if(a){a.observe("change",f)}g.observe("keyup",function(i){i.stop();var c=i.element();e.updateLocation({sourceName:encodeURIComponent(c.value)})});$("sortHeader").observe("click",function(c){e.sort(c)});Event.observe(window,"scroll",function(c){e.fixedTableHeader(c)});d=new Booli.Widgets.SlidingBox($("sidebarAds"),0);if(this.allEl){this.allEl.observe("click",function(c){c.stop();e.update(1);Booli.Pageview.add("visa-alla")})}},locationHandler:function(a){var b=a.split("/");this.params.sort=b[1]&&b[1]!==""?b[1]:this._SORT;this.params.order=b[2]&&b[2]!==""?b[2]:this._ORDER;this.params.sourceName=b[3]?b[3]:"";this.updateNavGui();if(a!==""&&a!=="/"){this.update();$("all").href="/maklare/"+window.location.hash}else{this.hitListTable.removeClassName("update");this.updating=false}},update:function(a){this.hitListTable.addClassName("update");if(this.request){this.request.abort()}var d=this,c,b=$("hitBody");this.updating=true;this.request=new Ajax.Request("/source/update?sourceName="+this.params.sourceName,{method:"get",parameters:{sort:this.params.sort,order:this.params.order,areaId:this.params.area,all:a},onComplete:function(e){c=e.responseText.evalJSON();b.update(c);if(d.allEl){d.allEl[a?"hide":"show"]()}d.hitListTable.removeClassName("update");d.updating=false}})},updateNavGui:function(){if(this.sortElement){this.sortElement.up().removeClassName("sorted");this.sortElement.removeClassName(this.className)}this.className=this.params.order==="fallande"?"desc":"asc";this.sortElement=$(this.params.sort);this.sortElement.up().addClassName("sorted");this.sortElement.addClassName(this.className);$("sourceNameSearch").value=decodeURIComponent(this.params.sourceName)},sort:function(c){c.stop();if(this.updating){return}var b=c.element(),a,d;if(!b.match("div[id]")){b.up()}if(!b.match("div[id]")){return}if(b.id===this.params.sort){d=this.params.order==="stigande"?"fallande":"stigande"}else{if(b.id!==this._SORT){d="fallande"}}a=b.id;Booli.Pageview.add("sortera");this.updateLocation({sort:a,order:d})},updateLocation:function(f){var a=f.sort||this.params.sort,c=f.order||this.params.order,b=(f.sourceName||f.sourceName==="")?f.sourceName:this.params.sourceName,d="/"+a+"/"+c+"/"+b,g,e;if(!f.areaId){if(Booli.Hash.get()!=d){this.hitListTable.addClassName("update");Booli.Hash.set(d);if(this.scrolled){$("hits").scrollTo()}}}else{this.hitListTable.addClassName("update");if(this.params.sort===this._SORT&&this.params.order===this._ORDER&&!b){d=""}else{d="#"+d}g=this.refineArea.match("Välj")?"":Toolbox.standardizeUrl(this.refineArea)+"/";e=f.areaId==="77104"?"":f.areaId+"/";window.location="/maklare/"+g+e+d}},fixedTableHeader:(function(){var b=$("tableHeader"),a,c;c=$("topBar")?536:308;return function(d){a=document.viewport.getScrollOffsets();if(a.top<=c){if(!this.scrolled){return}this.scrolled=0;b.setStyle({position:"absolute"})}else{if(this.scrolled){return}this.scrolled=1;b.setStyle({position:"fixed"})}}}())};Booli.Search={};Booli.Search.Source={};Booli.Search.Index={};Booli.Search.Map={};Booli.Search.Abstract={_staticParams:{},_params:{},REFINE_URL:"/search/update",GEOPOS_URL:"/map/getSearchUrl",trackStr:"forfina",url:"",setup:function(){var c=this,b={type:"type",areaId:"areaId",objectType:"typ"},d=Booli.Server.params&&!Object.isArray(Booli.Server.params)?Object.clone(Booli.Server.params):{};this._staticParams.type=this.type;Object.keys(b).each(function(e){if(d[e]){if(e==="objectType"){c._staticParams[b[e]]=!Object.isArray(d[e])?[d[e]]:d[e]}else{c._staticParams[b[e]]=d[e]}}});if(d.page){this._params.sida=d.page}this.addListeners();if(this.list&&!this.list.getContainer()&&this.noHits){this.noHits()}this.refineFromStart=1;this.refineFromStartTimer=setTimeout(function(){c.refineFromStart=0},2000);var a=$("searchForm");if(a){a.observe("submit",this.submit.bind(this))}CustomEvents.observe(this,"location:fail",function(){CustomEvents.notify(this,"search:update_fail")})},submit:function(d){d.stop();var b=this.getRefineParams(),a=this._getAreaPart(),f=navigator.geolocation,c=this;if(a===""){if(f){f.getCurrentPosition(function(e){var h=e.coords;var g=new Ajax.Request(c.GEOPOS_URL,{method:"get",parameters:{lat:h.latitude,lng:h.longitude},onSuccess:function(i){a=i.responseText.evalJSON();c.setLocation(b,a)}})})}else{CustomEvents.notify(this,"search:update_fail");return}}else{this.setLocation(b,a)}},setLocation:function(b,a){Booli.Location.set({params:b.params,pathname:this._getUrlTypePart()+this._getObjectTypePart(b)+a},["sortering","ordning"])},getRefineParams:function(){return this.refine?this.refine.getParams():{}},_getObjectTypePart:function(a){return a.typ?"/"+Toolbox.standardizeUrl(a.typ.join("/")):""},_getUrlTypePart:function(){return(this.getParams().type&&this.getParams().type==="transactions")?"/salda":this.url},_getAreaPart:function(){if(this.searchField){var b=this.searchField.getAreas(),d=b.pluck("areaName").join(","),c=b.pluck("areaId").join(",");if(c){return Toolbox.standardizeUrl("/"+(d?d+"/":"")+(c+"/"))}else{if(d){return"/"+d+"/"}}}return""},addListeners:function(){},newLocation:function(){},locationHandler:function(a){if(a.source.hash!==""){this._params=a.source.params;this.requestHits();this.newLocation(a.source.hash,this._params)}else{if(this.list&&this.list.getContainer()){}}},getParams:function(){return Object.extend(Object.clone(this._params),this._staticParams)},getLink:function(b,c){var a=window.location,d=Booli.ie<7?unescape(a.pathname):decodeURIComponent(a.pathname);return(c||"")+d+(b?a.hash.replace("#/",""):a.hash)},getMonitorLink:function(){return this.removeNavParams(this.getLink(true))},removeNavParams:function(a){return a.replace(/(sida|page|sortering|ordning)\:[0-9a-z\-]+\/?/ig,"")},requestHits:function(a){if(this.list&&this.list.getContainer()){this.list.getContainer().addClassName("update")}if(this._req){this._req.transport.abort()}var c=this,d=this.getParams(),b;delete d.parent;delete d.areaName;if(d.typ){d.typ=Object.isArray(d.typ)?d.typ.join(","):d.typ}else{delete d.typ}if(Object.isArray(d.areaId)){d["areaId[]"]=d.areaId;delete d.areaId}this._req=new Ajax.Request(this.REFINE_URL,{method:"get",parameters:d,onSuccess:function(e){b=e.responseText.evalJSON();c.newResult(b)}});if(this.refineFromStart){clearTimeout(this.refineFromStartTimer)}},newResult:function(a){CustomEvents.notify(a,"search:update");this.track()},track:function(){if(this.refineFromStart){this.refineFromStart=0;this.trackStr="forfina/start"}var a=this.trackStr;setTimeout(function(){Booli.Pageview.add(a,{forceAd:1,domchange:1})},400);this.trackStr="forfina"}};Booli.Search.AreaStatistics=function(){this.setup()};Booli.Search.AreaStatistics.prototype=Object.extend({},Booli.Search.Abstract);Object.extend(Booli.Search.AreaStatistics.prototype,{type:"hybrid",name:"areaStatistics",url:"/bostadsmarknad"});Booli.Search.Index.AreaStatistics=function(){this.setup();this.searchField=new Booli.SearchField(this)};Booli.Search.Index.AreaStatistics.prototype=Object.extend({},Booli.Search.Abstract);Object.extend(Booli.Search.Index.AreaStatistics.prototype,{type:"hybrid",url:"/bostadsmarknad",name:"indexAreaStatistics"});Booli.Search.Index.Listings=function(){this.setup();this.searchField=new Booli.SearchField(this)};Booli.Search.Index.Listings.prototype=Object.extend({},Booli.Search.Abstract);Object.extend(Booli.Search.Index.Listings.prototype,{type:"listings",name:"indexListings",addListeners:function(){this._extendParamsControl()},_extendParamsControl:function(){var b=$("extendedOpen"),d=$("extendedClosed"),a=function(c){c.stop();b.toggle();d.toggle();$("extendedParams").toggle()};if(b){b.observe("click",a)}if(d){d.observe("click",a)}}});Booli.Search.Index.Transactions=function(){this.setup();this.searchField=new Booli.SearchField(this)};Booli.Search.Index.Transactions.prototype=Object.extend({},Booli.Search.Index.Listings.prototype);Object.extend(Booli.Search.Index.Transactions.prototype,{type:"transactions",name:"indexTransactions",url:"/salda"});Booli.Search.Listings=function(){this.list=new Booli.List(this.type);this.setup();CustomEvents.observe(this,"location:changed",this.locationHandler.bind(this));Booli.Location.initHash();CustomEvents.observe(this,"Topbar:toggleSaved",this.toggleSaved)};Booli.Search.Listings.prototype=Object.extend({},Booli.Search.Abstract);Object.extend(Booli.Search.Listings.prototype,{type:"listings",name:"listings",_sort:"daysActive",_order:"asc",addListeners:function(){var b=this,a;$("hitlist").observe("click",function(c){a=c.element();if(a.up("#hitsWrapper")){b.list.clickDelegater(c)}else{if(a.up("#pagination")){c.stop(c);b.paginationClick(a)}else{if(a.up("thead")){c.stop(c);b.sortClick(a)}}}return false});CustomEvents.observe(this,"Topbar:monitor",this.monitor);this.setupObjectsPerPage()},noHits:function(){var a=$("noHitsMonitor");if(a){a.observe("click",this.monitor.bind(this))}CustomEvents.notify({},"search:no_hits")},paginationClick:function(a){if(a.href){Booli.Location.update({sida:a.href.match(/sida:([\d]+)/)[1]});this.trackStr="sortera";setTimeout(function(){window.scrollTo(0,0)},50)}},sortClick:function(a){if(!a.id.match(/Col/)&&a.id!==""){Booli.Location.update({sortering:a.id,ordning:a.className==="asc"?"fallande":"stigande",sida:1});this.trackStr="paginering"}},newResult:function(a){var b=$("objectsPerPage");if(b){b.stopObserving()}this.changeTopBarInfo(a);CustomEvents.notify(a,"search:update");this.track();this.setupObjectsPerPage();if(parseInt(a.nrOfHits,10)===0){this.noHits()}},setupObjectsPerPage:function(){var a=this,b=$("objectsPerPage");if(b){b.observe("change",function(c){c.stop();a._staticParams.hitsPerPage=this.value;a._params.sida=1;a.requestHits();delete a._params.sida})}},monitor:function(){var b=this,a=function(){if(!Booli.Auth.isLoggedIn()){$("monitorInfo").show()}};if(this.monitorEl){a();this.monitorEl.show();return}this.monitorEl=Booli.Widgets.ModalBox.lazy({id:"monitorBox",style:"display:none;"},"/lazyload",{resource:"monitor",jsRev:Booli.Config.jsRev},function(c){a();b.monitorListeners()})},monitorListeners:function(){var f=this,c,g,d=$("monitorInfo"),b=function(h){var a=h.responseText.evalJSON(true);d.innerHTML=a.message;d.show();f.monitorEl.show();if(a.messageType=="success"){setTimeout(function(){f.monitorEl.hide();d.hide()},2000)}},e=function(a){c=new Ajax.Request("/save/search?"+Object.toQueryString(g)+"&link="+encodeURIComponent(f.getMonitorLink()),{onComplete:b})};$("monitorForm").observe("change",function(a){if(a.element().id==="RSS"){d.hide()}else{if(!Booli.Auth.isLoggedIn()){d.show()}}}).observe("submit",function(a){a.stop();g=Form.serializeElements(this.getElements(),{hash:true});if(g.monitorOption==="rss"){f.monitorEl.hide();window.open("/rss/feed"+f.getMonitorLink())}else{Booli.Auth.LoginAsync(e,"Logga in för att spara bevakningen.")}})},changeTopBarInfo:function(a){var c=$("refineDescription"),b=$("nr");if(c&&a.description){c.update(a.description.truncate(32)).title=a.description}if(b&&(a.nrOfHits||a.nrOfHits===0)){b.update(a.nrOfHits)}},getBaseRefineHash:function(){return this.removeNavParams(window.location.hash)},newLocation:function(e,f){var d=this;if(e.match("sparade")){Booli.Auth.isLoggedInAsync(function(g){if(g){$("toggleSaved").addClassName("active");$("nrOfHits").addClassName("disabled");$("changeSearch").addClassName("disabled");$("monitor").addClassName("disabled");CustomEvents.notify({},"search:showing_saved")}else{window.location.hash="/"}})}else{$("toggleSaved").removeClassName("active");$("nrOfHits").removeClassName("disabled");$("changeSearch").removeClassName("disabled");$("monitor").removeClassName("disabled");CustomEvents.notify({},"search:hiding_saved");var a=$("listingsTab"),c=$("transactionsTab"),b=this.getBaseRefineHash();if(a&&a.href){a.href=a.href.replace(/\#.*/,"")+b}if(c&&c.href){c.href=c.href.replace(/\#.*/,"")+b}}},toggleSaved:function(){if($("toggleSaved").hasClassName("active")){this.oldSavedHash=window.location.hash;window.location.hash=this.oldHash&&this.oldHash!==""?this.oldHash:"/"}else{if(!Booli.Auth.isLoggedIn()){Booli.Auth.LoginAsync(this.toggleSaved.bind(this),"Du måste vara inloggad för att kunna visa sparade objekt");return}this.oldHash=window.location.hash;window.location.hash=this.oldSavedHash&&this.oldSavedHash!==""?this.oldSavedHash:"/sparade:1/";this.trackStr="sparade"}}});Booli.Search.Map.Listings=function(){this.setup();CustomEvents.observe(this,"location:changed",this.locationHandler.bind(this));Booli.Location.initHash()};Booli.Search.Map.Listings.prototype=Object.extend({},Booli.Search.Abstract);Object.extend(Booli.Search.Map.Listings.prototype,{type:"listings",name:"mapSearch",REFINE_URL:"/map/update",submit:function(a){a.stop();Booli.Location.set({params:this.getRefineParams(),pathname:"/kartsok"+this.url+"/"},["sortering","ordning"])},getRefineParams:function(){var a=this.refine?this.refine.getParams():{};if(a.typ){a.params.typ=[];a.typ.each(function(b){a.params.typ.push(encodeURIComponent(b))});a.params.typ=a.params.typ.join(",")}return a.params},newResult:function(a){var b=$("changeType");if(b){b.href=$("changeType").href.replace(/#.*/,"")+window.location.hash}CustomEvents.notify(a,"search:update");this.track()}});Booli.Search.Map.Transactions=function(){this.setup();CustomEvents.observe(this,"location:changed",this.locationHandler.bind(this));Booli.Location.initHash()};Booli.Search.Map.Transactions.prototype=Object.extend({},Booli.Search.Map.Listings.prototype);Object.extend(Booli.Search.Map.Transactions.prototype,{type:"transactions",url:"/salda"});Booli.Search.Object=function(a){this.type=a;this.setup()};Booli.Search.Object.prototype=Object.extend({},Booli.Search.Abstract);Object.extend(Booli.Search.Object.prototype,{type:"listings",name:"object"});Booli.SearchField=function(a){this.searchField=$("searchField");if(!this.searchField){return}if(this.searchField.value===""){this.searchField.value="Gata, ort eller kommun"}this.suggest=new Booli.Suggest(this.searchField,a?a.type:"hybrid");this.addListeners()};Booli.SearchField.prototype={areas:[],addListeners:function(){CustomEvents.observe(this,"suggest:suggested",this.newSuggest.bind(this));CustomEvents.observe(this,"suggest:highlighted",this.fieldUpdate.bind(this));this.searchField.observe("keydown",this.keydown.bind(this));Event.observe(document,"click",this.documentClick.bind(this));this.searchField.observe("keyup",this.keyup.bind(this));this.searchField.observe("focus",this.removeHint);this.searchField.observe("paste",this.paste.bind(this))},keydown:function(c){var a=c.keyCode?c.keyCode:c.charCode;if(a===8&&this.searchField.value===""){this.removeSuggest("previous");c.stop()}if(a===46&&this.searchField.value===""){this.removeSuggest("next");c.stop()}if(a===37&&this.searchField.value===""){this.moveSearchField("previous");c.stop()}if(a===39&&this.searchField.value===""){this.moveSearchField("next");c.stop()}if(a!==8&&a!==46){var b=this.getAreaElements();b.each(function(d){d.removeClassName("hl")})}},documentClick:function(b){var a=b.element();if(a.up("#searchFieldWrap")){if(a.hasClassName("suggest")||a.up().hasClassName("suggest")){a=a.hasClassName("suggest")?a:a.up();this.removeAreaElement(a)}}else{if(a===$("searchFieldWrap")){this.searchField.focus()}}},keyup:function(b){var a=b.keyCode?b.keyCode:b.charCode,c=[13,27,40,38,37,39];if(c.indexOf(parseInt(a,10))===-1){this.fieldUpdate()}},getAreas:function(){if(this.areas.length!==0){return this.areas}else{var a=this.suggest.getSuggest();if(a){return[a]}else{return[{areaName:this.getValue()}]}}},getValue:function(){return this.searchField.value!==this.searchField.title?this.searchField.value:""},populate:function(){var d=this,b,c;if(Object.isArray(Booli.Server.areas)){return}Object.keys(Booli.Server.areas||{}).each(function(a){if(!c){d.removeHint.call(d.searchField);d.setSize("");c=1}b=Booli.Server.areas[a];d.areas.push(b);d.searchField.up().insert({before:new Element("span",{id:"a_"+b.areaId,"class":"suggest"}).update(b.areaName+" <em>x</em>")})})},newSuggest:function(a){if(this.areas.pluck("areaId").indexOf(a.source.areaId)===-1){this.areas.push(a.source);this.searchField.value="";this.searchField.up().insert({before:new Element("span",{id:"a_"+a.source.areaId,"class":"suggest"}).update(a.source.areaName+" <em>x</em>")});this.fieldUpdate()}this.searchField.focus()},paste:function(){var a=this;this.searchField.maxLength=100;setTimeout(function(){a.fieldUpdate()},2)},fieldUpdate:function(b){var c=b&&b.source?b.source:this.searchField.value,a=$("searchFieldWrap");if(c!==""||(this.searchField.size&&c==="")){if(a.hasClassName("shift")){this.setSize(this.searchField.value)}else{this.setSize(c)}}Toolbox.absTop("suggestHits","suggestsWrapper",{zIndex:200},true,true)},setSize:function(b){var a=b?b.length:1;this.searchField.style.width="auto";this.searchField.size=Booli.Config.isTouch?a+3:a;this.searchField.maxLength=a+5},moveSearchField:function(e){var d=this.searchField.up(),c=d[e](),b=$("searchFieldWrap");if(c&&c.hasClassName("suggest")){d.insert(e==="previous"?{after:c}:{before:c})}var a=this.getLastAreaElement();if(a.previousSiblings().indexOf(d)!==-1){b.addClassName("shift")}else{b.removeClassName("shift")}},removeSuggest:function(c){var b=this.searchField.up(),a=b[c]();if(!a||!a.hasClassName("suggest")){return}if(a.hasClassName("hl")){this.removeAreaElement(a)}else{a.addClassName("hl")}this.searchField.focus()},getAreaElements:function(){var b=$("searchFieldWrap").adjacent("span"),a=this.getLastAreaElement(b);if(a&&a.hasClassName("submitBG")){b.pop(a)}return b},getLastAreaElement:function(c){var b=c||this.getAreaElements(),a=b[b.length-1];return a},getPosition:function(c,a){for(var b=0;b<c.length;b++){if(c[b]==a){return b}}},removeAreaElement:function(c){var b=this.getAreaElements(),e=this.getPosition(b,c),d=c.siblings(),a=$("searchFieldWrap");if(d[b.length-1]===$("fieldWrap")){a.removeClassName("shift")}c.remove();this.searchField.focus();this.areas.splice(e,1);CustomEvents.notify({},"searchField:areaRemoved")},removeHint:function(a){if(this.value==="Gata, ort eller kommun"){this.value="";this.setStyle({color:"#595959",fontWeight:"normal"})}}};Booli.Search.Source.Listings=function(){this._staticParams.sourceId=Booli.Server.params.sourceId;this.list=new Booli.List(this.type);this.setup();CustomEvents.observe(this,"location:changed",this.locationHandler.bind(this));Booli.Location.initHash()};Booli.Search.Source.Listings.prototype=Object.extend({},Booli.Search.Listings.prototype);Object.extend(Booli.Search.Source.Listings.prototype,{name:"sourceListings",REFINE_URL:"/source/updateSearch",newLocation:function(){}});Booli.Search.Source.Transactions=function(){this._staticParams.sourceId=Booli.Server.params.sourceId;this.list=new Booli.List(this.type);this.setup();CustomEvents.observe(this,"location:changed",this.locationHandler.bind(this));Booli.Location.initHash()};Booli.Search.Source.Transactions.prototype=Object.extend({},Booli.Search.Source.Listings.prototype);Object.extend(Booli.Search.Source.Transactions.prototype,{type:"transactions",name:"sourceTransactions",REFINE_URL:"/source/updateSearch"});Booli.Search.Transactions=function(){this.list=new Booli.List(this.type);this.setup();CustomEvents.observe(this,"location:changed",this.locationHandler.bind(this));Booli.Location.initHash()};Booli.Search.Transactions.prototype=Object.extend({},Booli.Search.Listings.prototype);Booli.Search.Transactions.prototype=Object.extend(Booli.Search.Transactions.prototype,{type:"transactions",name:"transactions",url:"/salda",newLocation:function(d,e){var a=$("listingsTab"),c=$("transactionsTab"),b=this.getBaseRefineHash();if(a&&a.href){a.href=a.href.replace(/\#.*/,"")+b}if(c&&c.href){c.href=c.href.replace(/\#.*/,"")+b}}});Booli.Search.History={_key:"last_search",_maxToStore:3,init:function(a){this.search=a;CustomEvents.observe(this,"search:update",function(b){this._update(b)});this._update()},addIndexHtml:function(){var c=$.bjStorage.get(this._key)||[];if(c.length){var b=this._render(c);$("indexLeftContainer").insert({top:b})}else{}var a=$("latestSearches");if(a){a.observe("click",function(d){Booli.Pageview.add("senaste",{noAd:1})})}},_update:function(a){var b={params:this.search.getParams(),desc:a?a.source.description:Booli.Server.description,link:this.search.getLink(),areas:Booli.Server.areas};if(!b.params.areaId){return}this._setAdCookie(b);this._addLocalStorage(b)},_render:function(e){var h="<div id='latestSearches' class='module'><div style='float:left; width:59%;'><h2>Mina senaste sökningar</h2><ul>";for(var b=0;e&&b<e.length;b++){var a=e[b].link.replace(/\/sida:[0-9]+/,""),c=e[b].params.type==="transactions"?"Slutpriser":null,c=e[b].params.type==="hybrid"?"Bostadsmarknad":c,g=!e[b].desc||e[b].desc.match("Antal")?"":e[b].desc,d=e[b].params.areaName?e[b].params.areaName:"",f;if(e[b].areas){f=Object.values(e[b].areas).pluck("areaName");if(f.length<=3){d=f.join(", ")}else{if(f.length>3){d=f[0]+", "+f[1]+" & "+(f.length-2)+" andra områden"}}}g=g!==""||c?" - "+(g!==""&&c?c+", ":c||"")+g:"";h+="<li><a href='"+encodeURI(a)+"'>"+d.escapeHTML()+"<span>"+g+"</span></a></li>"}h+="</ul></div></div>";return h},_setAdCookie:function(a){Cookies.set(this._key+"[0]",Object.toJSON(a),30,"/ad/")},_addLocalStorage:function(a){var b=$.bjStorage.get(this._key)||[];b=[a].concat(b);b=this._removeDupes(b);b=b.slice(0,this._maxToStore);$.bjStorage.set(this._key,b)},_removeDupes:function(e){var b={},a=[],d;for(var c=0;c<e.length;c++){d=e[c].params.areaId+e[c].params.type;if(!b[d]){b[d]=true;a.push(e[c])}}return a}};Booli.Location={_params:{},_pathname:"",init:function(a){var b=a||{};this.useHash=true;this.keepQueryParams=b.keepQueryParams;this.wl=Object.clone(window.location);if(this.keepQueryParams){this.wl.pathname=this.wl.pathname+this.wl.search}this._pathname=this.wl.pathname},initHash:function(){if(this.useHash){var a=new Element("iframe",{style:"display:none;"});Element.insert(document.body,a);Booli.Hash.init(this._hashChange.bind(this),a)}},set:function(a,f){var c,g,d,b=f||[],e=this;if(typeof a==="object"){this._pathname=a.pathname||this._pathname;g=a.params}else{this._setHref(a);return}b.each(function(h){if(e._params[h]){g[h]=e._params[h]}});this.wl=Object.clone(window.location);this._setHref((this._pathname?this._pathname:this.wl.pathname)+this._getQueryParams(g))},update:function(a){this._params=Object.extend(this._params,a);this.set({params:this._params})},reset:function(){if(this.useHash){Booli.Hash.set("#/")}else{window.location=window.location}},isSet:function(a){return !!this._params[a]},_setHref:function(a){if((this.wl.pathname+this.wl.hash)===a){CustomEvents.notify({},"location:fail")}else{window.location=a}},_getQueryParams:function(b){var a=decodeURIComponent(Object.toQueryString(b).replace(/\&/g,"/").replace(/\=/g,":"));if(a===""){if(Object.toQueryString(this._params)!==""){a=this.useHash?"#/":""}}else{a=(this.useHash?"#/":"")+a+"/"}return a},_hashChange:function(a){if(a!==""){this._params=a.replace(/:/g,"=").replace(/\//g,"&").toQueryParams()}CustomEvents.notify({params:this._params,hash:a},"location:changed")}};Booli.Effect={_loaded:false,run:function(c,b,g,a){var e=function(){var f=Effect[b]&&new Effect[b](c,g);if(a){a(f)}},d=this;if(!this._loaded){LazyLoad.js(Booli.Config.scriptUrl+"library/scriptaculous/effects"+Booli.Config.jsRev+".js",function(){e();d._loaded=true},null)}else{e()}}};var Survey=function(){if(Booli.Server.controller==="Survey"){return}if(!Cookies.isEnabled()||Cookies.get("survey_booliUsers")){return}var b=10,a=1+Math.floor(Math.random()*b);if(a!==b){Cookies.set("survey_booliUsers","1",1,"/");return}Cookies.set("survey_booliUsers","1",60,"/");var c=Booli.Widgets.ModalBox.lazy({id:"surveyBox"},"/survey/getSurveyPopup",{format:"json"},function(){var d=function(){c.hide()};$("modal_overlay").observe("click",d);$("surveyForm").observe("submit",d)})};
