/*
 * Compressed by JSA(www.xidea.org)
 */
function Map2s(B,$){this._marker=null;this.map=null;this.mapNode=_g(B);this.resize();this.d_status=false,this.point1=null,this.point2=null,this.rect=null;this.map=new GMap2(this.mapNode);new GKeyboardHandler(this.map);switch($){case"small":this.map.addControl(new GSmallMapControl());break;case"large":default:this.map.addControl(new GLargeMapControl())}this.setup();var A=this,_=this.mapNode.className;if(_=="mapsearch"||_=="mapidx2")window.onresize=function(){A.resize()}}Map2s.prototype.resize=function(){if(this.mapNode.className=="mapsearch"){this.mapNode.style.width=($(document).width()-510)+"px";if(this.map!=null){this.map.checkResize();this.setup()}}if(this.mapNode.className=="mapidx2")if(this.map!=null)this.map.checkResize()};Map2s.prototype.setup=function(){this.map.setCenter(new GLatLng(39.916715,116.397142),14)};Map2s.getDistance=function(A,C,_,$){if(typeof(A)=="number"&&typeof(C)=="number"&&typeof(_)=="number"&&typeof($)=="number"&&A!=0&&C!=0&&_!=0&&$!=0){var B=Math.round((new GLatLng($,_).distanceFrom(new GLatLng(C,A)))/10)/100;B=B>0?B+"Km":"";return B}return};Map2s.prototype.getPagePos=function(B){var A=B.getIcon().iconAnchor.x-B.getIcon().infoWindowAnchor.x,_=B.getIcon().iconAnchor.y-B.getIcon().infoWindowAnchor.y,E=new GPoint(A,_),$=B.getPoint(),C=this.map.fromLatLngToDivPixel($),D=this.map.getPane(G_MAP_MAP_PANE).parentNode,H=C.x+parseInt(D.style.left),G=C.y+parseInt(D.style.top),F=findPos(this.map.getContainer());G+=F[1];H+=F[0];G-=E.y;H-=E.x;G+=B.getIcon().iconSize.height;return new WPoint(H,G)};Map2s.prototype.getPos=function(_){if(typeof(_)=="undefined")_=2;else if(!isInt(_))_=2;var $=this.map.getContainer(),A=findPos($),C=A[0]+Math.round(this.map.getSize().width/_),B=A[1]+Math.round(this.map.getSize().height/_);return new WPoint(C,B)};Map2s.prototype.getCenterPos=function(){return this.getPos(2)};Map2s.prototype.addPoint1=function(A,_){var B=this,$=function($){if(B._marker==null)return false;w.UI.hint.create("","\u786e\u5b9a\u5728\u8fd9\u91cc\u6dfb\u52a0\u623f\u6e90\u4e48\uff1f",[{caption:"\u786e \u5b9a",callback:function(){var $="/"+(channel=="th"?"2h":channel)+"/check.php?posid="+B._marker.getLatLng().lng()+","+B._marker.getLatLng().lat();window.location.href=$}},{caption:"\u53d6 \u6d88",callback:function(){}}],true)};if(A==null){if(this._marker!=null)this.map.removeOverlay(this._marker);this._marker=new GMarker(_,{draggable:true});GEvent.addListener(this._marker,"dragend",function(){$(321)});this.map.addOverlay(this._marker)}$(123)};Map2s.prototype.addPoint2=function(A,_){var B=this,$=function($){if(B._marker==null)return false;B.o_lng.value=B._marker.getPoint().lng();B.o_lat.value=B._marker.getPoint().lat()};if(A==null){if(this._marker!=null)this.map.removeOverlay(this._marker);this._marker=new GMarker(_,{draggable:true});GEvent.addListener(this._marker,"dragend",function(){$(321)});this.map.addOverlay(this._marker)}$(123)};Map2s.prototype.addPoint3=function(A,_){var B=this,$=function($){if(B._marker==null)return false;w.UI.hint.create("","\u60a8\u60f3\u5728\u8fd9\u4e2a\u5730\u65b9\u6dfb\u52a0\u4fe1\u606f\u5417\uff1f",[{caption:"\u786e \u5b9a",callback:function(){window.location="/user_track.php?ac=addpoint&x="+B._marker.getLatLng().lng()+"&y="+B._marker.getLatLng().lat()}},{caption:"\u53d6 \u6d88",callback:function(){B.map.removeOverlay(B._marker)}}],true)};if(A==null){if(this._marker!=null)this.map.removeOverlay(this._marker);this._marker=new GMarker(_,{icon:G_START_ICON});GEvent.addListener(this._marker,"dragend",function(){$(321)});this.map.addOverlay(this._marker);$(321)}};Map2s.prototype.switchMode=function(){if(this.map.draggingEnabled())this.map.disableDragging();else this.map.enableDragging()};Map2s.prototype.resetRect=function(){if(this.rect!=null)this.map.removeOverlay(this.rect);this.map.enableDragging();this.d_status=false,this.point1=null,this.point2=null};Map2s.prototype.submitRect=function(){var B=this,D=["/rent/s.php","/2h/s.php","/s.php?t=3","/s.php?t=1","/s.php?t=2","/s.php?t=4","/s.php?t=5"],C=["\u6211\u60f3\u627e\u51fa\u79df\u7684\u623f\u5b50","\u6211\u60f3\u627e\u4e8c\u624b\u623f\u4ea4\u6613","\u6211\u60f3\u627e\u8fd9\u91cc\u7684\u90bb\u5c45","\u6211\u60f3\u627e\u8fd9\u91cc\u7684\u5e97\u94fa","\u6211\u60f3\u627e\u9644\u8fd1\u7684\u996d\u9986","\u6211\u60f3\u627e\u51fa\u5a31\u4e50\u573a\u6240","\u6211\u60f3\u627e\u6b64\u5730\u7684\u516c\u53f8"],A=0;switch(channel){case"th":A=1;break;case"rent":default:A=0}if(gc("lastuc")!=null)A=gc("lastuc");var _=function(_){var B="",$=[];for(var D=0,A=C.length;D<A;D++){B="";if(D==_)B="checked=checked";$.push("<input type='radio' name='stype' id='s"+D+"' value='"+D+"' "+B+"/><label for='s"+D+"' class='f14'>"+C[D]+"</label>")}return $.join("<br/>")};w.UI.hint.create("",_(A),[{caption:"\u786e \u5b9a",callback:function(){var A=$("input[name=stype]:checked").val();sc("lastuc",A,30);if(A<7){var E=D[A],C=location.pathname;if(A==0&&((C).indexOf("/rent/ss.php")>-1||(C).indexOf("/rent/ls.php")>-1))E=C;var _=E+((E.indexOf("?")>-1)?"&":"?")+"area="+B.point1.toUrlValue()+","+B.point2.toUrlValue();_+="&ms="+B.map.getCenter().toUrlValue();_+="&zoom="+B.map.getZoom();window.location.href=_}B.resetRect()}},{caption:"\u53d6 \u6d88",callback:function(){B.resetRect()}}],true)};Map2s.prototype.drawRect=function(_,$){if(this.map.getZoom()<12)return false;if(this.d_status){this.point2=$;this.submitRect();return false}else{this.point1=$;this.d_status=true}var A=this;GEvent.addListener(this.map,"zoomend",function($,_){A.resetRect()});GEvent.addListener(this.map,"singlerightclick",function(){A.resetRect()});this.rect=new WRedBox($);this.map.addOverlay(this.rect)};Map2s.prototype.getContractBounds=function(B){B=B||new WPoint(8,8);var $=this.map.getBounds(),_=$.getSouthWest(),E=$.getNorthEast(),D=(E.lng()-_.lng())/B.x,C=(E.lat()-_.lat())/B.y,A=new GLatLngBounds(new GLatLng(_.lat()+C,_.lng()+D),new GLatLng(E.lat()-C,E.lng()-D));return A};function WRedBox($){this.point=$;this.old_pos=[];this.new_pos=[];this.rect_handle=null}WRedBox.prototype=new GOverlay();WRedBox.prototype.initialize=function($){this.map=$;var _=this;this.div=document.createElement("div");this.div.style.width=0;this.div.style.height=0;this.div.style.border="2px red solid";this.div.style.position="absolute";this.div.style.cursor="default";this.div.innerHTML="<img width=\"0\" height=\"0\" alt=\"\" src=\"\" />";$.getPane(G_MAP_MARKER_PANE).appendChild(this.div);this.rect_handle=GEvent.addListener(this.map,"mousemove",function(A){if(_.map.draggingEnabled())_.map.disableDragging();var $=_.map.fromLatLngToDivPixel(A);_.new_pos=[$.x,$.y];if(_.new_pos[0]<=_.old_pos[0]){_.div.style.left=_.new_pos[0]+"px";_.div.style.width=Math.abs(_.new_pos[0]-_.old_pos[0])+"px"}else{_.div.style.left=_.old_pos[0]+"px";_.div.style.width=Math.abs(_.new_pos[0]-_.old_pos[0]-7)+"px"}if(_.new_pos[1]<=_.old_pos[1]){_.div.style.top=_.new_pos[1]+"px";_.div.style.height=Math.abs(_.new_pos[1]-_.old_pos[1])+"px"}else{_.div.style.top=_.old_pos[1]+"px";_.div.style.height=Math.abs(_.new_pos[1]-_.old_pos[1]-7)+"px"}})};WRedBox.prototype.remove=function(){if(this.div&&this.div.parentNode)this.div.parentNode.removeChild(this.div);if(this.rect_handle!=null){GEvent.removeListener(this.rect_handle);this.rect_handle=null}};WRedBox.prototype.redraw=function(_){var $=this.map.fromLatLngToDivPixel(this.point);this.div.style.left=$.x+"px";this.div.style.top=$.y+"px";this.old_pos=[$.x,$.y]};function WInfoWindow(){this.div=null;this.node=null;this.isVisible=false;this.init()}WInfoWindow.prototype.init=function(){if(this.node==null||this.div==null){this.div=document.createElement("div");this.div.className="trackform";this.div.style.zIndex=1000;document.body.appendChild(this.div);this.node=w.UI.box.trans("333","","","",true,true,true);this.div.appendChild(this.node.box);this.closeEvent()}};WInfoWindow.prototype.getWidth=function(){if(this.div)return this.div.offsetWidth;return 0};WInfoWindow.prototype.closeEvent=function(A){var _=this;$(this.node.caption).prev().unbind("click").bind("click",function(){_.hide()});if(typeof(A)=="function")$(this.node.caption).prev().bind("click",function(){A()})};WInfoWindow.prototype.setContent=function(A){this.init();var _=this;$(_.node.textbody).empty();var B=$("<div>"+A+"<div>").appendTo(_.node.textbody);this.show();if($.isFunction(tb_init))tb_init("a.thickbox")};WInfoWindow.prototype.setCaption=function($){this.init();this.node.caption.innerHTML="<h4>"+$+"</h4>";this.show()};WInfoWindow.prototype.loadingTip=function(){this.setContent(res_char.hintTip.loadingMsg)};WInfoWindow.prototype.show=function(){if(this.div&&this.div.style.display!="block")$(this.div).show();this.isVisible=true};WInfoWindow.prototype.hide=function(){if(this.div&&this.div.style.display!="none")$(this.div).hide();this.isVisible=false};WInfoWindow.prototype.remove=function(){this.div=null;rmo(this.div);this.isVisible=false};WInfoWindow.prototype.redraw=function($){if($&&this.div){this.div.style.left=$.x+"px";this.div.style.top=$.y+"px";this.show()}};var WMap={mo:null,newmark:"newmark",markers:new Hash(),moveendListener:null,markOffset:null,init:function(){if(GBrowserIsCompatible()){var _=null,B=0,$=this;if(typeof(initpara2.point)!="undefined"){_=initpara2.point;B=_.length}Map2s.prototype.setup=function(){var A=(gp("zoom")!=null)?parseInt(gp("zoom")):13,$=new GLatLng(39.916715,116.397142);if(B>0&&_[B-1][1]>0&&_[B-1][2]>0)$=new GLatLng(_[B-1][2],_[B-1][1]);else if(typeof(initpara2.initpos)!="undefined"&&initpara2.initpos.length==2)$=new GLatLng(initpara2.initpos[0],initpara2.initpos[1]);if($)this.map.setCenter($,A)};this.mo=new Map2s("maparea","small");GEvent.addListener(this.mo.map,"zoomend",function($,_){WTrackForm.hide()});GEvent.addListener(this.mo.map,"dragstart",function(){WTrackForm.hide()});GEvent.addListener(this.mo.map,"click",function(_,A){$.addPoint(_,A)});if(B>0)for(var A=0;A<B;A++)this.mo.map.addOverlay(this.createMarker(A))}else alert("\u5f88\u62b1\u6b49\uff0c\u60a8\u7684\u6d4f\u89c8\u5668\u4e0d\u80fd\u6d4f\u89c8\u672c\u7ad9\u7684\u5730\u56fe\u529f\u80fd\u3002")},createMarker:function(B,C){var _=this,D=null;if(B>-1){D=initpara2.point[B];C=new GLatLng(D[2],D[1]);var A=new GMarker(C,{title:D[3],draggable:true});this.markers.setItem(D[0],[A,B])}else A=new GMarker(C,{title:"\u65b0\u6dfb\u52a0\u7684\u5730\u65b9",draggable:true,icon:G_START_ICON});GEvent.addListener(A,"click",function(){if(_.moveendListener!=null){GEvent.removeListener(_.moveendListener);_.moveendListener=null}_.markOffset=_.mo.getPagePos(this);if(!_.isInRect(this)){var $=_.mo.map.getBounds(),C=$.getSouthWest(),G=$.getNorthEast(),F=(G.lng()-C.lng())/4,D=(G.lat()-C.lat())/4,E=this.getLatLng(),A=new GLatLng(parseFloat(E.lat())-D,parseFloat(E.lng())+F);_.mo.map.panTo(A);_.markOffset=_.mo.getPos(4)}WTrackForm.show(B,this)});GEvent.addListener(A,"dragstart",function(){WTrackForm.hide()});GEvent.addListener(A,"dragend",function(){if(B==-1){GEvent.trigger(this,"click");return false}var _=this,A="\u786e\u5b9a\u8981\u628a["+D[3]+"]\u79fb\u52a8\u5230\u8fd9\u91cc\u4e48\uff1f";w.UI.hint.create("",A,[{caption:"\u786e \u5b9a",callback:function(){var A=_.getLatLng();D[1]=A.lng();D[2]=A.lat();$.ajax({url:"/x/edit_pos.php",type:"POST",data:"ac=move&id="+D[0]+"&pos_x="+D[1]+"&pos_y="+D[2],dataType:"json",timeout:10000,error:function(){},success:page_process})}},{caption:"\u53d6 \u6d88",callback:function(){_.setLatLng(new GLatLng(D[2],D[1]))}}],true)});return A},createMarker2:function(A){var $=this,B=initpara2.point[A];latlng=new GLatLng(B[2],B[1]);var C=B[3],_=new GMarker(latlng,{title:C});this.markers.setItem(B[0],[_,A]);GEvent.addListener(_,"click",function(){if($.moveendListener!=null){GEvent.removeListener($.moveendListener);$.moveendListener=null}$.markOffset=$.mo.getPagePos(this);if(!$.isInRect(this)){var _=$.mo.map.getBounds(),C=_.getSouthWest(),G=_.getNorthEast(),F=parseFloat((G.lng()-C.lng())/4),D=parseFloat((G.lat()-C.lat())/4),E=this.getLatLng(),B=new GLatLng(parseFloat(E.lat())-D,parseFloat(E.lng())+F);$.mo.map.panTo(B);$.markOffset=$.mo.getPos(4)}WTrackForm.show(A,this)});GEvent.addListener(_,"mouseover",function(){this.setImage("/i/m/dd-start.png")});GEvent.addListener(_,"mouseout",function(){this.setImage("/i/m/marker.png")});return _},addPoint:function(_,A){if(_==null){var $=this.createMarker(-1,A);if(this.markers.hasItem(this.newmark))this.markers.getItem(this.newmark).setLatLng(A);else{this.markers.setItem(this.newmark,$);this.mo.map.addOverlay($)}this.toPoint($)}},toPoint:function(B){if(this.isInRect(B))GEvent.trigger(B,"click");else{this.moveendListener=GEvent.addListener(this.mo.map,"moveend",function(){GEvent.trigger(B,"click")});var $=this.mo.map.getBounds(),A=$.getSouthWest(),F=$.getNorthEast(),E=(F.lng()-A.lng())/4,C=(F.lat()-A.lat())/4,D=B.getLatLng(),_=new GLatLng(parseFloat(D.lat())-C,parseFloat(D.lng())+E);this.mo.map.panTo(_)}},removePoint:function(C){var A=this,_=null,B=null;if(typeof(C)=="string"){if(!this.markers.hasItem(C))return false;_=this.markers.getItem(C)[0];B=initpara2.point[this.markers.getItem(C)[1]][3]}else{C=this.newmark;if(!this.markers.hasItem(C))return false;_=this.markers.getItem(C);B="\u521a\u6dfb\u52a0\u7684\u4f4d\u7f6e"}w.UI.hint.create("","\u786e\u5b9a\u8981\u5220\u9664["+B+"]\u4e48\uff1f",[{caption:"\u786e \u5b9a",callback:function(){A.mo.map.removeOverlay(_);A.markers.removeItem(C);if(C!=A.newmark)$.ajax({url:"/x/edit_pos.php",type:"get",data:"ac=del&id="+C,dataType:"json",timeout:10000,error:function(){},success:page_process});WTrackForm.hide()}},{caption:"\u53d6 \u6d88",callback:function(){}}],true)},updatePoint:function(A){if(isArray(A)){var _=initpara2.point.push(A),$=_-1,B=this.markers.removeItem(this.newmark);this.mo.map.removeOverlay(B);this.mo.map.addOverlay(this.createMarker($));WTrackForm.hide();WTrackForm.infoIdx=null}},isInRect:function($){return this.mo.getContractBounds().containsLatLng($.getLatLng())}},WTrackList={infoIdx:null,toPoint:function(A){if(WMap.markers.hasItem(A)){var _=WMap.markers.getItem(A),$=_[0];WMap.toPoint($)}else wTools.hint("\u60a8\u6240\u8bbf\u95ee\u7684\u6807\u8bb0\u5df2\u7ecf\u88ab\u5b83\u7684\u4e3b\u4eba\u5220\u9664\u4e86\uff01")},highLight:function($){if($>-1){var _=_g("p_"+initpara2.point[$][0]);if(_)_.style.backgroundColor="#fcfc8a";if(this.infoIdx!=null&&this.infoIdx!=$){_=_g("p_"+initpara2.point[this.infoIdx][0]);if(_)_.style.backgroundColor="#fff"}this.infoIdx=$}else this.infoIdx=null}},WTrackForm={infoWin:null,infoWinCaption:"WoXiangYouGeJia.com",infoIdx:null,liveinCateId:3,init:function(){if(this.infoWin==null)this.infoWin=new WInfoWindow();this.infoWin.closeEvent(function(){WTrackForm.close()})},checkForm:function(_){if(trim(_.caption.value)==""){var $=op_tip(_.caption,"\u8bf7\u586b\u5199\u6807\u9898",-80);auto_hide($,10);_.caption.focus();return false}if(_.content.value.len()>4000){$=op_tip(_.content,"\u6700\u591a\u80fd\u8f93\u51652000\u4e2a\u6c49\u5b57\u54e6~",-30);auto_hide($,10);_.content.focus();return false}return true},submitForm:function(B){if(this.checkForm(B)){var A=B.cate_id.value,_=["ac="+B.ac.value+"&id="+B.id.value+"&cate_id="+A+"&pos_x="+B.pos_x.value+"&pos_y="+B.pos_y.value+"&is_present="+((B.is_present.checked)?1:0)];_.push("caption="+encodeURIComponent(B.caption.value));_.push("content="+encodeURIComponent(B.content.value));_.push("stage="+encodeURIComponent(B.stage.value));$("input[type=submit]",B).attr("disabled","true");$("input[type=button]",B).attr("disabled","true");$("#submit_loading_box").css("display","block");$.ajax({url:"/x/edit_pos.php",type:"POST",data:_.join("&"),dataType:"json",timeout:10000,error:function(){wTools.hint(res_char.hintTip.error);$("input[type=submit]",B).attr("disabled",false);$("input[type=button]",B).attr("disabled",false);$("#submit_loading_box").css("display","none")},success:function($){page_process($)}});op_tip(null);return false}return false},changeType:function($){_g("caption_label").innerHTML=cap_arr[_g("pf").cate_id.value]+"\uff1a";this.setType($)},setType:function($){if($==this.liveinCateId)_g("i_ipt").style.display="block";else _g("i_ipt").style.display="none";if(arguments.length==2){_g("show_cate").innerHTML=cate_arr[$-1];_g("show_cate").style.display="block";_g("sel_cate").style.display="none"}else{_g("show_cate").style.display="none";_g("sel_cate").style.display="block"}},show:function(F,D){var B=this;this.infoIdx=F;this.init();WTrackList.highLight(F);var E=this.infoWin,_=WMap.markOffset;if(_.x>(document.body.offsetWidth-360-10))_.x-=360;E.redraw(_);E.loadingTip();E.setCaption(this.infoWinCaption);if(F>-1){try{$.ajax({url:"/x/edit_pos.php",type:"get",data:"ac=read&id="+initpara2.point[F][0],dataType:"json",timeout:15000,error:function(){wTools.hint("\u7cfb\u7edf\u51fa\u95ee\u9898\u4e86\uff0c\u8bf7\u7a0d\u5019\u518d\u8bd5\uff01")},success:page_process})}catch(C){wTools.hint(res_char.hintTip.error)}}else{var A=D.getLatLng();E.setContent(t_form);var G=_g("pf");G.reset();$("#btndel").click(function(){B.del()});$("#btncancel").click(function(){B.cancel()});$("#sel_cate>select").change(function(){B.changeType(this.value)});$(G).submit(function(){return B.submitForm(this)});G.ac.value="add";G.pos_x.value=A.lng();G.pos_y.value=A.lat();if(gp("c")!=null)G.caption.value=unescape(gp("c"));var H=1;if(typeof(old_cid)!="undefined")H=(typeof(old_cid.split("_")[1])!="undefined")?old_cid.split("_")[1]:1;G.cate_id.value=H;this.changeType(H)}},hide:function(){if(this.infoWin)this.infoWin.hide()},close:function(){if(this.infoIdx==-1)WMap.removePoint()},del:function($){if(this.infoIdx==-1&&typeof($)=="undefined")this.close();else{if(typeof($)=="undefined")$=initpara2.point[this.infoIdx][0];WMap.removePoint($)}},cancel:function(){if(this.infoIdx==-1)this.close();else this.hide()}}