String.prototype.substringPro=function(C,D){var E="";D=D||"...";if(this.getLen()<=C){return this}for(var B=0,A=0;A<C-D.length;){if(this.charCodeAt(B)>=0&&this.charCodeAt(B)<256){E+=this.charAt(B);A++}else{if((A+=3)<=C){E+=this.charAt(B)}}B++}E+=D;return E};String.prototype.getRootDomain=function(){var A=/^([^:]*:\/\/)?([^\/\.]+\.([^\/]+))/.exec(this);return A&&A[3]!==undefined?A[3]+"":""};String.prototype.Trim=function(){return this.replace(/(^\s*)|(\s*$)/g,"")};String.prototype.getLen=function(){var A=0;for(var B=0;B<this.length;++B){if(this.charCodeAt(B)>127){A+=3}else{A++}}return A};String.prototype.chkLen=function(B,A){var C=this.getLen(this);if(C>A||C<B){return false}else{return true}};String.prototype.chkType=function(A){switch(A){case"int":return(/^[0-9]?[0-9]*$/).test(this);case"url":return(/^https?:\/\/([a-z0-9-]+\.)+[a-z0-9]{2,4}.*$/).test(this);case"email":return(/^[a-z0-9_+.-]+\@([a-z0-9-]+\.)+[a-z0-9]{2,4}$/i).test(this);case"idcard":return(/^[0-9]{15}$|^[0-9]{17}[a-zA-Z0-9]/).test(this);case"area":return(/^\d+(\.\d*)?$/).test(this);case"money":return(/^\d+(\.\d*)?$/).test(this)}return false};window.openNew=function(C,A){var B=document.createElement("form");form.action=C;form.target=A;form.submit()};APF.Namespace.register("anjuke.global.header");anjuke.global.header.CitySelector=Class.create({initialize:function(D,C,A){this.selector=$(D);this.panelId=C;this.hideTimeout=A;var B=$(C);this.iframe=B.select("iframe").first();this.iframe.setStyle({width:B.getWidth()+"px",height:B.getHeight()+"px"});this.selector.observe("mouseover",function(){window.clearTimeout(this.timeoutHandle);$(this.panelId).show()}.bind(this));this.selector.observe("mouseout",function(){window.clearTimeout(this.timeoutHandle);this.timeoutHandle=window.setTimeout("$('"+this.panelId+"').hide()",this.hideTimeout)}.bind(this));var E=this.selector.select("a").first();if(E!=undefined){E.observe("click",function(F){F.preventDefault()})}}});APF.Namespace.register("anjuke.global.header");anjuke.global.header.CornerLinks=Class.create({initialize:function(A){this.element=$(A)},test:function(B,A){$(B).hide();A.className="myanjuke"},bindEvents:function(C,B,A){this.selector=$(C);this.panelId=B;this.panel=$(B);this.hideTimeout=A;this.selector.observe("mouseover",function(D){window.clearTimeout(this.timeoutHandle);this.panel.style.display="block";this.selector.addClassName("myanjuke_hover")}.bind(this));this.panel.observe("mouseover",function(){window.clearTimeout(this.timeoutHandle);this.selector.addClassName("myanjuke_hover")}.bind(this));this.panel.observe("mouseout",function(){window.clearTimeout(this.timeoutHandle);this.timeoutHandle=window.setTimeout("$('"+this.panelId+"').hide();$('"+C+"').removeClassName('myanjuke_hover');",this.hideTimeout)}.bind(this));this.selector.observe("mouseout",function(){window.clearTimeout(this.timeoutHandle);this.timeoutHandle=window.setTimeout("$('"+this.panelId+"').hide();$('"+C+"').removeClassName('myanjuke_hover');",this.hideTimeout)}.bind(this))}});APF.Namespace.register("anjuke.global.search");anjuke.global.search.Autocompleter=Class.create(Ajax.Autocompleter,{initialize:function($super,C,D,B,A){$super(C,D,B,A);this.index=-1;this._fixChineseInputMethodProblem()},_fixChineseInputMethodProblem:function(){var A=window.setInterval(function(){if(this.oldElementValue==this.element.value){return }this.oldElementValue=this.element.value;if(this.observer){clearTimeout(this.observer)}this.observer=setTimeout(this.onObserverEvent.bind(this),0)}.bind(this),this.options.frequency*1000)},selectEntry:function($super){this.oldElementValue=this.element.value;if(this.observer){clearTimeout(this.observer)}$super()},updateChoices:function($super,C){if(!this.changed&&this.hasFocus){this.update.innerHTML=C;Element.cleanWhitespace(this.update);Element.cleanWhitespace(this.update.down());if(this.update.firstChild&&this.update.down().childNodes){this.entryCount=this.update.down().childNodes.length;for(var A=0;A<this.entryCount;A++){var B=this.getEntry(A);B.autocompleteIndex=A;this.addObservers(B)}}else{this.entryCount=0}this.stopIndicator();this.index=-1;if(this.entryCount==1&&this.options.autoSelect){this.selectEntry();this.hide()}else{this.render()}}},onKeyPress:function(A){if(this.observer){clearTimeout(this.observer);this.observer=null}if(this.active){switch(A.keyCode){case Event.KEY_RETURN:if(this.index<0){return }this.selectEntry();Event.stop(A);case Event.KEY_TAB:case Event.KEY_ESC:this.hide();this.active=false;Event.stop(A);return ;case Event.KEY_LEFT:case Event.KEY_RIGHT:return ;case Event.KEY_UP:this.markPrevious();this.render();Event.stop(A);return ;case Event.KEY_DOWN:this.markNext();this.render();Event.stop(A);return }}else{if(A.keyCode==Event.KEY_TAB||A.keyCode==Event.KEY_RETURN||(Prototype.Browser.WebKit>0&&A.keyCode==0)){return }}this.changed=true;this.hasFocus=true},show:function($super){$super();this.update.setStyle({width:this.update.getWidth()-2+"px"})},markPrevious:function(){if(this.index>0){this.index--}else{this.index=this.entryCount-1}this.getEntry(this.index).scrollIntoView(false)},getUpdatedChoices:function($super){this.startIndicator();var B=encodeURIComponent(this.options.paramName)+"="+encodeURIComponent(this.getToken());this.options.parameters=this.options.callback?this.options.callback(this.element,B):B;if(this.options.defaultParams){this.options.parameters+="&"+this.options.defaultParams}var A=new Ajax.Request(this.url,this.options);this.requestingURL=A.url},onComplete:function(A){if(this.requestingURL==A.request.url){this.requestingURL=null;this.updateChoices(A.responseText)}}});anjuke.global.search.SearchSuggestion=Class.create({initialize:function(C,B,A){this.options=A||{};this.element=$(C);this.update=this.options.update?$(this.options.update):this._createUpdateElement();this.url=B;this.useSuggestion=false;this.autocompleter=new anjuke.global.search.Autocompleter(this.element,this.update,this.url,{method:"GET",frequency:0.2,minChars:1,afterUpdateElement:function(D,F){D.value=F.firstDescendant().innerHTML;var E=this._findParentForm(D);if(E){E.submit()}}.bind(this),callback:function(D,E){if(!this.options.onParameters){return E}var F=this.options.onParameters(E);if(F&&"function"==typeof (F.toQueryString)){return F.toQueryString()}else{return F}}.bind(this)})},_findParentForm:function(A){var B=A;while(B){if(B.tagName=="FORM"){break}B=B.parentNode}return B},_createUpdateElement:function(){var A=$(document.createElement("div"));this.options.className=this.options.className||"SearchSuggestion";A.addClassName(this.options.className);var B=this._getInternetExplorerVersion();if(B>0&&B<=7){Element.insert(this.element.getOffsetParent(),{after:A})}else{Element.insert(document.body,{top:A})}return A},_getInternetExplorerVersion:function(){var C=-1;if(navigator.appName=="Microsoft Internet Explorer"){var A=navigator.userAgent;var B=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");if(B.exec(A)!=null){C=parseFloat(RegExp.$1)}}return C}});APF.Namespace.register("anjuke.global.header");anjuke.global.header.OptionList=Class.create({initialize:function(J,D,B,F,G,H){this.trigger=$(J);this.panel=$(D);var A=$(D);var I=$(F);var E=$(B);var C=$(H);this.trigger.observe("click",function(){if(this.panel.style.display=="none"){this.panel.style.display="block"}else{this.panel.style.display="none"}}.bind(this));E.observe("mouseover",function(){E.addClassName("current_option_hover")});E.observe("mouseout",function(){if(A.visible()){return }E.removeClassName("current_option_hover")});E.observe("blur",function(K){var L=K.explicitOriginalTarget==undefined?document.activeElement:K.explicitOriginalTarget;if(Element.descendantOf(L,this.panel)){E.focus();return }E.removeClassName("current_option_hover");A.hide()}.bind(this));this.panel.getElementsBySelector("span").each(function(K){K.observe("click",function(){E.innerHTML=K.innerHTML;I.value=K.getAttribute("v");if(I.value=="5"){$(G).value="请输入房源特征,地点或楼盘名..."}else{if(I.value=="3"){$(G).value="请输入小区名或路名..."}else{$(G).value="请输入房源特征,地点或小区名..."}}if(I.value=="1"){C.target=""}else{C.target="_blank"}if(I.value=="3"){$("sbtn").className="btn2"}else{$("sbtn").className="btn"}E.removeClassName("current_option_hover");A.hide();Element.fire(document,"SearchBar:OptionList",I.value);A.getElementsBySelector("span").each(function(L){L.setAttribute("s","none");L.setAttribute("class","item");L.setAttribute("className","item")});K.setAttribute("s","selected");K.setAttribute("class","selected");K.setAttribute("className","selected")});K.observe("mouseover",function(){if(K.getAttribute("s")!="selected"){K.setAttribute("class","mousehover");K.setAttribute("className","mousehover")}});K.observe("mouseout",function(){if(K.getAttribute("s")!="selected"){K.setAttribute("class","item");K.setAttribute("className","item")}})})},descendantOfPanel:function(A){if(A==null){return false}if(A==this.panel){return true}return this.descendantOfPanel(A.parentNode)}});APF.Namespace.register("Anjuke.Map2");Anjuke.Map2.Header=Class.create({initialize:function(R,H){this.map2Header=$(R);this.hideTimeout=H;var L=this.map2Header.select(".qwhereimg").first();var A=this.map2Header.select(".qwhereinput").first();var P=this.map2Header.select(".filter_price a");var G=this.map2Header.select(".filter_model a");var N=this.map2Header.select(".filter_range a");var O=this.map2Header.select(".filter_fitment a");var F=this.map2Header.select(".tmp_filter a");var E=this.map2Header.select(".qtb1").first();var D=this.map2Header.select(".qtb2").first();var B=this.map2Header.select(".qtb3").first();var M=this.map2Header.select(".filter_price").first();var K=this.map2Header.select(".filter_model").first();var J=this.map2Header.select(".filter_range").first();if(J==undefined){J=this.map2Header.select(".filter_fitment").first()}var C=this.map2Header.select(".qmtype_normal").first();var Q=this.map2Header.select(".qmtype_hybrid").first();this.timeoutHandles=[];var I=[[E,M,2],[D,K,3],[B,J,4]];I.each(function(V){var S=V[0];var U=V[1];var T=V[2];if(S!=undefined){S.observe("mouseover",function(){window.clearTimeout(this.timeoutHandles[T]);I.each(function(W){qf=W[1];if(qf!=undefined){qf.setStyle({display:"none"})}});U.setStyle({display:"block"})}.bind(this));S.observe("mouseout",function(W){window.clearTimeout(this.timeoutHandles[T]);this.hideDiv(W,U,H,T)}.bind(this))}if(U!=undefined){U.observe("mouseover",function(W){window.clearTimeout(this.timeoutHandles[T])}.bind(this));U.observe("mouseout",function(W){window.clearTimeout(this.timeoutHandles[T]);this.hideDiv(W,U,H,T)}.bind(this))}}.bind(this));if(P.length>0){P.each(function(S){S.observe("click",function(){var T=S.readAttribute("paramid");M.setStyle({display:"none"});E.update(S.innerHTML);E.setStyle({color:"#EB6100"});document.fire("filter:price",{price:T})})})}if(G.length>0){G.each(function(S){S.observe("click",function(){var T=S.readAttribute("paramid");document.fire("filter:model",{model:T});K.setStyle({display:"none"});D.update(S.innerHTML);D.setStyle({color:"#EB6100"})})})}if(O.length>0){O.each(function(S){S.observe("click",function(){var T=S.readAttribute("paramid");document.fire("filter:fitment",{fitment:T});J.setStyle({display:"none"});B.update(S.innerHTML);B.setStyle({color:"#EB6100"})})})}if(N.length>0){N.each(function(S){S.observe("click",function(){var T=S.readAttribute("paramid");document.fire("filter:range",{range:T});J.setStyle({display:"none"});B.update(S.innerHTML);B.setStyle({color:"#EB6100"})})})}C.observe("click",function(){document.fire("map:type",{type:"normal"})});Q.observe("click",function(){document.fire("map:type",{type:"hybrid"})});L.observe("click",function(){var S=A.className.indexOf("gray")==-1?A.value:"";if(!S.blank()){document.fire("map:geo",{keyword:S})}});A.observe("keyup",function(T){if(T.keyCode==13){var S=A.value;if(!S.blank()){document.fire("map:geo",{keyword:S})}}});A.observe("focus",function(S){if(A.className.indexOf("gray")!=-1){A.removeClassName("gray");A.value=""}$("search_result_panel").innerHTML="";$("search_result_panel").setStyle("display:none")});A.observe("blur",function(S){if(A.value==""){A.addClassName("gray");A.value="输入名称或地标"}});if(F.length>0){F.each(function(S){S.observe("click",function(){var T=S.readAttribute("paramid");document.fire("filter:price",{price:T});F.each(function(U){U.setStyle({color:""})});S.setStyle({color:"red"})})})}document.observe("filter:price",function(S){P.each(function(T){var U=T.readAttribute("paramid");if(U==S.memo.id){E.update(T.innerHTML);E.setStyle({color:"#EB6100"})}})});document.observe("filter:room",function(S){G.each(function(T){var U=T.readAttribute("paramid");if(U==S.memo.id){D.update(T.innerHTML);D.setStyle({color:"#EB6100"})}})});document.observe("filter:area",function(S){N.each(function(T){var U=T.readAttribute("paramid");if(U==S.memo.id){B.update(T.innerHTML);B.setStyle({color:"#EB6100"})}})});document.observe("filter:fitment",function(S){O.each(function(T){var U=T.readAttribute("paramid");if(U==S.memo.id){B.update(T.innerHTML);B.setStyle({color:"#EB6100"})}})})},hideDiv:function(D,C,B,A){if(this.realOut(D,C)==true){window.clearTimeout(this.timeoutHandles[A]);this.timeoutHandles[A]=window.setTimeout(function(){C.setStyle({display:"none"})},B)}},realOut:function(A,C){var B=A.explicitOriginalTarget==undefined?document.activeElement:A.explicitOriginalTarget;if(Element.descendantOf(B,C)){return false}else{return true}}});APF.Namespace.register("Anjuke.Map2");Anjuke.Map2.Findding2=Class.create({initialize:function(B,A){this.cavanId=B;this.cavansElement=$(B);this.canvas=this.cavansElement.select("#"+B+"_map2_canvas2").first();this.commname=this.cavansElement.select(".map2_commname").first();this.commname_heighlight=this.cavansElement.select(".map2_commname_highlight").first();this.propwind=this.cavansElement.select(".map2_propwind").first();this.proparrow=this.cavansElement.select(".map2_proparrow").first();this.propwind_commname=this.propwind.select(".map2_propwind_commname").first();this.propwind_listlink=this.propwind.select(".map2_propwind_listlink").first();this.serch_result_container=$("search_result_panel");this.hqbutton=$("map2_is_hq");this.maxSearchNumber=8;this.getCanvasDimension();this.DEF_CITY_INFO=A.cityInfo;this.DEF_TRADE_TYPE=A.tradetype;this.filter=A.filter;this.DEF_PROP_WINDOW_HEIGHT=360;this.DEF_PROP_WINDOW_WIDTH=360;this.DEF_LEFT_LIMIT=380;this.DEF_ARROW_WIDTH=7;this.keyword="";this.mapMarkers=new Hash();this.pwCommId=0;this.propPage=1;this.propOrder=41;this.propIsHq=0;this.dragging=0;this.subwayZoom=16;this.currentCommId=0;this.maxPage=0;this.curr_lat=A.cityInfo.lat;this.curr_lng=A.cityInfo.lng;this.curr_zoom=A.cityInfo.zoom;this.logurl="/v2/map/log/";this.mapTrackers=new Array();this.mapPolyline=null;this.cavansElement.select(".map2_propwind_close").each(function(C){C.observe("click",function(){this.hidePropWind()}.bind(this))}.bind(this));this.propwind.select(".page_next").first().observe("click",function(){if(this.propPage<this.maxPage){this.propPage+=1;this.updatePropWind(this.propCommId,this.propPage,this.propOrder)}}.bind(this));this.propwind.select(".page_prev").first().observe("click",function(){this.propPage-=1;if(this.propPage==0){this.propPage=1}this.updatePropWind(this.propCommId,this.propPage,this.propOrder)}.bind(this));this.hqbutton.observe("click",function(){if(this.hqbutton.checked){this.propIsHq=1}else{this.propIsHq=0}this.propPage=1;this.updatePropWind(this.propCommId,this.propPage,this.propOrder)}.bind(this));document.observe("map:pan",function(C){this.map.panTo(new GLatLng(C.memo.lat,C.memo.lng));if(C.memo.zoom!=undefined){this.removeMapMarkers();this.map.setZoom(C.memo.zoom)}}.bind(this));document.observe("map:center",function(C){this.map.setCenter(new GLatLng(C.memo.lat,C.memo.lng),C.memo.zoom)}.bind(this));document.observe("map:zoom",function(C){this.map.setZoom(C.memo.zoom)}.bind(this));document.observe("filter:price",function(C){this.filter.price=C.memo.price;this.hidePropWind();this.getJsonMarkers()}.bind(this));document.observe("filter:model",function(C){this.filter.room=C.memo.model;this.hidePropWind();this.getJsonMarkers()}.bind(this));document.observe("filter:range",function(C){this.filter.area=C.memo.range;this.hidePropWind();this.getJsonMarkers()}.bind(this));document.observe("filter:fitment",function(C){this.filter.fitment=C.memo.fitment;this.hidePropWind();this.getJsonMarkers()}.bind(this));document.observe("map:type",function(C){if(C.memo.type=="normal"){this.map.setMapType(G_NORMAL_MAP);this.logging("map.maptype","{tradetype:"+this.DEF_TRADE_TYPE+",frommode:'hybrid',tomode:'normal'}")}else{if(C.memo.type=="hybrid"){this.map.setMapType(G_HYBRID_MAP);this.logging("map.maptype",'{"tradetype":"'+this.DEF_TRADE_TYPE+'","frommode":"normal","tomode":"hybrid"}')}}}.bind(this));document.observe("map:geo",function(D){var C=D.memo.keyword;this.getGeo(C);this.logging("map.searchbox",'{"tradetype":"'+this.DEF_TRADE_TYPE+'","keywords":"'+C+'"}')}.bind(this));document.observe("custom:tracker",function(C){this.filter.customtype=C.memo.type;this.filter.customid=C.memo.id;this.customTrackers(true)}.bind(this));this.propWindOrder=this.propwind.select(".map2_propwind_order_buttons").first().select(".map2_order_button");this.propWindOrder.each(function(C){C.observe("click",function(D){this.propWindOrder.each(function(E){E.className="map2_order_button"}.bind(this));switch(C.rel){case"11":if(this.propOrder==11){C.className="map2_order_button orderup";this.propOrder=12}else{C.className="map2_order_button orderdown";this.propOrder=11}break;case"21":if(this.propOrder==21){C.className="map2_order_button orderup";this.propOrder=22}else{C.className="map2_order_button orderdown";this.propOrder=21}break;case"41":C.className="map2_order_button orderdown";this.propOrder=41;break}this.updatePropWind(this.propCommId,this.propPage,this.propOrder)}.bind(this))}.bind(this));if(this.filter.customtype>0&&this.filter.customid>0){document.fire("custom:tracker",{type:this.filter.customtype,id:this.filter.customid})}},customTrackers:function(D){this.removeTrackers();this.removePolyLine();if(D==false&&this.jsonTrackers!=undefined){this.drawTrackers(this.jsonTrackers);return false}if(this.filter.customtype==undefined&&this.filter.customid==undefined){return false}var B=this.filter.customtype;var C=this.filter.customid;var A="/v2/map/markers/"+C;new Ajax.Request(A,{method:"get",onSuccess:function(E){if(this.filter.customid==C){this.jsonTrackers=E.responseJSON;this.drawTrackers(this.jsonTrackers)}}.bind(this)})},drawTrackers:function(A){this.mapTrackers.length=0;if(A&&A.points!=null){A.points.each(function(B){if(B.title.blank()){return false}if($("tracker_"+this.filter.customtype+B.lat+B.lng)){$("tracker_"+this.filter.customtype+B.lat+B.lng).remove()}var C=this.buildTracker(this.filter.customtype,B.title,B.lat,B.lng);this.mapTrackers[this.mapTrackers.length]=C;var E=new GLatLng(B.lat,B.lng);var D=this.map.fromLatLngToDivPixel(E);this.drawTracker(C,D.y,D.x)}.bind(this))}if(A.lines!=null&&A.lines!=""){latlngs=new Array();for(j=0;j<A.lines.vertex.length;j++){latlngs[j]=new GLatLng(A.lines.vertex[j].lat,A.lines.vertex[j].lng)}this.polyLineLatlngs=latlngs;this.polyLineColor=A.lines.color;this.polyLineWeight=A.lines.weight;this.polyLineOpacity=0.9;this.buildPolyLine()}},removeTrackers:function(){if(this.mapTrackers.length>0){for(i=0;i<this.mapTrackers.length;i++){if($(this.mapTrackers[i].id)){this.mapTrackers[i].remove()}}}},removePolyLine:function(){if(this.mapPolyline!=null){this.map.removeOverlay(this.mapPolyline);this.mapPolyline=null}},buildPolyLine:function(){this.mapPolyline=new GPolyline(this.polyLineLatlngs,this.polyLineColor,this.polyLineWeight,this.polyLineOpacity);this.map.addOverlay(this.mapPolyline)},buildTracker:function(E,A,G,B){var F=$(document.createElement("div"));F.id="tracker_"+E+G+B;F.className="tracker";var D=$(document.createElement("div"));if(E==2){D.className="tracker_icon icon_subway"}else{D.className="tracker_icon icon_custom"}var H=$(document.createElement("div"));H.className="tracker_text";H.update(A);var C=$(document.createElement("div"));C.className="tracker_right";Event.observe(D,"mouseover",function(I){F.className="tracker tracker_hover"});Event.observe(D,"mouseout",function(I){F.className="tracker"});Event.observe(H,"mouseover",function(I){F.className="tracker tracker_hover"});Event.observe(H,"mouseout",function(I){F.className="tracker"});Event.observe(D,"click",function(){document.fire("map:center",{lat:G,lng:B,zoom:this.subwayZoom})}.bind(this));Event.observe(H,"click",function(){document.fire("map:center",{lat:G,lng:B,zoom:this.subwayZoom})}.bind(this));F.insert(D);F.insert(H);F.insert(C);return F},drawTracker:function(A,C,B){Element.insert(this.markerPanel,A);A.setStyle({top:C-50+"px",left:B+"px",display:"block"})},getGeo:function(A){if(this.geocoder==undefined){this.geocoder=new GClientGeocoder();this.searchBound=new GLatLngBounds(new GLatLng(this.DEF_CITY_INFO.swlat,this.DEF_CITY_INFO.swlng),new GLatLng(this.DEF_CITY_INFO.nelat,this.DEF_CITY_INFO.nelng));this.geocoder.setViewport(this.searchBound)}this.hidePropWind();$kw=this.DEF_CITY_INFO.name+"+"+A;this.loadingAutoComplatePanel();this.geocoder.getLocations($kw,function(D){if(!D||D.Status.code!=200){this.disappearAutoComplatePanel();this.showResultErr();APF.log("NO ADDRESS")}else{var C=D.Placemark[0];var B=new GLatLng(C.Point.coordinates[1],C.Point.coordinates[0]);if(B&&this.searchBound.containsLatLng(B)){this.searchPoint=B;this.map.panTo(B);if(this.searchMarker==undefined){this.searchMarker=new GMarker(B);this.map.addOverlay(this.searchMarker)}else{this.searchMarker.setLatLng(B)}this.updateAutoComplatePanel(D.Placemark);this.searchMarker.openInfoWindowHtml(C.address)}else{if(this.noticeNoResult==undefined){this.noticeNoResult=this.cavansElement.select(".map2_notice_noresult").first();var E=this.noticeNoResult.select(".l4").first();E.observe("click",function(){this.hideNoResultNotice()}.bind(this))}var F=(this.canvasDimension.width-360)/2;this.noticeNoResult.select(".l1").first().innerHTML="找不到这个地方："+A;this.noticeNoResult.setStyle({display:"block",left:F+"px"});this.disappearAutoComplatePanel()}}}.bind(this))},getCanvasDimension:function(){this.canvasDimension=this.canvas.getDimensions()},drawMap:function(){this.map=new GMap2(this.canvas);var A=new GLatLng(this.DEF_CITY_INFO.lat,this.DEF_CITY_INFO.lng);this.map.setCenter(A,this.DEF_CITY_INFO.zoom);this.getBounds();this.markerPanel=this.map.getPane(G_MAP_MARKER_PANE);this.map.enableScrollWheelZoom();this.map.addControl(new GLargeMapControl());G_NORMAL_MAP.getMinimumResolution=function(){return 9};G_NORMAL_MAP.getMaximumResolution=function(){return 19};G_HYBRID_MAP.getMinimumResolution=function(){return 9};G_HYBRID_MAP.getMaximumResolution=function(){return 19};GEvent.addListener(this.map,"click",function(){this.disappearAutoComplatePanel()}.bind(this));GEvent.addListener(this.map,"dragstart",function(){this.disappearAutoComplatePanel()}.bind(this));GEvent.addListener(this.map,"zoomend",function(){window.clearTimeout(this.timeoutHandle);this.hideCommName();this.hideCommNameHighLight();this.hidePropWind();this.removeMapMarkers();this.removeTrackers()}.bind(this));GEvent.addListener(this.map,"movestart",function(){window.clearTimeout(this.timeoutHandle);this.hidePropWind();this.hideCommName();this.hideCommNameHighLight();this.hideNotice();this.dragging=1}.bind(this));GEvent.addListener(this.map,"moveend",function(){this.timeoutHandle=window.setTimeout(function(){this.getBounds();this.getJsonMarkers();this.customTrackers(false)}.bind(this),800);this.dragging=0;this.hidePropWind();this.hideCommName();this.hideCommNameHighLight()}.bind(this))},getBounds:function(){var E=80;var G=this.map.fromContainerPixelToLatLng(new GPoint(E,E/2));var D=this.map.fromContainerPixelToLatLng(new GPoint(this.canvasDimension.width-E/2,this.canvasDimension.height-E/2));var B=D.lat().toFixed(3);var A=G.lat().toFixed(3);var F=G.lng().toFixed(3);var C=D.lng().toFixed(3);this.bounds={slatFrom:B,slatTo:A,slngFrom:F,slngTo:C}},buildMarker:function(C,B,E,D){var A=$(document.createElement("div"));A.update('<div id="prop_num_'+D+'"><strong>'+C+"</strong>&nbsp;套</div>");A.className="marker";A.writeAttribute("propNum",C);A.id=D;A.name=B;this.updateMarker(A,E);return A},buildDefaultCommName:function(A,B){if($("map2_commname_default_"+A.id)){$("map2_commname_default_"+A.id).remove()}comm_name=$(document.createElement("div"));comm_name.className="map2_commname_default";comm_name.id="map2_commname_default_"+A.id;comm_name.update(A.name);Event.observe(comm_name,"click",function(){if(this.currentCommId>0){$("prop_num_"+this.currentCommId).parentNode.className="marker"}var C=this.map.fromLatLngToContainerPixel(B);this.showPropWind(C.y,C.x,A.id,A.name)}.bind(this));Event.observe(comm_name,"mouseover",function(C){if(C.stopPropagation){C.stopPropagation()}else{C.cancelBubble=true}A.className="marker marker_hover";$("map2_commname_default_"+A.id).addClassName("map2_commname_hover")}.bind(this));Event.observe(comm_name,"mouseout",function(C){if(this.currentCommId!=A.id){if(this.currentCommId!=A.id){if(C.stopPropagation){C.stopPropagation()}else{C.cancelBubble=true}A.className="marker"}}$("map2_commname_default_"+A.id).removeClassName("map2_commname_hover")}.bind(this));return comm_name},drawMarker:function(A,C,B,D){Element.insert(this.markerPanel,A);A.setStyle({top:C-40+"px",left:B+"px",display:"block"});current_zoom=this.map.getZoom();if(current_zoom>15){default_commname=this.buildDefaultCommName(A,D);default_commname.setStyle({top:C-40+"px",left:B+45+"px"});Element.insert(this.markerPanel,default_commname)}},updateMarker:function(A,B){Event.observe(A,"mouseover",function(C){Event.stop(C);A.className="marker marker_hover";if(this.dragging==0){var D=this.map.fromLatLngToContainerPixel(B);this.showCommName(A.name,D.y,D.x)}}.bind(this));Event.observe(A,"mouseout",function(C){if(this.currentCommId!=A.id){Event.stop(C);A.className="marker";this.hideCommName()}}.bind(this));Event.observe(A,"click",function(){if(this.currentCommId>0){$("prop_num_"+this.currentCommId).parentNode.className="marker"}var C=this.map.fromLatLngToContainerPixel(B);this.showPropWind(C.y,C.x,A.id,A.name)}.bind(this))},showInfoWindow:function(E,D){this.showWindArrow(E,D);var A=this.DEF_PROP_WINDOW_WIDTH;var F=this.DEF_PROP_WINDOW_HEIGHT;var C=parseInt((this.canvasDimension.height-F)/2);if(C>E-14){C=E-40}else{if((E-C)>F-40){C=this.canvasDimension.height-F}}var B=D;if(B<this.DEF_LEFT_LIMIT){B=D+this.DEF_ARROW_WIDTH}else{B=D-this.DEF_ARROW_WIDTH-A}this.propwind.setStyle({top:C+"px",left:B+"px",display:"block"})},showCommName:function(A,C,B){this.commname.update(A);this.commname.setStyle({top:C-39+"px",left:B+45+"px",display:"block"})},showCommNameDefault:function(A,D,C){var B=new Element("div");B.className="map2_commname_default";B.update(A);B.setStyle({top:D-40+"px",left:C+45+"px",display:"block"});this.cavansElement.appendChild(B)},hideCommName:function(){this.commname.setStyle({display:"none"})},showCommNameHighLight:function(A,C,B){this.hideCommName();this.commname_heighlight.update(A);this.commname_heighlight.setStyle({top:C-39+"px",left:B+45+"px",display:"block"})},hideCommNameHighLight:function(){if(this.currentCommId>0&&$("prop_num_"+this.currentCommId)){$("prop_num_"+this.currentCommId).parentNode.className="marker"}if($("map2_commname_default_"+this.currentCommId)){$("map2_commname_default_"+this.currentCommId).removeClassName("map2_commname_hover")}this.currentCommId=0;this.hideCommName();this.commname_heighlight.setStyle({display:"none"})},showWindArrow:function(B,A){if(A<this.DEF_LEFT_LIMIT){this.proparrow.className="map2_proparrow map2_proparrow_right";windowLeft=A}else{this.proparrow.className="map2_proparrow map2_proparrow_left";windowLeft=A-this.DEF_ARROW_WIDTH-1}this.proparrow.setStyle({top:B-7+"px",left:windowLeft+"px",display:"block"})},showPropWind:function(C,B,D,A){this.currentCommId=D;this.showCommNameHighLight(A,C,B);$("prop_num_"+this.currentCommId).parentNode.addClassName("marker_hover");this.setFilter(this.propWindOrder,0);this.showWindArrow(C,B);this.propwind_commname.update(A);this.propwind_commname.href="/v2/community/view/"+D;if(this.DEF_TRADE_TYPE==1){this.propwind_listlink.href="/v2/community/props/sale/"+D}else{this.propwind_listlink.href="/v2/community/props/rent/"+D}this.propCommId=D;this.propPage=1;this.propOrder=41;this.propIsHq=0;this.hqbutton.checked=false;this.updatePropWind(this.propCommId,this.propPage,this.propOrder);this.showInfoWindow(C,B)},hidePropWind:function(){this.proparrow.setStyle({display:"none"});this.propwind.setStyle({display:"none"});this.hideCommNameHighLight()},updatePropWind:function(D,C,A){this.showLoading();var B=this.buildUrl(D,C,A);new Ajax.Request(B,{method:"get",onSuccess:function(E){this.drawPropBox(E.responseJSON)}.bind(this)})},drawPropBox:function(G){if(this.propBoxes==undefined){this.propBoxes=this.propwind.select(".prop_box");this.propImages=this.propwind.select(".prop_image");this.propLine1s=this.propwind.select(".prop_line1");this.propLine2s=this.propwind.select(".prop_line2");this.propNum=this.cavansElement.select(".prop_num").first();this.propPriceTrend=this.cavansElement.select(".prop_pricetrend").first();this.propBoxes.each(function(K){K.observe("mouseover",function(){K.setStyle({backgroundColor:"#FFFCE4"})});K.observe("mouseout",function(){K.setStyle({backgroundColor:"white"})})})}var H=this.propBoxes.length;this.propNum.update(G[0]);this.maxPage=G[0]%H==0?parseInt(G[0]/H):parseInt(G[0]/H)+1;if(this.propPage==1){this.propwind.select(".page_prev").first().setStyle("display:none;")}else{this.propwind.select(".page_prev").first().setStyle("display:block;")}if(this.propPage<this.maxPage){this.propwind.select(".page_next").first().setStyle("display:block;")}else{this.propwind.select(".page_next").first().setStyle("display:none;")}this.propPriceTrend.update(G[1]);var I=G[2];if(I.length>0){$("noprops").setStyle("display:none;");for(var E=0;E<H;E++){var A=I[E];if(A!=undefined){var D=new Element("a",{href:A[5],target:"_blank"});var F=new Element("img",{"class":"picture",src:A[1]});F.setAttribute("width",100);F.setAttribute("height",75);D.insert(F);this.propImages[E].update(D);var C=new Element("a",{href:A[5],target:"_blank"});C.update(A[2]+"室&nbsp;");var B=new Element("a",{href:A[5],target:"_blank"});B.update(A[3]+"平米");this.propLine1s[E].update(C);this.propLine1s[E].insert({bottom:B});var J=new Element("a",{href:A[5],target:"_blank"});J.update(A[4]+"元");this.propLine2s[E].update(J)}else{this.propImages[E].update(null);this.propLine1s[E].update(null);this.propLine2s[E].update(null)}}this.hideLoading()}else{if(this.propIsHq==1){$("noprops").update("这个小区没有符合您要求的多图房源哦。")}else{$("noprops").update("这个小区没有符合您要求的房源哦。")}$("noprops").setStyle("display:block;");this.propwindLoad.hide();this.propwindNumber.show()}},showLoading:function(){if(this.propwindTable==undefined){this.propwindLoad=this.propwind.select(".map2_propwind_load").first();this.propwindTable=this.propwind.select(".map2_propwind_table").first();this.propwindNumber=this.propwind.select(".map2_propwind_numbinfo").first()}this.propwindLoad.show();this.propwindTable.hide();this.propwindNumber.hide()},hideLoading:function(){this.propwindLoad.hide();this.propwindTable.show();this.propwindNumber.show()},getJsonMarkers:function(){document.fire("tip:loading");this.hideNotice();var A=this.buildUrl(0,1,0);this.updateLocationHref();new Ajax.Request(A,{method:"get",onSuccess:function(H){var F=H.responseJSON;var E=Object.keys(F);var B=E.length;document.fire("tip:finished",{num:B});if(B==0){this.removeMapMarkers();this.hideCommName();if(this.notice==undefined){this.notice=this.cavansElement.select(".map2_notice").first();var D=this.notice.select(".l4").first();D.observe("click",function(){this.hideNotice()}.bind(this))}var G=(this.canvasDimension.width-360)/2;this.notice.setStyle({display:"block",left:G+"px"})}else{this.mapMarkers.each(function(J){var I=F[J.key];if(I==undefined||I[1]!=J.value.readAttribute("propNum")){if($("map2_commname_default_"+J.key)){$("map2_commname_default_"+J.key).remove()}this.mapMarkers.get(J.key).remove();if(this.currentCommId==J.key){this.hidePropWind();hideCommNameHighLight()}this.mapMarkers.unset(J.key)}else{var L=new GLatLng(I[2],I[3]);var K=this.map.fromLatLngToDivPixel(L);this.mapMarkers.get(J.key).remove();if($("map2_commname_default_"+J.key)){$("map2_commname_default_"+J.key).remove()}this.drawMarker(this.mapMarkers.get(J.key),K.y,K.x,L)}}.bind(this));var C=0;E.each(function(I){if(this.mapMarkers.get(I)==undefined){window.setTimeout(function(){var K=F[I];var M=new GLatLng(K[2],K[3]);var J=this.buildMarker(K[1],K[0],M,I);var L=this.map.fromLatLngToDivPixel(M);if(this.mapMarkers.get(I)){this.mapMarkers.get(I).remove()}this.drawMarker(J,L.y,L.x,M);this.mapMarkers.set(I,J)}.bind(this),C++*30)}}.bind(this))}}.bind(this)})},removeMapMarkers:function(){this.mapMarkers.each(function(A){if($("map2_commname_default_"+A.key)){$("map2_commname_default_"+A.key).remove()}this.mapMarkers.get(A.key).remove();this.mapMarkers.unset(A.key)}.bind(this))},buildUrl:function(D,E,B){var G=this.map.getCenter();var F=this.map.getZoom();var A=$H({p2:this.DEF_TRADE_TYPE,p3:this.bounds.slatFrom,p4:this.bounds.slatTo,p5:this.bounds.slngFrom,p6:this.bounds.slngTo,p7:this.filter.price,p8:this.filter.area,p9:this.filter.room,p14:this.filter.fitment,p11:D,p12:E,p13:B,p15:1,p16:1,p17:this.curr_lat,p18:this.curr_lng,p19:G.lat(),p20:G.lng(),p21:this.curr_zoom,p22:F,p23:this.filter.customtype,p24:this.filter.customid,is_hq:this.propIsHq}).toQueryString();var C="/v2/map/search?"+A;return C},setFilter:function(A,B){if(A==undefined){return }this.propWindOrder.each(function(C){C.className="map2_order_button";if(C.rel==41){C.className="map2_order_button orderdown"}}.bind(this))},hideNotice:function(){if(this.notice!=undefined){this.notice.setStyle({display:"none"})}},hideNoResultNotice:function(){if(this.noticeNoResult!=undefined){this.noticeNoResult.setStyle({display:"none"})}},wlog:function(A){GLog.write(A)},updateLocationHref:function(){var B=document.location.hash.substring(1).toQueryParams();var C=this.map.getCenter();var A=this.map.getZoom();upparams={};upparams.l1=C.lat();upparams.l2=C.lng();upparams.l3=A;this.curr_lat=upparams.l1;this.curr_lng=upparams.l2;this.curr_zoom=upparams.l3;B.kw="";upparams.f1=this.filter.price;upparams.f2=this.filter.area;upparams.f3=this.filter.room;upparams.f4=this.filter.fitment;upparams.f5=this.filter.customtype;upparams.f6=this.filter.customid;document.location.hash=Object.toQueryString(upparams)},logging:function(B,A){new Ajax.Request(this.logurl,{method:"get",parameters:{key:B,string:A},onSuccess:function(C){}.bind(this)})},updateAutoComplatePanel:function(B){this.serch_result_container.innerHTML="";this.serch_result_container.removeClassName("loading");this.serch_result_container.setStyle("display:block");list_content=new Element("ul");for(i=0;i<B.length;i++){if(i>=this.maxSearchNumber){break}var A=new Element("li");if(i==0){A.addClassName("selected")}A.innerHTML='<a href="javascript:;" rel="'+i+'" id="item_address_'+i+'">'+B[i]["address"]+"</a>";list_content.appendChild(A)}closeLi=new Element("li");closeLi.addClassName("close");closeLi.innerHTML='<a href="javascript:;" id="item_close">关闭</a>';list_content.appendChild(closeLi);this.serch_result_container.appendChild(list_content);this.serch_result_container.select("a").each(function(C){if(C.id=="item_close"){C.observe("click",function(){this.disappearAutoComplatePanel()}.bind(this))}else{C.observe("click",function(){this.serch_result_container.select("li").each(function(F){if(F.select("a").first().id==C.id){F.addClassName("selected")}else{F.removeClassName("selected")}}.bind(this));var E=B[C.rel];var D=new GLatLng(E.Point.coordinates[1],E.Point.coordinates[0]);this.searchPoint=D;this.map.setCenter(D);if(this.searchMarker==undefined){this.searchMarker=new GMarker(D);this.map.addOverlay(this.searchMarker)}else{this.searchMarker.setLatLng(D)}this.searchMarker.openInfoWindowHtml(E.address)}.bind(this))}}.bind(this))},loadingAutoComplatePanel:function(){this.serch_result_container.addClassName("loading");this.serch_result_container.setStyle("display:block");this.serch_result_container.innerHTML="正在查找，请稍候..."},disappearAutoComplatePanel:function(){this.serch_result_container.innerHTML="";this.serch_result_container.removeClassName("loading");this.serch_result_container.setStyle("display:none")}});APF.Namespace.register("Anjuke.Map2");Anjuke.Map2.Sidebar=Class.create({initialize:function(B){var E=$(B);var C=E.select(".map2_sidebar_box_1 a");var D=E.select(".map2_sidebar_box_2 a");var A=E.select(".map2_sidebar_box_3 a");C.each(function(F){F.observe("click",function(){var I=F.readAttribute("lat");var G=F.readAttribute("lng");var H=parseInt(F.readAttribute("zoom"));document.fire("map:center",{lat:I,lng:G,zoom:H})})});D.each(function(F){F.observe("click",function(){var J=F.readAttribute("lat");var G=F.readAttribute("lng");var I=parseInt(F.readAttribute("zoom"));document.fire("map:center",{lat:J,lng:G,zoom:I});var H=F.readAttribute("type");var K=F.readAttribute("oid");document.fire("custom:tracker",{type:H,id:K})})});A.each(function(F){F.observe("click",function(){var J=F.readAttribute("lat");var G=F.readAttribute("lng");var I=parseInt(F.readAttribute("zoom"));document.fire("map:center",{lat:J,lng:G,zoom:I});var H=F.readAttribute("type");var K=F.readAttribute("oid");document.fire("custom:tracker",{type:H,id:K})})})}});