//Global.g[0]=function(a,b,c,d){return "http://lspengine.go2map.com/seamless/"+a.join("/")+".GIF"}
var _m,_cv;
(function(){
var g={path:'map413/',city:{map:'全国',bus:"北京",appid:"1421",nav:"全国",isBus:true,isNav:true,isUrlBusInfo:false,isUrlBus:false,isUrlNav:false},size:{busMiddleContainerHeight:0,busFinalContainerHeight:0,navMiddleContainerHeight:0},appCode:false
,engine:'http://lspengine4.go2map.com/WebSite/Engine'
,vamengine:'http://map.sogou.com/vamengine/VamEngine.do'
,itemUrl:"http://map.sogou.com/poi"
,APPID:'1361',SPInfo:'1,1',UserInfo:',,',ScriptType:'jsp',toolboxOn:false,mapOffsetLeft:[2,296,290]
,rps:'SDS==<custom>!!hidden_MapTool==map.EntireMap!!hidden_DISABLEQDS==true!!hidden_APPID==1361'
,sds:{id:270,name:" ",caption:" ",areaId:0,areaid:0,defaultLevel:5,defaultdisplevel:5,defaultCX:11950000,defaultdispcx:11950000,defaultCY:4150000,defaultdispcy:4150000,rmp:{id:174,name:"",caption:"",mp:{mplevel:[{caption:"",cellcountx:653,cellcounty:566,cellheight:256,cellwidth:256,deltax:64000,deltay:64000,id:719,zoompercell:64000,zoomperpixel:250,zoomscreen:256000},{caption:"",cellcountx:2609,cellcounty:2262,cellheight:256,cellwidth:256,deltax:16000,deltay:16000,id:717,zoompercell:16000,zoomperpixel:62.5,zoomscreen:64000},{caption:"",cellcountx:10436,cellcounty:9046,cellheight:256,cellwidth:256,deltax:4000.00000000003,deltay:4000,id:715,zoompercell:4000,zoomperpixel:15.6250000000001,zoomscreen:16000},{caption:"",cellcountx:41742,cellcounty:36184,cellheight:256,cellwidth:256,deltax:1000.00000000003,deltay:1000,id:713,zoompercell:1000,zoomperpixel:3.90625000000011,zoomscreen:4000},{caption:"",cellcountx:166968,cellcounty:144736,cellheight:256,cellwidth:256,deltax:249.999999999971,deltay:250,id:711,zoompercell:250,zoomperpixel:0.976562499999886,zoomscreen:1000},{caption:"",cellcountx:2,cellcounty:2,cellheight:256,cellwidth:256,deltax:32768000,deltay:32768000,id:728,zoompercell:32768000,zoomperpixel:128000,zoomscreen:131072000},{caption:"",cellcountx:6,cellcounty:5,cellheight:256,cellwidth:256,deltax:8192000,deltay:8192000,id:726,zoompercell:8192000,zoomperpixel:32000,zoomscreen:32768000},{caption:"",cellcountx:21,cellcounty:18,cellheight:256,cellwidth:256,deltax:2048000,deltay:2048000,id:724,zoompercell:2048000,zoomperpixel:8000,zoomscreen:8192000},{caption:"",cellcountx:82,cellcounty:71,cellheight:256,cellwidth:256,deltax:512000,deltay:512000,id:722,zoompercell:512000,zoomperpixel:2000,zoomscreen:2048000},{caption:"",cellcountx:11,cellcounty:9,cellheight:256,cellwidth:256,deltax:4096000,deltay:4096000,id:725,zoompercell:4096000,zoomperpixel:16000,zoomscreen:16384000},{caption:"",cellcountx:41,cellcounty:36,cellheight:256,cellwidth:256,deltax:1024000,deltay:1024000,id:723,zoompercell:1024000,zoomperpixel:4000,zoomscreen:4096000},{caption:"",cellcountx:3,cellcounty:3,cellheight:256,cellwidth:256,deltax:16384000,deltay:16384000,id:727,zoompercell:16384000,zoomperpixel:64000,zoomscreen:65536000},{caption:"",cellcountx:164,cellcounty:142,cellheight:256,cellwidth:256,deltax:256000,deltay:256000,id:721,zoompercell:256000,zoomperpixel:1000,zoomscreen:1024000},{caption:"",cellcountx:327,cellcounty:283,cellheight:256,cellwidth:256,deltax:128000,deltay:128000,id:720,zoompercell:128000,zoomperpixel:500,zoomscreen:512000},{caption:"",cellcountx:1305,cellcounty:1131,cellheight:256,cellwidth:256,deltax:32000,deltay:32000,id:718,zoompercell:32000,zoomperpixel:125,zoomscreen:128000},{caption:"",cellcountx:5218,cellcounty:4523,cellheight:256,cellwidth:256,deltax:8000.00000000006,deltay:8000,id:716,zoompercell:8000,zoomperpixel:31.2500000000002,zoomscreen:32000},{caption:"",cellcountx:20871,cellcounty:18092,cellheight:256,cellwidth:256,deltax:1999.99999999997,deltay:2000,id:714,zoompercell:2000,zoomperpixel:7.81249999999989,zoomscreen:8000},{caption:"",cellcountx:83484,cellcounty:72368,cellheight:256,cellwidth:256,deltax:499.999999999971,deltay:500,id:712,zoompercell:500,zoomperpixel:1.95312499999989,zoomscreen:2000},{caption:"",cellcountx:524288,cellcounty:524288,cellheight:256,cellwidth:256,deltax:125,deltay:125,id:792,zoompercell:125,zoomperpixel:0.48828125,zoomscreen:500}],caption:"",id:"",maxx:32768000,maxy:32768000,minx:-32768000,miny:-32768000}},vmp:{id:"",name:"",caption:""},qds:{},dom:{}}

};
g.StyleLibraryRoot=g.path+'lib/style/';
g.msFeatures=[];
g.hotc=[];
g.city={name:"",c:""};
function resizePage(){var a=_el("maparea");var s=document.body.clientHeight-27;if(s<=20)return;a.style.height=s+"px";if(_m)	_m.map.onResize()}
function initMap()
{
	function gp(a){return _getParameter(a)}
	function shb(a){if(a){a=a.split(",");if(_m)_m.setHyBrid(a[0]=="1",a[1]=="1")}}
	var a=_el("maparea"),c=gp("c"),city=gp("city"),dc=getCookie("sogoumapdefaultcity"),lq=gp("lq"),hb=gp("hb"),appid=gp("appid");
	g.detailURL=g.path+"detail2.jsp?appid="+appid+"&cpid=%cpid%&dataid=%dataid%&uid=%uid%";
	if(!lq) lq=gp("kw");
	
	_cv=new ConvertorLLndMC();
	_m=new MapClient(a);
	_m.setEngineURL(g.engine);
	_m.setStyleLibraryRoot(g.StyleLibraryRoot);
	_m.setAppId(appid);
	_m.isInfoWinAutoOpen=false;
	if(c)
	{
		if(lq) G.isFixView=true;
	}
	_m.createMapArea();
	shb(hb);
	Event.addListener(_m,"sdschange",function(a)
	{
		StyleLib.preLoadStyle("preloadstyles");
		initService();
		_m.coordRecenterTo(  parseFloat(g_Jason_House.point.split(",")[0]),parseFloat(g_Jason_House.point.split(",")[1]),14);
	});

	if(!appid)
	{
		_m.setSds(g.sds);
		_m.mapProcess.callback(g.rps);
	}
	else
	{
		var etm	=new EntireMapOperation(_m);
		etm.submit();
	}
	
}
function creatDom(o,parentNode){function applyStyles(el, styles){function setStyle(el,prop, value){if(!el||typeof value !="string") return;prop=prop?prop:"";value=value?value:"";el.style[prop]=value;return el};if(!styles)	return;if(typeof styles == "string"){var re = /\s?([a-z\-]*)\:\s?([^;]*);?/gi,matches;while ((matches = re.exec(styles)) != null){setStyle(el,matches[1], matches[2])}}else if (typeof styles=="object"){for (var style in styles){setStyle(el,style,styles[style])}}};var el=document.createElement(o.tag||'div'),useSet=el.setAttribute?true:false; for(var attr in o){if(attr=="tag"||attr=="children"||attr=="cn"||attr=="html"||attr=="style"||typeof o[attr]=="function") continue;if(attr=="cls"){el.className = o["cls"];}else{if(useSet) el.setAttribute(attr,o[attr]);else el[attr] = o[attr];}}if(o.html){el.innerHTML=o.html;}applyStyles(el,o.style);if(parentNode){parentNode.appendChild(el);}return el}	
g.creatDom=creatDom;
window.G=g;
window.resizePage=resizePage;
window.initMap=initMap;
})();
function ce(a){return document.createElement(a)}
function ct(a){return document.createTextNode(a)}
function ci(){var b=ce("iframe");b.setAttribute("frameborder","0",0);return b}
function ap(a,b){a.appendChild(b)}
function px(a){return a+"px"}
function pa(a){a.style.position="absolute"}
function lf(a,b){a.style.left=px(b)}
function tp(a,b){a.style.top=px(b)}
function wd(a,b){a.style.width=px(b)}
function ht(a,b){a.style.height=px(b)}
function cd(a){var b=ce("div");if(a) b.id=a;return b}
function cc(a){var b=ce("div");b.className=a;return b}
function cbtn(a){var b=ce("input");b.type="button";b.value=a;return b}
function el(a){return document.getElementById(a)}
function d0(a){a.style.display="none"}
function d1(a){a.style.display="block"}
function gts(a,b){return a.getElementsByTagName(b)}
function gt(a,b){var c=gts(a,b);return c&&c.length>0?c[0]:null}
function ga(a,b){return a.getAttribute(b)}
function sa(a,b,c){a.setAttribute(b,c)}
function sz(a,b){a.style.zIndex=b}
function sv(a,b){if(a&&b!=null)_el(a).value=b}

function _loadScript(url,id){var a=document.getElementById(id),b=document.createElement("script");b.type="text/javascript";b.charset="GB2312";b.id=id;b.src=url ;document.getElementsByTagName('body')[0].replaceChild(b,a);}
function getPageURL(a){var a=a?a:window.location.href,b,c;b=a.indexOf("?");if(b>-1) a=a.substring(0,b);c=a.indexOf("#");if(c>-1) a=a.substring(0,c);return a}
function getState(){if(_m)return [_m.getCenterX(),_m.getCenterY(),_m.getLevelIndex()]}
function getService(a,b){if(a&&b){var ab=a.split("!!");for(var i=0;i<ab.length;i++){var ac=ab[i].split("==");if(ac[0]==b){return ac[1];}}return "";}}
function _parseDomFromString_(a){var aa = a.getResult("Wmsxml");var dom;if (aa!=""){aa=(aa.indexOf("<?xml version=")>-1?'':'<?xml version="1.0" encoding="GB2312"?>')+aa;dom = _getDomFromString(aa);}if(dom)	{return dom;}else{return false;}}
function addFavorite(){var a="搜狗Sogou--地图搜索";var b;b=window.location.href;if (typeof window.sidebar=='object'&&typeof window.sidebar.addPanel=='function'){window.sidebar.addPanel(a,b,"")}else{window.external.AddFavorite(b,a); }}

function blurPoint(a,b,c){if(a){if(b){b.style.backgroundColor="";b.style.borderTop="1px solid #FFF";b.style.borderBottom="1px solid #FFF";}var i=_m.getFeatureById(a);if(i&&!c){var iw=_m.map.infoWindow;if(iw&&iw.feature&&iw.feature==i&&iw.isVisible())	return;i.element.blur();var b=i.element.label;if(b&&i.label.on=="false")b.style.visibility="hidden";}}}
function focusPoint(a,b,c){if(a){if(b){b.style.backgroundColor="#EAEAEA";b.style.borderTop="1px dashed gray";b.style.borderBottom="1px dashed gray";}var i=_m.getFeatureById(a);if(i&&!c){i.element.focus();var b=i.element.label;if( b )b.style.visibility="visible";}}}
function loadData(a){cleanMapAreaMark();drawFeatures(a,null,null,null,G.isFixView);if(G.isFixView){var b=_getParameter("iw"),c;if(b){c=_m.getFeatureById(b);if(c)_m.setTimeout(_m.showInfoWindow,500,c)}}G.isFixView=false}
function getMapResultFactory(a){var b=new MapResultFactory();b.setResult(a);return b;}
function drawPoint(a,fs){try{if(vsc) vsc.close();cleanMapAreaMark(2);var f=_m.getFeatureById(a),b,c,d,e,g;b=!f;if(b||f.type!="S"){fs=!fs?G.msFeatures:fs;for(var i=0;i<fs.length;i++){c=fs[i].id;if(c=="COPY_"+a) d=fs[i];else if(c==a) f=fs[i];if((f&&d)||(f&&f.type=="S")) break;}if(b) _m.map.addFeature(f);if(f.type!="S"&&d&&!_m.getFeatureById(d.id)) _m.map.addFeature(d);}var l=f.level;if(f.type!="S") _m.adjustMapFitFeature(f,14);else if (l){g=_m.getLevelIndex();l=parseInt(l);l=l>g?l:g;e=f.bounds,x=(e.minX+e.maxX)/2,y=(e.minY+e.maxY)/2;_m.coordRecenterTo(x,y,l)}_m.showInfoWindow(!d?f:d);}catch(e){alert("drawPoint()::"+e.description)}}
function getCluster(a){var b=G.ifrmClusterRqst;if(!b){b=G.ifrmClusterRqst=ci();ap(document.body,b);d0(b)}b.src=G.path+"cluster.html?id="+a}
function drawXY(a,b,c,d,e){return _m.map.addPoint(a,b,c,'',d,{"on":"true","style":e})}
function getDeCode(a){if(a&&a.indexOf("%")>-1){try{var d=_getDomFromFile(G.path+"inc/decode.jsp?w="+a);a=d.selectSingleNode( "/Data" ).getAttribute("word");}catch(e){}}return a}
function getEnCode(a){try{var d=_getDomFromFile(G.path+"inc/encode.jsp?w="+a);a=d.selectSingleNode( "/Data" ).getAttribute("word");}catch(e){}return a}
function removeFeatrues(a){if (!a)	return;var fs,b,c;if(a.features){fs=a.features;}else {fs=a}if(_m) {b=_m.map;c=b.infoWindow}for(var i=0;i<fs.length;i++){_m.map.removeFeature(fs[i]);if(c&&c.feature==fs[i]) b.closeInfoWindow();}}
function clearArray(a){while(a.length>0){var i=a.length-1;a.pop();return a}}
function showCityList(f,c,d,e){var id="dialog_citylist",a=G.cityListDialog,b;G.cityListDlgSrc=f;function u(z){z=z||window.event;var v=!z.target?z.srcElement:z.target;if(f&&v!=G.cityListDlgSrc)a.close()};if(!a){a=new Dialog(id,460,300,148,145);sz(a.div,2008);ap(a.title,ct("城市列表"));b=ci();a.iframe=b;pa(b);lf(b,2);tp(b,2);wd(b,456);ht(b,271);ap(a.body,b);G.cityListDialog=a;Event.addBuiltInListener(document,"click",u);a.div.onclick=function(z){_stopEvent(z)}}a.show();c=!c?"mapcitylist2.jsp":c;a.iframe.src=G.path+c+(c.indexOf("?")>-1?"&":"?")+"el="+id;a.setLeftTop(!d?148:d,!e?145:e);}
function replaceCity(a){if(a){a=a.replace("市","");return a;}}
function getCookieVal(offset){var endstr=document.cookie.indexOf(";",offset);if(endstr==-1)endstr=document.cookie.length;return unescape(document.cookie.substring(offset,endstr));}
function getCookie(name){var arg=name+"=",alen=arg.length,clen=document.cookie.length;var i=0;while(i<clen){var j=i+alen;if(document.cookie.substring(i,j)==arg)return getCookieVal(j);i=document.cookie.indexOf(" ",i)+1;if(i==0)break;}return null;}
function setCookie(name,value){var argv=arguments;var argc=argv.length;var date = new Date();date.setTime(date.getTime()+31536000);var expires=(2<argc)?argv[2]:date;var path="/";var domain=null;var secure=false;document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");}
function setCity(a,b){var d=getState();d=!d?"":d.join(",");if(a)G.city.name=a;G.city.c=!b?d:b;if(toolbox)toolbox.setNowCity(G.city.name+","+G.city.c,true);}
function transformNode(a,b,c,d){try{if (typeof(a)=="string"){a=_getDomFromString(a);}g=StyleLib.baseURL+b;h=XmlStyleSheet.getCached(g);if(!h){h=XmlStyleSheet.create(_getDomFromFile(g));XmlStyleSheet.cache(g,h);}h.transformToHTML(a,c);}catch(ex){}}
function autoSubmitSearch(a){if(a){submitLocalQuery({what:a});}}
function vMapCitys(){var a=_el("city").value,b=G.city;if((b.name&&a!=b.name)||_el("map_panel_result").innerHTML==""){submitLocalQuery({init:b.name});}}
function voidCitys(a){if(!a)return;function mapcitys(a){a=a?replaceCity(a):'全国';}if(typeof a=="object"){a.city=getDeCode(a.city);a.city=(a.city=="ALL"?"全国":a.city);setCity(a.city);mapcitys(a.city);}}
function resetQueryState(){sv("where","");sv("fType","Name");sv("page","1");sv("dataSet","2");sv("radius","");sv("vam","0");sv("init","");sv("c","");}
function submitLocalQuery(a){var c,d;if(a){if(a.city){a.city=a.city.split(":");c=a.city[0];voidCitys({city:c})}if(!c&&a.init) c=a.init;if(c){c=(c=="ALL"?"全国":c);}if(a.c){d=a.c.split(",")}if(a.what)sv("query",a.what);sv("where",a.where?a.where:"");sv("fType",a.type?a.type:"Name");sv("page",a.page?a.page:"1");sv("dataSet",a.dataSet?a.dataSet:"2");sv("radius",a.radius?a.radius:"");sv("vam",a.vam?a.vam:"0");sv("init",a.init?a.init:"");sv("c",a.c?a.c:"");}el("map_form").submit()}
function cleanMapAreaMark(a){try{if(_m)_m.map.closeInfoWindow();removeFeatrues(G.msFeatures)}catch(e){}}




var toolbox;
function initService()
{
	function gp(a){return _getParameter(a)}	
	var city=gp("city"),lq=gp("lq"),page=gp("page"),uids=gp("uids"),mymap=gp("mymap"),c=gp("c"), tip=gp("tip"),dc=getCookie("sogoumapdefaultcity"),s=gp("s"),ms=gp("ms"),lab=gp("lab"),msv=gp("mapservice");
	if(!lq) lq=gp("kw");
	if(dc){	dc=dc.split(",");city=!city?dc[0]:city;}
	G.city={name:!city?"全国":getDeCode(city.trim()),c:!c?null:c};
	Event.addListener(_m,"update",function(a)
	{
		var b=getState(),c=b.join(",");
		try{shHotCity(3<b[2]&&b[2]<9);}catch(ex){}			
	});	
}

Array.prototype.each = function(a){for(var i=0;ob=this[i];i++) {a(ob, i);}}
SEvent.addBuiltInListener(window,"load",function(){
	var tmp=el("hrefSogouMap");
	if(tmp) tmp.onclick=function(){Log.send("page=poi&&click=navSogouMap");}
	tmp=el("nfdp");
	if(tmp) tmp.onclick=function(){	Log.send("page=poi&&click=netComment");}
	if(el("dTitle")){
		var t=el("dTitle").getElementsByTagName("a");
		if(t.length>0){
			t[0].onclick=function(){
				Log.send("page=poi&&click=logo");
			}
		}
	}
	tmp=el("spSalinglink");
	if(tmp) tmp.onclick=function(){Log.send("page=poi&&click=salinglink");}
	tmp=el("spLink");
	if(tmp) tmp.onclick=function(){Log.send("page=poi&&click=detaillink");}
	tmp=el("spRealpic");
	if(tmp) tmp.onclick=function(){Log.send("page=poi&&click=outsideview");}
	tmp=el("spRoompic");
	if(tmp) tmp.onclick=function(){Log.send("page=poi&&click=layoutlink");}		
	Log.send("page=poi&&referrer="+document.referrer);
	Log.send("page=poi&&tool=pageload&&referrer="+document.referrer);
});

