var poptemp=0,divtemp=0,idtemp=1,popshowtemp=0,bBus=0;
var reqvalue;
var XMLHttpReq;
//创建XMLHttpRequest对象
function createXMLHttpRequest() {
	if(window.XMLHttpRequest) { //Mozilla 浏览器
		XMLHttpReq = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) { // IE浏览器
		try {
			XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
}
function showpop(id,mapid){
	var url = "/mstmap50007/g_search_pop.jsp?g_poiId="+id+"&g_mapid="+mapid;
	createXMLHttpRequest();
	XMLHttpReq.onreadystatechange = showpopResponse;	
	XMLHttpReq.open("GET", url, true);
	XMLHttpReq.setRequestHeader("If-Modified-Since","0");
	XMLHttpReq.send(null);
}
function showpopResponse(){
	if (XMLHttpReq.readyState == 4) { // 判断对象状态
		if (XMLHttpReq.status == 200) { // 信息已经成功返回，开始处理信息
			reqvalue=XMLHttpReq.responseText;
			document.getElementById("srh_pop_out").innerHTML=reqvalue;			
			
		}
	}
}
function show_othfun(divnum,id,mapid,p){
	divtemp=1;
	popshowtemp=1;
	
	if(!bBus){
		document.getElementById("srh_u3_mu4_"+divnum).className="green";
		document.getElementById("srh_u3_mu4_div_"+divnum).style.display="";
	}
}
function show_othfunhid(divnum,p){
	divtemp=0;
	idtemp=divnum;
	if(bBus)
		document.getElementById("srh_u3_umain"+divnum).style.background="#ffffff";
	else{
		document.getElementById("srh_u3_mu4_"+divnum).className="nogreen";
		document.getElementById("srh_u3_mu4_div_"+divnum).style.display="none";
		if(divnum>1)
		document.getElementById("srh_u3_umain"+divnum).style.background="#ffffff";
		
	}
}
function popshow(arg1){
	poptemp=arg1;
	if(poptemp==0){
		popshowtemp=0;
		show_othfunhid(idtemp);
		document.getElementById("srh_pop_out").innerText="";
	}else{
		document.getElementById("srh_u3_mu4_"+idtemp).className="green";
		document.getElementById("srh_u3_mu4_div_"+idtemp).style.display="";
		document.getElementById("srh_u3_umain"+idtemp).style.background="#f4fff5";
	}
	
}

function moveDiv()
{ 
	var diffY;
	if (document.documentElement && document.documentElement.scrollTop)
	  diffY = document.documentElement.scrollTop;
	else if (document.body)
	  diffY = document.body.scrollTop;
	else
	   {/*Netscape stuff*/}  
	percent=.1*(diffY-lastScrollY); 
	if(percent>0)percent=Math.ceil(percent); 
	else percent=Math.floor(percent); 
	basicTop = 140;
	
	var mapTop = mapObj.style.top.substring(0,mapObj.style.top.length-2);
	if(lastScrollY>basicTop&&lastScrollY<(list_h-mapObj.offsetHeight+basicTop)){
	//if(lastScrollY>basicTop&&((percent>=0&&mapTop<=list_h-mapObj.offsetHeight)||(percent<0&&mapTop>0))){
		mapObj.style.top=parseInt(mapObj.style.top)+percent+"px";
	}
	lastScrollY=lastScrollY+percent; 
	if(mapTop<0)
		mapObj.style.top="0px";
	
}

function mapmove(){
	var mapnomove=document.getElementById("mapnomove");
	if(mapnomove.checked){
		clearInterval(divmove);
	}else{
		divmove=setInterval("moveDiv()",1);
	}
}

function openSel(type,selname){
	var arg1=document.getElementById("se"+type);
	var arg2=document.getElementById(selname);
	arg1.style.left=(arg2.offsetLeft+document.body.offsetLeft)+"px";
	arg1.style.top=(arg2.offsetTop+document.body.offsetTop+28)+"px";
	if(arg1.style.display=="none"){
		arg1.style.display="";
	}
}
function chosetype(type1,type2,obj1){
	var arg1=document.getElementById("srh_u3_u5_"+type1);
	var arg2=document.getElementById("se"+type2);
	var arg3=document.getElementById("srh_"+type1);
	arg1.innerHTML="<a href='#' onclick=\"openSel('type','srh_u3_u5_flsx')\">"+obj1.innerText+"</a>";
	if(obj1.innerText=="不限")
		arg3.value="";
	else
		arg3.value=obj1.innerText;
	arg2.style.display="none";
}
function lightMapIco(divNum){
	try{
		mst_mapwin.cgdpicls(divnum,"");
	}
	catch(err){}
}
function lMapIco(divNum){
	try{
		mst_mapwin.cgdpicls(divNum,"_");
	}
	catch(err){}
}
function dMapIco(divNum){
	try{
		mst_mapwin.cgdpicls(divNum,"");
	}
	catch(err){}
}
function selSearch(){
	var arg1=document.getElementById("srh_flsx").value;
	var arg2=document.getElementById("srh_ddfb").value;
	if(arg1.length==0 && arg2.length==0){
		document.getElementById("srh_u3_u5_du1").style.display="";
		return;
	}else{
		var arg3=arg1+" "+arg2;	location='/mstmap50007/g_search.jsp?g_env_cx=<%=strCenterX%>&g_env_cy=<%=strCenterY%>&g_mapid=<%=strMapid%>&g_cmd_addr=g_getxy&g_scope=<%=strCenterScope%>&typename='+arg3+'&g_addr=<%=strCenterAddr%>';
	}
}
function choseAddr(obj){
	var objValue = obj.value;
	var frm = window.document.sfrm;
	try{
		var gx =frm.g_env_cx;
		gx.value = objValue.split("@")[1];
		var gy = frm.g_env_cy;
		gy.value = objValue.split("@")[2];
		var gaddr = frm.g_addr;
		gaddr.value = objValue.split("@")[0];
	}catch(e){alert(e);}
}
function showBMap(addr,label,poiId,mapId){if(mapId!=null)g_mapId = mapId;window.open("/mstmap50007/g_d_bmap.jsp?g_mapid="+g_mapId+"&g_label="+label+"&g_addr="+addr+"&g_poiId="+poiId,"_blank","height=680,width=1000,top=0,left=0,status=1");}
/*startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;
*/
window.mst_bus_se_sg=function(){this.ajaxurl='';this.object='';this.b=0;this.c=500;this.d='';this.fa=function(){var objBody=document.getElementsByTagName("body").item(0);var objDivSg=document.createElement("div");objDivSg.setAttribute('id','div_sg');objDivSg.setAttribute('align','left');objBody.appendChild(objDivSg);if(!document.all){window.document.addEventListener("click",this.fc,false);}else{window.document.attachEvent("onclick",this.fc);}};this.fa1=function(allsgs){var htmlsgs='';if(allsgs.length<1||!allsgs[0]){this.fc();}for(i=0;i<allsgs.length;i++){htmlsgs+='<ul onclick="pObj.fillText(\''+allsgs[i]+'\');">'+allsgs[i]+'</ul>';}document.getElementById("div_sg").innerHTML=htmlsgs;var nodes=document.getElementById("div_sg").childNodes;for(var i=0;i<nodes.length;i++){nodes[i].onmouseover=function(){this.className="msover";};nodes[i].onmouseout=function(){this.className="";}}};this.fb=function(){var objTarget=this.object;var xPos,yPos;xPos=getLstDivShowLeft(objTarget);yPos=getLstDivShowTop(objTarget);document.getElementById("div_sg").style.left=xPos+"px";if(yPos-document.body.scrollTop+100>document.body.clientHeight){document.getElementById(
"div_sg").style.top=yPos-140+"px";}else document.getElementById("div_sg").style.top=yPos+23+"px";};this.fc=function(){this.lstk_val=-1;document.getElementById("div_sg").style.visibility="hidden";if(bHidScope){var scopeObj=window.document.getElementById('g_scope');if(scopeObj)scopeObj.style.display='';}};this.fd=function(){document.getElementById("div_sg").style.visibility="visible";};this.isShowSg=function(){if(document.getElementById("div_sg").style.visibility=="visible")return true;else return false;};this.sleep=function(n){var start=new Date().getTime();while(true)if(new Date().getTime()-start>n)break;};this.ltrim=function(strtext){return strtext.replace(/[\$d&\|\^*%#@! ]+/,'');};this.fillText=function(keys){this.object.value=keys;};this.fe=function(){if(this.lstk_val>0)this.lstk_val--;var nodes=document.getElementById("div_sg").childNodes;if(this.lstk_val<0)this.lstk_val=nodes.length-1;var b=0;for(var i=0;i<nodes.length;i++){if(b==this.lstk_val){document.getElementById("div_sg").childNodes[i].className="msover";this.fillText(document.getElementById("div_sg").childNodes[i].innerHTML);}else{document.getElementById("div_sg").childNodes[i].className="";}b++;}};this.ff=function(){this.lstk_val++;var nodes=document.getElementById("div_sg").childNodes;if(this.lstk_val>=nodes.length){this.lstk_val--;return;}var b=0;for(var i=0;i<nodes.length;i++){if(b==this.lstk_val){document.getElementById("div_sg").childNodes[i].className="msover";this.fillText(document.getElementById("div_sg").childNodes[i].innerHTML);}else{document.getElementById("div_sg").childNodes[i].className="";}b++;}};this.fg=function(e){var code;if(!e)var e=window.event;if(e.keyCode)code=e.keyCode;else if(e.which)code=e.which;return code;};this.show=function(object,e,tp){if(document.readyState!="complete")return;if(!document.getElementById("div_sg"))this.fa();if(!e)e=window.event;e.stopPropagation;e.cancelBubble=true;if(e.target)targ=e.target;else if(e.srcElement)targ=e.srcElement;if(targ.nodeType==3)targ=targ.parentNode;var inputkeys=this.fg(e);if(!object.value){this.fc();return;}switch(inputkeys){case 39:case 37:case 38:case 40:return;break;case 18:case 27:this.fc();return;break;}this.object=object;if(object.value==this.d)return;else this.d=object.value;if(window.opera)this.sleep(500);pObj=this;if(this.b)window.clearTimeout(this.b);this.b=setTimeout("pObj.wantInputSg("+tp+");",this.c);};this.showEx=function(object,e,tp,sp){bHidScope=sp;this.show(object,e,tp);};this.setScope=function(bS){bHidScope=bS;};this.wantInputSg=function(tp){platkeys=this.object.value;if(!platkeys)return;
if(platkeys.length<3||platkeys.indexOf(" ")!=-1||platkeys.indexOf(",")!=-1)return;if(platkeys.length>5){this.fc();return;};platkeys=encodeURI(encodeURI(platkeys));var req=new XHR();if(req){req.onreadystatechange=function(){if(req.readyState==4&&(req.status==200||req.status==304)){var vtxt=req.responseText;if(vtxt.indexOf("nothing")==-1){pObj.fd();pObj.fa1(vtxt.split(','));pObj.fb();if(bHidScope){var scopeObj=window.document.getElementById('g_scope');if(scopeObj)scopeObj.style.display='none';}}}else pObj.fc();};req.open('GET',this.ajaxurl+'?mapno='+g_mapId+'&keys='+platkeys+"&tp="+tp);req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');req.send(null);}}}

if(window.ActiveXObject&&!window.XHR){window.XHR=function(){var msxmls=new Array('Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0','Msxml2.XMLHTTP','Microsoft.XMLHTTP');for(var i=0;i<msxmls.length;i++){try{return new ActiveXObject(msxmls[i]);}catch(e){}}return null;};}if(window.XMLHttpRequest && !window.XHR){window.XHR=function(){return new XMLHttpRequest();};}if(!window.ActiveXObject&&window.XHR){window.ActiveXObject=function(type){switch(type.toLowerCase()){case 'microsoft.xmlhttp':case 'msxml2.xmlhttp':case 'msxml2.xmlhttp.3.0':case 'msxml2.xmlhttp.4.0':case 'msxml2.xmlhttp.5.0':return new XHR();}window.ActiveXObject.async   =   false; return null;};}
