function closewindow(){self.close();}
function informPage(c,t){
	var np=0;
	if(t=='zb_cent'){np=Number(GetObjValue('batch_zb_cent'));ShowoPage('上一页','下一页',"<font color='red'>","</font>","[<font color='red'>","</font>]",c,10,2,np,"page_num_zb_cent",t);}
	else if(t=='ss'){np=Number(GetObjValue('batch_ss'));ShowoPage('上一页','下一页',"<font color='red'>","</font>","[<font color='red'>","</font>]",c,10,2,np,"page_num",t);}
	else if(t=='zb'){np=Number(GetObjValue('batch_zb'));ShowoPage('上一页','下一页',"<font color='red'>","</font>","[<font color='red'>","</font>]",c,10,2,np,"page_num_zb",t);}
}
function pageNum(i,t){
	if(t=='zb_cent'){SetObjValue('batch_zb_cent',i);GetCenterXY(i);}
	else if(t=='ss'){SetObjValue('batch_ss',i);searchByKeyword('','',i);}
	else if(t=='zb'){SetObjValue('batch_zb',i);SearchAround('','','','',i)}
}
function lastPageNum(t){
	if(t=='zb_cent'){SetObjValue('batch_zb_cent',(Number(GetObjValue('batch_zb_cent'))-1));GetCenterXY(GetObjValue('batch_zb_cent'));}
	else if(t=='ss'){SetObjValue('batch_ss',(Number(GetObjValue('batch_ss'))-1));searchByKeyword('','',GetObjValue('batch_ss'));}
	else if(t=='zb'){SetObjValue('batch_zb',(Number(GetObjValue('batch_zb'))-1));SearchAround('','','','',GetObjValue('batch_zb'));}
}
function nextPageNum(t){
	if(t=='zb_cent'){SetObjValue('batch_zb_cent',(Number(GetObjValue('batch_zb_cent'))+1));GetCenterXY(GetObjValue('batch_zb_cent'));}
	else if(t=='ss'){SetObjValue('batch_ss',(Number(GetObjValue('batch_ss'))+1));searchByKeyword('','',GetObjValue('batch_ss'));}
	else if(t=='zb'){SetObjValue('batch_zb',(Number(GetObjValue('batch_zb'))+1));SearchAround('','','','',GetObjValue('batch_zb'));}
}
function ShowoPage(PrevFont,NextFont,PageNumFont1,PageNumFont2,PageNumFont3,PageNumFont4,RecCount,RecPerPage,PageNum,CurrPage,DivId,t){
	if(RecCount%RecPerPage==0){PageCount=RecCount/RecPerPage;}
	else{PageCount=(parseInt(RecCount/RecPerPage)+1);}
	if(PageCount<=1){PageCount=1;}
	prevpage=parseInt(CurrPage-1);
	if(prevpage<1){prevpage=1;}
	nextpage=parseInt(CurrPage+1)
	if(nextpage>PageCount){nextpage=PageCount;}
	if(CurrPage<=1&&PageCount==1){CurrPage=1;PrevPageUrl="&nbsp;"+PrevFont+"&nbsp;";NextPageUrl="&nbsp;"+NextFont+"&nbsp;";}
	else if(CurrPage<=1){CurrPage=1;PrevPageUrl="&nbsp;"+PrevFont+"&nbsp;";NextPageUrl="&nbsp;<a href=\"javascript:nextPageNum('"+t+"');\">"+NextFont+"</a>&nbsp;";}
	else if(CurrPage>=PageCount){CurrPage=PageCount;PrevPageUrl="&nbsp;<a href=\"javascript:lastPageNum('"+t+"');\">"+PrevFont+"</a>&nbsp;";NextPageUrl="&nbsp;"+NextFont+"&nbsp;";}
	else{CurrPage=CurrPage;PrevPageUrl="&nbsp;<a href=\"javascript:lastPageNum('"+t+"');\">"+PrevFont+"</a>&nbsp;";NextPageUrl="&nbsp;<a href=\"javascript:nextPageNum('"+t+"');\">"+NextFont+"</a>&nbsp;";}
	PageStart=CurrPage-PageNum<=1?1:(CurrPage-PageNum-(CurrPage>PageCount-PageNum?PageNum+CurrPage-PageCount:0));
	PageEnd=CurrPage+PageNum>=PageCount?PageCount:(CurrPage+PageNum+(CurrPage-1<PageNum?PageNum-CurrPage+1:0));
	if(PageStart<1){PageStart=1;}
	if(PageNum*2 +1>PageCount){PageEnd=PageCount;}
	$(DivId).innerHTML=PrevPageUrl;
	for(i=PageStart;i<=PageEnd;i++){if(i==CurrPage){$(DivId).innerHTML+="&nbsp;"+PageNumFont3+i+PageNumFont4+"&nbsp;";}else{$(DivId).innerHTML+="&nbsp;<a href=\"javascript:pageNum("+i+',\''+t+"\');\">"+PageNumFont1+i+PageNumFont2+"</a>&nbsp;";}}
	$(DivId).innerHTML+=NextPageUrl;
}
function SwitchSearchPanel(tagid){
	CleanMap();
	var active_ss=active_gj=active_zj=active_zb='';
	if(tagid=='ss'){
		ShowObj('ss');
		HideObj('ext');
		HideObj('gj');
		HideObj('zj');
		HideObj('zb');
		HideObj('page_num_zb');
		active_ss=" class=\"active\"";
	}else if(tagid=='gj'){
		ShowObj('gj');
		ShowObj('searchbegin_gj');
		ShowObj('searchend_gj');
		HideObj('ext');
		HideObj('searchresultcenter_gj');
		HideObj('gjresult');
		HideObj('ss');
		HideObj('zj');
		HideObj('zb');
		active_gj=" class=\"active\"";
		if((GetInnerHTML('searchbegin_gj')).indexOf('起点')>=0&&(GetInnerHTML('searchend_gj')).indexOf('终点')>=0){
			ShowObj('searchresultcenter_gj');
		}
	}else if(tagid=='zj'){
		ShowObj('zj');
		ShowObj('searchbegin_zj');
		ShowObj('searchend_zj');
		HideObj('ext');
		HideObj('searchresultcenter_zj');
		HideObj('zjresult');
		HideObj('ss');
		HideObj('gj');
		HideObj('zb');
		active_zj=" class=\"active\"";
		if((GetInnerHTML('searchbegin_zj')).indexOf('起点')>=0&&(GetInnerHTML('searchend_zj')).indexOf('终点')>=0){
			document.getElementById("searchresultcenter_zj").style.display='';
		}
	}else if(tagid=='zb'){
		ShowObj('zb');
		HideObj('ext');
		HideObj('ss');
		HideObj('gj');
		HideObj('zj');
		active_zb=" class=\"active\"";
	}
	$('tabs_searchresult').innerHTML="<ul class=\"tabs\"><li"+active_ss+"><a href=\"javascript:SwitchSearchPanel('ss');\">搜索</a></li><li"+active_gj+"><a href=\"javascript:SwitchSearchPanel('gj');\">公交</a></li><li"+active_zj+"><a href=\"javascript:SwitchSearchPanel('zj');\">自驾</a></li><li"+active_zb+"><a href=\"javascript:SwitchSearchPanel('zb');\">周边</a></li></ul>";
}
function save_illegal(url,type){
	var filter_t=escape(filterContentbyid('illegal_message'));
	var reason=getRadioBoxValue('illegal_reason');
	if(!reason){
		alert('请点选举报的原因！');
		return false;
	}
	if(filter_t==''){
		alert('描述不能为空！');
		return false;
	}

	if(reason){
		var filter_url=filterContentbystr(url);
		document.getElementById('savestatus').innerHTML='';
		var filter_type=filterContentbystr(type);
		var url=('sp_source/map_save.php?type='+filter_type+'&text='+filter_t+'&reason='+reason+'&url='+filter_url);
		xmlHttp_save.onreadystatechange=handleSave;
		xmlHttp_save.open('GET',url,true);
		xmlHttp_save.send(null);
	}else{
		alert('请点选举报的原因！');
		return false;
	}
}
function changeIcon(){
	try{
		if(GetObjValue('sp_hd_hold_drawpointx')==''){
			var obj=document.getElementsByName('point_type');
			obj[0].checked=true;
			alert('请先在地图上标点！');
			return false;
		}
	}catch(e){}
	var pointX='';
	var pointY='';
	var code='';
	try{
		pointX=GetObjValue('sp_hd_hold_drawpointx');
		pointY=GetObjValue('sp_hd_hold_drawpointy');
		code=document.map.sp_hd_hold_drawpointreturntelnum.value;
	}catch(e){
		pointX=document.hold.x.value;
		pointY=document.hold.y.value;
	}
	var centerPointStyle=GetDefaultPointStyle();
	var sContent='';
	if(code != ''){
		sContent=("<a href=\"javascript:ext_fill(1,'"+pointX+"','"+pointY+"','"+code+"','我的标点');\">到此处</a> <a href=\"javascript:ext_fill(2,'"+pointX+"','"+pointY+"','"+code+"','我的标点');\">从此处去</a> <a href=\"javascript:fill_searcharound('我的标点','"+pointX+"','"+pointY+"',0,'"+code+"');\">周边</a> <a href=\"javascript:reporterror('','"+pointX+"','"+pointY+"');\">报错</a>");
	}
	centerPointStyle.textContent=sContent;
	var icon_index=getRadioBoxValue('point_type');
	var icon=GetIconUsedOnMap(icon_index);
	var centerPoint=new MCustomPointOverlay(new MLatLng(pointY,pointX),icon,centerPointStyle,1000);
	mapObj.addOverlay(centerPoint,true);
}
function sp_hd_hold_drawpoint(pic_id){
	if(pic_id>0){
		document.getElementById('currenteditpicid').value=pic_id;
	}
	var pointStyle=new MStyle();
	pointStyle.fillOpacity=0;
	pointStyle.lineOpacity=0;
	pointStyle.canBeTop=false;
	mapObj.beginDrawPointOnMap(pointStyle);
}
function setthispoitohdaddress(poix,poiy){
	CleanMap();
	try{
		document.hold.x.value=poix;
		document.hold.y.value=poiy;
		getReturnCity(poix,poiy);
	}catch(e){}
	//var centerPoint=new MDragablePointWithoutTip(new MLatLng(poiy,poix),new MStyle(),1000);
	var centerPointStyle=GetDefaultPointStyle();
	var centerPoint=new MCustomPointOverlay(new MLatLng(poiy,poix),'http://211.151.71.88/sp_image/gongyi.png',centerPointStyle,1000);
	mapObj.addOverlay(centerPoint,true);
}
function getReturnCity(pointX,pointY){
	var sis=new MSISSearch();
	var searchspatialpara=new MSearchSpatialPara();
	sis.setSISCallbackFunction(getReturnCityCB);
	searchspatialpara.setXY(pointX,pointY);
	searchspatialpara.setPoiNumber('1');
	searchspatialpara.setRange('1000');
	searchspatialpara.setPattern('1');
	searchspatialpara.setLevel('1');
	sis.reverseGeoCoding(searchspatialpara);
}
function getReturnCityCB(data){
	if(data.SpatialBean.poiList.length>0){
		for(var i=0; i < data.SpatialBean.poiList.length;i++){
			try{
				document.map.sp_hd_hold_drawpointreturncity.value=data.SpatialBean.City.name;
				document.map.sp_hd_hold_drawpointreturndistrict.value=data.SpatialBean.District.name;
				document.map.sp_hd_hold_drawpointreturntelnum.value=data.SpatialBean.City.telnum;
		        changeIcon();
			}catch(e){
				try{
					document.registerform.thishdcity.value=data.SpatialBean.City.name;
					document.registerform.thishddistrict.value=data.SpatialBean.District.name;
					document.registerform.thishdtelnum.value=data.SpatialBean.City.telnum;
				}catch(e){}
			}
			try{
				var returncity=data.SpatialBean.City.name;
				document.hold.thishdcity.value=data.SpatialBean.City.name;
				document.hold.thishddistrict.value=data.SpatialBean.District.name;
				document.hold.thishdtelnum.value=data.SpatialBean.City.telnum;
			}catch(e){}
		}
	}else{
		try{
			document.map.sp_hd_hold_drawpointreturncity.value='未知城市';
		}catch(e){}
		try{
			document.hold.thishdcity.value='未知城市';
		}catch(e){}
	}
}

function GetCenterXY(setbatch){
	CleanMap();
	document.getElementById('page_num_zb_cent').style.display='';
	document.getElementById('page_num_zb').style.display='none';
	var citycode=document.map.searcharound_city.value;
	var keyword=document.map.searcharound_poi.value;
	var number=10;
	var batch=1;
	if(setbatch>1){
		batch=setbatch;
	}
	if(keyword==''){
		document.getElementById('searcharound_poi').disabled=false;
		alert('请输入中心点关键字！');
		return false;
	}
	var sis=new MSISSearch();
	var searchpointpara=new MSearchPointPara();
	sis.setSISCallbackFunction(GetCenterXYcallback); 
	
	searchpointpara.setCitycode(citycode);
	searchpointpara.setKeyword(keyword);
	searchpointpara.setNumber(number);
	searchpointpara.setBatch(batch);
	sis.searchByKeyword(searchpointpara);
	showLoading_mine('searchresult1_zb');
}
function GetCenterXYcallback(data){
	
	var html='';
	if (data.count != 0){
		html+='<div><div class="msri">共'+data.count+'条结果</div>';
		for (var i=0; i < data.poilist.length;i++){
			var pid=data.poilist[i].pguid;
			var data_citycode=data.poilist[i].citycode;
			var x=data.poilist[i].x;
			var y=data.poilist[i].y;
			
		    var type=data.poilist[i].type;
		    if (type==''||type=='undefined'||type==null){
		    	type=noDetail;
		    }
		    var address=data.poilist[i].address;
		    if (address==''||address=='undefined'||address==null){
		    	address=noDetail;
		    }
		    var tel=data.poilist[i].tel;
		    if (tel==''||tel=='undefined'||tel==null){
		    	tel=noDetail;
		    }
		    var sContent=data.poilist[i].name;
		    if (!type=='' && type != null){
		   		sContent+='<br/>类型:'+type;
		   	}
		   	if (!address=='' && address != null){
				sContent+='<br/>地址:'+address;
			}
			if (!tel=='' && tel != null){
				sContent+='<br/>电话:'+tel;
			}
			var pointStyle=GetDefaultPointStyle();
			pointStyle.textContent=sContent;
			var icon=sp_imageURL+(i+1)+'_10.gif';
			centerPoint=new MCustomPointOverlay(new MLatLng(y,x),icon,pointStyle,i+1);
			mapObj.addOverlay(centerPoint,false);
			html+="<div class=\"resultitem\"><div class=\"result_caption\"><font color=\"#e1570e\"><a href=\"javascript:void(0);\" onclick=\"mapObj.setCenterByLatLng('"+data.poilist[i].y+"','"+data.poilist[i].x+"');mapObj.openTipById('"+(i+1)+"');fillCenXY4SearchAround('"+data.poilist[i].name+"','"+data.poilist[i].x+"','"+data.poilist[i].y+"');\">"+"<img src=\""+sp_imageURL+""+(i+1)+"_10.gif\">  "+"  "+data.poilist[i].name+"</a></font></div><div class=\"result_detail\"><span class=\"gray\">类型：</span>"+type+"<br/><span class=\"gray\">地址：</span>"+address+"<br/><span class=\"gray\">电话：</span>"+tel+"</div>"+"<div class=\"result_action\"><a href=\"javascript:void(0);\" onclick=\"fillCenXY4SearchAround('"+data.poilist[i].name+"','"+data.poilist[i].x+"','"+data.poilist[i].y+"');\">将此设为中心点</a></div></div>";
			informPage(data.count,'zb_cent');
		}
	}else{
		alert('对不起，此城市没有查到合适的地点！');
	}
	html+='</div>';
	$('searchresult1_zb').innerHTML=html;
}
function fillCenXY4SearchAround(centname,centx,centy){
	document.getElementById('page_num_zb_cent').style.display='none';
	document.getElementById('page_num_zb').style.display='';
	document.map.searcharound_poi.value=centname;
	document.getElementById('searcharound_poix').value=centx;
	document.getElementById('searcharound_poiy').value=centy;
}
function searchByKeyword(citycode_ext,keyword_ext,setbatch){
	if(keyword_ext){
		document.getElementById('searchkeyword_keyword').value=keyword_ext; 
	}
	if(citycode_ext){
		document.getElementById('searchkeyword_city').value=citycode_ext; 
	}
	try{
		document.getElementById('page_num').style.display='';
	}catch(e){}
	try{
		if(document.getElementById('city').diabled==true){}
	}catch(e){CleanMap();}
	try{
		var citycode=document.map.searchkeyword_city.value;
		var keyword=document.map.searchkeyword_keyword.value;
	}catch(e){}
	try{
		var citycode=document.hold.citycode.value;
		var keyword=document.hold.keyword.value;
	}catch(e){}
	try{
		var citycode=GetObjValue('diycitycode');
		var keyword=GetObjValue('diykeyword');
	}catch(e){}
	var number=10;
	var batch=1;
	if(setbatch>1){
		batch=setbatch;
	}
	if(citycode_ext){
		citycode=citycode_ext;
	}
	if(keyword_ext){
		keyword=keyword_ext;
	}
	if(keyword==''){
		alert('请输入搜索关键字！');
		return false;
	}else if(keyword=='请输入关键字。。。'){
		alert('请输入搜索关键字！');
		return false;
	}
	showLoading_mine('ssresult');
	try{
		GetObjValue('inmapdiypage');
		showLoading_mine('loading');
	}catch(e){
		CleanMap();
	}
	var sis=new MSISSearch();
	var searchpointpara=new MSearchPointPara();
	sis.setSISCallbackFunction(searchbykeywordCallBack); 
	searchpointpara.setCitycode(citycode);
	searchpointpara.setKeyword(keyword);
	searchpointpara.setNumber(number);
	searchpointpara.setBatch(batch);
	sis.searchByKeyword(searchpointpara);
	if(citycode_ext||setbatch>1){}
	else{
		try{
			keyword_temp=document.map.searchkeyword_keyword.value;
			code1=document.map.searchkeyword_city.value;
			saveHistory(keyword_temp,code1,0,0,0,0,0,0,0,1);
		}catch(e){}
	}
	try{
		document.getElementById('batch_ss').value=batch;
	}catch(e){}
}
function searchbykeywordCallBack(data){
	try{
		GetObjValue('inmapdiypage');
		delsearchpoi();
		SetInnerHTML('loading','');
	}catch(e){}
	var html='<div><div class="msri">';
	if(data.count!=0){
		html+=('共'+data.count+'条结果</div>');
		var move_to_poiy=move_to_poix='';
		for(var i=0;i<data.poilist.length;i++){
			var pid=data.poilist[i].pguid;
			var data_citycode=data.poilist[i].citycode;
			var x=data.poilist[i].x;
			var y=data.poilist[i].y;
			var pointStyle=GetDefaultPointStyle();
			var type=data.poilist[i].type;
			if (type==''||type=='undefined'||type==null){
				type=noDetail;
			}
			var address=data.poilist[i].address;
			if(address==''||address=='undefined'||address==null){
				address=noDetail;
			}
			var tel=data.poilist[i].tel;
			if(tel==''||tel=='undefined'||tel==null){
				tel=noDetail;
			}
			var sContent=data.poilist[i].name;
			if(!type==''&&type!=null){
				sContent+='<br/>类型:'+type;
			}
			if(!address==''&&address!=null){
			sContent+='<br/>地址:'+address;
			}
			if(!tel==''&&tel!=null){
			sContent+='<br/>电话:'+tel;
			}
			pointStyle.textContent=sContent;
			var icon=sp_imageURL+(i+1)+'_10.gif';
			centerPoint=new MCustomPointOverlay(new MLatLng(y,x),icon,pointStyle,i+1);
			mapObj.addOverlay(centerPoint,false);
			var save_location_text=('名称:'+data.poilist[i].name+'. 类型:'+type+'. 地点: '+address+'. 电话:'+tel);
			try{
				document.getElementById('inhdeditpage').value=document.getElementById('inhdeditpage').value;
				setcenter="<a href=\"javascript:setthispoitohdaddress('"+data.poilist[i].x+"','"+data.poilist[i].y+"');\">将此设为活动地址</a><br/>";
				try{
					document.getElementById('inplaceeditpage').value=document.getElementById('inplaceeditpage').value;
					setcenter='';
				}catch(e){}
				document.hold.x.value=document.hold.x.value;
				html+="<a href=\"javascript:void(0);\" onclick=\"mapObj.setCenterByLatLng('"+data.poilist[i].y+"','"+data.poilist[i].x+"');mapObj.openTipById('"+(i+1)+"')\">"+"<img src=\""+icon+"\">  "+data.poilist[i].name+"</a><br/>类型："+type+"<br/>地址："+address+"<br/>电话："+tel+"<br/>"+setcenter;
				informPage(data.count,'ss');
			}catch(e){
				try{
					citycode=document.getElementById('searchkeyword_city').value;
					poiname=document.getElementById('searchkeyword_keyword').value;
					if(data.poilist[i].name!=''){
						poiname=data.poilist[i].name;
					}
					html+="<div class=\"resultitem\"><div class=\"result_caption\"><font color=\"#e1570e\"><a href=\"javascript:void(0);\" onclick=\"mapObj.setCenterByLatLng('"+data.poilist[i].y+"','"+data.poilist[i].x+"');mapObj.openTipById('"+(i+1)+"')\">"+"<img src=\""+icon+"\">  "+"  "+data.poilist[i].name+"</a></font></div><div class=\"result_detail\"><span class=\"gray\">类型：</span>"+type+"<br/><span class=\"gray\">地址：</span>"+address+"<br/><span class=\"gray\">电话：</span>"+tel+"</div>"+"<div class=\"result_action\"><a href=\"javascript:ext_fill(1,'"+data.poilist[i].x+"','"+data.poilist[i].y+"','"+citycode+"','"+poiname+"','local');\">到此处</a><a href=\"javascript:ext_fill(2,'"+data.poilist[i].x+"','"+data.poilist[i].y+"','"+citycode+"','"+poiname+"','local');\">从此处去</a><a onclick=\"javascript:fill_searcharound('"+data.poilist[i].name+"','"+data.poilist[i].x+"','"+data.poilist[i].y+"','1','"+''+"');\">周边</a><a id=\""+i+"\" href=\"javascript:HideObj('"+i+"');\" onclick=\"savemine('"+save_location_text+"','location','"+data.poilist[i].x+"','"+data.poilist[i].y+"','','','','','');\">收藏</a><a onclick=\"javascript:sharet('"+data.poilist[i].name+"','"+data.poilist[i].x+"','"+data.poilist[i].y+"','"+data.poilist[i].pguid+"');\">分享微博</a></div></div>";
					informPage(data.count,'ss');
				}catch(e){}
			}
			if(i==0){
				move_to_poix=data.poilist[i].x;
				move_to_poiy=data.poilist[i].y;
			}
		}
		mapObj.setCenterByLatLng(move_to_poiy,move_to_poix);
	}else{
		alert('对不起！此城市没有查到合适的地点。');
	}
	html=html+'</div>';
	$('ssresult').innerHTML=html;
}
function fill_searcharound(poiname,x,y,change,telnum){
	try{
		SwitchSearchPanel('zb');
		DisableObj('searcharound_poi');
		ShowObj('page_num_zb');
		HideObj('page_num_zb_cent');
	}catch(e){}
	if(change){
		document.map.searcharound_city.value=document.map.searchkeyword_city.value;
	}
	if(telnum){
		document.map.searcharound_city.value=telnum;
	}
	document.map.searcharound_poi.value=poiname;
	SetObjValue('searcharound_poix',x);
	SetObjValue('searcharound_poiy',y);
}
function SearchAround(citycode_ext,keyword_ext,x_ext,y_ext,setbatch){
	try{
		DisableObj('searcharound_poi');
	}catch(e){}
	CleanMap();
	var citycode=document.map.searcharound_city.value;
	var keyword=document.map.searcharound_keyword.value;
	var x=GetObjValue('searcharound_poix');
	var y=GetObjValue('searcharound_poiy');
	if(keyword_ext){
		citycode=citycode_ext;
		SwitchSearchPanel('zb');
		HideObj('page_num_zb_cent');
		ShowObj('page_num_zb');
		SetObjValue('searcharound_poi','中心点');
		SetObjValue('searcharound_keyword',keyword_ext);
		if(keyword_ext=='全部'){
			keyword='';
		}else{
			keyword=keyword_ext;
		}
		x=x_ext;
		y=y_ext;
	}else if(x==''||y==''){
		GetCenterXY();
		return false;
	}
	showLoading_mine('searchresult1_zb');
	var number=10;
	var batch=1;
	if(setbatch>1){
		batch=setbatch;
	}
	var sis=new MSISSearch();
	var searchpointpara=new MSearchPointPara();
	sis.setSISCallbackFunction(searcharoundCallBack);
	searchpointpara.setCitycode(citycode);
	searchpointpara.setCenXY(x,y);
	searchpointpara.setKeyword(keyword);
	searchpointpara.setRange('3000');
	searchpointpara.setNumber(number);
	searchpointpara.setBatch(batch);
	searchpointpara.setDataSet(MSISSearch.BASE);
	sis.localSearchByXY(searchpointpara);
	if(citycode_ext||setbatch>1){}
	else{
		try{
			code1=document.map.searcharound_city.value;
			name1=document.map.searcharound_poi.value;
			x1=document.getElementById('searcharound_poix').value;
			y1=document.getElementById('searcharound_poiy').value;
			name2=document.map.searcharound_keyword.value;
			saveHistory(0,code1,name1,x1,y1,0,name2,0,0,2);
		}catch(e){}
	}
}
function searcharoundCallBack(data){
	var html='<div><div class="msri">';
	if(data.count!=0){
		html+=('共'+data.count+'条结果</div>');
		var move_to_poix='';
		var move_to_poiy='';
		for(var i=0;i<data.poilist.length;i++){
			var pid=data.poilist[i].pguid;
			var data_citycode=data.poilist[i].citycode;
			var x=data.poilist[i].x;
			var y=data.poilist[i].y;
			var pointStyle=GetDefaultPointStyle();
			var type=data.poilist[i].type;
			if (type==''||type=='undefined'||type==null){
				type=noDetail;
			}
			var address=data.poilist[i].address;
			if(address==''||address=='undefined'||address==null){
				address=noDetail;
			}
			var tel=data.poilist[i].tel;
			if(tel==''||tel=='undefined'||tel==null){
				tel=noDetail;
			}
			var sContent=data.poilist[i].name;
			if(!type==''&&type!=null){
				sContent+='<br/>类型:'+type;
			}
			if(!address==''&&address!=null){
				sContent+='<br/>地址:'+address;
			}
			if(!tel==''&&tel!=null){
				sContent+='<br/>电话:'+tel;
			}
			pointStyle.textContent=sContent;
			var icon=sp_imageURL+(i+1)+'_10.gif';
			centerPoint=new MCustomPointOverlay(new MLatLng(y,x),icon,pointStyle,i+1);
			mapObj.addOverlay(centerPoint,false);
			var save_location_text=('名称:'+data.poilist[i].name+'. 类型:'+type+'. 地点: '+address+'. 电话:'+tel);
			html+="<div class=\"resultitem\"><div class=\"result_caption\"><font color=\"#e1570e\"><a href=\"javascript:void(0);\" onclick=\"mapObj.setCenterByLatLng('"+data.poilist[i].y+"','"+data.poilist[i].x+"');mapObj.openTipById('"+(i+1)+"')\">"+"<img src=\""+sp_imageURL+""+(i+1)+"_10.gif\">  "+"  "+data.poilist[i].name+"</a></font></div><div class=\"result_detail\"><span class=\"gray\">类型：</span>"+type+"<br/><span class=\"gray\">地址：</span>"+address+"<br/><span class=\"gray\">电话：</span>"+tel+"</div><div class=\"result_action\"><a href=\"javascript:ext_fill(1,'"+data.poilist[i].x+"','"+data.poilist[i].y+"','','"+data.poilist[i].name+"','local');\">到此处</a><a href=\"javascript:ext_fill(2,'"+data.poilist[i].x+"','"+data.poilist[i].y+"','','"+data.poilist[i].name+"','local');\">从此处去</a><a href=\"javascript:fill_searcharound('"+data.poilist[i].name+"','"+data.poilist[i].x+"','"+data.poilist[i].y+"','1','"+''+"');\">周边</a><a id=\""+500+i+"\" href=\"javascript:HideObj('"+500+i+"');\" onclick=\"savemine('"+save_location_text+"','location','"+data.poilist[i].x+"','"+data.poilist[i].y+"','','','','','');\">收藏</a></div></div>";
			informPage(data.count,'zb')
			if(i==0){
				move_to_poix=data.poilist[i].x;
				move_to_poiy=data.poilist[i].y;
			}
		}
		mapObj.setCenterByLatLng(move_to_poiy,move_to_poix);
	}else{
		alert('对不起！在周边没有查到合适的地点。');
	}
	html+='</div>';
	$('searchresult1_zb').innerHTML=html;
}
function searchbusstartandend(){
	if(document.map.searchbus_startx.value==''||document.map.searchbus_starty.value==''){
		document.getElementById('searchbus_start_name').disabled=true;
		searchstart('bus');
	}
	if(document.map.searchbus_endx.value==''||document.map.searchbus_endy.value==''){
		document.getElementById('searchbus_end_name').disabled=true;
		setTimeout("searchend(\"bus\")",1500);
	}
	if(document.map.searchbus_startx.value&&document.map.searchbus_endx.value){
		searchbus();
	}
	
}
function searchstart(type){
	CleanMap();
	var citycode='';
	var keyword='';
	if(type=='bus'){
		showLoading_mine('searchbegin_gj');
		citycode=document.map.searchbus_city.value;
		keyword=document.map.searchbus_start_name.value;
	}else if(type=='drive'){
		showLoading_mine('searchbegin_zj');
		citycode=document.map.searchdrive_startcity.value;
		keyword=document.map.searchdrive_start_name.value;
	}
	var number=10;
	var batch=1;
	if(keyword==''){
		if(type=='bus'){
			EnableObj('searchbus_start_name');
		}else if(type=='drive'){
			EnableObj('searchdrive_start_name');
		}
		alert('请输入起点关键字！');
		return false;
	}
	var sis=new MSISSearch();
	var searchpointpara=new MSearchPointPara();
	if(type=='bus'){
		sis.setSISCallbackFunction(searchstartcallbackforbus);
	}else if(type=='drive'){
		sis.setSISCallbackFunction(searchstartcallbackfordrive);
	}
	searchpointpara.setCitycode(citycode);
	searchpointpara.setKeyword(keyword);
	searchpointpara.setNumber(number);
	searchpointpara.setBatch(batch);
	sis.searchByKeyword(searchpointpara);
}
function searchstartcallbackforbus(data){
	var html="<div><div class=\"msri\"><b>请选择起点：</b></div>";
	if(data.count!=0){
		for(var i=0;i<data.poilist.length;i++){
			var pid=data.poilist[i].pguid;
			var data_citycode=data.poilist[i].citycode;
			var x=data.poilist[i].x;
			var y=data.poilist[i].y;
			var pointStyle=GetDefaultPointStyle();
			var type=data.poilist[i].type;
			if (type==''||type=='undefined'||type==null){
				type=noDetail;
			}
			var address=data.poilist[i].address;
			if (address==''||address=='undefined'||address==null){
				address=noDetail;
			}
			var tel=data.poilist[i].tel;
			if (tel==''||tel=='undefined'||tel==null){
				tel=noDetail;
			}	    
			var sContent=data.poilist[i].name;
			if (!type=='' && type != null){
				sContent+='<br/>类型:'+type;
			}
			if(!address==''&&address!=null){
				sContent+='<br/>地址:'+address;
			}
			if(!tel==''&&tel!=null){
				sContent+='<br/>电话:'+tel;
			}
			pointStyle.textContent=sContent;
			var icon=sp_imageURL+(i+1)+'_10.gif';
			centerPoint=new MCustomPointOverlay(new MLatLng(y,x),icon,pointStyle,i+1);
			mapObj.addOverlay(centerPoint,false);
			html+="<div class=\"resultitem\"><div class=\"result_caption\"><font color=\"#e1570e\"><a href=\"javascript:void(0);\" onclick=\"mapObj.setCenterByLatLng('"+data.poilist[i].y+"','"+data.poilist[i].x+"');mapObj.openTipById('"+(i+1)+"');fill_busstart('"+data.poilist[i].name+"','"+data.poilist[i].x+"','"+data.poilist[i].y+"');\">"+"<img src=\""+icon+"\">"+"  "+data.poilist[i].name+"</a></font></div><div class=\"result_detail\"><span class=\"gray\">类型：</span>"+type+"<br /><span class=\"gray\">地址：</span>"+address+"<br /><span class=\"gray\">电话：</span>"+tel+"<br/><a href=\"javascript:void(0);\" onclick=\"fill_busstart('"+data.poilist[i].name+"','"+data.poilist[i].x+"','"+data.poilist[i].y+"');\">设为公交起点</a></div></div>";
		}
	}else{
		alert('对不起！此城市没有查到合适的公交起点。');
	}
	html+='</div>';
	$('searchbegin_gj').innerHTML=html;
}
function searchstartcallbackfordrive(data){
	var html="<div><div class=\"msri\"><b>请选择起点：</b></div>";
	if(data.count!=0){
		for(var i=0;i<data.poilist.length;i++){
			var pid=data.poilist[i].pguid;
			var data_citycode=data.poilist[i].citycode;
			var x=data.poilist[i].x;
			var y=data.poilist[i].y;
			var pointStyle=GetDefaultPointStyle();
			var type=data.poilist[i].type;
			if(type==''||type=='undefined'||type==null){
				type=noDetail;
			}
			var address=data.poilist[i].address;
			if(address==''||address=='undefined'||address==null){
				address=noDetail;
			}
			var tel=data.poilist[i].tel;
			if(tel==''||tel=='undefined'||tel==null){
				tel=noDetail;
			}
			var sContent=data.poilist[i].name;
			if(!type==''&&type!=null){
				sContent+='<br/>类型:'+type;
			}
			if(!address==''&&address!=null){
				sContent+='<br/>地址:'+address;
			}
			if(!tel==''&&tel!=null){
				sContent+='<br/>电话:'+tel;
			}
			pointStyle.textContent=sContent;
			var icon=sp_imageURL+(i+1)+'_10.gif';
			centerPoint=new MCustomPointOverlay(new MLatLng(y,x),icon,pointStyle,i+1);
			mapObj.addOverlay(centerPoint,false);
			html+="<div class=\"resultitem\"><div class=\"result_caption\"><font color=\"#e1570e\"><a href=\"javascript:void(0);\" onclick=\"mapObj.setCenterByLatLng('"+data.poilist[i].y+"','"+data.poilist[i].x+"');mapObj.openTipById('"+(i+1)+"');fill_drivestart('"+data.poilist[i].name+"','"+data.poilist[i].x+"','"+data.poilist[i].y+"');\">"+"<img src=\""+icon+"\">"+"  "+data.poilist[i].name+"</a></font></div><div class=\"result_detail\"><span class=\"gray\">类型：</span>"+type+"<br /><span class=\"gray\">地址：</span>"+address+"<br /><span class=\"gray\">电话：</span>"+tel+"<br/><a href=\"javascript:void(0);\" onclick=\"fill_drivestart('"+data.poilist[i].name+"','"+data.poilist[i].x+"','"+data.poilist[i].y+"');\">设为自驾起点</a></div></div>";
		}
	}else{
		alert('对不起！此城市没有查到合适的自驾起点。');
	}
	html+='</div>';
	$('searchbegin_zj').innerHTML=html;
}
function searchend(type){
	var keyword=citycode='';
	if(type=='bus'){
		showLoading_mine('searchend_gj');
		citycode=document.map.searchbus_city.value;
		keyword=document.map.searchbus_end_name.value;
	}else if(type=='drive'){
		ShowObj('searchresultcenter_zj');
		showLoading_mine('searchend_zj');
		citycode=document.map.searchdrive_startcity.value;
		if(document.getElementById('drive_end_city').value != ''){
			citycode=document.getElementById('searchdrive_endcity').value;
		}
		keyword=document.map.searchdrive_end_name.value;
	}
	var number=10;
	var batch=1;
	if(keyword==''){
		if(type=='bus'){
			document.getElementById('searchbus_end_name').disabled=false;
		}else if(type=='drive'){
			document.getElementById('searchdrive_end_name').disabled=false;
		}
		alert('请输入终点关键字！');
		return false;
	}
	var sis=new MSISSearch();
	var searchpointpara=new MSearchPointPara();
	if(type=='bus'){
		sis.setSISCallbackFunction(searchendcallbackforbus);
	}else if(type=='drive'){
		sis.setSISCallbackFunction(searchendcallbackfordrive);
	}
	searchpointpara.setCitycode(citycode);
	searchpointpara.setKeyword(keyword);
	searchpointpara.setNumber(number);
	searchpointpara.setBatch(batch);
	sis.searchByKeyword(searchpointpara);
}
function searchendcallbackforbus(data){
	var html="<div><div class=\"msri\"><b>请选择终点：</b></div>";
	if(data.count!=0){
		document.getElementById('searchresultcenter_gj').style.display='';
		for(var i=0;i<data.poilist.length;i++){
			var pid=data.poilist[i].pguid;
			var data_citycode=data.poilist[i].citycode;
			var x=data.poilist[i].x;
			var y=data.poilist[i].y;
			var pointStyle=GetDefaultPointStyle();
			var type=data.poilist[i].type;
			if(type==''||type=='undefined'||type==null){
				type=noDetail;
			}
			var address=data.poilist[i].address;
			if(address==''||address=='undefined'||address==null){
				address=noDetail;
			}
			var tel=data.poilist[i].tel;
			if(tel==''||tel=='undefined'||tel==null){
				tel=noDetail;
			}
			var sContent=data.poilist[i].name;
			if(!type==''&&type!=null){
				sContent+='<br/>类型:'+type;
			}
			if(!address==''&&address!=null){
				sContent+='<br/>地址:'+address;
			}
			if(!tel==''&&tel!=null){
				sContent+='<br/>电话:'+tel;
			}
			pointStyle.textContent=sContent;
			var icon=sp_imageURL+(i+1)+'_10.gif';
			centerPoint=new MCustomPointOverlay(new MLatLng(y,x),icon,pointStyle,i+11);
			mapObj.addOverlay(centerPoint,false);
			
			html+="<div class=\"resultitem\"><div class=\"result_caption\"><font color=\"#e1570e\"><a href=\"javascript:void(0);\" onclick=\"mapObj.setCenterByLatLng('"+data.poilist[i].y+"','"+data.poilist[i].x+"');mapObj.openTipById('"+(i+11)+"');fill_busend('"+data.poilist[i].name+"','"+data.poilist[i].x+"','"+data.poilist[i].y+"');\">"+"<img src=\""+icon+"\">"+"  "+data.poilist[i].name+"</a></font></div><div class=\"result_detail\"><span class=\"gray\">类型：</span>"+type+"<br/><span class=\"gray\">地址：</span>"+address+"<br/><span class=\"gray\">电话：</span>"+tel+"<br/><a href=\"javascript:void(0);\" onclick=\"fill_busend('"+data.poilist[i].name+"','"+data.poilist[i].x+"','"+data.poilist[i].y+"');\">设为公交终点</a></div></div>";
		}
	}else{
		alert('对不起！此城市没有查到合适的公交终点。');
	}
	html+='</div>';
	$('searchend_gj').innerHTML=html;
}
function searchendcallbackfordrive(data){
	document.getElementById('searchresultcenter_zj').style.display='';
	var html="<div><div class=\"msri\"><b>请选择终点：</b></div>";
	if(data.count!=0){
		for(var i=0;i<data.poilist.length;i++){
			var pid=data.poilist[i].pguid;
			var data_citycode=data.poilist[i].citycode;
			var x=data.poilist[i].x;
			var y=data.poilist[i].y;
			var pointStyle=GetDefaultPointStyle();
			var type=data.poilist[i].type;
			if(type==''||type=='undefined'||type==null){
				type=noDetail;
			}
			var address=data.poilist[i].address;
			if(address==''||address=='undefined'||address==null){
				address=noDetail;
			}
			var tel=data.poilist[i].tel;
			if(tel==''||tel=='undefined'||tel==null){
				tel=noDetail;
			}
			var sContent=data.poilist[i].name;
			if(!type==''&&type!=null){
					sContent+='<br/>类型:'+type;
			}
			if(!address==''&&address!=null){
				sContent+='<br/>地址:'+address;
			}
			if(!tel==''&&tel!=null){
				sContent+='<br/>电话:'+tel;
			}
			pointStyle.textContent=sContent;
			var icon=sp_imageURL+(i+1)+'_10.gif';
			centerPoint=new MCustomPointOverlay(new MLatLng(y,x),icon,pointStyle,i+11);
			mapObj.addOverlay(centerPoint,false);
			html+="<div class=\"resultitem\"><div class=\"result_caption\"><font color=\"#e1570e\"><a href=\"javascript:void(0);\" onclick=\"mapObj.setCenterByLatLng('"+data.poilist[i].y+"','"+data.poilist[i].x+"');mapObj.openTipById('"+(i+11)+"');fill_driveend('"+data.poilist[i].name+"','"+data.poilist[i].x+"','"+data.poilist[i].y+"');\">"+"<img src=\""+icon+"\">"+"  "+data.poilist[i].name+"</a></font></div><div class=\"result_detail\"><span class=\"gray\">类型：</span>"+type+"<br/><span class=\"gray\">地址：</span>"+address+"<br/><span class=\"gray\">电话：</span>"+tel+"<br/><a href=\"javascript:void(0);\" onclick=\"fill_driveend('"+data.poilist[i].name+"','"+data.poilist[i].x+"','"+data.poilist[i].y+"');\">设为自驾终点</a></div></div>";
		}
	}else{
		alert('对不起！此城市没有查到合适的自驾终点。');
	}
	html+='</div>';
	$('searchend_zj').innerHTML=html;
}
function fill_busstart(startname,startx,starty){
	document.map.searchbus_start_name.value=startname;
	document.map.searchbus_startx.value=startx;
	document.map.searchbus_starty.value=starty;
}
function fill_busend(endname,endx,endy){
	document.map.searchbus_end_name.value=endname;
	document.map.searchbus_endx.value=endx;
	document.map.searchbus_endy.value=endy;
}
function searchbus(citycode_ext,startx_ext,starty_ext,endx_ext,endy_ext,name1,name2){
	showLoading_mine('gjresult');
	try{
		document.getElementById('searchbegin_gj').style.display='none';
		document.getElementById('searchend_gj').style.display='none';
		document.getElementById('gjresult').style.display='';
		document.getElementById('searchdriveconfirm').style.display='none';
	}catch(e){
		try{
			document.getElementById('x1').value=startx_ext;
			document.getElementById('y1').value=starty_ext;
			document.getElementById('x2').value=endx_ext;
			document.getElementById('y2').value=endy_ext;
		}catch(e){}
	}
	var sis=new MSISSearch();
	var bus=new MSearchRoutPara();
	var routtype=1;
	try{
		routtype=document.map.searchbus_routeType.value;
	}catch(e){}
	sis.setSISCallbackFunction(searchBusCallBack);
	if(startx_ext&&endx_ext){
		try{
			SwitchSearchPanel('gj');
			document.getElementById('searchbegin_gj').style.display='none';
			document.getElementById('searchend_gj').style.display='none';
			document.getElementById('gjresult').style.display='';
			document.getElementById('searchbus_start_name').value=name1;
			document.getElementById('searchbus_start_name').disabled=true;
			document.getElementById('searchbus_end_name').value=name2;
			document.getElementById('searchbus_end_name').disabled=true;
			document.getElementById('searchbus_startx').value=startx_ext;
			document.getElementById('searchbus_starty').value=starty_ext;
			document.getElementById('searchbus_endx').value=endx_ext;
			document.getElementById('searchbus_endy').value=endy_ext;
		}catch(e){}
		bus.setStartXY(startx_ext,starty_ext);
		bus.setEndXY(endx_ext,endy_ext);
		bus.setCitycode(citycode_ext);
	}else{
		bus.setStartXY(document.map.searchbus_startx.value,document.map.searchbus_starty.value);
		bus.setEndXY(document.map.searchbus_endx.value,document.map.searchbus_endy.value);
		bus.setCitycode(document.map.searchbus_city.value);
	}
	bus.setRouteType(routtype);
	bus.setType('bus');
	sis.searchBusAndDrive(bus);
	if(startx_ext){}
	else{
		try{
			code1=document.map.searchbus_city.value;
			name1=document.map.searchbus_start_name.value;
			x1=document.map.searchbus_startx.value;
			y1=document.map.searchbus_starty.value;
			name2=document.map.searchbus_end_name.value;
			x2=document.map.searchbus_endx.value;
			y2=document.map.searchbus_endy.value;
			saveHistory(0,code1,name1,x1,y1,code1,name2,x2,y2,3);
		}catch(e){}
	}
}
function searchBusCallBack(data){
	if(data.count!=0){
		try{
			document.getElementById('searchresultcenter_gj').style.display='none';
		}catch(e){}
		xy_array=new Array();
		xy_hc_array=new Array();
		var bus_line='';
		try{
			bus_line=('<div><div class="msri"><b>从：'+document.map.searchbus_start_name.value+'</b><br /><b>到：'+document.map.searchbus_end_name.value+'</b></div>');
		}catch(e){}
		var bus_map=eval('(data)');
		var bus_count=bus_map.busList.length;
		for(var i=0;i<bus_map.busList.length;i++){
			var bus_text=str_xy=bus_num=xy_hc=bus_length=0;
			for(var k=0;k<bus_map.busList[i].segmentList.length;k++){
				if(k==0){
					bus_num+=(bus_map.busList[i].segmentList[k].busName).split('(')[0];			
					bus_text+='步行'+bus_map.busList[i].segmentList[k].footLength+'米到达'+bus_map.busList[i].segmentList[k].startName+',换乘'+bus_map.busList[i].segmentList[k].busName+',途径'+bus_map.busList[i].segmentList[k].passDepotCount+'站,到达'+bus_map.busList[i].segmentList[k].endName+'.';
					var xy=(bus_map.busList[i].segmentList[k].coordinateList).split(',');
					xy_hc+=xy[xy.length-3]+','+xy[xy.length-2]+',';
				}else{
					bus_num=bus_num+'转'+(bus_map.busList[i].segmentList[k].busName).split('(')[0];
					bus_text+='下车步行'+bus_map.busList[i].segmentList[k].footLength+'米到达'+bus_map.busList[i].segmentList[k].startName+',换乘'+bus_map.busList[i].segmentList[k].busName+',途径'+bus_map.busList[i].segmentList[k].passDepotCount+'站,到达'+bus_map.busList[i].segmentList[k].endName+'.';
					var xy=(bus_map.busList[i].segmentList[k].coordinateList).split(',');
					xy_hc+=xy[0]+','+xy[1]+',';
				}
				str_xy+=bus_map.busList[i].segmentList[k].coordinateList;						
				bus_length=bus_length+parseInt(bus_map.busList[i].segmentList[k].driverLength);
				if(bus_map.busList[i].segmentList.length==1){
					xy_hc='';
				}
			}
			xy_array[i]=str_xy;
			xy_hc_array[i]=xy_hc;
			var save_bus_text='';
			try{
				save_bus_text=('从'+document.map.searchbus_start_name.value+'到'+document.map.searchbus_end_name.value+': '+bus_text);
			bus_line+="<div class=\"resultitem\"><div class=\"result_caption\"><font color=\"#e1570e\">方案"+(i+1)+":  "+bus_text.substring(0,30)+"...</font></div><div class=\"result_detail\">"+bus_text+"</div><a id=\""+50+i+"\" href=\"javascript:HideObj('"+50+i+"');\" onclick=\"savemine('"+save_bus_text+"','bus','"+document.map.searchbus_startx.value+"','"+document.map.searchbus_starty.value+"','"+document.map.searchbus_city.value+"','"+document.map.searchbus_endx.value+"','"+document.map.searchbus_endy.value+"','起点','终点');\">收藏</a></div>";
			}catch(e){}
		}
		bus_line+='</div>';
		try{
			$('gjresult').innerHTML=bus_line;
		}catch(e){}
		var poi_xy=xy_array[0].split(',');
		var arrX='';
		var arrY='';
		for(var e=0;e<poi_xy.length-1;e=e+2){	
			if(e==poi_xy.length-3){
				arrX+=poi_xy[e];
				arrY+=poi_xy[e+1];
			}else{
				arrX+=poi_xy[e]+',';
				arrY+=poi_xy[e+1]+',';
			}
		}
		var poi_xy_hc=xy_hc_array[0].split(',');
		var hcx='';
		var hcy ='';
		for(var e=0;e<poi_xy_hc.length-1;e=e+2){	
			if(e==poi_xy_hc.length-3){
				hcx+=poi_xy_hc[e];
				hcy+=poi_xy_hc[e+1];
			}else{
				hcx+=poi_xy_hc[e]+',';
				hcy+=poi_xy_hc[e+1]+',';
			}
		}
		try{
			drawABusLine(arrX,arrY,document.map.searchbus_startx.value,document.map.searchbus_starty.value,document.map.searchbus_endx.value,document.map.searchbus_endy.value,hcx,hcy);
		}catch(e){
			drawABusLine(arrX,arrY,document.getElementById('x1').value,document.getElementById('y1').value,document.getElementById('x2').value,document.getElementById('y2').value,hcx,hcy);
		}
	}else{alert('未找到合适公交路线！');}
}
function drawABusLine(arrX,arrY,qdpoix,qdpoiy,zdpoix,zdpoiy,changex,changey){
	CleanMap();
	var startObj=new MStyle();
	startObj.lineColor='0xFFFFFF';
	startObj.lineOpacity='80';
	startObj.lineSize='2';
	startObj.fillOpacity='100';
	startObj.fillColor='0x4b8bd9';
	startObj.labelColor='0xFFFFFF';
	startObj.textContent='';
	var endObj=new MStyle();
	endObj.textContent='';
	endObj.lineColor='0xFFFFFF';
	endObj.lineOpacity='80';
	endObj.fillColor='0xEF501A';
	endObj.lineSize='2';
	endObj.fillOpacity='100';
	endObj.fillColor='0x4b8bd9';
	endObj.labelColor='0xFFFFFF';
	var lineObj=new MStyle();
	lineObj.lineSize=6;
	lineObj.lineColor=0x0000ff;
	lineObj.lineOpacity='60';
	var startPoint='';
	var endPoint='';
	try{
		startPoint=new MPointOverlay(new MLatLng(qdpoiy,qdpoix),document.map.searchbus_start_name.value,startObj);
		endPoint=new MPointOverlay(new MLatLng(zdpoiy,zdpoix),document.map.searchbus_end_name.value,endObj);
	}catch(e){
		startPoint=new MPointOverlay(new MLatLng(qdpoiy,qdpoix),'起点',startObj);
		endPoint=new MPointOverlay(new MLatLng(zdpoiy,zdpoix),'终点',endObj);
	}
	if(qdpoix==''||qdpoix=='null'||zdpoix==''||zdpoiy=='null'){
	}else{
		mapObj.drawBusLine(arrX,arrY,changex,changey,startPoint,endPoint,lineObj,true);
	}
}
function searchdrivestartandend(){
	if(document.map.searchdrive_startx.value==''||document.map.searchdrive_starty.value==''){
		searchstart('drive');
		document.getElementById('searchdrive_start_name').disabled=true;
	}
	if(document.map.searchdrive_endx.value==''||document.map.searchdrive_endy.value==''){
		setTimeout("searchend(\"drive\")",1500);
		document.getElementById('searchdrive_end_name').disabled=true;
	}
	if(document.map.searchdrive_startx.value&&document.map.searchdrive_endx.value){
		searchdrive();
	}
	
}
function fill_drivestart(startname,startx,starty){
	document.map.searchdrive_start_name.value=startname;
	document.map.searchdrive_startx.value=startx;
	document.map.searchdrive_starty.value=starty;
}
function fill_driveend(endname,endx,endy){
	document.map.searchdrive_end_name.value=endname;
	document.map.searchdrive_endx.value=endx;
	document.map.searchdrive_endy.value=endy;
}
function searchdrive(startx_ext,starty_ext,endx_ext,endy_ext,startcitycode_ext,name1,name2){
	showLoading_mine('zjresult');
	try{
		document.getElementById('searchbegin_zj').style.display='none';
		document.getElementById('searchend_zj').style.display='none';
		document.getElementById('zjresult').style.display='';
	}catch(e){
		document.getElementById('x1').value=startx_ext;
		document.getElementById('y1').value=starty_ext;
		document.getElementById('x2').value=endx_ext;
		document.getElementById('y2').value=endy_ext;
	}
	var sis=new MSISSearch();
	var route_driver=new MSearchRoutPara();
	sis.setSISCallbackFunction(searchDriveCallBack);
	if(startx_ext){
		route_driver.setStartXY(startx_ext,starty_ext);
		route_driver.setEndXY(endx_ext,endy_ext);
		route_driver.setCitycode(startcitycode_ext);
		try{
			SwitchSearchPanel('zj');
			document.getElementById('searchbegin_zj').style.display='none';
			document.getElementById('searchend_zj').style.display='none';
			document.getElementById('zjresult').style.display='';
			document.getElementById('searchdrive_start_name').value=name1;
			document.getElementById('searchdrive_start_name').disabled=true;
			document.getElementById('searchdrive_end_name').value=name2;
			document.getElementById('searchdrive_end_name').disabled=true;
			document.getElementById('searchdrive_startx').value=startx_ext;
			document.getElementById('searchdrive_starty').value=starty_ext;
			document.getElementById('searchdrive_endx').value=endx_ext;
			document.getElementById('searchdrive_endy').value=endy_ext;
		}catch(e){}
	}else{
		route_driver.setStartXY(document.map.searchdrive_startx.value,document.map.searchdrive_starty.value);
		route_driver.setEndXY(document.map.searchdrive_endx.value,document.map.searchdrive_endy.value);
		route_driver.setCitycode(document.map.searchdrive_startcity.value);
	}
	try{
		var route_way=document.getElementById('searchdrive_routeType').value;
	}catch(e){var route_way=1;}
	route_driver.setRouteType(route_way);
	route_driver.setType('drive');
	try{
		
	}catch(e){}
	sis.searchBusAndDrive(route_driver);
	
	if(startx_ext){}
	else{
		try{
			code1=document.map.searchdrive_startcity.value;
			name1=document.map.searchdrive_start_name.value;
			x1=document.map.searchdrive_startx.value;
			y1=document.map.searchdrive_starty.value;
			name2=document.map.searchdrive_end_name.value;
			x2=document.map.searchdrive_endx.value;
			y2=document.map.searchdrive_endy.value;
			code2=document.map.searchdrive_startcity.value;
			saveHistory(0,code1,name1,x1,y1,code2,name2,x2,y2,4);
		}catch(e){}
	}
}
function searchDriveCallBack(data){
	CleanMap();
	if(data.count!=0){
		try{
			document.getElementById('searchresultcenter_zj').style.display='none';
		}catch(e){}
		var road_length=0;
		var route_line='';
		try{
			route_line='<div><div class="msri"><b>从：'+document.map.searchdrive_start_name.value+'</b><br /><b>到：'+document.map.searchdrive_end_name.value+'</b></div>';
		}catch(e){}
		var route_line_limit='';
		var phone_xin='';
		var str_xy='';
		var route_map=eval('(data)');
		for(var i=0;i<route_map.segmengList.length;i++){
			route_line+="<div class=\"resultitem\"><div class=\"result_detail\"><a href=\"javascript:void(0);\">"+(i+1)+"</a> "+route_map.segmengList[i].textInfo+"</div></div>";
			route_line_limit+=(' '+(i+1)+' '+route_map.segmengList[i].textInfo);
			phone_xin+=route_map.segmengList[i].textInfo+'．';		
			road_length=road_length+parseInt(route_map.segmengList[i].roadLength);
			str_xy+=route_map.segmengList[i].coor;
		}
		if(road_length>1000){
			road_length=road_length/1000;
		}
		var save_drive_text='';
		try{
			save_drive_text=('从'+document.map.searchdrive_start_name.value+'到'+document.map.searchdrive_end_name.value+': '+route_line_limit+'.行程: '+road_length+'公里.');
		$('zjresult').innerHTML=route_line+'行驶 '+road_length+"公里<a id=\""+100+i+"\" href=\"javascript:HideObj('"+100+i+"');\" onclick=\"savemine('"+save_drive_text+"','drive','"+document.map.searchdrive_startx.value+"','"+document.map.searchdrive_starty.value+"','"+document.map.searchdrive_startcity.value+"','"+document.map.searchdrive_endx.value+"','"+document.map.searchdrive_endy.value+"','起点','终点');\"><br/>收藏</a></div>";
		}catch(e){}
		poi_xy_r=str_xy.split(',');
		arrX_r='';
		arrY_r='';
		for(var e=0;e<poi_xy_r.length-1;e=e+2){	
			if(e==poi_xy_r.length-3){
				arrX_r+=poi_xy_r[e];
				arrY_r+=poi_xy_r[e+1];
			}else{
				arrX_r+=poi_xy_r[e]+',';
				arrY_r+=poi_xy_r[e+1]+',';
			}
		}
		try{
			routeaddline(arrX_r,arrY_r,document.map.searchdrive_starty.value,document.map.searchdrive_startx.value,document.map.searchdrive_endy.value,document.map.searchdrive_endx.value);
		}catch(e){
			routeaddline(arrX_r,arrY_r,document.getElementById('y1').value,document.getElementById('x1').value,document.getElementById('y2').value,document.getElementById('x2').value);
		}
	}else{
		alert('对不起！未找到合适的驾车路线！');
	}
}
function routeaddline(arrX,arrY,startX,startY,endX,endY){
	var startObj=new MStyle();
	startObj.lineColor='0xFFFFFF';
	startObj.lineOpacity='80';
	startObj.fillColor='0x4b8bd9';
	startObj.lineSize='2';
	startObj.fillOpacity='100';
	startObj.labelColor='0xFFFFFF';
	startObj.textContent='起点';
	var endObj=new MStyle();
	endObj.textContent='终点';
	endObj.lineColor='0xFFFFFF';
	endObj.lineOpacity='80';
	endObj.fillColor='0x4b8bd9';
	endObj.lineSize='2';
	endObj.fillOpacity='100';
	endObj.labelColor='0xFFFFFF';
	var lineObj=new MStyle();
	lineObj.lineSize='6';
	lineObj.lineColor='0x0000ff';
	lineObj.lineOpacity='60';
	var startPoint='';
	var endPoint='';
	try{
		startPoint=new MPointOverlay(new MLatLng(startX,startY),document.map.searchdrive_start_name.value,startObj);
		endPoint=new MPointOverlay(new MLatLng(endX,endY),document.map.searchdrive_end_name.value,endObj);
	}catch(e){
		startPoint=new MPointOverlay(new MLatLng(startX,startY),'起点',startObj);
		endPoint=new MPointOverlay(new MLatLng(endX,endY),'终点',endObj);
	}
	mapObj.drawDriveLine(arrX,arrY,startPoint,endPoint,lineObj,true);
}
var xmlHttp_save=createXmlHttpRequestObject();
function createXmlHttpRequestObject(){	
	var objXML=null,xmlStr
if(window.ActiveXObject){
	var xmlStr=new Array(
	'Msxml2.XMLHTTP.5.0',
	'Msxml2.XMLHTTP.5.0',
	'Msxml2.XMLHTTP.4.0',
	'Msxml2.XMLHTTP.3.0',
	'Msxml2.XMLHTTP',
	'Microsoft.XMLHTTP');
      for(var i=0;i<xmlStr.length;i++){
          try{
              var objXML=new ActiveXObject(xmlStr[i]);
              return objXML;
          }catch(e){}
      }
    }else if(window.XMLHttpRequest){
        var objXML=new window.XMLHttpRequest()
        return objXML;
    }
}
function savemine(text,type,x,y,citycode,x1,y1,name1,name2){
	text=escape(filterContentbystr(text));
	name1=escape(filterContentbystr(name1));
	name2=escape(filterContentbystr(name2));
	if(x){
		if(y){
			var url=('sp_source/map_save.php?type='+type+'&text='+text+'&x='+x+'&y='+y+'&c='+citycode+'&x1='+x1+'&y1='+y1+'&s='+name1+'&e='+name2);
		}else{
			return false;
		}
	}else{
		var url=('sp_source/map_save.php?type='+type+'&text='+text);
	}
	xmlHttp_save.onreadystatechange=handleSave;
	xmlHttp_save.open('GET',url,true);
	xmlHttp_save.send(null);
}
function handleSave(){
	if(xmlHttp_save.readyState==4){
		if(xmlHttp_save.status==200){
			xmlResponse=xmlHttp_save.responseXML;
			var xmlRoot=xmlResponse.documentElement;
			var response=xmlRoot.getElementsByTagName('status');
			var status=0;
			var o='';
			try{
				status=response.item(0).firstChild.data;
				if(status!=1){
					o="<a style=\"display:none;\" id=\"status\" onclick=\"ajaxmenu(event,this.id,99999,'',-1)\"></a>";
					SetInnerHTML('savestatus',o);
					OpenStatusMenu(status);
					if(status==31||status==32){
						setTimeout("window.close()",1500);
					}
				}
			}catch(e){}
		}else{
			alert('错误: ' + xmlHttp_save.statusText);
		}
	}
}
function OpenStatusMenu(t){
	obj=document.getElementById('status');
	obj.href='status.php?status='+t;
	if(document.all){
		obj.click();
	}else{
		var evt=document.createEvent('MouseEvents');
		evt.initEvent('click',true,true);
		obj.dispatchEvent(evt);
	}
	if(t!=33&&t!=35){
		setTimeout("hideMenu()",2000);
	}
}
var xmlHttp_favorite=createXmlHttpRequestObject();
function directshowline(type,x1,y1,x2,y2,code){
	code=('0'+code);
	if(type=='bus'){
		searchbus(code,x1,y1,x2,y2,'起点','终点');
	}else if(type=='drive'){
		searchdrive(x1,y1,x2,y2,code,'起点','终点');
	}
}
function del_favorite(id,type,hiddenid)
{
	if(confirm('确定要删除这条记录吗？')){
		document.getElementById(hiddenid).style.display='none';
		update_favorite(id,'del');
	}
}
function showcomment(id,type){
	var url=('map.php?do=comment&id='+id);
	window.open(url);
}
function edit_favorite(id,text,status,description,shortname,editrowid){
	var check0=check1=''; 
	if(status=='1'){
		check1='checked';
	}else{
		check0='checked';
	}
	var edit_text_id='edit_text'+id.toString();
	var edit_description_id='edit_description'+id.toString();
	var favorite_status_name='favorite_status'+id.toString();
	if(shortname != text){
		document.getElementById(editrowid).innerHTML=("<ul class=\"fts\"><li class=\"fts1\">名称:</li><li class=\"fts2\"><input type=\"hidden\" disabled value=\""+id+"\"/><input type=\"text\" value=\""+shortname+"\" size=\"55\" class=\"t_input\" disabled readonly=\"readonly\"/></li><li class=\"fts1\">详情:</li> <li class=\"fts2\"><textarea readonly=\"readonly\" id=\""+edit_text_id+"\" name=\"edit_text\" rows=\"2\" cols=\"55\" disabled></textarea></li><li class=\"fts1\">描述: </li><li class=\"fts2\"><textarea id=\""+edit_description_id+"\" name=\""+edit_description_id+"\" rows=\"2\" cols=\"55\"></textarea></li><li class=\"fts1\">状态:</li> <li class=\"fts2\"><input type=\"radio\" "+check1+" name=\""+favorite_status_name+"\" value=\"1\"/>公开 <input type=\"radio\" "+check0+" name=\""+favorite_status_name+"\" value=\"0\"/>不公开</li><li class=\"fts3\"><input type=\"button\" value=\"更新\" onclick=\"update_favorite("+id+");document.getElementById('"+editrowid+"').style.display='none';\"  class=\"submit_r\" /> <input type=\"button\"value=\"关闭\" onclick=\"javascript:document.getElementById('"+editrowid+"').style.display='none';\" class=\"button\"></li></ul>");
	}else{
		document.getElementById(editrowid).innerHTML=("<ul class=\"fts\"><li class=\"fts1\">链接: </li><li class=\"fts2\"><textarea readonly=\"readonly\" id=\""+edit_text_id+"\" name=\"edit_text\" rows=\"2\" cols=\"55\" disabled></textarea></li><li class=\"fts1\">描述: </li><li class=\"fts2\"><textarea id=\""+edit_description_id+"\" name=\"edit_description\" rows=\"2\" cols=\"55\"></textarea></li><li class=\"fts1\">状态: </li><li class=\"fts2\"><input type=\"radio\" "+check1+" name=\""+favorite_status_name+"\" value=\"1\"/>公开 <input type=\"radio\" "+check0+" name=\""+favorite_status_name+"\" value=\"0\"/>不公开</li><li class=\"fts3\"><input type=\"button\" value=\"更新\" onclick=\"update_favorite("+id+");document.getElementById('"+editrowid+"').style.display='none';\"  class=\"submit_r\" /> <input type=\"button\"value=\"关闭\" onclick=\"javascript:document.getElementById('"+editrowid+"').style.display='none';\" class=\"button\"></li></ul>");
	}
	document.getElementById(edit_text_id).innerHTML=text;
	document.getElementById(edit_description_id).innerHTML=description;
}
var xmlHttp_updatefavorite=createXmlHttpRequestObject();
function update_favorite(id,type){
	if(type=='del'){
		var url=('sp_source/map_favorite.php?do=del&id='+id);
		xmlHttp_updatefavorite.onreadystatechange=handleupdate_favorite;
		xmlHttp_updatefavorite.open('GET',url,true);
		xmlHttp_updatefavorite.send(null);
	}else{
		var edit_text_id='edit_text'+id.toString();
		var edit_description_di='edit_description'+id.toString();
		var favorite_status_name='favorite_status'+id.toString();
		var update_text=document.getElementById(edit_text_id).value;
		var filter_update_text=escape(filterContentbystr(update_text));
		var update_description=document.getElementById(edit_description_di).value;
		var filter_update_description=escape(filterContentbystr(update_description));
		var status=getRadioBoxValue(favorite_status_name);
		var description_id='description_'+id.toString();
		var status_id='status_'+id.toString();
		document.getElementById(description_id).innerHTML=update_description;
			if(status=='1'){
				document.getElementById(status_id).innerHTML="<img src=\"image/pub1.gif\">";
			}else{
				document.getElementById(status_id).innerHTML="<img src=\"image/pub0.gif\">";
			}
		var url=('sp_source/map_favorite.php?id='+id+'&text='+filter_update_text+'&description='+filter_update_description+'&status='+status);
		xmlHttp_updatefavorite.onreadystatechange=handleupdate_favorite;
		xmlHttp_updatefavorite.open("GET",url,true);
		xmlHttp_updatefavorite.send(null);
	}
}
function handleupdate_favorite(){
	if (xmlHttp_updatefavorite.readyState==4){
		if (xmlHttp_updatefavorite.status==200){
			xmlResponse=xmlHttp_updatefavorite.responseXML;
			var xmlRoot=xmlResponse.documentElement;
			var response=xmlRoot.getElementsByTagName('status');
			var status=0;
			var o='';
			status=response.item(0).firstChild.data;
			if(status=='11'){
				o="<a style=\"display:none;\" id=\"status\" onclick=\"ajaxmenu(event,this.id,99999,'',-1)\"></a>";
				SetInnerHTML('savestatus',o);
				OpenStatusMenu('11');
			}else if(status=='12'){
				o="<a style=\"display:none;\" id=\"status\" onclick=\"ajaxmenu(event,this.id,99999,'',-1)\"></a>";
				SetInnerHTML('savestatus',o);
				OpenStatusMenu('12');
			}
		}else{
			alert('错误： ' + xmlHttp_updatefavorite.statusText);
		}
	}
}
function reporterror(name,x,y){
	if(confirm('您发现错误了吗？')){
		document.getElementById("savestatus").innerHTML="<form name=\"errorreport\">地址:  <input type=\"text\" name=\"error_poiname\" size=\"15\" value=\""+name+"\"><input type=\"hidden\" name=\"error_poix\" readonly=\"readonly\" size=\"5\" value=\""+x+"\"><input type=\"hidden\" readonly=\"readonly\" name=\"error_poiy\" size=\"5\" value=\""+y+"\"><br/>描述:  <input type=\"text\" id=\"error_message\" name=\"error_message\" size=\"50\"><br/><input type=\"button\" onclick=\"save_maperror('"+name+"','"+x+"','"+y+"','maperror');\" value=\"提交\"></form>";
	}
}
function save_maperror(name,x,y,type){
	var filter_name=escape(filterContentbystr(name));
	if(filter_name==''){
		alert('请填写地址！');
		return false;
	}
	var filter_t=escape(filterContentbyid('error_message'));
	if(filter_t==''){
		alert('请填写描述！');
		return false;
	}else{
		document.getElementById('savestatus').innerHTML='';
	}
	var filter_x=filterContentbystr(x);
	var filter_y=filterContentbystr(y);
	var filter_type=filterContentbystr(type);
	var url=('sp_source/map_save.php?type='+filter_type+'&text='+filter_t+'&name='+filter_name+'&x='+filter_x+'&y='+filter_y);
	xmlHttp_save.onreadystatechange=handleSave;
	xmlHttp_save.open('GET',url,true);
	xmlHttp_save.send(null);
}
function reportillegal(windowtype,reporttype){
	var URL=location.href;
	if(windowtype=='newwindow'){
		URL=('report.php?url=' + URL + '&t=' + reporttype);
		window.open(URL);
	}
}
function openWindow(url,type){
	if(type=='newwindow'){
		window.open(url);
	}else if(type=='thiswindow'){
		if(url.indexOf('event.php')>=0||url.indexOf('place.php')>=0){
			if(confirm('确定取消所有已作修改吗？')){
				window.location=url;
			}
		}else{
			window.location=url;
		}
	}else if(type=='self'){
		window.location.reload();
	}
}
function searchhistory(type,action){
	if(type=='thiswindow'){
		if(action=='show'){
			showhistory();
			try{
				document.getElementById('page_num').style.display='none';
			}catch(e){}
		}else if(action=='save'){}
	}
}
function saveHistory(keyword,code1,name1,x1,y1,code2,name2,x2,y2,from){
	if(keyword != 0){
		keyword=escape(filterContentbystr(keyword));
	}
	if(name1 != 0){
		name1=escape(filterContentbystr(name1));
	}
	if(name2 != 0){
		name2=escape(filterContentbystr(name2));
	}
	var url=('sp_source/map_save.php?type=history&keyword='+keyword+'&code1='+code1+'&name1='+name1+'&x1='+x1+'&y1='+y1+'&code2='+code2+'&name2='+name2+'&x2='+x2+'&y2='+y2+'&fr='+from);
	xmlHttp_save.onreadystatechange=handleSave;
	xmlHttp_save.open('GET',url,true);
	xmlHttp_save.send(null);
}
var xmlHttp_history=createXmlHttpRequestObject();
function showhistory(){
	xmlHttp_history.onreadystatechange=handleshowhistory;
	xmlHttp_history.open('GET','sp_source/map_history.php',true);
	xmlHttp_history.send(null);
}
function handleshowhistory(){
	if(xmlHttp_history.readyState==4){
		if(xmlHttp_history.status==200){
			xmlResponse=xmlHttp_history.responseXML;
		  	var xmlRoot=xmlResponse.documentElement;
			var record='';
			var searchlocation=xmlRoot.getElementsByTagName('searchlocation');
			var from_citycode=xmlRoot.getElementsByTagName('from_citycode_searchlocation');
			var keyword=xmlRoot.getElementsByTagName('keyword');
			var record_searchlocation='';
			if(searchlocation.length>0){
				for (var i=0;i<searchlocation.length;i++){
					var cityname=GetCitynameThroughCitycode(from_citycode.item(i).firstChild.data);
					record_searchlocation+=("<a href=\"javascript:searchByKeyword('"+from_citycode.item(i).firstChild.data+'\',\''+keyword.item(i).firstChild.data+"');\">在 "+cityname+' 查找 '+keyword.item(i).firstChild.data+'</a><br/>-----------<br/>');
				}
			}
		 	var searcharound=xmlRoot.getElementsByTagName('searcharound');
			var from_citycode=xmlRoot.getElementsByTagName('from_citycode_searcharound');
			var from_x=xmlRoot.getElementsByTagName('from_x_searcharound');
			var from_y=xmlRoot.getElementsByTagName('from_y_searcharound');
			var name1=xmlRoot.getElementsByTagName('name1_searcharound');
			var name2=xmlRoot.getElementsByTagName('name2_searcharound');
			var record_searcharound='';
			if(searcharound.length>0){
				for (var i=0;i<searcharound.length;i++){
					var name2_trans='';
					try{
						name2_trans=name2.item(i).firstChild.data;
						if(name2_trans=='null'){
							name2_trans='全部';
						}
					}catch(e){}
					var cityname=GetCitynameThroughCitycode(from_citycode.item(i).firstChild.data);
					record_searcharound+=("<a href=\"javascript:SearchAround('"+from_citycode.item(i).firstChild.data+"','"+name2_trans+"','"+from_x.item(i).firstChild.data+"','"+from_y.item(i).firstChild.data+"');\">在 "+cityname+' 中心点 '+name1.item(i).firstChild.data+'('+from_x.item(i).firstChild.data+','+from_y.item(i).firstChild.data+') 查找: '+name2_trans+'</a><br/>-----------<br/>');
		      	}
			}
			var searchbus=xmlRoot.getElementsByTagName('searchbus');
			var from_citycode=xmlRoot.getElementsByTagName('from_citycode_searchbus');
			var from_x=xmlRoot.getElementsByTagName('from_x_searchbus');
			var from_y=xmlRoot.getElementsByTagName('from_y_searchbus');
			var to_x=xmlRoot.getElementsByTagName('to_x_searchbus');
			var to_y=xmlRoot.getElementsByTagName('to_y_searchbus');
			var name1=xmlRoot.getElementsByTagName('name1_searchbus');
			var name2=xmlRoot.getElementsByTagName('name2_searchbus');
			var record_searchbus='';
			if(searchbus.length>0){
				for (var i=0;i<searchbus.length;i++){
					var cityname=GetCitynameThroughCitycode(from_citycode.item(i).firstChild.data);
					record_searchbus+=("<a href=\"javascript:searchbus('"+from_citycode.item(i).firstChild.data+"','"+from_x.item(i).firstChild.data+"','"+from_y.item(i).firstChild.data+"','"+to_x.item(i).firstChild.data+"','"+to_y.item(i).firstChild.data+"','"+name1.item(i).firstChild.data+"','"+name2.item(i).firstChild.data+"');\">在 "+cityname+' 从 '+name1.item(i).firstChild.data+'('+from_x.item(i).firstChild.data+','+from_y.item(i).firstChild.data+')'+' 到 '+name2.item(i).firstChild.data+' ('+to_x.item(i).firstChild.data+','+to_y.item(i).firstChild.data+') '+'</a><br/>-----------<br/>');
			      }
			}
			var searchdrive=xmlRoot.getElementsByTagName('searchdrive');
			var from_citycode=xmlRoot.getElementsByTagName('from_citycode_searchdrive');
			var to_citycode=xmlRoot.getElementsByTagName('to_citycode_searchdrive');
			var from_x=xmlRoot.getElementsByTagName('from_x_searchdrive');
			var from_y=xmlRoot.getElementsByTagName('from_y_searchdrive');
			var to_x=xmlRoot.getElementsByTagName('to_x_searchdrive');
			var to_y=xmlRoot.getElementsByTagName('to_y_searchdrive');
			var name1=xmlRoot.getElementsByTagName('name1_searchdrive');
			var name2=xmlRoot.getElementsByTagName('name2_searchdrive');
			var record_searchdrive='';
			var begin='<div><div class="msri"><b>搜索历史:</b></div>';
			var end='</div>';
			if(searchdrive.length>0){
				for (var i=0;i<searchdrive.length;i++){
				var cityname=GetCitynameThroughCitycode(from_citycode.item(i).firstChild.data);
				var cityname2=GetCitynameThroughCitycode(to_citycode.item(i).firstChild.data);
				record_searchdrive+=("<a href=\"javascript:searchdrive('"+from_x.item(i).firstChild.data+"','"+from_y.item(i).firstChild.data+"','"+to_x.item(i).firstChild.data+"','"+to_y.item(i).firstChild.data+"','"+from_citycode.item(i).firstChild.data+"','"+name1.item(i).firstChild.data+"','"+name2.item(i).firstChild.data+"');\">在 "+cityname+' 从 '+name1.item(i).firstChild.data+'('+from_x.item(i).firstChild.data+','+from_y.item(i).firstChild.data+')'+' 到 '+cityname2+' '+name2.item(i).firstChild.data+' ('+to_x.item(i).firstChild.data+','+to_y.item(i).firstChild.data+') '+'</a><br/>-----------<br/>');
			     }
			}
			if((record_searchlocation + record_searcharound + record_searchbus + record_searchdrive)==''){
				document.getElementById('ssresult').innerHTML='<div><div class="msri"><b>搜索历史:</b></div>你还没有进行过搜索.</div>';
			}else{
				document.getElementById('ssresult').innerHTML=(begin + record_searchlocation + record_searcharound + record_searchbus + record_searchdrive + end);
			}
		}else{
			alert('错误： ' + xmlHttp_history.statusText);
		}
	}
}
function setfocusStyle(id){
    document.getElementById(id).style.background='white';
	if(id=='tag'){
		setHdtag();
	}else if(id=='holdsearchinputbox'){
		if(document.hold.keyword.value=='请输入关键字。。。'){
			document.hold.keyword.value='';
		}
	}
}
function setblurStyle(id){
    document.getElementById(id).style.background='#F7F7F7';
	if(id=='holdsearchinputbox'){
		if(document.hold.keyword.value==''){
			document.hold.keyword.value='请输入关键字。。。';
		}
	}
}
function strNotInHdTag(str){
    var value=GetObjValue('tag');
	if(value.indexOf(str)==-1){
		return true;
	}else{
		return false;
	}
}
function hiddendiv(id){
	document.getElementById(id).innerHTML='';
	document.getElementById(id).style.display='none';
}
function drawPoint(x,y,tag,name,address,startdate,enddate,userspace,username,id,pic,uppic,hdlink,membernum,moveable,icontype){
	if(moveable==0){
		var sContent='';
		var centerPoint;
		var centerPointStyle=new MStyle();
		centerPointStyle.lineColor=0xff230b;
		centerPointStyle.lineSize=2;
		centerPointStyle.fillColor=0xffffff;
		centerPointStyle.fillOpacity=100;
		centerPointStyle.labelColor=0xffffff;
		centerPointStyle.isShowLabels=false;
		centerPointStyle.isShowTip=true;
		centerPointStyle.textSize=13;
		centerPointStyle.isLabelsFontBold=false;
		centerPointStyle.backgroundColor=0xff230b;
		centerPointStyle.isLabelsBackground=false;
		centerPointStyle.textColor=0xffffff;
		if(name != '' && !uppic && !id){
			sContent+=name;
		}
		if(tag != ''){
			sContent+='<br>' + tag;
		}
		if(address != ''){
			sContent+='<br>' + address;
		}
		if(startdate != ''){
			sContent+='<br>开始时间：' + startdate;
		}
		if(enddate != ''){
			sContent+='<br>结束时间：' + enddate;
		}
		if(userspace != ''){
			sContent+='<br>' + userspace;
		}
		if(uppic){
			sContent+='<br/>' + uppic;
		}
		try{
			addressAction('test');
			sContent+="<a href=\"javascript:addressAction(1);\">到此处</a>  ";
			sContent+="<a href=\"javascript:addressAction(2);\">从此处去</a>  ";
			sContent+="<a href=\"javascript:addressAction(3);\">周边</a>  ";
			sContent+="<a href=\"javascript:addressAction(4);\">收藏</a>  ";
		}catch(e){}
		centerPointStyle.textContent=sContent;
		var icon=pic;
		var thisURL=location.href;
		if(icontype=='0'){
			icon=sp_imageURL+'default.png';
		}else if(icontype=='1'){
			icon=sp_imageURL+'dine.png';
		}else if(icontype=='2'){
			icon=sp_imageURL+'wild.png';
		}else if(icontype=='3'){
			icon=sp_imageURL+'show.png';
		}else if(icontype=='4'){
			icon=sp_imageURL+'exhibit.png';
		}else if(icontype=='5'){
			icon=sp_imageURL+'music.png';
		}else if(icontype=='6'){
			icon=sp_imageURL+'salon.png';
		}else if(icontype=='7'){
			icon=sp_imageURL+'gym.png';
		}else if(icontype=='8'){
			icon=sp_imageURL+'gongyi.png';
		}
		centerPoint=new MCustomPointOverlay(new MLatLng(x,y),icon,centerPointStyle,id);
		mapObj.addOverlay(centerPoint,true);
	}else if(moveable==1){
		if(id==''){
			var centerPoint=new MDragablePointWithoutTip(new MLatLng(x,y),new MStyle(),1000);
			mapObj.addOverlay(centerPoint,true);
		}else{
			var centerPoint=new MDragablePointWithoutTip(new MLatLng(x,y),new MStyle(),id);
			mapObj.addOverlay(centerPoint,true);
		}
	}
}
function checkFileType(obj){  
  var typeValue=obj.value;
  var type=typeValue.substring(typeValue.lastIndexOf('\\')+1,typeValue.length);
  type=type.substring(type.lastIndexOf('\.')+1,type.length);
  if (type.toUpperCase()=='GIF'||type.toUpperCase()=='JPG'||type.toUpperCase()=='PNG'){return true;}
  else{
	alert('对不起，不支持此类扩展名的图片。');
	obj.parentNode.innerHTML=obj.parentNode.innerHTML;
	return false;
  }
}
function ckAllCheckbox(a,b){
    var objForm=document.forms[a];
    var objLen=objForm.length;
    for(var iCount=0;iCount<objLen;iCount++){
        if(b.checked==true){
			if(objForm.elements[iCount].type=='checkbox'){
				objForm.elements[iCount].checked=true;
			}
		}else{
			if(objForm.elements[iCount].type=='checkbox'){
				objForm.elements[iCount].checked=false;
			}
		}
	}
}
function ckCheckbox(a,b){
	var objForm=document.forms[a];
	var objLen=objForm.length;
	var num=0;
	for(var iCount=0;iCount<objLen;iCount++){
		if(b.checked==false){
			document.getElementById('chk').checked=false;
		}else{
			if(objForm.elements[iCount].type=='checkbox'){
				if(objForm.elements[iCount].checked==true){
					num+=1;
				}
			}
		}
	}
	if((num+3)==objLen){
		document.getElementById('chk').checked=true;
	}
}
function GetCheckboxValue(checkbox){
	if(!checkbox.length&&checkbox.type.toLowerCase()=='checkbox'){
		return (checkbox.checked)?checkbox.value:'';
	}
	if(checkbox[0].tagName.toLowerCase()!='input'||checkbox[0].type.toLowerCase()!='checkbox'){
		return '';
	}
	var r='';
	var len=checkbox.length;
	for(i=0;i<len;i++){
		if(checkbox[i].checked){
			r+=(checkbox[i].value+',');
		}
	}
	return r;
}
function setAllCode4MapSearch(code){
	document.getElementById('searchkeyword_city').value=code;
	document.getElementById('searcharound_city').value=code;
	document.getElementById('searchbus_city').value=code;
	document.getElementById('searchdrive_startcity').value=code;
	document.getElementById('searchdrive_endcity').value=code;
}
function ext_fill(type,x,y,code,poiname,from){
	var pointname='我设置的点';
	if(poiname!=''){
		pointname=poiname;
	}
	if(code==''){
		code=document.getElementById('sp_hd_hold_drawpointreturntelnum').value;
	}
	if(code != ''){
		setAllCode4MapSearch(code);
	}
	if(type==1){
		document.getElementById('searchbus_startx').value='';
		document.getElementById('searchbus_starty').value='';
		document.getElementById('searchdrive_startx').value='';
		document.getElementById('searchdrive_starty').value='';
		SwitchSearchPanel('ss');
		document.getElementById('ss').style.display='';
		if(from=='local'){
			document.getElementById('ext').style.display='';
			document.getElementById('ss').style.display='none';
		}
		var html="<table cellspacing=\"2\" cellpadding=\"2\" width=\"100%\"><tr><td>从: <input name=\"cong\" id=\"cong\" size=\"20\" value=\"\" /></td></tr><tr><td>到: <input name=\"dao\" id=\"dao\" size=\"20\" value=\""+pointname+"\" /></td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"button\" class=\"submit\" value=\"公交\" onclick=\"settransfer('bus',1,'"+x+"','"+y+"','"+code+"','"+pointname+"');\">&nbsp;&nbsp;<input type=\"button\" value=\"自驾\" class=\"submit\" onclick=\"settransfer('drive',1,'"+x+"','"+y+"','"+code+"','"+pointname+"');\"></td></tr></table>";
		document.getElementById('ext').innerHTML=html;
	}else if(type==2){
		document.getElementById('searchbus_endx').value='';
		document.getElementById('searchbus_endy').value='';
		document.getElementById('searchdrive_endx').value='';
		document.getElementById('searchdrive_endy').value='';
		SwitchSearchPanel('ss');
		document.getElementById('ss').style.display='';
		if(from=='local'){
			document.getElementById('ext').style.display='';
			document.getElementById('ss').style.display='none';
		}
		var html="<table cellspacing=\"2\" cellpadding=\"2\" width=\"100%\"><tr><td>从: <input name=\"cong\" id=\"cong\" size=\"20\" value=\""+pointname+"\" /></td></tr><tr><td>到: <input name=\"dao\" id=\"dao\" size=\"20\" value=\"\" /></td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"button\" class=\"submit\" value=\"公交\" onclick=\"settransfer('bus',0,'"+x+"','"+y+"','"+code+"','"+pointname+"');\">&nbsp;&nbsp;<input type=\"button\" class=\"submit\" value=\"自驾\" onclick=\"settransfer('drive',0,'"+x+"','"+y+"','"+code+"','"+pointname+"');\"></td></tr></table>";
		document.getElementById('ext').innerHTML=html;
	}else if(type==3){
		SwitchSearchPanel('zb');
		document.getElementById('page_num_zb_cent').style.display='none';
		document.getElementById('page_num_zb').style.display='';
		document.map.searcharound_poi.value=pointname;
		document.getElementById('searcharound_poix').value=x;
		document.getElementById('searcharound_poiy').value=y;
		document.map.searcharound_city.value=code;
		SearchAround();
	}
}
function settransfer(searchtype,tohere,x,y,code,poiname){
	if(searchtype=='bus'){
		if(tohere==1){
			try{
				document.getElementById('cong').value=document.getElementById('from_poi_popup').value;
			}catch(e){}
			if(document.getElementById('cong').value==''){
				alert('请输入起点关键字！');
				return false;
			}else{
				try{
				hideMenu();
				}catch(e){}
				document.map.searchbus_end_name.value=poiname;
				document.map.searchbus_endx.value=x;
				document.map.searchbus_endy.value=y;
				if(code != ''){
					document.map.searchbus_city.value=code;
				}
				document.map.searchbus_start_name.value=document.getElementById('cong').value;
				SwitchSearchPanel('gj');
				document.getElementById('searchbus_end_name').disabled=true;
				searchbusstartandend();
			}
		}else if(tohere==0){
			try{
				document.getElementById('dao').value=document.getElementById('to_poi_popup').value;
			}catch(e){}
			if(document.getElementById('dao').value==''){
				alert('请输入终点关键字！');
				return false;
			}else{
				try{
				hideMenu();
				}catch(e){}
				document.map.searchbus_start_name.value=poiname;
				document.map.searchbus_startx.value=x;
				document.map.searchbus_starty.value=y;
				if(code != ''){
					document.map.searchbus_city.value=code;
				}
				document.map.searchbus_end_name.value=document.getElementById('dao').value;
				document.getElementById('searchbus_start_name').disabled=true;
				SwitchSearchPanel('gj');
				searchbusstartandend();
			}
		}
	}else if(searchtype=='drive'){
		if(tohere==1){
			try{
				document.getElementById('cong').value=document.getElementById('from_poi_popup').value;
			}catch(e){}
			if(document.getElementById('cong').value==''){
				alert('请输入起点关键字！');
				return false;
			}else{
				try{
					hideMenu();
				}catch(e){}
				document.map.searchdrive_end_name.value=poiname;
				document.map.searchdrive_endx.value=x;
				document.map.searchdrive_endy.value=y;
				document.map.searchdrive_startcity.value=code;
				document.map.searchdrive_start_name.value=document.getElementById('cong').value;
				document.getElementById('searchdrive_end_name').disabled=true;
				SwitchSearchPanel('zj');
				searchdrivestartandend();
			}
		}else if(tohere==0){
			try{
				document.getElementById('dao').value=document.getElementById('to_poi_popup').value;
			}catch(e){}
			if(document.getElementById('dao').value==''){
				alert('请输入终点关键字！');
				return false;
			}else{
				try{
				hideMenu();
				}catch(e){}
				document.map.searchdrive_start_name.value=poiname;
				document.map.searchdrive_startx.value=x;
				document.map.searchdrive_starty.value=y;
				document.map.searchdrive_startcity.value=code;
				document.map.searchdrive_end_name.value=document.getElementById('dao').value;
				document.getElementById('searchdrive_start_name').disabled=true;
				SwitchSearchPanel('zj');
				searchdrivestartandend();
			}
		}
	}
	return true;
}
function changesearchbar(page,cityname){
	if(page=='edit'){
		var c=search_type(cityname);
		document.hold.citycode.value=(c.split(','))[1];
		movetocity((c.split(','))[2],(c.split(','))[3]);
	}else if(page=='map'){
		var c=search_type(cityname);
		var citycode=(c.split(','))[1];
		setAllCode4MapSearch(citycode);
		document.getElementById('city').value=cityname;
		try{
			document.getElementById('temp_drive_start').value=cityname;
			document.getElementById('drive_end_city').value=cityname;
		}catch(e){}
		movetocity((c.split(','))[2],(c.split(','))[3]);
	}else if(page=='eventlist'){
		try{
			var c=search_type(cityname);
			movetocity((c.split(','))[2],(c.split(','))[3]);
		}catch(e){}
		try{
			try{
				document.getElementById('resideprovince').value=document.getElementById('city').value;
			}catch(e){}
			document.getElementById('hidplace').value=document.getElementById('resideprovince').value;
			gotoListPage('city_week','');
		}catch(e){}
	}
}
function movetocity(x,y){mapObj.setCenterByLatLng(y,x);}
function changemyplace(){
	var o=document.getElementById('changecity');
	if(o.style.display=='block'){
		o.style.display='none';
	}else{
		o.style.display='block';
	}
}
function gotoListPage(type,obj,fid,keyword,cid,login,place_init){
	var place=document.getElementById('hidplace').value;
	if(place_init+''=='undefined'){
		place_init='';
	}
	if(place_init!=''){
		place=place_init;
	}
	if(obj!=''){
		objcitySubMenu=document.getElementById('citySubMenu');
		objmineSubMenu=document.getElementById('mineSubMenu');
		var menus=document.getElementsByTagName('li');
		for(i=0;i<menus.length;i++){
			if(menus[i].name=='menu_li'){	
				if(type==menus[i].id){
					menus[i].className='active';
				}else{
					menus[i].className='';
				}
			}
		}
		if(type.indexOf('city')>=0){
			objcitySubMenu.style.display='block';
			objmineSubMenu.style.display='none';
			SwitchHDListMenu('cityMenu',type);
			ajaxget('do.php?ac=ajax&op=friendhdlist&viewnum=5&ajaxdiv=list_right','list_right');
		}else if(type.indexOf('mine')>=0){
			objcitySubMenu.style.display='none';
			objmineSubMenu.style.display='block';
			SwitchHDListMenu('mineMenu',type);
		}else if(type=='friends'){
			ajaxget('do.php?ac=ajax&op=hothdlist&viewnum=5&ajaxdiv=list_right','list_right');
			objcitySubMenu.style.display='none';
			objmineSubMenu.style.display='none';
			SetObjClassName('cityMenu','');
			SetObjClassName('mineMenu','');
			SetObjClassName('friendsMenu','active');
		}
		obj.parentNode.className='active';
	}else if(type=='category'||type=='tag'||type=='search'){
		document.getElementById('citySubMenu').style.display='none';
		document.getElementById('mineSubMenu').style.display='none';
		SetObjClassName('cityMenu','');
	}
	if(fid+''=='undefined'){fid='';}
	if(cid+''=='undefined'){cid='';}
	if(keyword+''=='undefined'){keyword='';}
	if(fid==''&&cid==''&&keyword==''){document.getElementById('subname').innerHTML='';}
	ajaxget('do.php?ac=ajax&op=hdlist&type='+type+'&id='+fid+'&cid='+cid+'&key='+encodeURIComponent(keyword)+'&place='+encodeURIComponent(place)+'&ajaxdiv=list_body','list_body');
	if(type.indexOf('mine')>=0){
		if(login=='1'){
			ajaxget('do.php?ac=ajax&op=friendhdlist&viewnum=5&ajaxdiv=list_right','list_right');
		}
	}
	window.scrollTo(0,0);
}
function setReside(){
	var o=encodeURIComponent(document.getElementById('city').value);
	ajaxget('do.php?ac=ajax&op=setresideplace&province='+o+'&city='+o+'&ajaxdiv=labsetasresidereturn','labsetasresidereturn');
	document.getElementById('labsetresideplace').style.display='none';
}
function SwitchHDListMenu(t,st){
	if(t=='cityMenu'){
		SetObjClassName('cityMenu','active');
		SetObjClassName('mineMenu','');
		SetObjClassName('friendsMenu','');
	}else if(t=='mineMenu'){
		SetObjClassName('cityMenu','');
		SetObjClassName('mineMenu','active');
		SetObjClassName('friendsMenu','');
	}else if(t=='friendsMenu'){
		SetObjClassName('cityMenu','');
		SetObjClassName('mineMenu','');
		SetObjClassName('friendsMenu','active');
	}
	if(st=='city_today'){
		SetObjClassName('city_today','active');
		SetObjClassName('city_week','');
		SetObjClassName('city_month','');
		SetObjClassName('city_all','');
	}else if(st=='city_week'){
		SetObjClassName('city_today','');
		SetObjClassName('city_week','active');
		SetObjClassName('city_month','');
		SetObjClassName('city_all','');
	}else if(st=='city_month'){
		SetObjClassName('city_today','');
		SetObjClassName('city_week','');
		SetObjClassName('city_month','active');
		SetObjClassName('city_all','');
	}else if(st=='city_all'){
		SetObjClassName('city_today','');
		SetObjClassName('city_week','');
		SetObjClassName('city_month','');
		SetObjClassName('city_all','active');
	}else if(st=='mine_now'){
		SetObjClassName('mine_now','active');
		SetObjClassName('mine_self','');
		SetObjClassName('mine_intent','');
		SetObjClassName('mine_pass','');
	}else if(st=='mine_intent'){
		SetObjClassName('mine_intent','active');
		SetObjClassName('mine_now','');
		SetObjClassName('mine_self','');
		SetObjClassName('mine_pass','');
	}else if(st=='mine_pass'){
		SetObjClassName('mine_pass','active');
		SetObjClassName('mine_now','');
		SetObjClassName('mine_self','');
		SetObjClassName('mine_intent','');
	}else if(st=='mine_self'){
		SetObjClassName('mine_self','active');
		SetObjClassName('mine_now','');
		SetObjClassName('mine_intent','');
		SetObjClassName('mine_pass','');
	}
} 
