		var spoint;//起点
		var epoint;//终点
		var poly = [];//公交线路
		var curPoly;//当前公交线路
		var curPage=1;//当前页号，为了翻页使用
		var cityPageSize=10;//城市查询的每页显示条数
		var cityPot=[];//城市查询标注点坐标，全局存储，用来翻页标注
		$(function(){
			initMap();
			$(window).resize(function(){
				if(maplet){
		       		var sWidth = $(window).width();
		        	var sHeight = $(window).height()
		        	$('#mapbar').css({width: sWidth-300+"px", height: sHeight-110+"px"});
		        	maplet.resize(sWidth-300+"px",sHeight-110+"px");
		        	maplet.setAutoZoom();
		        }
		    });
		    $('#area_name').searchInfo({type:'jd',width:'200',initData:initCityArea,callback:function(item){}});//有回调方法
		    $('#arriveCity').searchInfo({type:'jd',width:'200',initData:initCityArea,callback:function(item){}});//有回调方法
		   /*额外增加的一个小功能，如果传来经纬度及说明，可以显示坐标点位置*/
		    if(showLL=='')
		    ajaxChk();
		});
		var maplet = null;
		//初始化地图。
		function initMap() {
			var sWidth = $(window).width();
		    var sHeight = $(window).height();
		    $('#mapbar').css({width: sWidth-300+"px", height: sHeight-110+"px"});
			maplet = new Maplet("mapbar");
			maplet.centerAndZoom(new MPoint(defaultCenterLon, defaultCenterLat), 9);
			maplet.addControl(new MStandardControl());
			maplet.showOverview(true, false);
			/*额外增加的一个小功能，如果传来经纬度及说明，可以显示坐标点位置*/
			if(showLL!=''){
				maplet.addOverlay(new MMarker(new MPoint(showLL.split(',')[0],showLL.split(',')[1]),new MIcon('/www2009/images/bus/02.gif',25,28)));
			}
			maplet.setAutoZoom();
			//设置地图模式为拉框查询模式。
			maplet.setMode("pan");
			avBubble.width = 250;
		    avBubble.height = 160;
		}
		function clearParam(){
			spoint=null;epoint=null;poly = [];curPoly=null;cityPot=[];
		}
		function toPoint(lon,lat){
			maplet.centerAndZoom(new MPoint(lon,lat), 13);
		}
		function chgLine(x){
			if(curPoly){
				for(var i=0;i<curPoly.length;i++){
					maplet.removeOverlay(curPoly[i]);
				}
			}
			curPoly=[];
			var tmpP=poly[x];
	  		var carlatlons;
	  		var tmpArr;
	  		for(var i=0;i<tmpP.length;i++){
	  			carlatlons=tmpP[i].split(";");
	  			tmpArr=[];
	  			for(var t=0;t<carlatlons.length;t++){
	  				tmpArr[t]=new MPoint(carlatlons[t]);
	  			}
	  			var mb=new MBrush();
	  			mb.arrow=true;
				curPoly[i]=new MPolyline(
						tmpArr,
						mb
						//new MInfoWindow("信息窗口标题", "信息窗口内容")
				);	  
	  		}
	  		if(curPoly){
				for(var i=0;i<curPoly.length;i++){
					maplet.addOverlay(curPoly[i]);
				}
			}
			maplet.setAutoZoom();
		}
		
		function addStartMarker(lon,lat) {
			if(spoint)maplet.removeOverlay(spoint);
			spoint= new MMarker(new MPoint(lon,lat),new MIcon('/www2009/images/bus/02.gif',25,28));
			maplet.addOverlay(spoint);
			maplet.setAutoZoom();
		}
		
		function addArriveMarker(lon,lat) {
			if(epoint)maplet.removeOverlay(epoint);
			epoint= new MMarker(new MPoint(lon,lat),new MIcon('/www2009/images/bus/01.gif',25,28));
			maplet.addOverlay(epoint);
			maplet.setAutoZoom();
		}
		
		function chgType(t){
			/*额外增加的一个小功能，如果传来经纬度及说明，可以显示坐标点位置*/
			if(showLL!=''){
				maplet.clearOverlays();
				showLL='';
				showContent='';
			}
			var t_red=$('.tab-active');
			t_red.removeClass('tab-active');
			t_red.addClass('tab');
			document.getElementById('type_'+t).className='tab-active';
			if(t==0){
				document.getElementById('drive_cond').style.display='none';
				document.getElementById('near').style.display='none';
				document.getElementById('drive_pos').style.display='block';
				$('#textCityName').html('出发城市');
				$('#textPos').html('起点');
			}else if(t==1){
				document.getElementById('near').style.display='none';
				document.getElementById('drive_cond').style.display='block';
				document.getElementById('drive_pos').style.display='block';
				$('#textCityName').html('出发城市');
				$('#textPos').html('起点');
			}else if(t==2){
				document.getElementById('drive_cond').style.display='none';
				document.getElementById('drive_pos').style.display='none';
				document.getElementById('near').style.display='none';
				$('#textCityName').html('城市');
				$('#textPos').html('标志物');
			}else if(t==3){
				document.getElementById('drive_cond').style.display='none';
				document.getElementById('drive_pos').style.display='none';
				document.getElementById('near').style.display='block';
				$('#textCityName').html('城市');
				$('#textPos').html('标志物');
			}
			document.getElementById('type').value=t;
		}
		
		function chgPos(val,type){
			if(val=='')return;
			var arr=val.split('@#@');
			if(arr.length!=2)return;
			if(type==0){
				$('#spos').val(arr[1]);
				$('#slatlon').val(arr[0]);
				var t_arr=arr[0].split(",");
				if(t_arr.length==2){
					addStartMarker(t_arr[0],t_arr[1]);	
				}
			}else if(type==1){
				$('#epos').val(arr[1]);
				$('#elatlon').val(arr[0]);
				var t_arr=arr[0].split(",");
				if(t_arr.length==2){
					addArriveMarker(t_arr[0],t_arr[1]);
				}
			}
		}
		function chk(){
			var val=$('#type').val();
			if("0,1,2,3".indexOf(val)==-1){
				alert('请选择地图查询类型！');
				return;
			}
			if($.trim($('#area_name').val())==''){
				alert('请输入城市名');
				$('#area_name').focus();
				return;
			}
			if($.trim($('#startPos').val())==''){
				alert('请输入标志物名称');
				$('#startPos').focus();
				return;
			}
			if(val=='0'){
				if($.trim($('#arrivePos').val())==''){
					alert('请输入终点名称');
					$('#arrivePos').focus();
					return;
				}
			}else if(val=='1'){
				if($('#type').val()=='1'){
					if($.trim($('#arriveCity').val())==''){
						alert('请输入到达城市名');
						$('#arriveCity').focus();
						return;
					}	
				}
				if($.trim($('#arrivePos').val())==''){
					alert('请输入终点名称');
					$('#arrivePos').focus();
					return;
				}
			}else if(val=='2'){
			}else if(val=='3'){
			}else{
				return;
			}
			$.ajax({
				   type: "POST",
				   url: "/www2009/ajax/bus_ajax.jsp",
				   data: {
							startPos:$.trim($('#startPos').val()),
							arrivePos:$.trim($('#arrivePos').val()),
							width:$('#mapbar').css('width'),
							height:$('#mapbar').css('height'),
							custclass:$('#custclass').val(),
							area_name:$('#area_name').val(),
							arriveCity:$('#arriveCity').val(),
							type:$.trim($('#type').val())
				   		 },
				   beforeSend:function(){
				   		$("#right").html('<td width=\"300\" valign=\"top\">'+loadstr+'</td>');
				   },
				   success: function(msg){
				   		$("#right").html(msg);
				   }
			 });
		}
		function ajaxChk(){
			var calSort='';
			var calStyle='';
			var sort=document.getElementsByName('sort');
			var style=document.getElementsByName('style');
			if(sort!=null && sort.length>0){
				for(var i=0;i<sort.length;i++){
					if(sort[i].checked){
						calSort=sort[i].value;
						break;
					}
				}
			}
			if(style!=null && style.length>0){
				for(var i=0;i<style.length;i++){
					if(style[i].checked){
						calStyle=style[i].value;
						break;
					}
				}
			}
			$.ajax({
				   type: "POST",
				   url: "/www2009/ajax/bus_ajax.jsp",
				   data: {
				   			orig:$.trim($('#slatlon').val())==''?default_orig:$.trim($('#slatlon').val()),
							dest:$.trim($('#elatlon').val())==''?default_dest:$.trim($('#elatlon').val()),
							startPos:$.trim($('#startPos').val()),
							arrivePos:$.trim($('#arrivePos').val()),
							
							width:$('#mapbar').css('width'),
							height:$('#mapbar').css('height'),
							sort:calSort,
							style:calStyle,
							custclass:$('#custclass').val(),
							area_name:$('#area_name').val(),
							arriveCity:$('#arriveCity').val(),
							type:$.trim($('#type').val())
				   		 },
				   beforeSend:function(){
				   		$("#right").html('<td width=\"300\" valign=\"top\">'+loadstr+'</td>');
				   },
				   success: function(msg){
				   		$("#right").html(msg);
				   }
			 });
		}
		function checkClick(type,obj){
			var chk;
			if(type=='sort'){
				chk=document.getElementsByName('sort');
			}else{
				chk=document.getElementsByName('style');
			}
			for(var i=0;i<chk.length;i++){
				if(chk[i]!=obj){
					chk[i].checked=false;
				}
			}
		}
		function page(no){
			if(document.getElementById('page_1')!=null){
				$('#page_1').css({display:'none'});
				$('#pages_1').removeClass('red');
				$('#pages_1').addClass('blue');
			}
			if(document.getElementById('page_2')!=null){
				$('#page_2').css({display:'none'});
				$('#pages_2').removeClass('red');
				$('#pages_2').addClass('blue');
			}
			if(document.getElementById('page_3')!=null){	
				$('#page_3').css({display:'none'});
				$('#pages_3').removeClass('red');
				$('#pages_3').addClass('blue');
			}
			$('#page_'+no).css({display:'block'});
			document.getElementById('pages_'+no).className='red';
		}
		function zbPage(num,all){
			$.ajax({
				   type: "POST",
				   url: "/www2009/ajax/bus_ajax.jsp",
				   data: {
							startPos:$.trim($('#startPos').val()),
							arrivePos:$.trim($('#arrivePos').val()),
							pageNo:num,
							width:$('#mapbar').css('width'),
							height:$('#mapbar').css('height'),
							custclass:$('#custclass').val(),
							area_name:$('#area_name').val(),
							arriveCity:$('#arriveCity').val(),
							type:$.trim($('#type').val())
				   		 },
				   beforeSend:function(){
				   		$("#right").html('<td width=\"300\" valign=\"top\">'+loadstr+'</td>');
				   },
				   success: function(msg){
				   		$("#right").html(msg);
				   }
			 });
		}
		function cityPage(num,all){
			if(num==curPage)return;
			var tmp='<table width="87%" height="25" border="0" align="center" cellpadding="0" cellspacing="1">';
				tmp+='<tr>';
				tmp+='<td class="blue">';
				tmp+='第'+num+'/'+all+'页';
				if(num!=1){
					tmp+='<a href="javascript:cityPage(1,'+all+');" class="blue">首页</a>';
					tmp+='<a href="javascript:cityPage('+(num-1)+','+all+');" class="blue">上一页</a>';
				}	
				if(num+1<=all){
					tmp+='<a href="javascript:cityPage('+(num+1)+','+all+');" class="blue">下一页</a>';
					tmp+='<a href="javascript:cityPage('+all+','+all+');" class="blue">尾页</a>';
				}		
				tmp+='</td>';
				tmp+='</tr>';
				tmp+='</table>';
			$('#city_page_'+curPage).css({display:'none'});
			$('#city_page_'+num).css({display:'block'});
			curPage=num;
			maplet.clearOverlays();
			for(var i=(num-1)*cityPageSize,len=num*cityPageSize-1,x=0;i<=len;i++,x++){
				maplet.addOverlay(cityPot[i]);
			}
			maplet.setAutoZoom();
			$('#cp').html(tmp);	
		}
		function searchBus(type,city,lon,lat,spos,epos,cg){
			if(type==0){
				if(cg=='0'){
					location.href="/www2009/traffic/map.jsp?area_name="+escape(city)+"&arriveLatlon="+lon+","+lat+"&startPos="+escape(spos)+"&arrivePos="+escape(epos)+"&type="+type;
				}else if(cg=='1'){
					location.href="/www2009/traffic/map.jsp?area_name="+escape(city)+"&startLatlon="+lon+","+lat+"&startPos="+escape(spos)+"&arrivePos="+escape(epos)+"&type="+type;
				}				
			}else if(type==1){
				if(cg=='0'){
					location.href="/www2009/traffic/map.jsp?area_name="+escape(city)+"&arriveCity="+escape(city)+"&arriveLatlon="+lon+","+lat+"&startPos="+escape(spos)+"&arrivePos="+escape(epos)+"&type="+type;
				}else if(cg=='1'){
					location.href="/www2009/traffic/map.jsp?area_name="+escape(city)+"&arriveCity="+escape(city)+"&startLatlon="+lon+","+lat+"&startPos="+escape(spos)+"&arrivePos="+escape(epos)+"&type="+type;
				}	
			}
		}
		function searchZb(city,lon,lat,custclass,pos){
			location.href="/www2009/traffic/map.jsp?area_name="+escape(city)+"&startLatlon="+lon+","+lat+"&custclass="+custclass+"&startPos="+escape(pos)+"&type=3";
		}