var mapObjSearch,ishide,gdok,extdiv,extdiv1,extdiv2,csp,cep,cmode,cinfo,mx=110.6,my=33.5,mz=5,iscookie,cityname;function getWindowHeight(){if(window.self&&self.innerHeight)return self.innerHeight;if(document.documentElement&&document.documentElement.clientHeight)return document.documentElement.clientHeight;return 0}function mapresize(){var a=getWindowHeight(),b=a-130;document.getElementById("map").style.height=b+"px";if(ishide==1&&gdok==1)extdiv2.style.height=a-210+"px"}
function load(){mapresize();extdiv=document.getElementById("rightbar");extdiv1=document.getElementById("sharediv");extdiv2=document.getElementById("guidediv");var a=new MMapOptions;a.zoom=mz;a.center=new MLngLat(mx,my);a.toolbar=DEFAULT;a.toolbarPos=new MPoint(0,0);a.overviewMap=SHOW;a.scale=SHOW;a.zoomBox=!0;a.returnCoordType=COORD_TYPE_OFFSET;a.isCongruence=!0;a.hasDefaultMenu=!0;mapObjSearch=new MMap("map",a);if(iscookie==1&&(cityname=getCookie("cityname"),cityname!=null))document.getElementById("city").value=
cityname}var startX=null,startY=null,endX=null,endY=null;
function getStartXY(){var a=document.getElementById("city").value;if(a.length<2)return alert("\u8bf7\u8f93\u5165\u60a8\u6240\u5728\u57ce\u5e02\u7684\u540d\u79f0\u6216\u533a\u53f7\uff0c\u4f8b\u5982\u5317\u4eac\u3001\u4e0a\u6d77\u3001\u5e7f\u5dde\u3001\u897f\u5b89\u7b49\u7b49\u3002"),!1;setcity(a);var b=document.getElementById("skey").value;csp=b;gdok=0;var d=new MLocalSearch,e=new MLocalSearchOptions;e.recordsPerPage=1;d.setCallbackFunction(myfunc);d.poiSearchByKeywords(b,a,e)}
var markerOptions=new MMarkerOptions,pointsearch;function myfunc(a){if(typeof a.error_message!="undefined")alert(a.error_message);else{if(typeof a.poilist[0]=="undefined")return alert("\u60a8\u8f93\u5165\u7684\u8857\u8def\u5730\u5740\u6709\u8bef\uff0c\u8bf7\u4fee\u6b63\u540e\u91cd\u65b0\u63d0\u4ea4\u67e5\u8be2\u3002"),!1;startX=a.poilist[0].x;startY=a.poilist[0].y;getEndXY()}}
function getEndXY(){var a=document.getElementById("city").value,b=document.getElementById("ekey").value;csp=csp+"+"+b+"+"+a;var d=new MLocalSearch,e=new MLocalSearchOptions;e.recordsPerPage=1;d.setCallbackFunction(myfunc1);d.poiSearchByKeywords(b,a,e)}var pointsearch1;
function myfunc1(a){if(typeof a.error_message!="undefined")alert(a.error_message);else{if(typeof a.poilist[0]=="undefined")return alert("\u60a8\u8f93\u5165\u7684\u8857\u8def\u5730\u5740\u6709\u8bef\uff0c\u8bf7\u4fee\u6b63\u540e\u91cd\u65b0\u63d0\u4ea4\u67e5\u8be2\u3002"),!1;endX=a.poilist[0].x;endY=a.poilist[0].y}routSearchByStartXYAndEndXY()}
function routSearchByStartXYAndEndXY(){var a=document.getElementById("city").value,b=new MRoutSearch,d=new MRoutSearchOptions;b.setCallbackFunction(myfunc3);b.routSearchByStartXYAndEndXY("bus",new MLngLat(startX,startY),new MLngLat(endX,endY),a,d)}var xy_array=[],xy_c_array=[];
function myfunc3(a){var b=a.count,d="\u5171\u67e5\u627e\u5230<b>"+b+"</b>\u6761\u516c\u4ea4\u6362\u4e58\u8def\u7ebf\u65b9\u6848\uff0c\u8be6\u60c5\u5982\u4e0b\uff1a<br/><br/>";if(typeof a.busList=="undefined"||b<1)return alert("\u6ca1\u67e5\u5230\u5408\u9002\u7684\u6362\u4e58\u8def\u7ebf\uff0c\u53ef\u80fd\u662f\u8857\u8def\u5730\u5740\u4e0d\u51c6\u786e\uff0c\u8bf7\u4fee\u6b63\u540e\u91cd\u65b0\u63d0\u4ea4\u67e5\u8be2\u3002"),!1;for(b=0;b<a.busList.length;b++){for(var e="",h="",c="",f=a.busList[b].segmentList.length,
i=0;i<f;i++){var g=a.busList[b].segmentList[i].passDepotName,g=a.busList[b].segmentList[i].passDepotName.split(" "),g=g.length+1;c+="\u6b65\u884c"+Getdistance(a.busList[b].segmentList[i].footLength)+"\u5230"+a.busList[b].segmentList[i].startName+"\uff0c\u5728\u8f66\u7ad9\u4e58\u5750"+a.busList[b].segmentList[i].busName+"\u9014\u7ecf"+g+"\u7ad9\uff0c\u5728"+a.busList[b].segmentList[i].endName+"\u4e0b\u8f66\u3002";i==0?(g=a.busList[b].segmentList[i].coordinateList.split(","),h+=g[g.length-2]+","+g[g.length-
1]+","):i+1!=f?(g=a.busList[b].segmentList[i].coordinateList.split(","),h+=g[0]+","+g[1]+","+g[g.length-2]+","+g[g.length-1]+","):(g=a.busList[b].segmentList[i].coordinateList.split(","),h+=g[0]+","+g[1]+",");e+=a.busList[b].segmentList[i].coordinateList+",";f==1&&(h="")}xy_c_array[b]=h;xy_array[b]=e;d+="<b>\u7b2c"+(b+1)+"\u6761\u8def\u7ebf\uff1a</b><br />"+c+"<br /><br />"}extdiv2.innerHTML=d;a=getWindowHeight()-210;extdiv2.style.height=a+"px";gdok=1;cinfo=d;cmode="201";if(ishide!=1)extdiv2.style.visibility=
"visible",extdiv.innerHTML=" ",extdiv1.innerHTML='<center><a href="javascript:void(0)" onclick="return shareguide()" title="\u6536\u85cf\u5206\u4eab\u5f53\u524d\u8def\u7ebf\u5730\u56fe"><img border="0" src="http://www.ditu6.com/style/share.gif" /></a></center><br />',ishide=1;drawline2(0)}function Getdistance(a){return a<=1E3?a+"\u7c73":(a=Math.round(a/1E3),"\u7ea6"+a+"\u516c\u91cc")}
function drawline2(){mapObjSearch.removeAllOverlays();var a=[],b=new MMarkerOptions;b.imageUrl="http://www.ditu6.com/bus/style/start.png";b.picAgent=!0;b.isDraggable=!1;var d=new MLngLat(startX,startY),b=new MMarker(d,b);b.id="startid";a.push(b);b=new MMarkerOptions;b.imageUrl="http://www.ditu6.com/bus/style/end.png";b.picAgent=!0;b.isDraggable=!1;d=new MLngLat(endX,endY);b=new MMarker(d,b);b.id="endid";a.push(b);mapObjSearch.addOverlays(a,!0);cep=startX+"+"+startY+"+"+endX+"+"+endY}
function doshare(){gdok==1?(document.share.ssp.value=csp,document.share.sep.value=cep,document.share.smode.value=cmode,document.share.sinfo.value=cinfo,document.share.submit()):alert("\u51fa\u9519\u5566\uff01\u6ca1\u6709\u8def\u7ebf\u5730\u56fe\u53ef\u4ee5\u88ab\u4fdd\u5b58\u3002")}function shareguide(){doshare()}window.onresize=function(){mapresize()};function BusLineSearch(){}var busSL=new BusLineSearch,mrs;
function busSearch(){busSL.busCity=document.getElementById("city").value;busSL.busName=document.getElementById("busname").value;csp=busSL.busCity;cep=busSL.busName;cinfo="202";gdok=0;if(busSL.busCity=="")return alert("\u8bf7\u8f93\u5165\u60a8\u6240\u5728\u57ce\u5e02\u7684\u540d\u79f0\u6216\u533a\u53f7\uff0c\u4f8b\u5982\u5317\u4eac\u3001\u4e0a\u6d77\u3001\u5e7f\u5dde\u3001\u897f\u5b89\u7b49\u7b49\u3002"),!1;if(busSL.busName=="")return alert("\u8bf7\u8f93\u5165\u516c\u4ea4\u7ebf\u8def\u540d\u79f0\uff0c\u598212\u3001103\u3001\u65b0\u533a2\u7ebf\u7b49"),
!1;mrs=new MBusSearch;var a=new MBusSearchOptions;a.recordsPerPage=20;a.pageNum=1;a.resData=1;mrs.setCallbackFunction(busNameSearch_CallBack);mrs.busSearchByBusName(busSL.busName,busSL.busCity,a)}
function busNameSearch_CallBack(a){var b="";if(a.error_message!=null)return b="\u67e5\u8be2\u5f02\u5e38\uff01"+a.error_message,alert(b),!1;else{switch(a.message){case "ok":busSL.busline_xy=[];busSL.busline_poi=[];var d=a.list.length;resultCount=d;if(d!=0){var e="",h="";end_time="";for(var c=0;c<d;c++){e+='<div style="cursor:pointer;color:#3366CC;" id="busline_table'+a.list[c].line_id+'" onclick="drawbusLine(\''+a.list[c].line_id+"','"+c+"')\"><b>  \u25ba "+a.list[c].name+'</b></div><dl style="display:none" id="busline_id'+
c+'">';h=typeof a.list[c].start_time=="undefined"?"":a.list[c].start_time.substring(0,2)+":"+a.list[c].start_time.substring(2,4);end_time=typeof a.list[c].end_time=="undefined"?"":a.list[c].end_time.substring(0,2)+":"+a.list[c].end_time.substring(2,4);e+=h==""||end_time==""?"<dt><b>\u5168\u957f\uff1a</b>"+a.list[c].length+"\u516c\u91cc;</dt>":"<dt><b>\u9996\u672b\u8f66\u65f6\u95f4\uff1a</b>"+h+"-"+end_time+"<br /><b>\u5168\u957f\uff1a</b>"+a.list[c].length+"\u516c\u91cc</dt>";for(var h=[],h=mrs.getAllBusStations(a.list[c].stationdes,
0),f=h.length,i="",g=0;g<f;g++){var j=h[g].split(";");e+=g==0?"<b>\u9014\u5f84\u7ad9\u70b9\uff1a</b><a href=\"javascript:drawSinglePoi('"+j[1]+"','"+j[2]+"','"+j[3]+"','"+j[0]+"','"+a.list[c].name+"')\">"+j[0]+"</a>":"\uff0c<a href=\"javascript:drawSinglePoi('"+j[1]+"','"+j[2]+"','"+j[3]+"','"+j[0]+"','"+a.list[c].name+"')\">"+j[0]+"</a>";i+=j[1]+";"+j[2]+";"+j[3]+";"+j[0]+";"+a.list[0].name+","}e+="</dl>";busSL.busline_xy[a.list[c].line_id]=a.list[c].xys+",";busSL.busline_poi[a.list[c].line_id]=
i}b+=e;extdiv2.innerHTML=b;b=getWindowHeight()-210;extdiv2.style.height=b+"px";gdok=1;cmode="202";if(ishide!=1)extdiv2.style.visibility="visible",extdiv.innerHTML=" ",extdiv1.innerHTML='<center><a href="javascript:void(0)" onclick="shareguide();" title="\u6536\u85cf\u5206\u4eab\u5f53\u524d\u8def\u7ebf\u5730\u56fe"><img border="0" src="http://www.ditu6.com/style/share.gif" /></a></center><br />',ishide=1;setcity(csp)}else return alert("\u6ca1\u6709\u627e\u5230\u8be5\u7ebf\u8def\u4fe1\u606f\uff0c\u8bf7\u68c0\u67e5\u7ebf\u8def\u540d\u79f0\u662f\u5426\u8f93\u5165\u6b63\u786e\u3002"),
!1;break;case "error":return alert("\u7f51\u7edc\u7e41\u5fd9\uff0c\u8bf7\u7a0d\u540e\u91cd\u8bd5\u3002"),!1;default:return alert("\u7f51\u7edc\u7e41\u5fd9\uff0c\u8bf7\u7a0d\u540e\u91cd\u8bd5\u3002"),!1}drawbusLine(a.list[0].line_id,"0")}}function removeAllOverlays(){mapObjSearch.removeAllOverlays()}
function drawbusLine(a,b){removeAllOverlays();for(var d=0;d<resultCount;d++)document.getElementById("busline_id"+d).style.display="none";document.getElementById("busline_id"+b).style.display="";for(var d=[],e=busSL.busline_xy[a].split(","),h=e.length-2,c=0;c<h;c+=2)d.push(new MLngLat(e[c],e[c+1]));e=new MLineOptions;e.lineStyle.thickness=6;e.lineStyle.color=23733;e.lineStyle.alpha=0.8;d=new MPolyline(d,e);mapObjSearch.addOverlay(d,!0)}
function drawSinglePoi(a,b,d,e,h){mapObjSearch.removeOverlayById(busSL.buslin_pointid);busSL.buslin_pointid=d+1;var c=new MMarkerOptions;c.imageUrl="http://code.mapabc.com/images/point.png";var f=new MTipOptions;f.title=e;f.content="<br>\u6240\u5c5e\u7ebf\u8def\uff1a"+h+"<br>\u7ad9\u70b9\u5e8f\u53f7\uff1a\u7b2c"+d+"\u7ad9";f.borderStyle.thickness=2;f.borderStyle.color=23733;f.borderStyle.alpha=1;f.titleFontStyle.name="Arial";f.titleFontStyle.size=12;f.titleFontStyle.color=16777215;f.titleFontStyle.bold=
!0;f.contentFontStyle.name="Arial";f.contentFontStyle.size=13;f.contentFontStyle.color=0;f.contentFontStyle.bold=!1;f.fillStyle.color=16777215;f.fillStyle.alpha=1;f.titleFillStyle.color=23733;f.titleFillStyle.alpha=1;c.tipOption=f;c.canShowTip=!0;a=new MLngLat(a,b);c=new MMarker(a,c);c.id=d+1;mapObjSearch.addEventListener(mapObjSearch,ADD_OVERLAY,addOverlayEventOpenTip);mapObjSearch.addOverlay(c,!0)}
function addOverlayEventOpenTip(a){mapObjSearch.openOverlayTip(a.overlayId);mapObjSearch.removeEventListener(mapObjSearch,ADD_OVERLAY,addOverlayEventOpenTip)}function setcity(a){if(iscookie==1&&cityname!=a){var b="cityname="+encodeURIComponent(a);b+="; expires=Mon, 31 Dec 2998 16:00:00 GMT";document.cookie=b;cityname=a}}function getCookie(a){return RegExp("(?:; )?"+a+"=([^;]*);?").test(document.cookie)?decodeURIComponent(RegExp.$1):null};

