var myPOI;
var myContextMenu;
var myPOITip;
var myClickPOI;				
var myNavigation;
var myMapLevel;
var myMapTool;
var myLandmark;
var mySerachPOI;
var g_mmStart;





function TBBusInit()
{
	myPOI = new POI();
	myContextMenu = new ContextMenu();
	myPOITip = new POITip();
	myNavigation = new Navigation();
	myMapLevel = new MapLevel(10,10,50);
	myMapTool = new MapTool(10,10);
	
	
	//MovePosition(215921,2671964,5);
	MovePosition(276949,2762723,4);
}


function MovePosition(px,py,le)
{

//   alert(px);
//    alert(py);
//    alert(le);
//    var XXX=  RealToMapPosX(px);
//    alert('XXX');

	gMapBase.MoveMapTo(RealToMapPosX(px),RealToMapPosY(py));  
	gMapBase.putMapLevel(le);	
	gMapBase.RefreshMap(true, true);
	
	if (ActionPOI.length >0) CreateAction(true);
	if (StopPOI.length >0) CreateBus(true);
	if(document.all.TabInfo.innerHTML != '')                                                         
	{                                                                                          
		ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(smalldivX),RealToMapPosY(smalldivY));
		document.all.TabInfo.style.left = ScreenClientPt.X-50;                                   
		document.all.TabInfo.style.top = ScreenClientPt.Y-100;                                   
	 }
			 
	
	gEye.MapTo(gMapBase.getCenterX(),gMapBase.getCenterY());
   	gEye.SetCuboidSize(gMapBase.ToMapPoint(0,0),gMapBase.ToMapPoint(gMapBase.getClientWidth(),gMapBase.getClientHeight()),true);
}


function SmoothMoveMap(poiX,poiY)
{
//    alert('SmoothMoveMap (' +poiX + ' , '+poiY+' )');
	cpt = gMapBase.ToMapPoint(poiX,poiY); 	
	
	var TimeMove = function()
	{
		var centerX = gMapBase.getCenterX();	
		var centerY = gMapBase.getCenterY();	
		if (gMapBase.FromMapDistX(Math.abs(centerX - cpt.X)) < 5 && 
			gMapBase.FromMapDistY(Math.abs(centerY - cpt.Y)) < 5)
		{
			gMapBase.MoveMapTo(cpt.X , cpt.Y);	
			gMapBase.RefreshMap(true, true);
			
			//eagle eye
			gEye.MapTo(cpt.X , cpt.Y);
			
			myPOI.RefreshPoi();
			tFunc = null;
		}
		else
		{
				gMapBase.MoveMapTo((centerX + cpt.X) / 2 , (centerY + cpt.Y) / 2);
				gMapBase.RefreshMap(true, true);
				tFunc = setTimeout(TimeMove, 50);
		}
	}
	TimeMove();
}

function POI()
{
	var arrPois = new Array();
	var divPOI = document.createElement("div");
	var myDocument = document.all.oGlobal;
	
	 
	divPOI.style.position = "absolute";
  	divPOI.style.left = 0; 
	divPOI.style.top = 0;
	divPOI.style.zIndex = 5;
	
	//divPOI.width = "100%";
  	//divPOI.height = "100%";
  	//divPOI.id = "divPOI";
  	//divPOI.style.border = "solid 0px red";
	//divPOI.style.background = "lightblue";
	//divPOI.innerHTML = "test";
	
	myDocument.appendChild(divPOI);
	

	this.AddPOI = function(p)
	{
//		alert('AddPOI : '+p);
//		alert(arrPois.length-1);
		arrPois[arrPois.length] = new Array();
		arrPois[arrPois.length -1] = eval("new " + p + "();");
	}
	
	this.AddGeneralPOI = function(p)
	{
		arrPois[arrPois.length] = new Array();
		arrPois[arrPois.length -1] = new GeneralPOI(p);
	}
	
	this.AddLandmarkPOI = function(p)
	{
//        alert('AddLandmarkPOI : '+p);
		arrPois[arrPois.length] = new Array();
//      alert("AddLandmarkPOI");
		myLandmark = new Landmark(p);
		//arrPois[arrPois.length -1] = new Landmark(p);
		arrPois[arrPois.length -1] = myLandmark;
	}
	

	this.AddBusStopPOI = function(p)
	{
//        alert('AddBusStopPOI : '+p);
		arrPois[arrPois.length] = new Array();
		myBusStop = new BusStop(p);
		//arrPois[arrPois.length -1] = new Landmark(p);
		arrPois[arrPois.length -1] = myBusStop;
	}

	
	this.AddSearchPoi = function(px,py,na)
	{
//	    alert(px + ' , ' + py + ' , '+ na);
//	    alert('AddSearchPoi : (' + px +' , ' + py + ' , '+ na +' )');
		mySerachPOI = new SerachPOI(px,py,na);
		this.RefreshPoi();
		
		/*

		var SearchPoiExist = false;
		for(i = 0; i < arrPois.length; i++)
		{
			if(arrPois[i].GetName() == 'SerachPOI') 
			{
				SearchPoiExist = true;
				arrPois[i] = new SerachPOI(px,py,na);
				break;
			}
		}
		if(!SearchPoiExist)
		{
			arrPois[arrPois.length] = new Array();	
			arrPois[arrPois.length -1] = new SerachPOI(px,py,na);
		}
		
		this.RefreshPoi();
		SearchPoiExist = null;
		*/
	}
	 

	this.RemovePOI = function(strPoiName)
	{
//	    alert('RemovePOI:' +strPoiName);
		arrNewPois = new Array();
		
		for(i = 0; i < arrPois.length; i++)
		{
			if(arrPois[i].GetName() != strPoiName)
			{
				arrNewPois[arrNewPois.length] = new Array();
				arrNewPois[arrNewPois.length -1] = arrPois[i];
			}
		}
		
		arrPois = arrNewPois;
		arrNewPois = null;
	}
	

	this.InsertPOI = function(str)
	{
//		alert('InsertPOI : ' +str);
//		window.open("").document.write('InsertPOI : ' +str);
		divPOI.innerHTML += str;
//		alert('end');
	}
	

	this.MoveLocation = function(px,py)
	{
//	    alert('MoveLocation : ('+ px +' , ' + py +' )');
		divPOI.style.left = px; 
		divPOI.style.top = py;
//		alert('end');
	}
	

	this.GetLocation = function()
	{

		return [parseInt(divPOI.style.left),parseInt(divPOI.style.top)];
	}
	

	this.RefreshPoi = function()
	{
		this.ClearPOI();
		 
//		alert(arrPois.length);
		
		if(mySerachPOI)
			mySerachPOI.ShowPOI();
			
		for(i = 0; i < arrPois.length; i++)
		{		
			//alert(arrPois[i].GetName());
			arrPois[i].ShowPOI();	
			
		}
		
		myPOITip.MovePosition();
		myNavigation.ShowPOI();
	}
	

	this.ClearPOI = function()
	{
		//divPOI.innerHTML = "";
		
//	    alert('clearpoi');
		myDocument.removeChild(divPOI);
		divPOI = null;
		
		divPOI = document.createElement("div");
		divPOI.style.position = "absolute";
  		divPOI.style.left = 0; 
		divPOI.style.top = 0;
		
		myDocument.appendChild(divPOI);
	}
	

	this.RemoveChild = function(sid)
	{
//	    alert('delete');
		var tmp1 = document.getElementById(sid);
		if(tmp1 != null)
		{
			divPOI.removeChild(tmp1);
		}
		tmp1 = null; 		
	}
	

	this.ShowLoading = function()
	{
		window.status = "Loading";
	}
	

	this.DisLoading = function()
	{
		window.status = "";
	}
}

function PrototypePOI()	
{
	var Name = "Prototype";
	
	this.SetName = function(na)
	{	  
		Name = na;
//		alert(Name);
	}
	
	this.GetName = function()
	{
		return Name;
	}
	
	this.GetDefaultPOIStyle = function()  
	{
//	    alert('GetDefaultPOIStyle');
		return "onmouseover='this.style.zIndex=10' onmouseout='this.style.zIndex=1' border=0";
	}
}


BusStop.prototype = new PrototypePOI();	
CityCCTV.prototype = new PrototypePOI();
GeneralPOI.prototype = new PrototypePOI();
SerachPOI.prototype = new PrototypePOI();
Landmark.prototype = new PrototypePOI();



function BusStop(p)
{
	var DefaultPOIStyle = this.GetDefaultPOIStyle();
	
	this.SetName("BusStop");
	
	this.ShowPOI = function()
	{
		var hr = new XMLHttpRequest;
		
		hr.onreadystatechange = function()
		{
			if (hr.readyState == 4 && hr.status == 200)
			{
				var obj = eval ("(" + hr.responseText + ")");
				var result = "";
				
				for(i = 0; i < obj.pois.length; i++)
				{		
					ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(obj.pois[i].px),RealToMapPosY(obj.pois[i].py));
					
					if(ScreenClientPt.X > 0 && ScreenClientPt.Y > 0 &&  
						ScreenClientPt.X <= gMapBase.getClientWidth() &&  
						ScreenClientPt.Y <= gMapBase.getClientHeight() )
					{
						result += "<img type='BusStop' src='images/站牌.gif' style='width:32px;height:32px;z-index:1;position:absolute;top:" + (ScreenClientPt.Y-32) + 
				 				  ";left:" + (ScreenClientPt.X-16) + "' id='"+ obj.pois[i].id + "' alt='"+ obj.pois[i].name +"' "+ DefaultPOIStyle +
				 				  " onclick='POIClick(this)' px='"+ obj.pois[i].px +"' py='"+ obj.pois[i].py +"'>";
					}
				}
				
				myPOI.InsertPOI(result);
				
				result = null;
				obj = null;				
				myPOI.DisLoading();
			}
			else
			{
				myPOI.ShowLoading();	
			}
		}
		
		//window.open("").document.write("poi/BusStopPOI.aspx");
		hr.open("GET", "poi/poiBusStop.ashx?poi=" + p.split('|')[0] , true);

		
//		hr.open("GET", "poi/BusStopPOI.aspx" , true);		
		hr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		hr.send(null);
		

	}
}

function CityCCTV()
{
	var DefaultPOIStyle = this.GetDefaultPOIStyle();
	
	this.SetName("CityCCTV");
	
	this.ShowPOI = function()
	{
		var hr = new XMLHttpRequest;
		
		hr.onreadystatechange = function()
		{
			if (hr.readyState == 4 && hr.status == 200)
			{
				var obj = eval ("(" + hr.responseText + ")");
				var result = "";
				
				for(i = 0; i < obj.pois.length; i++)
				{		
					ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(obj.pois[i].px),RealToMapPosY(obj.pois[i].py));
					
					if(ScreenClientPt.X > 0 && ScreenClientPt.Y > 0 &&  
						ScreenClientPt.X <= gMapBase.getClientWidth() &&  
						ScreenClientPt.Y <= gMapBase.getClientHeight() )
					{
						result += "<img type='CityCCTV' src='images/cctv.gif' style='z-index:1;position:absolute;top:" + ScreenClientPt.Y + 
				 				  ";left:" + ScreenClientPt.X + "' id='"+ obj.pois[i].id + "' alt='"+ obj.pois[i].name +"' "+ DefaultPOIStyle + 
				 				  " onclick='POIClick(this)' px='"+ obj.pois[i].px +"' py='"+ obj.pois[i].py +"'>";
					}
				}
				
				myPOI.InsertPOI(result);
				
				result = null;
				obj = null;
				
				myPOI.DisLoading();
			}
			else
			{
				myPOI.ShowLoading();	
			}
		}
		
		//window.open("").document.write("poi/CityCCTVPOI.aspx");
		hr.open("GET", "poi/CityCCTVPOI.aspx" , true);
		hr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		hr.send(null);
	}
}

function GeneralPOI(p)
{
	var DefaultPOIStyle = this.GetDefaultPOIStyle();
	
	this.SetName("GeneralPOI");
	
	this.ShowPOI = function()
	{
		var hr = new XMLHttpRequest;
		
		hr.onreadystatechange = function()
		{
			if (hr.readyState == 4 && hr.status == 200)
			{
				if(hr.responseText.length < 20)
				{
					myPOI.DisLoading();		
					return;
				}
				
				var obj = eval ("(" + hr.responseText + ")");
				var result = "";
				var pic = "images/poi/" + p.split('|')[1] + ".bmp";
				var ScreenClientPt;
				for(i = 0; i < obj.pois.length; i++)
				{		
					ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(obj.pois[i].px),RealToMapPosY(obj.pois[i].py));
					
					if(ScreenClientPt.X > 0 && ScreenClientPt.Y > 0 &&  
						ScreenClientPt.X <= gMapBase.getClientWidth() &&  
						ScreenClientPt.Y <= gMapBase.getClientHeight() )
					{
						result += "<img type='GeneralPOI' src='"+ pic +"' style='z-index:1;position:absolute;top:" + ScreenClientPt.Y + 
				 				  ";left:" + ScreenClientPt.X + "' id='"+ obj.pois[i].id + "' alt='"+ obj.pois[i].name +"' "+ DefaultPOIStyle + 
				 				  " onclick='POIClick(this)' px='"+ obj.pois[i].px +"' py='"+ obj.pois[i].py + "'" +
				 				  " city='"+ obj.pois[i].city +"' town='"+ obj.pois[i].town + "'" + 
				 				  " tel='"+ obj.pois[i].tel +"' address='"+ obj.pois[i].address + "'>";
					}
				}
				
				myPOI.InsertPOI(result);
				
				result = null;
				obj = null;
				ScreenClientPt = null;
				myPOI.DisLoading();
			}
			else
			{
				myPOI.ShowLoading();	
			}
		}
		
		//window.open("").document.write("poi/poiGeneralPOI.ashx?poi=" + p.split('|')[0]);
		//hr.open("GET", "poi/GeneralPOI.aspx?poi=" + p.split('|')[0] , true);
		hr.open("GET", "poi/poiGeneralPOI.ashx?poi=" + p.split('|')[0] , true);
		hr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		hr.send(null);
	}
}

function Landmark(p)
{

//  alert('Landmark : ' + p);
	var DefaultPOIStyle = this.GetDefaultPOIStyle();  //PrtotypePOI().GetDefaultPOIStyle
	
	this.SetName("Landmark");
	
	this.ShowPOI = function()
	{
		var hr = new XMLHttpRequest;
		
		hr.onreadystatechange = function()
		{
			if (hr.readyState == 4 && hr.status == 200)
			{
				if(hr.responseText.length < 20)
				{
					myPOI.DisLoading();		
					return;
				}

				var obj = eval ("(" + hr.responseText + ")");
				var result = "";
				
			
                if(p == '3|交通')
                {
                   	var pic1 = "images/交通.gif"; 
                   	var pic2 = "images/航空站_01.gif";
                   	var pic3 = "images/高鐵.jpg"; 
                   	var ScreenClientPt;

				    for(i = 0; i < obj.pois.length; i++)
				    {		

				        if (obj.pois[i].id == '19000456')
				        {
					        ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(obj.pois[i].px),RealToMapPosY(obj.pois[i].py));
					
					     	if(ScreenClientPt.X > 0 && ScreenClientPt.Y > 0 &&        /
						       ScreenClientPt.X <= gMapBase.getClientWidth() &&  
						       ScreenClientPt.Y <= gMapBase.getClientHeight() )
					        {
						                result += "<img type='Landmark' src='"+ pic2 +"' style='width:28px;height:28px;z-index:1;position:absolute;top:" + (ScreenClientPt.Y-32) + 
				 			    	      ";left:" + (ScreenClientPt.X-16) + "' id='"+ obj.pois[i].id + "' alt='"+ obj.pois[i].name +"' "+ DefaultPOIStyle + 
				 				          " onclick='POIClick(this)' px='"+ obj.pois[i].px +"' py='"+ obj.pois[i].py + "'" + "'>";
					        }
					    }
					 	else if (obj.pois[i].id == '19000455')
				        {
					         ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(obj.pois[i].px),RealToMapPosY(obj.pois[i].py));
					  
					         if(ScreenClientPt.X > 0 && ScreenClientPt.Y > 0 &&     
						        ScreenClientPt.X <= gMapBase.getClientWidth() &&       
						        ScreenClientPt.Y <= gMapBase.getClientHeight() )
					         {
						                result += "<img type='Landmark' src='"+ pic3 +"' style='width:34px;height:28px;z-index:1;position:absolute;top:" +(ScreenClientPt.Y-32) + 
				 			    	      ";left:" + (ScreenClientPt.X-16) + "' id='"+ obj.pois[i].id + "' alt='"+ obj.pois[i].name +"' "+ DefaultPOIStyle + 
				 				          " onclick='POIClick(this)' px='"+ obj.pois[i].px +"' py='"+ obj.pois[i].py + "'" + "'>";
					         }
					    }
					    else
					    {
					          ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(obj.pois[i].px),RealToMapPosY(obj.pois[i].py));

					          if(ScreenClientPt.X > 0 && ScreenClientPt.Y > 0 &&      
						         ScreenClientPt.X <= gMapBase.getClientWidth() &&        
						         ScreenClientPt.Y <= gMapBase.getClientHeight() )
					          {
						                result += "<img type='Landmark' src='"+ pic1 +"' style='width:24px;height:24px;z-index:1;position:absolute;top:" + (ScreenClientPt.Y-32) + 
				 			    	      ";left:" + (ScreenClientPt.X-16) + "' id='"+ obj.pois[i].id + "' alt='"+ obj.pois[i].name +"' "+ DefaultPOIStyle + 
				 				          " onclick='POIClick(this)' px='"+ obj.pois[i].px +"' py='"+ obj.pois[i].py + "'" + "'>";
					          }
					    }
					    
				    }       
       
                }
                else
                {
                    var pic = "images/" + p.split('|')[1] + ".gif";   
				    var ScreenClientPt;

				    for(i = 0; i < obj.pois.length; i++)
				    {		
					    ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(obj.pois[i].px),RealToMapPosY(obj.pois[i].py));
					
					    if(ScreenClientPt.X > 0 && ScreenClientPt.Y > 0 &&      
						   ScreenClientPt.X <= gMapBase.getClientWidth() &&        
						   ScreenClientPt.Y <= gMapBase.getClientHeight() )
					    {
						            result += "<img type='Landmark' src='"+ pic +"' style='width:24px;height:24px;z-index:1;position:absolute;top:" + (ScreenClientPt.Y-32) + 
				 			    	  ";left:" + (ScreenClientPt.X-16) + "' id='"+ obj.pois[i].id + "' alt='"+ obj.pois[i].name +"' "+ DefaultPOIStyle + 
				 				      " onclick='POIClick(this)' px='"+ obj.pois[i].px +"' py='"+ obj.pois[i].py + "'" + "'>";
					    }
				    }
                }
                                     
//				var pic = "images/" + p.split('|')[1] + ".gif"; //圖片
//				var ScreenClientPt;
//				for(i = 0; i < obj.pois.length; i++)
//				{		
//					ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(obj.pois[i].px),RealToMapPosY(obj.pois[i].py));
//					
//					if(ScreenClientPt.X > 0 && ScreenClientPt.Y > 0 &&  //轉出的螢幕座標 > 0
//						ScreenClientPt.X <= gMapBase.getClientWidth() &&  //轉出的螢幕座標在目前的螢幕範圍之內
//						ScreenClientPt.Y <= gMapBase.getClientHeight() )
//					{
//						result += "<img type='Landmark' src='"+ pic +"' style='width:24px;height:24px;z-index:1;position:absolute;top:" + ScreenClientPt.Y + 
//				 				  ";left:" + ScreenClientPt.X + "' id='"+ obj.pois[i].id + "' alt='"+ obj.pois[i].name +"' "+ DefaultPOIStyle + 
//				 				  " onclick='POIClick(this)' px='"+ obj.pois[i].px +"' py='"+ obj.pois[i].py + "'" + "'>";
//					}
//				}
				
////////////////////////////////						
			
				myPOI.InsertPOI(result);
				
				result = null;
				obj = null;
				ScreenClientPt = null;
				myPOI.DisLoading();
			}
			else
			{
				myPOI.ShowLoading();	
			}
		}		
		//window.open("").document.write("poi/poiLandmark.ashx?poi=" + p.split('|')[0]);
		hr.open("GET", "poi/poiLandmark.ashx?poi=" + p.split('|')[0] , true);
//		window.open("http://www.yahoo.com.tw");
		hr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		hr.send(null);	
	}
	
	this.GetSingleLandmarkInfo = function (sid)
	{
//      show出POI的id 	
	    //alert(sid);   
	    
		var hr = new XMLHttpRequest;	

		hr.open("GET", "poi/poiSingleLandmark.ashx?sid=" + sid , false);	
		hr.send(null);

		var result = '<div style="width:100%;Height:160;overflow:auto">' + 
		             '<table><tr>'+
		             '<td><a href='+hr.responseText.split('|')[2] +' target=_blank>'+
		             hr.responseText.split('|')[3] + 
		             '</a></td>'+
		             //'<td><div style="height:143px;width:100%;Overflow:auto;scrollbar-face-color:#5BC5D7;scrollbar-arrow-color:#ffffff;">'+
		             '<td><div style="height:143px;width:100%;Overflow:auto;">'+
					 '<font color="#3333DD">●</font><font color="#DD0000"><b>'+hr.responseText.split('|')[0] + '</b></font><br/>' +
					 hr.responseText.split('|')[1] + 
					 '</div></td>'+
					 '</tr></table>'+
					 '</div>';	
//alert(result);
//alert(hr.responseText.split('|')[0]);
//alert(hr.responseText.split('|')[1]);
//alert(hr.responseText.split('|')[2]);
//alert(hr.responseText.split('|')[3]);
		return result;
		obj = null;
	}
}

function SerachPOI(px,py,na)
{
	SPX = px;
	SPY = py;
	
	var DefaultPOIStyle = this.GetDefaultPOIStyle();
	this.SetName("SerachPOI");
	
	this.ShowPOI = function()
	{
		var ScreenClientPt = gMapBase.FromMapPoint(RealToMapPosX(SPX),RealToMapPosY(SPY));
		
		//var tmp = "<img type='SerachPOI' alt='"+ na +"' px='"+ SPX +"' py='"+ SPY +"' src='images/05.gif' style='position:absolute;" +
		//	   	  "top:" + (ScreenClientPt.Y - 16) + ";left:" + (ScreenClientPt.X - 8) + "' " +
		//	      "onclick='POIClick(this)'>";
		
		var tmp = "<img id='SerachPOI' type='SerachPOI' alt='"+ na +"' px='"+ SPX +"' py='"+ SPY +"' src='images/05.gif' style='position:absolute;" +
			   	  "top:" + (ScreenClientPt.Y-32) + ";left:" + (ScreenClientPt.X-16) + "' " +
			      "onclick='POIClick(this)'>";	
		    
		myPOI.InsertPOI(tmp);		
		
		tmp = null;
		ScreenClientPt = null;
		
		
	}
	
POIClick(document.getElementById("SerachPOI"));
	
}


function ContextMenu()
{
	var divContextMenu = document.createElement("div");
	
	divContextMenu.width = 300;
  	divContextMenu.height = 200;
  	divContextMenu.id = "divContextMenu";
  	divContextMenu.style.position = "absolute";
  	divContextMenu.style.left = 0; 
	divContextMenu.style.top = 0;
	divContextMenu.style.visibility = "hidden";
	divContextMenu.style.zIndex = 10;
	
	divContextMenu.style.border = "solid 1px black";
	divContextMenu.style.background = "lightblue";
	
	divContextMenu.innerHTML = "<table width=100>" +
							   "<tr><td align=center><div onclick=myContextMenu.AddNavigationPOI('Start')>起點</div></td></tr>" +
							   "<tr><td align=center><div onclick=myContextMenu.AddNavigationPOI('Pass')>經過點</div></td></tr>" +
							   "<tr><td align=center><div onclick=myContextMenu.AddNavigationPOI('End')>終點</div></td></tr></table>";
	
	document.body.appendChild(divContextMenu);
	
	var px,py;
	
	this.Show = function()
	{
		px = event.clientX;
		py = event.clientY;
		
		divContextMenu.style.visibility = "visible";
		divContextMenu.style.left = event.clientX - 5;
		divContextMenu.style.top = event.clientY - 5;
	}
	
	this.AddNavigationPOI = function(ty)
	{
		var ltpt = gMapBase.ToMapPoint(px, py);
		var obj = new Object();
		
		obj.px = MapToRealPosX(ltpt.X);
		obj.py = MapToRealPosY(ltpt.Y);
		obj.alt = "圖面自訂點";
		
		myClickPOI = obj;
		
		if(ty == "Start")
			myNavigation.AddStart();
		else if(ty == "End")
			myNavigation.AddEnd();
		else	
				
			myNavigation.AddPass();
			
		this.SetVisibility(false);
	}
	
	this.SetVisibility = function(bo)
	{
		divContextMenu.style.visibility = (bo)?	"visible" : "hidden";
	}
	
	AttachEvent(divContextMenu, "mouseover", function() {divContextMenu.style.visibility = "visible";}, false);
	AttachEvent(divContextMenu, "mouseout", function() {divContextMenu.style.visibility = "hidden";}, false);
}

function POITip()
{
	var px,py;
	var TipVisibility = false;
	
	var divPOITip = document.createElement("div");	
	
	divPOITip.style.position = "absolute";
	//divPOITip.style.border = "solid 1px black";
	//divPOITip.style.background = "lightblue";
	divPOITip.style.visibility = "hidden";
	divPOITip.style.zIndex=10;
	/*
	divPOITip.innerHTML = "<table width=300 height=200>" + 
						  "<tr><td height=5 valign=top align=right><div onclick=myPOITip.SetTipVisibility(false)>X</div></td></tr>"+
						  "<tr><td valign=top><div id=divPOITipContent></div></td></tr>" +
						  "<tr><td height=5 valign=bottom align=center>" +
						  "<div id=divSetRouting>" + 
						  "<span onclick=myNavigation.AddStart();myPOITip.SetTipVisibility(false)>設為起點</span> | " + 
						  "<span onclick=myNavigation.AddPass();myPOITip.SetTipVisibility(false)>設為經過點</span> | " + 
						  "<span onclick=myNavigation.AddEnd();myPOITip.SetTipVisibility(false)>設為終點</span>" + 
						  "</div>" +
						  "</td></tr></table>";
	*/				

    /*
    	divPOITip.innerHTML = "<table width='350' height='255' border='0' cellspacing='1' bgcolor='#306962'>" + 
						  "<tr><td height='16' align='right' bgcolor='#29A58C'><img onclick='myPOITip.SetTipVisibility(false)' src='images/x.gif' alt='關閉' width='10' height='10' hspace='2' /></td></tr>"+
						  "<tr><td bgcolor='#EEFDFA' valign=top><div id=divPOITipContent></div></td></tr>" +
						  "<tr><td height='24' align='center' bgcolor='#29A58C'>" +
						  "<div id=divSetRouting>" + 
						  "<table width='271' border='0' cellpadding='2' cellspacing='2'>" + 
					      "  <tr>" +
					      "    <td width='76' align='center' bordercolor='#FFFFFF' bgcolor='#E0F8EC'><span onclick='myNavigation.AddStart();myPOITip.SetTipVisibility(false)'><img src='images/arrow1.gif' width='10' height='10' align='absmiddle' /> 設為起點</span></td>" +
					      "    <td width='99' align='center' bordercolor='#FFFFFF' bgcolor='#E0F8EC'><img src='images/arrow1.gif' width='10' height='10' align='absmiddle' /> <span onclick='myNavigation.AddPass();myPOITip.SetTipVisibility(false)'>設為經過點</span></td>" +
					      "    <td width='88' align='center' bordercolor='#FFFFFF' bgcolor='#E0F8EC'><span onclick='myNavigation.AddEnd();myPOITip.SetTipVisibility(false)'><img src='images/arrow1.gif' width='10' height='10' align='absmiddle' /> 設為終點</span></td>" +
					      "  </tr>" +
					      "</table>" +
						  "</div>" +
						  "</td></tr></table>";
    */
    
  	document.body.appendChild(divPOITip);
  	
	this.SetTipVisibility = function(bo)
	{
		TipVisibility = bo;
		divPOITip.style.visibility = (bo)?"visible":"hidden";
	}
	
	this.GetTipVisibility = function(bo)
	{
		return TipVisibility;
	}
	
	this.SetTip = function(th)
	{

        divPOITip.innerHTML = "<table width=\"329\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> "+
                              "<tr>     " +
                              "<td width=\"7\"><img src=\"images/win_02.gif\" width=\"7\" height=\"30\"></td>" +
                              "<td width=\"314\" background=\"images/win_03.gif\"><div align=\"right\"><img alt=\"關閉\" onclick='myPOITip.SetTipVisibility(false)' src=\"images/close_07.gif\" name=\"Image26\" width=\"20\" height=\"18\" border=\"0\"></div></td>" +
                              "<td width=\"8\"><img src=\"images/win_05.gif\" width=\"8\" height=\"30\"></td>" +
                              "</tr>" +
                              "<tr>" +
                              "<td width=\"7\" background=\"images/win_09.gif\">&nbsp;</td>" +
                              "<td valign=\"top\">" +
                              "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" +
                              "<tr><td bgcolor=\"#FFFFFF\">" +
                              "<div id=divPOITipContent></div>" +
                              "</td></tr>" +
                              "</table><div id=divSetRouting>" +
                              "</td>" +
                              "<td width=\"8\" background=\"images/win_11.gif\">&nbsp;</td>" +
                              "</tr>" +
                              "<td background=\"images/win_09.gif\">&nbsp;</td>" +
                              "<td valign=\"top\" bgcolor=\"#FFFFFF\"><table width=\"154\" border=\"0\" align=\"left\" cellpadding=\"0\" cellspacing=\"0\">" +
                              "<tr>" +
                              "<td width=\"51\"><span onclick='myNavigation.AddStart();myPOITip.SetTipVisibility(false)'><img src=\"images/btn3_13.gif\" name=\"Image23\" width=\"50\" height=\"20\" border=\"0\"></span></td>" +
                              "<td width=\"52\"><span onclick='myNavigation.AddPass();myPOITip.SetTipVisibility(false)'><img src=\"images/btn3_14.gif\" name=\"Image24\" width=\"51\" height=\"20\" border=\"0\"></span></td>" +
                              "<td width=\"51\"><span onclick='myNavigation.AddEnd();myPOITip.SetTipVisibility(false)'><img src=\"images/btn3_15.gif\" name=\"Image25\" width=\"54\" height=\"20\" border=\"0\" ></span></td>" +
                              "</tr>" +
                              "</table></td>" +
                              "<td background=\"images/win_11.gif\">&nbsp;</td>" +
                              "</tr>" +
                              "<tr>" +
                              "<td colspan=3><img src=\"images/win_12.gif\" width=\"329\" height=\"27\"></td>" +
                              "</tr>" +
                              "</table>";
          
//                          "<table width='350' height='255' border='0' cellspacing='1' bgcolor='#306962'>" + 
//						  "<tr><td height='16' align='right' bgcolor='#29A58C'><img onclick='myPOITip.SetTipVisibility(false)' src='images/x.gif' alt='關閉' width='10' height='10' hspace='2' /></td></tr>"+
//						  "<tr><td bgcolor='#EEFDFA' valign=top></td></tr>" +
//						  "<tr><td height='24' align='center' bgcolor='#29A58C'>" +
//						  "" + 
//						  "<table width='271' border='0' cellpadding='2' cellspacing='2'>" + 
//					      "  <tr>" +
//					      "    <td width='76' align='center' bordercolor='#FFFFFF' bgcolor='#E0F8EC'><span onclick='myNavigation.AddStart();myPOITip.SetTipVisibility(false)'><img src='images/arrow1.gif' width='10' height='10' align='absmiddle' /> 設為起點</span></td>" +
//					      "    <td width='99' align='center' bordercolor='#FFFFFF' bgcolor='#E0F8EC'><img src='images/arrow1.gif' width='10' height='10' align='absmiddle' /> <span onclick='myNavigation.AddPass();myPOITip.SetTipVisibility(false)'>設為經過點</span></td>" +
//					      "    <td width='88' align='center' bordercolor='#FFFFFF' bgcolor='#E0F8EC'><span onclick='myNavigation.AddEnd();myPOITip.SetTipVisibility(false)'><img src='images/arrow1.gif' width='10' height='10' align='absmiddle' /> 設為終點</span></td>" +
//					      "  </tr>" +
//					      "</table>" +
//						  "</div>" +
//						  "</td></tr></table>";
		var POITipContent = document.getElementById("divPOITipContent");
		POITipContent.innerHTML = th.msg;
		
		this.SetPosition(parseInt(th.px),parseInt(th.py));
		this.MoveFitPosition();
		this.SetTipVisibility(true);
	}
	
	
	this.SetTip2 = function(th)
	{
    	divPOITip.innerHTML = "<table width='350' height='255' border='0' cellspacing='1' bgcolor='#306962'>" + 
						  "<tr><td height='16' align='right' bgcolor='#29A58C'><img onclick='myPOITip.SetTipVisibility(false)' src='images/x.gif' alt='關閉' width='10' height='10' hspace='2' /></td></tr>"+
						  "<tr><td bgcolor='#EEFDFA' valign=top><div id=divPOITipContent></div></td></tr>" +
						  "<tr><td height='24' align='center' bgcolor='#29A58C'>" +
						  "<div id=divSetRouting>" + 
						  "<table width='271' border='0' cellpadding='2' cellspacing='2'>" + 
					      "  <tr>" +
					      "    <td width='76' align='center' bordercolor='#FFFFFF' bgcolor='#E0F8EC'><span onclick='myNavigation.AddStart();myPOITip.SetTipVisibility(false)'><img src='images/arrow1.gif' width='10' height='10' align='absmiddle' /> 設為起點</span></td>" +
///////					      //"    <td width='99' align='center' bordercolor='#FFFFFF' bgcolor='#E0F8EC'><img src='images/arrow1.gif' width='10' height='10' align='absmiddle' /> <span onclick='myNavigation.AddPass();myPOITip.SetTipVisibility(false)'>設為經過點</span></td>" +
					      "    <td width='88' align='center' bordercolor='#FFFFFF' bgcolor='#E0F8EC'><span onclick='myNavigation.AddEnd();myPOITip.SetTipVisibility(false)'><img src='images/arrow1.gif' width='10' height='10' align='absmiddle' /> 設為終點</span></td>" +
					      "  </tr>" +
					      "</table>" +
						  "</div>" +
						  "</td></tr></table>";
		var POITipContent = document.getElementById("divPOITipContent");
		POITipContent.innerHTML = th.msg;
		
		this.SetPosition(parseInt(th.px),parseInt(th.py));
		this.MoveFitPosition();
		this.SetTipVisibility(true);
	}
	
	
	this.MoveFitPosition = function()
	{
		var topScale = 0;												
		var leftScale = 0;												
		var rightScale = parseInt(document.body.clientWidth);			
		var bottomScale = parseInt(document.body.clientHeight);			
		var ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(px),RealToMapPosY(py));
		
		//divPOITip.style.top = ScreenClientPt.Y - divPOITip.offsetHeight - 45;
		divPOITip.style.top = ScreenClientPt.Y - divPOITip.offsetHeight + 2;
		//divPOITip.style.left = ScreenClientPt.X - (divPOITip.offsetWidth /2);
		divPOITip.style.left = ScreenClientPt.X - (divPOITip.offsetWidth /2) + 13;
//alert(divPOITip.style.top);
//alert(divPOITip.style.left);
		var cx = document.body.clientWidth / 2; 				
		var cy = document.body.clientHeight / 2;				
		
		
		if(parseInt(divPOITip.style.top) < topScale+40)
		{
			cy = cy - ( topScale - parseInt(divPOITip.style.top)+40);
		}
		
		if(parseInt(divPOITip.style.left) < leftScale+40)
		{
			cx = cx - ( leftScale - parseInt(divPOITip.style.left)+40);
		}
		
		var rm = parseInt(divPOITip.style.left) +  divPOITip.offsetWidth;
		
		if(rm > rightScale)
		{
			cx = cx + (rm - rightScale) + 30;
		}
		
		var bm  = parseInt(divPOITip.style.top) +  divPOITip.offsetHeight;
		
		if(bm > bottomScale)
		{
		    cy = cy + (bm-bottomScale) + 50;
		}
		
		if(cx != (document.body.clientWidth / 2) || cy != (document.body.clientHeight / 2))
		{
			SmoothMoveMap(cx,cy);
		}
		
		topScale = null;
		leftScale = null;
		rightScale = null;
		
		cx = null;
		cy = null;
		rm = null;
	}
	
	this.MovePosition = function()
	{
		if(!this.GetTipVisibility()) return;
		
		var ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(px),RealToMapPosY(py));
		
		divPOITip.style.top = ScreenClientPt.Y - divPOITip.offsetHeight + 2;
		divPOITip.style.left = ScreenClientPt.X - (divPOITip.offsetWidth /2) +13;
		
		ScreenClientPt = null;
	}
	
	this.SetPosition = function(tx,ty)
	{
		var ltpt = gMapBase.ToMapPoint(tx,ty);
		px = MapToRealPosX(ltpt.X);
		py = MapToRealPosY(ltpt.Y);
	}
}

function POIClick(th)
{

	if(myClickPOI == th) 
	{
//	    alert('click the same POI');
	    return;
	}
	
	myClickPOI = th;
	
	//var hr = new XMLHttpRequest;
	var obj = new Object();
	var path = "";
	obj.px = th.style.left;
	obj.py = th.style.top;
	
	switch(th.type)
	{
		case "CityCCTV":
			obj.msg = th.alt;
			break;	
		case "BusStop":	
			obj.msg = th.alt;
			break;
		case "GeneralPOI":	
			obj.msg = th.alt + "<br/>" + th.tel + "<br/>" + th.address;
			break;
		case "SerachPOI":
			obj.msg = th.alt + "<br/>";
			break;
		case "Landmark":
			//obj.msg = th.alt + "<br/>";
			obj.msg = myLandmark.GetSingleLandmarkInfo(th.id);
			break;	
	}
	
	if(th.type == "BusStop")
	{

	    myPOITip.SetTip2(obj);
	}
	else
	{

	    myPOITip.SetTip(obj);
	}
	

}

function Navigation()
{
	var StartPOI = null;
	var EndPOI = null;
	var PassPOI = new Array();
	var DivNavigationResult = parent.document.getElementById("divNavigationResult");
	var DivNavigationPOI = parent.document.getElementById("divNavigationPOI");
	
	var hr = null;
	
	this.AddStart = function()	
	{
		this.RemoveStartPOI();
		StartPOI = myClickPOI;
		
		g_mmStart=myClickPOI;
		
		//DivStartPOI.innerHTML = StartPOI.alt;
//		alert('StartPOI.(px,py) : (' +StartPOI.px +' , ' +StartPOI.py+ ')');
		
//		parent.DivShow("divNavigation");
		
		var ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(StartPOI.px),RealToMapPosY(StartPOI.py));
		myPOI.InsertPOI("<img src='images/起點.gif' style='z-index:6;position:absolute;top:" + (ScreenClientPt.Y-58) + 
				 		";left:" + (ScreenClientPt.X-18) + "' id='imgStart' alt='起點'>");
//        alert(myPOI.InsertPOI.innerHTML);				 		
		
		ScreenClientPt = null;
		
		this.ShowPOITable();
	}
	
	this.AddEnd = function()	
	{
		this.RemoveEndPOI();
		EndPOI = myClickPOI;
		
		
		//DivEndPOI.innerHTML = EndPOI.alt;
//parent.DivShow("divNavigation");
		
		var ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(EndPOI.px),RealToMapPosY(EndPOI.py));
		myPOI.InsertPOI("<img src='images/終點.gif' style='z-index:6;position:absolute;top:" + (ScreenClientPt.Y-58) + 
				 		";left:" + (ScreenClientPt.X-18) + "' name='imgEnd' id='imgEnd' alt='終點'>");
		
		ScreenClientPt = null;
		
		this.ShowPOITable();	
	}
	
	this.AddPass = function()
	{
		//parent.DivShow("divNavigation");	//show navigation tab
		
		var ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(myClickPOI.px),RealToMapPosY(myClickPOI.py));
		
		if(PassPOI.length < 3)	
		{
			PassPOI[PassPOI.length] = new Array();
		}
		else
		{
			myPOI.RemoveChild("divPass2");		
		}
		PassPOI[PassPOI.length -1] = myClickPOI;	
		
		myPOI.InsertPOI("<div style='width:20px;height:20px;background-image:url(images/point_red.gif);z-index:6;position:absolute;top:" + (ScreenClientPt.Y-29) + 
				 			";left:" + (ScreenClientPt.X-14) + "' id='divPass"+ (PassPOI.length -1) +"'>" + 
				 			"<center><font size='2' color='#ffffff' style='font-family: Arial, Helvetica, sans-serif;'><strong> " + 
				 			PassPOI.length +"</strong></font></center></div>");
				 			
		ScreenClientPt = null;
		
		this.ShowPOITable();
	}
	
	this.RemoveStartPOI = function()	
	{
		StartPOI = null;
		myPOI.RemoveChild("imgStart");
		this.ShowPOITable();
	}
	
	this.RemoveEndPOI = function()	
	{
		EndPOI = null;		
		myPOI.RemoveChild("imgEnd");
		this.ShowPOITable();
	}
	
	this.RemoveAllPOI = function()	
	{
		for(i = 0; i < PassPOI.length; i++)
		{
			myPOI.RemoveChild("divPass"+ i);
		}
		
		PassPOI = new Array();
		
		this.RemoveStartPOI();
		this.RemoveEndPOI();
		
		//DivNavigationResult.innerHTML = "";
	}
	
	this.RemovePass = function(idx)		
	{
		var arrNewPois = new Array();
		
		for(i = 0; i < PassPOI.length; i++)
		{
			if(i != idx)
			{
				arrNewPois[arrNewPois.length] = new Array();
				arrNewPois[arrNewPois.length -1] = PassPOI[i];
			}
			myPOI.RemoveChild("divPass"+ i);
		}
		
		PassPOI = arrNewPois;
		arrNewPois = null;
		
		var ScreenClientPt;
		for(i = 0; i < PassPOI.length; i++)
		{	
			ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(PassPOI[i].px),RealToMapPosY(PassPOI[i].py));
				
			myPOI.InsertPOI("<div style='width:20px;height:20px;background-image:url(images/point_red.gif);z-index:6;position:absolute;top:" + (ScreenClientPt.Y-29) + 
				 		";left:" + (ScreenClientPt.X-14) + "' id='divPass"+ i +"'>" + 
				 		"<center><font size='2' color='#ffffff' style='font-family: Arial, Helvetica, sans-serif;'><strong> " + 
				 		(i + 1) +"</strong></font></center></div>");	
		}
		
		ScreenClientPt = null;
		
		this.ShowPOITable();	
	}
	
	this.RemoveStartEndPOI = function()	
	{
		this.RemoveStartPOI();	
		this.RemoveEndPOI();
	}
	
	this.ShowPOI = function()
	{
		var ScreenClientPt;
		
		if(StartPOI != null)	
		{
			ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(StartPOI.px),RealToMapPosY(StartPOI.py));
			myPOI.InsertPOI("<img src='images/起點.gif' style='z-index:6;position:absolute;top:" + (ScreenClientPt.Y-58) + 
				 		";left:" + (ScreenClientPt.X-18) + "' id='imgStart' alt='起點'>");	
		}
		
		if(EndPOI != null)	
		{
			ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(EndPOI.px),RealToMapPosY(EndPOI.py));
			myPOI.InsertPOI("<img src='images/終點.gif' style='z-index:6;position:absolute;top:" + (ScreenClientPt.Y-58) + 
				 		";left:" + (ScreenClientPt.X-18) + "' id='imgEnd' alt='終點'>");
		}
		
		for(i = 0; i < PassPOI.length; i++)	
		{	
			ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(PassPOI[i].px),RealToMapPosY(PassPOI[i].py));
				
			myPOI.InsertPOI("<div style='width:20px;height:20px;background-image:url(images/point_red.gif);z-index:6;position:absolute;top:" + (ScreenClientPt.Y-29) + 
				 		";left:" + (ScreenClientPt.X-14) + "' id='divPass"+ i +"'>" + 
				 		"<center><font size='2' color='#ffffff' style='font-family: Arial, Helvetica, sans-serif;'><strong> " + 
				 		(i + 1) +"</strong></font></center></div>");	
		}
		
		ScreenClientPt = null;
	}
	
	this.GetNavigation = function()
	{
		
		var cnt = 0;
		var query = "?";
		
		if(StartPOI == null)
		{   
		    alert('請增設起始點');
		    return;
		}
		if(StartPOI != null)
		{
		    
			cnt++;
			query += "Start=" +StartPOI.px + "," + StartPOI.py + "," + StartPOI.alt;
		}
		
		if(EndPOI == null)
		{   
		    alert('請增設終點');
		    return;
		}
		if(EndPOI != null)
		{
			cnt++;
			query += "&End=" +EndPOI.px + "," + EndPOI.py + "," + EndPOI.alt;
		}
		
		cnt += PassPOI.length;
		
//		if((EndPOI.alt !=null) && cnt < 2)
//		{
//			alert("行程規劃景點數不足...!!");
//			return;	
//		}
		if((StartPOI.alt==EndPOI.alt) && cnt < 3)
		{
					alert('請增設中繼點...!!');
//					alert('S: '+StartPOI.alt);
//					alert('E: '+EndPOI.alt);
			return;
		}

//		if(parent.document.all.txtBoxDate.value == '')
//		{
//			alert("請輸入出發時間");
//			return;	
//		}
		

		    query += "&Pass=";
    		
		    for(i = 0; i < PassPOI.length; i++)
		    {
			    query += PassPOI[i].px + "," + PassPOI[i].py + "," + PassPOI[i].alt +"|";	
		    }
		
//		query += "&time=" + parent.document.all.txtBoxDate.value + " " + 
//					parent.document.all.selHH.value + ":" + parent.document.all.selMM.value;
        if(cnt < 3)
        {
            parent.ifNavigation.location.href = "modules/NavigationResultDetail1.aspx?Pass=" +StartPOI.px + "," + StartPOI.py + "," + StartPOI.alt + "|"+EndPOI.px + "," + EndPOI.py + "," + EndPOI.alt+"|";
        }
        else
        {
		    parent.ifNavigation.location.href = "modules/NavigationResult2.aspx" + query;
		}
	    cnt = null;
//alert("方案規劃中..");
		
		var NavigationReslt = parent.document.getElementById("divNavigationResult");
		var NavigateionFrame = parent.document.getElementById("ifNavigation");
		var w = parseInt(parent.document.body.clientWidth);	//screen width
		var h = parseInt(parent.document.body.clientHeight);	//screen height
			
		NavigationReslt.style.visibility = "visible";
		NavigateionFrame.style.visibility = "visible";
		
		NavigationReslt.style.width = 993 + "px";
		NavigationReslt.style.height = 580 + "px";
		NavigationReslt.style.left = 0
		NavigationReslt.style.top = 0; 
		
		
		NavigateionFrame.style.width = w - 150;
		NavigateionFrame.style.height = h - 100;
		
		//NavigateionFrame.style.width = w - 300;
		////////////////////////////////////////////				
		NavigateionFrame.style.left = w / 2 - (w - 150) / 2;
		NavigateionFrame.style.top = 80;
		
//        window.open("").document.write("modules/NavigationResult2.aspx" + query);
		//將資料傳到 NavigationResult


		//NavigateionFrame.location.href = "modules/NavigationResult.aspx" + query;		//失敗?? 
		
		/*
		hr = new XMLHttpRequest;
		
		hr.onreadystatechange = function()
		{
			if(hr.readyState == 4 && hr.status == 200)
			{
				ProcessNavigationReturn();
				myPOI.DisLoading();	
			}
			else
				myPOI.ShowLoading();
		}
		*/
		//組合qurey string
		//var query = "?";
		/*
		if(StartPOI != null)
		{
			query += "Start=" +StartPOI.px + "," + StartPOI.py;
		}
		
		if(EndPOI != null)
		{
			query += "&End=" +EndPOI.px + "," + EndPOI.py;
		}
		*/
		
		
		
		
		//window.open("").document.write("poi/poiBusNavigation.ashx" + query);
		//hr.open("GET", "poi/poiBusNavigation.ashx" + query, true);
		//hr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		//hr.send(null);
		
		/*
		if(StartPOI == null || EndPOI == null)
		{
			alert("請設定起點與迄點。");
			return;	
		}
		
		if(Math.sqrt(Math.pow(StartPOI.px - EndPOI.px,2) + Math.pow(StartPOI.py - EndPOI.py,2)) < 500)
		{
			alert("起點與訖點距離在可以步行範圍之內。");
			return;	
		}		
		
		var hr = new XMLHttpRequest;
		
		hr.onreadystatechange = function()
		{
			if (hr.readyState == 4 && hr.status == 200)
			{
				//alert(hr.responseText);
				if(hr.responseText.length < 20)
				{
					DivNavigationResult.innerHTML = "沒有可行方案。";
					myPOI.DisLoading();		
					return;
				}
				
				var obj = eval ("(" + hr.responseText + ")");
				var result = "";
				
				for(i = 0; i < obj.pois.length; i++)
				{	
					if(obj.pois[i].Type == "direct")
					{
						result += "直達方案 : 由 "+ StartPOI.alt + 
								  " 步行約 "+ obj.pois[i].StartDistance +" 公尺至 "+ obj.pois[i].Stop_Name1 + 
								  " 搭乘 "+ obj.pois[i].Route_Name +" 路公車直達 "+ obj.pois[i].Stop_Name2 +
								  " 再步行約 "+ obj.pois[i].EndDistance +" 公尺，到達 "+ EndPOI.alt +
								  " 。共經過 "+ obj.pois[i].count +" 個站。<p>"
					}
					else if(obj.pois[i].Type == "once")
					{
						result += "一次轉乘 : 由 "+ StartPOI.alt +" 步行約 "+ obj.pois[i].StartDistance + " 公尺到達 " + obj.pois[i].Stop_Name1 + 
								  " 搭乘 "+ obj.pois[i].Route_Name1 +" 路公車，經過 "+ obj.pois[i].Count1 +" 站到達 "+ obj.pois[i].Stop_Name2 + 
								  " ，下車步行約 "+ obj.pois[i].Cost +" 公尺到達 "+ obj.pois[i].Stop_Name3 +" 搭乘 "+ obj.pois[i].Route_Name2 + 
								  " 路公車經過 "+ obj.pois[i].Count2 +" 站到達 "+ obj.pois[i].Stop_Name4 +" 下車，下車步行約 "+ obj.pois[i].EndDistance + 
								  " 公尺到達 "+ EndPOI.alt +" 。<p>";	
					}	
				}
				
				DivNavigationResult.innerHTML = result;
				//alert(DivNavigationResult.innerHTML);
				result = null;
				obj = null;
				
				myPOI.DisLoading();
			}
			else
			{
				myPOI.ShowLoading();	
			}
		}
		
		//window.open("").document.write("poi/BusNavigation.aspx?spx="+ StartPOI.px +"&spy="+ StartPOI.py +"&epx="+ EndPOI.px +"&epy=" + EndPOI.py);
		hr.open("GET", "poi/BusNavigation.aspx?spx="+ StartPOI.px +"&spy="+ StartPOI.py +"&epx="+ EndPOI.px +"&epy=" + EndPOI.py, true);
		hr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		hr.send(null);
		*/
	}
	
	function ProcessNavigationReturn()
	{
		//alert(hr.responseText);
		var tmpPOI = new Array();
		
		if(StartPOI != null)
		{
			tmpPOI[tmpPOI.length] = new Array();
			tmpPOI[tmpPOI.length - 1] = StartPOI;	
		}
		
		for(i = 0; i < PassPOI.length; i++)
		{
			tmpPOI[tmpPOI.length] = new Array();
			tmpPOI[tmpPOI.length - 1] = PassPOI[i];
		}
		
		if(EndPOI != null)
		{
			tmpPOI[tmpPOI.length] = new Array();
			tmpPOI[tmpPOI.length - 1] = EndPOI;	
		}

		if(hr.responseText.length < 20)
		{
			DivNavigationResult.innerHTML = "沒有可行方案。";
			return;
		}
		
		var obj = eval ("(" + hr.responseText + ")");
		var result = "";
		var iPOI = 0;
		for(i = 0; i < obj.pois.length; i++)
		{	
			if(obj.pois[i].Type == "direct")
			{
				result += "直達方案 : 由 "+ tmpPOI[iPOI++].alt + 
						  " 步行約 "+ obj.pois[i].StartDistance +" 公尺至 "+ obj.pois[i].Stop_Name1 + 
						  " 搭乘 "+ obj.pois[i].Route_Name +" 路公車直達 "+ obj.pois[i].Stop_Name2 +
						  " 再步行約 "+ obj.pois[i].EndDistance +" 公尺，到達 "+ tmpPOI[iPOI].alt +
						  " 。共經過 "+ obj.pois[i].count +" 個站。<p>"
			}
			else if(obj.pois[i].Type == "once")
			{
				result += "一次轉乘 : 由 "+ tmpPOI[iPOI++].alt +" 步行約 "+ obj.pois[i].StartDistance + " 公尺到達 " + obj.pois[i].Stop_Name1 + 
						  " 搭乘 "+ obj.pois[i].Route_Name1 +" 路公車，經過 "+ obj.pois[i].Count1 +" 站到達 "+ obj.pois[i].Stop_Name2 + 
						  " ，下車步行約 "+ obj.pois[i].Cost +" 公尺到達 "+ obj.pois[i].Stop_Name3 +" 搭乘 "+ obj.pois[i].Route_Name2 + 
						  " 路公車經過 "+ obj.pois[i].Count2 +" 站到達 "+ obj.pois[i].Stop_Name4 +" 下車，下車步行約 "+ obj.pois[i].EndDistance + 
						  " 公尺到達 "+ tmpPOI[iPOI].alt +" 。<p>";	
			}
			else if(obj.pois[i].Type == "NoResult")
			{
				result += "無轉乘方案 : " + tmpPOI[iPOI++].alt + " - " + tmpPOI[iPOI].alt + "<p>";
			}	
		}
		
		DivNavigationResult.innerHTML = result;
		alert("規劃完成!!");
		//alert(DivNavigationResult.innerHTML);
		result = null;
		obj = null;
		tmpPOI = null;	
		iPOI = null;
	}
	
	this.ShowPOITable = function()
	{
		var tmp1 = ""; 
		var cnt = 0;
		var bg1 = "#FEE2C5";
		var bg2 = "#E4EDFC";
		var bg = "";
		
		
//		tmp1 =  '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
//				 '<tr>' +
//				 '   	<td width="13"><img src="images/right_02.gif" width="13" height="14" alt=""></td>' +
//				 '   	<td width="165" background="images/right_03.gif"><img src="images/right_03.gif" width="158" height="14" alt=""></td>' +
//				 '   	<td width="15" height="14"><img src="images/right_04.gif" width="15" height="14" alt=""></td>' +
//				 ' 	</tr>' +
//				 ' 	<tr>' +
//				 '   	<td background="images/right_05.gif">&nbsp;</td>' +
//				 '   	<td bgcolor="#FFFFFF">';
        tmp1 = '<table border="0" cellpadding="0" cellspacing="1" bordercolor="#FF9933">'+
               '<tr>'+
               '<td width="250" class="black10">';
		
		
		tmp1 += '<table width="100%" border="0" cellpadding="3" cellspacing="1">';
		
		
		if(StartPOI != null)
		{	
		    
			cnt ++;
			//bg = (cnt % 2)?bg1:bg2;
			//tmp1 += '<tr valign="bottom" bgcolor="'+ bg +'">' +
			tmp1 += '<tr bordercolor="#FF9933">' +
					'    <td width="20%" bgcolor="#FFFF99" align="right" ><div align="right" class="black9t">起點</div></td>' +
					'    <td width="69%" class="black9t"><span class="style9">'+ StartPOI.alt +'</span></td>' +
					'    <td width="11%" class="black10"><img onclick="map.myNavigation.RemoveStartPOI()" src="images/flag3_(delete)_16x16.gif" width="16" height="16" alt="刪除此項"> </td>' +
					'</tr>';

//			alert('StartPOI.alt : ' +StartPOI.alt);
		}
		else
		{
		cnt ++;
					tmp1 += '<tr bordercolor="#FF9933">' +
					'    <td width="20%" bgcolor="#FFFF99" align="right" ><div align="right" class="black9t">起點</div></td>' +
					'    <td width="69%" class="red9t"><span class="style9">請由上方輸入</span></td>' +
					'    <td width="11%" class="black10"></td>' +
					'</tr>';
		}
		
		
		for(i = 0; i < PassPOI.length; i++)
		{
			cnt ++;
			//bg = (cnt % 2)?bg1:bg2;
			//tmp1 += '<tr valign="bottom" bgcolor="'+ bg +'">' +
			tmp1 += '<tr bordercolor="#336699">' +
					'	 <td width="20%" bgcolor="#FFFF99" class="black10"><div align="right" class="black9t">中間點</div></td>' +
					'    <td width="69%" class="black9t">'+ PassPOI[i].alt +' </td>' +
					'    <td width="11%" class="black10">' + 
					'		<img onclick="map.myNavigation.RemovePass(\''+ i +'\')" src="images/flag3_(delete)_16x16.gif" width="16" height="16" alt="刪除此項"></td>' +
					'</tr>';
		}
		
		
		if(EndPOI != null)
		{
			cnt ++;
			//bg = (cnt % 2)?bg1:bg2;
			//tmp1 += '<tr valign="bottom" bgcolor="'+ bg +'">' +
			tmp1 += '<tr bordercolor="#336699">' +
					'	<td width="20%" bgcolor="#FFFF99" class="black10"><div align="right" class="black9t">迄點</div></td>' +
					'	<td width="69%" class="black9t">'+ EndPOI.alt +' </td>' +
					'	<td width="11%" class="black10"><img onclick="map.myNavigation.RemoveEndPOI()" src="images/flag3_(delete)_16x16.gif" width="16" height="16" alt="刪除此項"></td>' +
					'</tr>';
		}
		else
		{
		cnt ++;
					tmp1 += '<tr bordercolor="#336699">' +
					'	<td width="20%" bgcolor="#FFFF99" class="black10"><div align="right" class="black9t">迄點</div></td>' +
					'	<td width="69%" class="red9t">請由上方輸入</td>' +
					'	<td width="11%" class="black10"></td>' +
					'</tr>';
		}
		
		
		tmp1 += '	<tr bordercolor="#336699">' +
				'		<td colspan="3" class="black9t">' +
				'			<span onclick="map.myNavigation.RemoveAllPOI();" class="style11">移除全部</span>' +
				'			<span class="style8"><img onclick="map.myNavigation.RemoveAllPOI()" src="images/cancel.gif" width="15" height="13" align="absmiddle"></span>' +
				'		</td>' +
				'	</tr>' +
				'</table>';
		
		 
//		tmp1 += ' 	</td>' +
//				'    	<td width="15" background="images/right_07.gif">' +
//				'    		<img src="images/right_07.gif" width="15" height="20" alt="">' +
//				'    	</td>' +
//				'	</tr>' +
//				'  	<tr>' +
//				'        <td height="15"><img src="images/right_08.gif" width="13" height="15" alt=""></td>' +
//				'        <td height="15" background="images/right_09.gif"><img src="images/right_09.gif" width="158" height="15" alt=""></td>' +
//				'        <td width="15" height="15"><img src="images/right_10.gif" width="15" height="15" alt=""></td>' +
//				'  	</tr>' +
//				'</table>';
tmp1 += '</td>'+
'</tr>'+
'</table>';
		
		DivNavigationPOI.innerHTML = (cnt)?tmp1:"";
		tmp1 = null;		
	}
}

function MapLevel(le,px,py)
{
	var divMapLevel = document.createElement("div");
	var myDocument = document.all.Maptool;
	
	divMapLevel.style.position = "absolute";
  	divMapLevel.style.left = px; 
	divMapLevel.style.top = py;
	divMapLevel.style.zIndex = 5;
	divMapLevel.id = "MapLevel";
	
	var style1 = "#FFFF99"; //mouseover
	var style2 = "#FFFFFF";	//mouseout
	var style3 = "#FFCC00"; //select
	
	this.MoveLevel = function(l)
	{
		gMapBase.putMapLevel(l);
		gMapBase.RefreshMap(true, true);
		CreateAction(true);
		CreateBus(true);
		if(document.all.TabInfo.innerHTML != '')
		{
		  ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(smalldivX),RealToMapPosY(smalldivY));
			document.all.TabInfo.style.left = ScreenClientPt.X-50;
			document.all.TabInfo.style.top = ScreenClientPt.Y-100;
		}
	}
	
	this.PutLevel = function(bo)
	{
		gMapBase.putMapLevel((bo)? parseInt(gMapBase.getMapLevel()) + 1 : parseInt(gMapBase.getMapLevel()) -1);
		gMapBase.RefreshMap(true, true);
		CreateAction(true);
		CreateBus(true);
		if(document.all.TabInfo.innerHTML != '')
		{
		  ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(smalldivX),RealToMapPosY(smalldivY));
			document.all.TabInfo.style.left = ScreenClientPt.X-50;
			document.all.TabInfo.style.top = ScreenClientPt.Y-100;
		}
	}

	
	this.ShowLevel = function()
	{
		var l = gMapBase.getMapLevel();
		var result = "";
		
		result = "<table border='0' cellpadding='0' cellspacing='0'>																	" + 	
				"    <tr>                                                                                                                                   " + 
				"      <td><a href='#'><img alt='放大層級' onclick=\"myMapLevel.PutLevel(true)\" onMouseOut='this.src=\"images/tool/zoomUP.gif\"' onMouseOver='this.src=\"images/tool/zoomUP_o.gif\"' src='images/tool/zoomUP.gif' name='Image28' border='0'></a></td>" + 
				"    </tr>"; 
				
		for(var i = 9; i >= 1; i--)
		{
			if(i != l) 
			{
				result += '<tr>' + 
						  '  <td><a href="#"><img onclick="myMapLevel.MoveLevel('+ i +')" onMouseOut="javascript:this.src=\'images/tool/zoom'+ i +'.gif\'" onMouseOver="javascript:this.src=\'images/tool/zoom'+ i +'_o.gif\'" src="images/tool/zoom'+ i +'.gif" name="Image27" border="0"></a></td>' + 
						  '</tr>';
			}	
			else 
			{
				result += '<tr>' + 
						  '  <td><img src="images/tool/zoom'+ i +'_o.gif" name="Image27" border="0"></td>' + 
						  '</tr>';	
			}		
		}
			
		result += "    <tr>                                                                                                                                   " + 
				"      <td><a href='#'><img alt='縮小層級' onclick=\"myMapLevel.PutLevel(false)\" onMouseOut='this.src=\"images/tool/zoomDown.gif\"' onMouseOver='this.src=\"images/tool/zoomDown_o.gif\"' src='images/tool/zoomDown.gif' name='Image38' border='0'></a></td>" + 
				"    </tr>                                                                                                                                  " + 
				"</table>"; 
		
		divMapLevel.innerHTML = result;	
		
		l = null;
		result = null;
	}
	
	this.ShowLevel();
	myDocument.appendChild(divMapLevel);	
}

function MapTool(px,py)
{
	var divMapTool = document.createElement("div");
	var myDocument = document.all.Maptool;
	
	divMapTool.style.position = "absolute";
  	divMapTool.style.left = px; 
	divMapTool.style.top = py;
	divMapTool.style.zIndex = 5;
	divMapTool.id = "MapTool";
	
	var style1 = "#FFFF99"; //mouseover
	var style2 = "#FFFFFF";	//mouseout
	var style3 = "#FFCC00"; //select

	
	this.ShowTool = function(i)
	{
		var result = "";
		
		result = '<table id="" border="0" cellpadding="0" cellspacing="0">' +
			    '<tr>';
		
		if(i == 1)
		{
			result += '<td><img src="images/tool/tool1_04.gif" name="Image11" width="44" height="26" border="0"></a></td>';
			gMapBase.SelectMapTool(new MapZoom(0));
		}
		else
		{
			result += '<td><a href="#"><img onclick="myMapTool.ShowTool(1)" onmouseover="this.src=\'images/tool/tool1_04.gif\'" onmouseout="this.src=\'images/tool/tool_04.gif\'" src="images/tool/tool_04.gif" name="Image11" width="44" height="26" border="0" alt="地圖放大"></a></td>';
		}
		
		
		if(i == 2)
		{
			result += '<td><img src="images/tool/tool1_06.gif" name="Image12" width="42" height="26" border="0"></a></td>';
			gMapBase.SelectMapTool(new MapZoom(1));
		}
		else
		{
			result += '<td><a href="#"><img onclick="myMapTool.ShowTool(2)" onmouseover="this.src=\'images/tool/tool1_06.gif\'" onmouseout="this.src=\'images/tool/tool_06.gif\'" src="images/tool/tool_06.gif" name="Image12" width="42" height="26" border="0" alt="地圖縮小"></a></td>';
		}
		
		
		if(i == 3)
		{
			result += '<td><a href="#"><img src="images/tool/tool1_08.gif" name="Image13" width="43" height="26" border="0"></a></td>';
			gMapBase.SelectMapTool(new MapMove);
		}
		else
		{
			result += '<td><a href="#"><img onclick="myMapTool.ShowTool(3)" onmouseover="this.src=\'images/tool/tool1_08.gif\'" onmouseout="this.src=\'images/tool/tool_08.gif\'" src="images/tool/tool_08.gif" name="Image13" width="43" height="26" border="0" alt="地圖平移"></a></td>';
		}
		
		
		
		result += '<td><div><a href="#"><img onmouseover="this.src=\'images/tool/tool1_10.gif\'" onmouseout="this.src=\'images/tool/tool_10.gif\'" onclick="MovePosition(276949,2762723,4)" src="images/tool/tool_10.gif" name="Image14" width="51" height="26" border="0" alt="移至預設中心點"></a></div></td>';
		
		result += '</tr>' +
				  '</table>';
		
		/*
		result = "<table border=\"0\" bgcolor=\""+ style1 +"\" style=\"\">";
		result += "<tr>";
		
		if(i == 1)
		{
			result +="<td bgcolor="+ style3 +">" +
					"放大" +
					"</td>";
					
			gMapBase.SelectMapTool(new MapZoom(0));		
		}
		else
		{
			result +="<td onclick=\"myMapTool.ShowTool(1)\" onmouseout=\"this.style.background='"+ style1 +"'\" onmouseover=\"this.style.background='"+ style2 +"'\">" +
					"放大" +
					"</td>";		
		}
		
		if(i == 2)
		{
			result +="<td bgcolor="+ style3 +">" +
					"縮小" +
					"</td>";
			
			gMapBase.SelectMapTool(new MapZoom(1));		
		}
		else
		{
			result +="<td onclick=\"myMapTool.ShowTool(2)\" onmouseout=\"this.style.background='"+ style1 +"'\" onmouseover=\"this.style.background='"+ style2 +"'\">" +
					"縮小" +
					"</td>";		
		}
		
		if(i == 3)
		{
			result +="<td bgcolor="+ style3 +">" +
					"平移" +
					"</td>";
					
			gMapBase.SelectMapTool(new MapMove);		
		}
		else
		{
			result +="<td onclick=\"myMapTool.ShowTool(3)\" onmouseout=\"this.style.background='"+ style1 +"'\" onmouseover=\"this.style.background='"+ style2 +"'\">" +
					"平移" +
					"</td>";		
		}
		
		result +="<td onclick=\"MovePosition(165768,2544522,7)\" onmouseout=\"this.style.background='"+ style1 +"'\" onmouseover=\"this.style.background='"+ style2 +"'\">" +
				"中心點" +
				"</td>";		
	
		result += "</tr>"; 
		result += "<table>";
		*/
		
		divMapTool.innerHTML = result;	
	}
	
	this.ShowTool(3);
	myDocument.appendChild(divMapTool);	
}
/*
function MouseWheelEvent()
{
	if (tFunc != null) return;
				
	var centerFlag = null;
	
	if (event.wheelDelta >= 120) //往前滾
	{
		if((gMapBase.getMapLevel() + 1) > gMapBase.getMapMaxLevel()) return;
		
		var tmp = gMapBase.getMapLevel();
		var lv = tmp + 1;
		var tmp2 = 1;
		var i = 0;
		
		function ZoonIn()
		{
			i++;
			if(i > 5)
			{
				gMapBase.putMapLevel(lv);
				gMapBase.RefreshMap(true, true);
				
				//myPOI.RefreshPoi();
				
				tFunc = null;
				tmp = null;
				lv = null;
				tmp2 = null;
				i = null;
				
				//鷹眼移動
				gEye.MapTo(gMapBase.getCenterX(),gMapBase.getCenterY());
				gEye.SetCuboidSize(gMapBase.ToMapPoint(0,0),gMapBase.ToMapPoint(gMapBase.getClientWidth(),gMapBase.getClientHeight()));
				
				document.body.removeChild(centerFlag); 
				centerFlag = null;
			}
			else
			{
				tmp2 = tmp2 / 2;
				tmp += tmp2;
				gMapBase.putMapLevel2(tmp);
				gMapBase.RefreshMap(false,true);
				tFunc = setTimeout(ZoonIn, 50);
			}
		}
		
		centerFlag = document.createElement("img");
		centerFlag.style.position = "absolute";
		centerFlag.src = 'images/out.gif';	
		centerFlag.style.left = event.clientX - (80 / 2); 
		centerFlag.style.top = event.clientY - (60 / 2);	
		document.body.appendChild(centerFlag); 
		
		MoveMouseCenter(true); // 放大
		tFunc = setTimeout(ZoonIn, 50);
	}	  
	else if (event.wheelDelta <= -120) //往後滾 
	{	
		if(parseInt(gMapBase.getMapLevel()) != 1)
		{
			if(tFunc != null) return;
			
			var tmp = gMapBase.getMapLevel();
			var lv = tmp - 1;
			var tmp2 = 1;
			var i = 0;
			
			function ZoonOut()
			{
				i++;
				if(i > 5)
				{
					gMapBase.putMapLevel(lv);
					gMapBase.RefreshMap(true, true);
					
					//myPOI.RefreshPoi();
					
					tFunc = null;
					tmp = null;
					lv = null;
					tmp2 = null;
					i = null;
					
					//鷹眼移動
					gEye.MapTo(gMapBase.getCenterX(),gMapBase.getCenterY());
					gEye.SetCuboidSize(gMapBase.ToMapPoint(0,0),gMapBase.ToMapPoint(gMapBase.getClientWidth(),gMapBase.getClientHeight()));
					
					document.body.removeChild(centerFlag); 
					centerFlag = null;
				}
				else
				{
					tmp2 = tmp2 / 2;
					tmp -= tmp2;
					gMapBase.putMapLevel2(tmp);
					gMapBase.RefreshMap(false,true);
					tFunc = setTimeout(ZoonOut, 50);
				}
			}
			
			centerFlag = document.createElement("img");
			centerFlag.style.position = "absolute";
			centerFlag.src = 'images/in.gif';	
			centerFlag.style.left = event.clientX - (80 / 2); 
			centerFlag.style.top = event.clientY - (60 / 2);	
			document.body.appendChild(centerFlag); 
			MoveMouseCenter(false); // 縮小
			tFunc = setTimeout(ZoonOut, 50);
		}
	}	
}
*/

function dropfunction(company)
{
var dropstr="<select id='routesearch'>";
switch(company)
{

case "桃園":
    dropstr += "<option value='3420'>【101】桃園-文中路-果菜市場 (原桃園101路)</option>"
    dropstr += "<option value='3030'>【102】桃園-景雲新村 (原桃園2路)</option>"
    dropstr += "<option value='3060'>【103】桃園-華映公司 (原桃園103路)</option>"
    dropstr += "<option value='3080'>【105】桃園-大有路 (原桃園5路)</option>"
    dropstr += "<option value='3200'>【107】桃園-中平路 (原桃園107路)</option>"
    dropstr += "<option value='3460'>【109】桃園-新興高中 (原桃園109路)</option>"
    dropstr += "<option value='3360'>【110】中壢-文化路 (原中壢110路)</option>"
    dropstr += "<option value='3180'>【113】桃園-幸福社區 (原桃園13路)</option>"
    dropstr += "<option value='3400'>【117】桃園-寶慶路口 (原桃園17路)</option>"
    dropstr += "<option value='3090'>【125】桃園-三聖宮 (原桃園5甲)</option>"
    dropstr += "<option value='3110'>【137】桃園-銘傳大學 (原桃園7路)</option>"
    dropstr += "<option value='3120'>【139】桃園-龍壽街-新庄廟 (原桃園9路)</option>"
    dropstr += "<option value='3130'>【150】桃園-煉油廠 (原桃園10路)</option>"
    dropstr += "<option value='3191'>【151】桃園-同安街 (原桃園15路)</option>"
    dropstr += "<option value='3192'>【152】桃園-同安街 (原桃園15路)</option>"
    dropstr += "<option value='3440'>【157】桃園-八德-新興高中 (原桃園117路)</option>"
    dropstr += "<option value='3160'>【206】桃園-高鐵桃園站 (原桃園106路)</option>"
    dropstr += "<option value='1501'>【5000】桃園-至善工商</option>"
    dropstr += "<option value='1506'>【5009】桃園-新莊（經台一線）</option>"
    dropstr += "<option value='80'>【5011】桃園-中壢（經竹巷）</option>"
    dropstr += "<option value='3132'>【5012】桃園-蘆竹國小</option>"
    dropstr += "<option value='350'>【5057】桃園-長庚醫院桃園分院</option>"
    dropstr += "<option value='10'>【5059】桃園-桃園機場（經南崁）</option>"
    dropstr += "<option value='110'>【5060】桃園-榮民之家（經更寮腳）</option>"
    dropstr += "<option value='320'>【5063】桃園-竹林山寺（經光華坑）</option>"
    dropstr += "<option value='360'>【5064】桃園-三德煤礦（經龜山、圓光橋）</option>"
    dropstr += "<option value='920'>【5065】桃園-體育學院（經大埔）</option>"
    dropstr += "<option value='923'>【5066】桃園-長庚桃園分院</option>"
    dropstr += "<option value='1240'>【5068】桃園-合家歡社區（經龜山后街）</option>"
    dropstr += "<option value='1010'>【5071】桃園-竹林山寺（經外社）</option>"
    dropstr += "<option value='1011'>【5072】桃園-外社</option>"
    dropstr += "<option value='322'>【5074】桃園-長庚醫院(許可證)</option>"
    dropstr += "<option value='15061'>【5075】桃園-新莊-林口長庚醫院</option>"
    dropstr += "<option value='330'>【5076】桃園-樹林（經嶺頂）</option>"
    dropstr += "<option value='100'>【5095】桃園-中壢（經更寮腳）</option>"
    dropstr += "<option value='15080'>【5116】桃園-台北長庚醫院（經松山機場）</option>"
    dropstr += "<option value='15160'>【9005】桃園市-中山高-台北市</option>"
    dropstr += "<option value='1520'>【9023】桃園-中山高-臺北市士林區</option>"
    dropstr += "<option value='15880'>【9102】台北-台一線-桃園</option>" 
    break;
case "中壢":
    dropstr += "<option value='3480'>【111】中壢-南勢 (原中壢111路)</option>"
    dropstr += "<option value='3260'>【112南】中壢-陸軍專科學校 (原112南路)</option>"
    dropstr += "<option value='3520'>【115】中壢-平東路 (原中壢115路)</option>"
    dropstr += "<option value='3290'>【116】中壢-自立新村 (原中壢6路)</option>"
    dropstr += "<option value='3370'>【118】中壢-中壢高中 (原中壢118路)</option>"
    dropstr += "<option value='3380'>【119】中壢-壢新醫院 (原中壢119路)</option>"
    dropstr += "<option value='3350'>【120】中壢-太子鎮 (原中壢102路)</option>"
    dropstr += "<option value='3220'>【132】中壢-中央大學 (原中壢2路)</option>"
    dropstr += "<option value='3450'>【135】中壢-內壢高中 (原中壢15路)</option>"
    dropstr += "<option value='3280'>【155】中壢-元智大學 (原中壢5路)</option>"
    dropstr += "<option value='3281'>【156】中壢-元智大學 (原中壢5路)</option>"
    dropstr += "<option value='3300'>【169】中壢-華勛社區 (原中壢9路)</option>"
    dropstr += "<option value='3330'>【171】中壢-高鐵桃園站 (原中壢11路)</option>"
    dropstr += "<option value='3020'>【1甲】中壢-桃園 (原中壢1甲)</option>"
    dropstr += "<option value='3010'>【1路】中壢-桃園 (原中壢1路)</option>"
    dropstr += "<option value='3550'>【301路】龜山-楊梅 (原301路)</option>"
    dropstr += "<option value='680'>【5006】中壢-長安路</option>"
    dropstr += "<option value='580'>【5007】中壢-東社</option>"
    dropstr += "<option value='970'>【5008】桃園-中壢（經龍岡）</option>"   
    dropstr += "<option value='70'>【5010】桃園-中壢（經仁美、八德）</option>"
    dropstr += "<option value='80'>【5011】桃園-中壢（經竹巷）</option>"    
    dropstr += "<option value='690'>【5029】中壢-高榮磚廠</option>"
    dropstr += "<option value='743'>【5034】中壢-富源-頭洲國小</option>"
    dropstr += "<option value='1530'>【9025】中壢-中山高-臺北市松山區</option>"
    break;
case "三峽":
    dropstr += "<option value='20'>【5001】桃園-三峽（經中湖）</option>"
    dropstr += "<option value='50'>【5005】桃園-三峽（經尖山）</option>"
    break;
case "大園":
    dropstr += "<option value='160'>【5061】桃園-建國十九村（經大竹）</option>"
    dropstr += "<option value='650'>【5077】中壢-大園（經柴梳崙）</option>"
    dropstr += "<option value='770'>【5078】中壢-建國八村</option>"
    dropstr += "<option value='760'>【5079】中壢-下內定（經五塊厝）</option>"
    dropstr += "<option value='1130'>【5081】中壢-大園（經下洽溪）</option>"
    dropstr += "<option value='640'>【5082】中壢-大園（經雙溪口）</option>"
    dropstr += "<option value='190'>【5083】大園-潮音</option>"
    dropstr += "<option value='200'>【5084】大園-下古亭</option>"
    dropstr += "<option value='210'>【5085】大園-沙崙港</option>"
    dropstr += "<option value='180'>【5086】桃園-大園（經五塊厝）</option>"
    dropstr += "<option value='630'>【5087】中壢-大園（經青埔）</option>"
    dropstr += "<option value='660'>【5089】中壢-桃園機場（經大園）</option>"
    break;
case "大溪":
    dropstr += "<option value='7020'>【702】大溪-長庚醫院 (原702)</option>"
    dropstr += "<option value='520'>【5046】大溪-龍潭（經九龍村）</option>"
    dropstr += "<option value='11480'>【5090】桃園-上巴陵-林班口</option>"
    dropstr += "<option value='11490'>【5091】中壢-上巴陵-林班口</option>"
    dropstr += "<option value='1380'>【5093】大溪-羅浮-巴陵</option>"
    dropstr += "<option value='1390'>【5094】大溪-三光（沙崙子）-巴陵</option>"
    dropstr += "<option value='390'>【5096】桃園-大溪（經更寮腳）</option>"
    dropstr += "<option value='460'>【5097】大溪-竹篙厝（經美華）</option>"
    dropstr += "<option value='480'>【5098】中壢-大溪（經官路缺）</option>"
    dropstr += "<option value='910'>【5099】大溪-阿姆坪（經懷德橋）</option>"
    dropstr += "<option value='10110'>【5100】大溪-龍岡-八德</option>"
    dropstr += "<option value='1490'>【5101】大溪-鶯歌（經中新）</option>"
    dropstr += "<option value='1500'>【5104】大溪-復興</option>"
    dropstr += "<option value='430'>【5105】大溪-小烏來（經三民）</option>"
    dropstr += "<option value='440'>【5106】大溪-霞雲村（經 復興）</option>"
    dropstr += "<option value='450'>【5107】大溪-蝙蝠洞（經三民）</option>"
    dropstr += "<option value='1283'>【5109】大溪-高遶（經羅浮）</option>"    
    dropstr += "<option value='470'>【5110】大溪-坪林</option>"
    dropstr += "<option value='1100'>【5112】大溪-中壢（經八德）</option>"
    dropstr += "<option value='15990'>【9103】大溪-貨饒村-台北</option>"


 
    break;
case "竹圍":
    dropstr += "<option value='1371'>【201】蘆竹-八德 (原201)</option>"
    dropstr += "<option value='3131'>【5014】桃園-南崁（經南祥路）</option>"
    dropstr += "<option value='260'>【5015】桃園-大園（經南崁）</option>"
    dropstr += "<option value='1830'>【5016】桃園-竹圍（經山腳）</option>"
    dropstr += "<option value='780'>【5017】中壢-沙崙海水浴場（經楊厝）</option>"
    dropstr += "<option value='1370'>【5018】桃園-水尾（經蘆竹）</option>"
    dropstr += "<option value='170'>【5019】桃園-沙崙（經蘆竹）</option>"
    dropstr += "<option value='1000'>【5020】桃園-下福</option>"
    dropstr += "<option value='310'>【5021】桃園-下海湖</option>"
    dropstr += "<option value='250'>【5022】桃園-沙崙（經南崁）</option>"
    dropstr += "<option value='270'>【5023】桃園-大園（經楊厝）</option>"
    dropstr += "<option value='900'>【5069】桃園-竹林山寺（經赤塗崎）</option>"
    dropstr += "<option value='1010'>【5071】桃園-竹林山寺（經外社）</option>"
    dropstr += "<option value='1011'>【5072】桃園-外社</option>"
    dropstr += "<option value='1012'>【5073】桃園-頂社</option>"
    dropstr += "<option value='11'>【5115】桃園-高鐵桃園站（經南崁、桃園機場）</option>"
    break;
case "新屋":
    dropstr += "<option value='820'>【5025】中壢-新屋（經藍埔）</option>"
    dropstr += "<option value='740'>【5026】中壢-新坡（經富源）</option>"
    dropstr += "<option value='810'>【5027】中壢-後湖</option>"
    dropstr += "<option value='791'>【5028】新屋-下北湖</option>"
//    dropstr += "<option value='690'>【5029】中壢-高榮磚廠</option>"
    dropstr += "<option value='790'>【5030】中壢-下北湖</option>"
    dropstr += "<option value='802'>【5031】中壢-永安漁港（經新屋）</option>"    
    dropstr += "<option value='840'>【5032】中壢-觀音（經石磊）</option>"
    dropstr += "<option value='850'>【5033】中壢-觀音（經保生）</option>"
    dropstr += "<option value='801'>【5034】中壢-頭洲國小（經富源）</option>"
    dropstr += "<option value='801'>【5035】中壢-新屋（經過嶺）</option>"
    break;
case "龍潭":
    dropstr += "<option value='7010'>【701】龍潭-長庚醫院 (原701)</option>"
    dropstr += "<option value='500'>【5044】桃園-龍潭（經十一份）</option>"
    dropstr += "<option value='510'>【5045】桃園-石門水庫（經員樹林）</option>"    
    dropstr += "<option value='550'>【5048】龍潭-石門水庫（經十一份）</option>"
    dropstr += "<option value='560'>【5049】龍潭-逸園（經三角林）</option>"
    dropstr += "<option value='610'>【5050】中壢-石門水庫（經員樹林）</option>"
    dropstr += "<option value='551'>【5051】龍潭-大坪</option>"
    dropstr += "<option value='490'>【5053】桃園-龍潭（經九龍村）</option>"
    dropstr += "<option value='570'>【5054】中壢-龍潭（經九龍村）</option>"       
    dropstr += "<option value='602'>【5055】中壢-石門水庫（經山仔頂）</option>"
    dropstr += "<option value='510'>【5056】桃園-大坪</option>"
    break;
case "蘆竹":

    break;
case "觀音":
    dropstr += "<option value='720'>【5038】中壢-東福園（經山東）</option>"
    dropstr += "<option value='1470'>【5039】中壢-中壢（經永安、觀音）</option>"    
    dropstr += "<option value='230'>【5040】桃園-觀音（經中厝）</option>"
    dropstr += "<option value='870'>【5041】中壢-觀音（經白玉）</option>"
    dropstr += "<option value='1470'>【5042】中壢-觀音海水浴場（經新坡）</option>"
    dropstr += "<option value='871'>【5043】中壢-樹林新村</option>"
    break;
case "觀光":
    dropstr += "<option value='16010'>【501】台灣好行景點接駁慈湖線</option>"
    break;
case "長庚醫院":
dropstr += "<option value='320'>【5063】桃園-竹林山寺（經光華坑）</option>"
dropstr += "<option value='15080'>【5116】桃園-台北長庚醫院（經松山機場）</option>"
    break;
case "機場":
    dropstr += "<option value='10'>【5059】桃園-桃園機場（經南崁）</option>"
    dropstr += "<option value='660'>【5089】中壢-桃園機場（經大園）</option>"
    dropstr += "<option value='15080'>【5116】桃園-台北長庚醫院（經松山機場）</option>"

    break;
case "高中":
    dropstr += "<option value='3080'>【105】桃園-大有路 (原桃園5路)</option>"
    dropstr += "<option value='3460'>【109】桃園-新興高中 (原桃園109路)</option>"
    dropstr += "<option value='3191'>【151】桃園-同安街 (原桃園15路)</option>"
    dropstr += "<option value='70'>【5010】桃園-中壢（經仁美、八德）</option>"
    dropstr += "<option value='870'>【5041】中壢-觀音（經白玉）</option>"
    dropstr += "<option value='640'>【5082】中壢-大園（經雙溪口）</option>"
    break;
case "大學":
    dropstr += "<option value='3110'>【137】桃園-銘傳大學 (原桃園7路)</option>"
    dropstr += "<option value='3550'>【301路】龜山-楊梅 (原301路)</option>"
    dropstr += "<option value='970'>【5008】桃園-中壢（經龍岡）</option>"
    dropstr += "<option value='15060'>【5009】桃園-新莊（經台一線）</option>"
    dropstr += "<option value='70'>【5010】桃園-中壢（經仁美、八德）</option>"
    dropstr += "<option value='270'>【5023】桃園-大園（經楊厝）</option>"
    dropstr += "<option value='720'>【5038】中壢-東福園（經山東）</option>"
    dropstr += "<option value='320'>【5063】桃園-竹林山寺（經光華坑）</option>"
    dropstr += "<option value='920'>【5065】桃園-體育學院（經大埔）</option>"
    dropstr += "<option value='650'>【5077】中壢-大園（經柴梳崙）</option>"
    dropstr += "<option value='180'>【5086】桃園-大園（經五塊厝）</option>"    
    dropstr += "<option value='15880'>【9102】台北-台一線-桃園</option>"  
    break;
case "百貨公司":
    dropstr += "<option value='3080'>【105】桃園-大有路 (原桃園5路)</option>"
    dropstr += "<option value='3180'>【113】桃園-幸福社區 (原桃園13路)</option>"
    dropstr += "<option value='3400'>【117】桃園-寶慶路口 (原桃園17路)</option>"
    dropstr += "<option value='3110'>【137】桃園-銘傳大學 (原桃園7路)</option>"
    dropstr += "<option value='3191'>【151】桃園-同安街 (原桃園15路)</option>"
    dropstr += "<option value='320'>【5063】桃園-竹林山寺（經光華坑）</option>"
    dropstr += "<option value='630'>【5087】中壢-大園（經青埔）</option>"
    dropstr += "<option value='15080'>【5116】桃園-台北長庚醫院（經松山機場）</option>"    
    break;
case "高鐵車站":
    dropstr += "<option value='3160'>【206】桃園-高鐵桃園站 (原桃園106路)</option>"
    dropstr += "<option value='630'>【5087】中壢-大園（經青埔）</option>"
    break;
case "公家機關":
    dropstr += "<option value='3420'>【101】桃園-文中路-果菜市場 (原桃園101路)</option>"
    dropstr += "<option value='3010'>【1路】中壢-桃園 (原中壢1路)</option>"
    dropstr += "<option value='3550'>【301路】龜山-楊梅 (原301路)</option>"
    dropstr += "<option value='970'>【5008】桃園-中壢（經龍岡）</option>"
    dropstr += "<option value='70'>【5010】桃園-中壢（經仁美、八德）</option>"
    dropstr += "<option value='790'>【5030】中壢-下北湖</option>"
    dropstr += "<option value='870'>【5041】中壢-觀音（經白玉）</option>"
    dropstr += "<option value='1470'>【5042】中壢-觀音海水浴場（經新坡）</option>"
    dropstr += "<option value='500'>【5044】桃園-龍潭（經十一份）</option>"
    break;
case "全部":
    dropstr += "<option value='3420'>【101】桃園-文中路-果菜市場 (原桃園101路)</option>"
    dropstr += "<option value='3030'>【102】桃園-景雲新村 (原桃園2路)</option>"
    dropstr += "<option value='3060'>【103】桃園-華映公司 (原桃園103路)</option>"
    dropstr += "<option value='3080'>【105】桃園-大有路 (原桃園5路)</option>"
    dropstr += "<option value='3290'>【116】中壢-自立新村 (原中壢6路)</option>"
    dropstr += "<option value='3200'>【107】桃園-中平路 (原桃園107路)</option>"
    dropstr += "<option value='3460'>【109】桃園-新興高中 (原桃園109路)</option>"
    dropstr += "<option value='3360'>【110】中壢-文化路 (原中壢110路)</option>"
    dropstr += "<option value='3480'>【111】中壢-南勢 (原中壢111路)</option>"
    dropstr += "<option value='3260'>【112南】中壢-陸軍專科學校 (原112南路)</option>"
    dropstr += "<option value='3180'>【113】桃園-幸福社區 (原桃園13路)</option>"
    dropstr += "<option value='3520'>【115】中壢-平東路 (原中壢115路)</option>"
    dropstr += "<option value='3400'>【117】桃園-寶慶路口 (原桃園17路)</option>"
    dropstr += "<option value='3370'>【118】中壢-中壢高中 (原中壢118路)</option>"
    dropstr += "<option value='3380'>【119】中壢-壢新醫院 (原中壢119路)</option>"
    dropstr += "<option value='3350'>【120】中壢-太子鎮 (原中壢102路)</option>"
    dropstr += "<option value='3090'>【125】桃園-三聖宮 (原桃園5甲)</option>"
    dropstr += "<option value='3220'>【132】中壢-中央大學 (原中壢2路)</option>"
    dropstr += "<option value='3450'>【135】中壢-內壢高中 (原中壢15路)</option>"
    dropstr += "<option value='3110'>【137】桃園-銘傳大學 (原桃園7路)</option>"
    dropstr += "<option value='3120'>【139】桃園-龍壽街-新庄廟 (原桃園9路)</option>"
    dropstr += "<option value='3130'>【150】桃園-煉油廠 (原桃園10路)</option>"
    dropstr += "<option value='3191'>【151】桃園-同安街 (原桃園15路)</option>"
    dropstr += "<option value='3192'>【152】桃園-同安街 (原桃園15路)</option>"
    dropstr += "<option value='3280'>【155】中壢-元智大學 (原中壢5路)</option>"
    dropstr += "<option value='3281'>【156】中壢-元智大學 (原中壢5路)</option>"
    dropstr += "<option value='3440'>【157】桃園-八德-新興高中 (原桃園117路)</option>"
    dropstr += "<option value='3300'>【169】中壢-華勛社區 (原中壢9路)</option>"
    dropstr += "<option value='3330'>【171】中壢-高鐵桃園站 (原中壢11路)</option>"
    dropstr += "<option value='3020'>【1甲】中壢-桃園 (原中壢1甲)</option>"
    dropstr += "<option value='3010'>【1路】中壢-桃園 (原中壢1路)</option>"
    dropstr += "<option value='1371'>【201】蘆竹-八德 (原201)</option>"
    dropstr += "<option value='3160'>【206】桃園-高鐵桃園站 (原桃園106路)</option>"
    dropstr += "<option value='3550'>【301路】龜山-楊梅 (原301路)</option>"
    dropstr += "<option value='16010'>【501】台灣好行景點接駁慈湖線</option>"
    dropstr += "<option value='7010'>【701】龍潭-長庚醫院 (原701)</option>"
    dropstr += "<option value='7020'>【702】大溪-長庚醫院 (原702)</option>"
    dropstr += "<option value='1501'>【5000】桃園-至善工商</option>"
    dropstr += "<option value='20'>【5001】桃園-三峽（經中湖）</option>"
    dropstr += "<option value='50'>【5005】桃園-三峽（經尖山）</option>"
    dropstr += "<option value='680'>【5006】中壢-長安路</option>"
    dropstr += "<option value='580'>【5007】中壢-東社</option>"
    dropstr += "<option value='970'>【5008】桃園-中壢（經龍岡）</option>"
    dropstr += "<option value='15060'>【5009】桃園-新莊（經台一線）</option>"
    dropstr += "<option value='70'>【5010】桃園-中壢（經仁美、八德）</option>"
    dropstr += "<option value='80'>【5011】桃園-中壢（經竹巷）</option>"
    dropstr += "<option value='3132'>【5012】桃園-蘆竹國小</option>"
    dropstr += "<option value='3131'>【5014】桃園-南崁（經南祥路）</option>"
    dropstr += "<option value='260'>【5015】桃園-大園（經南崁）</option>"
    dropstr += "<option value='1830'>【5016】桃園-竹圍（經山腳）</option>"
    dropstr += "<option value='780'>【5017】中壢-沙崙海水浴場（經楊厝）</option>"
    dropstr += "<option value='1370'>【5018】桃園-水尾（經蘆竹）</option>"
    dropstr += "<option value='170'>【5019】桃園-沙崙（經蘆竹）</option>"
    dropstr += "<option value='1000'>【5020】桃園-下福</option>"
    dropstr += "<option value='310'>【5021】桃園-下海湖</option>"
    dropstr += "<option value='250'>【5022】桃園-沙崙（經南崁）</option>"
    dropstr += "<option value='270'>【5023】桃園-大園（經楊厝）</option>"
    dropstr += "<option value='820'>【5025】中壢-新屋（經藍埔）</option>"
    dropstr += "<option value='740'>【5026】中壢-新坡（經富源）</option>"
    dropstr += "<option value='810'>【5027】中壢-後湖</option>"
    dropstr += "<option value='791'>【5028】新屋-下北湖</option>"
    dropstr += "<option value='690'>【5029】中壢-高榮磚廠</option>"
    dropstr += "<option value='790'>【5030】中壢-下北湖</option>"
    dropstr += "<option value='802'>【5031】中壢-永安漁港（經新屋）</option>"
    dropstr += "<option value='840'>【5032】中壢-觀音（經石磊）</option>"
    dropstr += "<option value='850'>【5033】中壢-觀音（經保生）</option>"
    dropstr += "<option value='801'>【5034】中壢-頭洲國小（經富源）</option>"
    dropstr += "<option value='743'>【5034】中壢-富源-頭洲國小</option>"    
    dropstr += "<option value='801'>【5035】中壢-新屋（經過嶺）</option>"
    dropstr += "<option value='720'>【5038】中壢-東福園（經山東）</option>"
    dropstr += "<option value='1470'>【5039】中壢-中壢（經永安、觀音）</option>"
    dropstr += "<option value='230'>【5040】桃園-觀音（經中厝）</option>"
    dropstr += "<option value='870'>【5041】中壢-觀音（經白玉）</option>"
    dropstr += "<option value='1470'>【5042】中壢-觀音海水浴場（經新坡）</option>"
    dropstr += "<option value='871'>【5043】中壢-樹林新村</option>"
    dropstr += "<option value='500'>【5044】桃園-龍潭（經十一份）</option>"
    dropstr += "<option value='510'>【5045】桃園-石門水庫（經員樹林）</option>"
    dropstr += "<option value='520'>【5046】大溪-龍潭（經九龍村）</option>"
    dropstr += "<option value='550'>【5048】龍潭-石門水庫（經十一份）</option>"   
    dropstr += "<option value='560'>【5049】龍潭-逸園（經三角林）</option>"
    dropstr += "<option value='610'>【5050】中壢-石門水庫（經員樹林）</option>"
    dropstr += "<option value='551'>【5051】龍潭-大坪</option>"
    dropstr += "<option value='490'>【5053】桃園-龍潭（經九龍村）</option>"
    dropstr += "<option value='570'>【5054】中壢-龍潭（經九龍村）</option>"
    dropstr += "<option value='602'>【5055】中壢-石門水庫（經山仔頂）</option>"
    dropstr += "<option value='510'>【5056】桃園-大坪</option>"
    dropstr += "<option value='350'>【5057】桃園-長庚醫院桃園分院</option>"
    dropstr += "<option value='10'>【5059】桃園-桃園機場（經南崁）</option>"
    dropstr += "<option value='110'>【5060】桃園-榮民之家（經更寮腳）</option>"
    dropstr += "<option value='160'>【5061】桃園-建國十九村（經大竹）</option>"
    dropstr += "<option value='320'>【5063】桃園-竹林山寺（經光華坑）</option>"
    dropstr += "<option value='360'>【5064】桃園-三德煤礦（經龜山、圓光橋）</option>"
    dropstr += "<option value='920'>【5065】桃園-體育學院（經大埔）</option>"
    dropstr += "<option value='923'>【5066】桃園-長庚桃園分院</option>"
    dropstr += "<option value='1240'>【5068】桃園-合家歡社區（經龜山后街）</option>"
    dropstr += "<option value='900'>【5069】桃園-竹林山寺（經赤塗崎）</option>"
//    dropstr += "<option value='1010'>【5071】桃園-竹林山寺（經外社）</option>"
//    dropstr += "<option value='1010'>【5072】桃園-外社</option>"
    dropstr += "<option value='1010'>【5071】桃園-竹林山寺（經外社）</option>"
    dropstr += "<option value='1011'>【5072】桃園-外社</option>"
    dropstr += "<option value='1012'>【5073】桃園-頂社</option>"
    dropstr += "<option value='322'>【5074】桃園-長庚醫院(許可證)</option>"    
    dropstr += "<option value='15061'>【5075】桃園-新莊-林口長庚醫院</option>"
    dropstr += "<option value='330'>【5076】桃園-樹林（經嶺頂）</option>"
    dropstr += "<option value='650'>【5077】中壢-大園（經柴梳崙）</option>"
    dropstr += "<option value='770'>【5078】中壢-建國八村</option>"
    dropstr += "<option value='760'>【5079】中壢-下內定（經五塊厝）</option>"
    dropstr += "<option value='1130'>【5081】中壢-大園（經下洽溪）</option>"
    dropstr += "<option value='640'>【5082】中壢-大園（經雙溪口）</option>"
    dropstr += "<option value='190'>【5083】大園-潮音</option>"
    dropstr += "<option value='200'>【5084】大園-下古亭</option>"
    dropstr += "<option value='210'>【5085】大園-沙崙港</option>"
    dropstr += "<option value='180'>【5086】桃園-大園（經五塊厝）</option>"
    dropstr += "<option value='630'>【5087】中壢-大園（經青埔）</option>"
    dropstr += "<option value='660'>【5089】中壢-桃園機場（經大園）</option>"
    dropstr += "<option value='11480'>【5090】桃園-上巴陵-林班口</option>"
    dropstr += "<option value='11490'>【5091】中壢-上巴陵-林班口</option>"
    dropstr += "<option value='1380'>【5093】大溪-羅浮-巴陵</option>"
    dropstr += "<option value='1390'>【5094】大溪-三光（沙崙子）-巴陵</option>"
    dropstr += "<option value='100'>【5095】桃園-中壢（經更寮腳）</option>"
    dropstr += "<option value='390'>【5096】桃園-大溪（經更寮腳）</option>"
    dropstr += "<option value='460'>【5097】大溪-竹篙厝（經美華）</option>"
    dropstr += "<option value='480'>【5098】中壢-大溪（經官路缺）</option>"
    dropstr += "<option value='10110'>【5100】大溪-龍岡-八德</option>"
    dropstr += "<option value='910'>【5099】大溪-阿姆坪（經懷德橋）</option>"
    dropstr += "<option value='1490'>【5101】大溪-鶯歌（經中新）</option>"
    dropstr += "<option value='1500'>【5104】大溪-復興</option>"
    dropstr += "<option value='430'>【5105】大溪-小烏來（經三民）</option>"
    dropstr += "<option value='440'>【5106】大溪-霞雲村（經 復興）</option>"
    dropstr += "<option value='450'>【5107】大溪-蝙蝠洞（經三民）</option>"
    dropstr += "<option value='1283'>【5109】大溪-高遶（經羅浮）</option>"
    dropstr += "<option value='470'>【5110】大溪-坪林</option>"
    dropstr += "<option value='1100'>【5112】大溪-中壢（經八德）</option>"
    dropstr += "<option value='11'>【5115】桃園-高鐵桃園站（經南崁、桃園機場）</option>"
    dropstr += "<option value='15080'>【5116】桃園-台北長庚醫院（經松山機場）</option>"
    dropstr += "<option value='15160'>【9005】桃園市-中山高-台北市</option>"
    dropstr += "<option value='1520'>【9023】桃園-中山高-臺北市士林區</option>"
    dropstr += "<option value='1530'>【9025】中壢-中山高-臺北市松山區</option>"
    dropstr += "<option value='15880'>【9102】台北-台一線-桃園</option>"
    dropstr += "<option value='15990'>【9103】大溪-貨饒村-台北</option>"    
	break;
}
dropstr+="</select>"
parent.document.getElementById("divDrop").innerHTML=dropstr;
}

function addbusrouteshp(routename,goback,comefirst)
{
  if(RouteShp.length > 0) removebusrouteshp(1);
  
  if (goback == 1)
    RouteShp.push({n:(routename+'_go'),shp:-1,c:0});
  else 
    RouteShp.push({n:(routename+'_back'),shp:-1,c:1});
  
  if(comefirst==0)GetRouteBound(routename+'_go');
  GetBusandStopOfRoute(routename,goback);
  GetStopofRoute(routename,goback);
  CreateDynamicBus();
  
  switch(routename)
{
//case "70":
//case "80":
//case "480":
//case "600":
//case "660":
//case "680":
//case "720":
//case "740":
//case "970":
//case "3010":
//case "3020":
//case "3220":
//case "3260":
//case "3270":
//case "3280":
//case "3291":
//case "3300":
//case "3330":
//case "3360":
//case "3450":
//case "3480":
//case "3550":
    case "3480":
    case "3260":
    case "3520":
    case "3220":
    case "3450":
    case "3280":
    case "3281":
    case "3300":
    case "3330":
    case "3020":
    case "3010":
    case "3550":
    case "680":
    case "970":
    case "70":
    case "80":
    case "3370":
    case "3380":
    case "3350":

    MovePosition(276949,2762723,5);
    break;
	
//case "10":
//case "110":
//case "320":
//case "350":
//case "360":
//case "370":
//case "900":
//case "920":
//case "1010":
//case "1240":
//case "3030":
//case "3060":
//case "3080":
//case "3090":
//case "3110":
//case "3120":
//case "3130":
//case "3160":
//case "3180":
//case "3191":
//case "3200":
//case "3400":
//case "3420":
//case "3460":
case "3420":
case "3030":
case "3060":
case "3080":
case "3200":
case "3460":
case "3360":
case "3180":
case "3400":
case "3090":
case "3110":
case "3120":
case "3130":
case "3191":
case "3192":
case "3160":
case "15060":
case "350":
case "10":
case "110":
case "320":
case "360":
case "920":
case "1240":
case "15061":
case "15080":
case "15160":
case "15880":
case "3440":
    MovePosition(282949,2765723,5);	
    break;

case "20":
case "50":	
//case "20":
//case "50":
//case "15110": 
//case "1490": 
    MovePosition(282949,2760723,5);
	break;
	
//case "162": 
//case "180":
//case "190":
//case "201":
//case "211":
//case "270":
//case "630":
//case "640":
//case "650":
//case "760":
//case "770":
//case "980":
//case "1130":
//case "1360":
case "160":
case "650":
case "770":
case "760":
case "1130":
case "640":
case "190":
case "200":
case "210":
case "180":
case "630":
case "660":
//case "170": 
   MovePosition(270949,2769723,5);
    break;
	
case "250":
case "310":
case "780":
case "1000":
case "1370":
case "3131":
case "260":
case "1830":
   MovePosition(280949,2769723,5);
    break;
	
//case "790":
//case "801":
//case "810":
//case "820":

case "791":
case "820":
case "740":
case "810":
case "790":
case "802":
case "840":
case "850":
case "801":
case "690":
//case "230":
//case "840":
//case "850":
//case "860":
//case "870":
//case "1470":
case "720":
case "1470":
case "230":
case "870":
case "1470":
case "871":
	MovePosition(265049,2765723,5);//觀音&新屋
	 break;
	
//case "30":
//case "430":
//case "440":
//case "450":
//case "460":
//case "470":
//case "520":
//case "530":
//case "910":
//case "1280":
//case "1380":
//case "1500":
//case "11490":
//case "11480":
//case "15990":
case "7020":
case "11480":
case "11490":
case "1380":
case "390":
case "460":
case "480":
case "910":
case "1490":
case "1500":
case "430":
case "440":
case "450":
case "470":
case "15990":
case "1390":
case "1283":
case "1100":

	MovePosition(276949,2752723,5);
    break;

case "7010":
case "500":
case "510":
case "550":
case "560":
case "610":
case "551":
case "490":
case "570":
case "602":
case "510":
//case "490": 
//case "500":
//case "501":
//case "510":
//case "550":
//case "560":
//case "570":
//case "610": 

//case "390":  
	MovePosition(276949,2755723,5);
    break;
	
case "7020": //702路(大溪-林口長庚)
case "7010": //701路(龍潭-林口長庚)
	MovePosition(282949,2762523,5);
    break;
	
case "15080":	//桃園-松山機場(台北長庚醫院)
case "15060":	//桃園-新莊
case "15880": //桃園-台一線-台北
    MovePosition(297000,2768756,5)
    break;
	
default:
    MovePosition(276949,2762723,5);//預
    break;
}
  
    
  parent.frames['Ifdynamic'].location.href=('./aspx/BusStopTimeIFrame.aspx?Routename='+routename+'&Goback='+goback);  
  parent.document.getElementById("Ifdynamic").height=330;
  parent.document.getElementById("Ifdynamic").width=250
}

function GetStopofRoute(routename,goback)
{
	hl.SetLinkFinish=SetLinkFinish2;
	var SetPage='./ASPX/DBusStop.aspx?Routename='+routename+'&Goback='+goback;
	hl.makeReques(SetPage,hl,'get',null,false);
}

function GetBusandStopOfRoute(routename,goback)
{
	parent.frames['Ifdynamic'].location.href=('./aspx/BusStopTimeIFrame.aspx?Routename='+routename+'&Goback='+goback);  
	bushl.SetLinkFinish=SetLinkFinish1;
	var SetPage='./ASPX/DBusLocation.aspx?Routename='+routename+'&Goback='+goback;
//window.open(SetPage);
	bushl.makeReques(SetPage,bushl,'get',null,false);
}

function SetLinkFinish1()
{
	//window.open('').document.write(bushl.HpptRequest.responseText);
	ActionPOI = bushl.HpptRequest.responseText.split('|_');
	
	for (var i=0;i<ActionPOI.length-1;i++)
  {
    //alert(ActionPOI[i]);
  	ActionPOI[i]=ActionPOI[i].split('&_');
  	//alert(ActionPOI[i]);
  	for (var j=0;j<ActionPOI[i].length-1;j++)
  	{
  		ActionPOI[i][j]=ActionPOI[i][j].split(',_');
//alert(ActionPOI[i][j]);
  	}
  }
  CreateAction(true);
  if(RouteShp.length > 0)
  {
  	timeID =setTimeout("ReBusandStopOfRoute()",20000);
  }
}

function SetLinkFinish2()
{
	//window.open('').document.write(hl.HpptRequest.responseText);
	StopPOI = hl.HpptRequest.responseText.split('|_');
	for (var i=0;i<StopPOI.length-1;i++)
  {
  	StopPOI[i]=StopPOI[i].split('&_');
  	for (var j=0;j<StopPOI[i].length-1;j++)
  	{
  		StopPOI[i][j]=StopPOI[i][j].split(',_');
//alert(StopPOI[i][j]);
  	}
  }
  CreateBus(true);
}

function GetRouteBound(routename)
{
	hl.SetLinkFinish=SetLinkFinish4;
	var SetPage='./aspx/ShpBound.aspx?Layer='+routename;
	hl.makeReques(SetPage,hl,'get',null,false);
}

function SetLinkFinish4()
{
	var boundxy;
	boundxy = hl.HpptRequest.responseText.split(',');
  SetMapBound(gMapBase,Number(boundxy[2])-2100,Number(boundxy[1])+2100,Number(boundxy[0])+2100,Number(boundxy[3])-2100);
	gMapBase.RefreshMap(true,true);
}

function ReBusandStopOfRoute()
{
	var route='',goback='';
  
	if (RouteShp.length > 0)
	{
	  if (RouteShp[0].c == 0 )
	  {
	   route = RouteShp[0].n.replace('_go','');
	   goback = '1';
	   //alert('1');
	  }
	  else if (RouteShp[0].c == 1 )
	  {
	   route = RouteShp[0].n.replace('_back','');
	   goback = '2';
	   //alert('2');
	  }
	  
	  parent.frames['Ifdynamic'].location.href=('./aspx/BusStopTimeIFrame.aspx?Routename='+route);  
	  bushl.SetLinkFinish=SetLinkFinish1;
	  var SetPage='./ASPX/DBusLocation.aspx?Routename='+route;
	  //window.open(SetPage);
	  bushl.makeReques(SetPage,bushl,'get',null,false);
	}
}


function CreateAction(t)
{
	
	var img = new String();
	var tmps = new Array();
	var goback = new String();
	var w = gMapBase.getClientWidth();
	var h = gMapBase.getClientHeight();

	if(t)
	{
	  if(ActionPOI.length > 0)
	  {	    
//alert(ActionPOI);

	    
	    if(ActionPOI[0] != null)
	  	{
	  		var routename='';
	  	  for (var i=0 ; i <ActionPOI[0].length-1; i++)
	  	  {
//alert(ActionPOI[0][i][5]);
	  	    if(ActionPOI[0][i][5] == 1) //去
	  	    {
	  	        if(parseInt(ActionPOI[0][i][3]) >= 0 && parseInt(ActionPOI[0][i][3])< 180)
	  	        {
	  	            img='./images/car1.gif';
	  	        }
	  	        else
	  	        {
	  	            img='./images/car1o.gif';
	  	        }	            
	            routename = RouteShp[0].n.replace('_go','');
	            goback='去程';
	  	    }
	        else if(ActionPOI[0][i][5] == 2) 
	        {
	            if(parseInt(ActionPOI[0][i][3]) >= 0 && parseInt(ActionPOI[0][i][3])< 180)
	  	        {
	  	            img='./images/car2.gif';
	  	        }
	  	        else
	  	        {
	  	            img='./images/car2o.gif';
	  	        }
	            routename = RouteShp[0].n.replace('_back','');
	            goback='回程';
	        }
	        else if(ActionPOI[0][i][5] == 0) 
	        {
    	  	    if(parseInt(ActionPOI[0][i][3]) >= 0 && parseInt(ActionPOI[0][i][3])< 180)
	  	        {
	                img='./images/car0.gif';	  	        
	  	        }
	  	        else
	  	        {
	                img='./images/car0o.gif';
	  	        }

	            routename = RouteShp[0].n.replace('_back','');
	            goback='循環';
	        }
	        
	  		  if(routename.indexOf('_go')==-1 || routename.indexOf('_back')==-1)
	  		  {
	  		    ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(ActionPOI[0][i][1]),RealToMapPosY(ActionPOI[0][i][2]));
	  			  if((ScreenClientPt.X>0 && ScreenClientPt.X<w)&&(ScreenClientPt.Y>0 && ScreenClientPt.Y<h) ) //ActionPOI[0][i][5]
    		    {
    		      tmps.push('<img border="0" src="'+img+'" title="'+'車號：'+ActionPOI[0][i][0]+'  路線：'+ActionPOI[0][i][4]+'  方向：'+goback+'   角度: '+ActionPOI[0][i][3]); 
    		      tmps.push('" onmouseover="this.style.zIndex=0;"  onmouseout = "this.style.zIndex=0;" style= "position:absolute;left:');
    		      tmps.push((ScreenClientPt.X-14)+'px;top:'+(ScreenClientPt.Y-9)+'px;z-index:0;"/>');	    
    		    }
    		  }	
	  	  }
	    }
	    document.all.RouteListLayer.innerHTML=tmps.join('');
	  }

  }         
}

function CreateBus(t)
{
	//StopPOI 0 為起
	var img = new String();
	var tmps = new Array();
	var w = gMapBase.getClientWidth();
	var h = gMapBase.getClientHeight();

	if(t)
	{
		if(StopPOI.length > 0)
	  {	    
	    
	  	if(StopPOI[0] != null)
	  	{
	  	  for (var i=0 ; i <StopPOI[0].length-1; i++)
	  	  {
	  		  ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(StopPOI[0][i][3]),RealToMapPosY(StopPOI[0][i][4]));
	  			if((ScreenClientPt.X>0 && ScreenClientPt.X<w)&&(ScreenClientPt.Y>0 && ScreenClientPt.Y<h) )
    		  {
    		  if(StopPOI[0][i][6] == 0)
    		  {
    		  	if (StopPOI[0][i][2] == 1)
    		  		img='images/station3.gif';
    		  	else
    		  		img='images/station1.gif';
    		  }
    		  else if(StopPOI[0][i][6] == 1)
    		  {
    		  	if (StopPOI[0][i][2] == 1)
    		  		img='images/station3_1.gif';
    		  	else
    		  		img='images/station1_1.gif';
    		  }
    		  else if(StopPOI[0][i][6] == 2)
    		  {
    		  	if (StopPOI[0][i][2] == 1)
    		  		img='images/station3_2.gif';
    		  	else
    		  		img='images/station1_2.gif';
    		  }
    		  else if(StopPOI[0][i][6] == 3)
    		  {
    		  	if (StopPOI[0][i][2] == 1)
    		  		img='images/station3_3.gif';
    		  	else
    		  		img='images/station1_3.gif';
    		  }
    		   else if(StopPOI[0][i][6] == 4)
    		  {
    		  	if (StopPOI[0][i][2] == 1)
    		  		img='images/station3_4.gif';
    		  	else
    		  		img='images/station1_4.gif';
    		  }
  		  		//alert(StopPOI[0][i][2]);
    		  		if (StopPOI[0][i][1] >= 10)
    		  		{
    		  		    if  (StopPOI[0][i][1] >= 100) //大於100
    		  		    {    		                    		                
    		                if(StopPOI[0][i][6] == 0)
    		                {
    		                    tmps.push('<img border="0" src="'+img+'" title="'+StopPOI[0][i][0]);
    		                    tmps.push('" onmouseover="this.style.zIndex=3;stopInfo(\''+StopPOI[0][i][5]+'\',\''+StopPOI[0][i][6]+'\',\''+StopPOI[0][i][2]+'\');"  onmouseout = "this.style.zIndex=3;" style= "position:absolute;left:');
    		                    tmps.push((ScreenClientPt.X-10)+'px;top:'+(ScreenClientPt.Y-10)+'px;z-index:3;" ');
    		                }
    		                else
    		                {
    		                    tmps.push('<img border="0" src="'+img+'" title="支線('+ StopPOI[0][i][6] +') '+StopPOI[0][i][0]);
    		                    tmps.push('" onmouseover="this.style.zIndex=2;stopInfo(\''+StopPOI[0][i][5]+'\',\''+StopPOI[0][i][6]+'\',\''+StopPOI[0][i][2]+'\');"  onmouseout = "this.style.zIndex=2;" style= "position:absolute;left:');
    		                    tmps.push((ScreenClientPt.X-10)+'px;top:'+(ScreenClientPt.Y-10)+'px;z-index:2;" ');
    		                }
    		                
    		                tmps.push('onclick="stopInfo(\''+StopPOI[0][i][5]+'\',\''+StopPOI[0][i][6]+'\',\''+StopPOI[0][i][2]+'\');" />');	
    		                tmps.push('<font onclick="stopInfo(\''+StopPOI[0][i][5]+'\',\''+StopPOI[0][i][6]+'\',\''+StopPOI[0][i][2]+'\');" ');
    		                
    		                if(StopPOI[0][i][6] == 0)
    		                {tmps.push(' style= "font-family:Arial;position:absolute;font-weight: bold;color: white;font-size:10px; left:'+((ScreenClientPt.X)-8)+'px;top:'+((ScreenClientPt.Y)-6)+'px;z-index:3;">'+StopPOI[0][i][1]+'</font>');}
    		                else
    		                {tmps.push(' style= "font-family:Arial;position:absolute;font-weight: bold;color: white;font-size:10px; left:'+((ScreenClientPt.X)-8)+'px;top:'+((ScreenClientPt.Y)-6)+'px;z-index:2;">'+StopPOI[0][i][1]+'</font>');}
    		            }
    		            else //10~ 99
    		            {
    		                if(StopPOI[0][i][6] == 0)
    		                {
    		                    tmps.push('<img border="0" src="'+img+'" title="'+StopPOI[0][i][0]);
    		                    tmps.push('" onmouseover="this.style.zIndex=3;stopInfo(\''+StopPOI[0][i][5]+'\',\''+StopPOI[0][i][6]+'\',\''+StopPOI[0][i][2]+'\');"  onmouseout = "this.style.zIndex=3;" style= "position:absolute;left:');
    		                    tmps.push((ScreenClientPt.X-10)+'px;top:'+(ScreenClientPt.Y-10)+'px;z-index:3;" ');
    		                }
    		                else
    		                { 
    		                    tmps.push('<img border="0" src="'+img+'" title="支線('+ StopPOI[0][i][6] +') '+StopPOI[0][i][0]);
    		                    tmps.push('" onmouseover="this.style.zIndex=2;stopInfo(\''+StopPOI[0][i][5]+'\',\''+StopPOI[0][i][6]+'\',\''+StopPOI[0][i][2]+'\');"  onmouseout = "this.style.zIndex=2;" style= "position:absolute;left:');
    		                    tmps.push((ScreenClientPt.X-10)+'px;top:'+(ScreenClientPt.Y-10)+'px;z-index:2;" ');
    		                }
    		                
    		                tmps.push('onclick="stopInfo(\''+StopPOI[0][i][5]+'\',\''+StopPOI[0][i][6]+'\',\''+StopPOI[0][i][2]+'\');" />');	 //stopInfo(\''+StopPOI[0][i][5]+'\');" />');	
    		                tmps.push('<font onclick="stopInfo(\''+StopPOI[0][i][5]+'\',\''+StopPOI[0][i][6]+'\',\''+StopPOI[0][i][2]+'\');" ');
    		                
    		                if(StopPOI[0][i][6] == 0)
    		                {tmps.push(' style= "font-family:Arial;position:absolute;font-weight: bold;color: white;font-size:10px; left:'+((ScreenClientPt.X)-6)+'px;top:'+((ScreenClientPt.Y)-6)+'px;z-index:3;">'+StopPOI[0][i][1]+'</font>');}
    		                else
    		                {tmps.push(' style= "font-family:Arial;position:absolute;font-weight: bold;color: white;font-size:10px; left:'+((ScreenClientPt.X)-6)+'px;top:'+((ScreenClientPt.Y)-6)+'px;z-index:2;">'+StopPOI[0][i][1]+'</font>');}
    		            }
    		        }
    		        else //小於10
    		        {
    		                if(StopPOI[0][i][6] == 0)
    		                {
    		                    tmps.push('<img border="0" src="'+img+'" title="'+StopPOI[0][i][0]);
    		                    tmps.push('" onmouseover="this.style.zIndex=3;stopInfo(\''+StopPOI[0][i][5]+'\',\''+StopPOI[0][i][6]+'\',\''+StopPOI[0][i][2]+'\');"  onmouseout = "this.style.zIndex=3;" style= "position:absolute;left:');
    		                    tmps.push((ScreenClientPt.X-10)+'px;top:'+(ScreenClientPt.Y-10)+'px;z-index:3;" ');
    		                }
    		                else
    		                {
    		                    tmps.push('<img border="0" src="'+img+'" title="支線('+ StopPOI[0][i][6] +') '+StopPOI[0][i][0]);
    		                    tmps.push('" onmouseover="this.style.zIndex=2;stopInfo(\''+StopPOI[0][i][5]+'\',\''+StopPOI[0][i][6]+'\',\''+StopPOI[0][i][2]+'\');"  onmouseout = "this.style.zIndex=2;" style= "position:absolute;left:');
    		                    tmps.push((ScreenClientPt.X-10)+'px;top:'+(ScreenClientPt.Y-10)+'px;z-index:2;" ');
    		                }
    		                
    		                tmps.push('onclick="stopInfo(\''+StopPOI[0][i][5]+'\',\''+StopPOI[0][i][6]+'\',\''+StopPOI[0][i][2]+'\');" />');	
    		                tmps.push('<font onclick="stopInfo(\''+StopPOI[0][i][5]+'\',\''+StopPOI[0][i][6]+'\',\''+StopPOI[0][i][2]+'\');" ');
    		                if(StopPOI[0][i][6] == 0)
    		                {tmps.push(' style= "font-family:Arial;position:absolute;font-weight: bold;color: white;font-size:10px; left:'+((ScreenClientPt.X)-3)+'px;top:'+((ScreenClientPt.Y)-6)+'px;z-index:3;">'+StopPOI[0][i][1]+'</font>');}
    		                else
    		                {tmps.push(' style= "font-family:Arial;position:absolute;font-weight: bold;color: white;font-size:10px; left:'+((ScreenClientPt.X)-3)+'px;top:'+((ScreenClientPt.Y)-6)+'px;z-index:2;">'+StopPOI[0][i][1]+'</font>');}
    		        }
    		  }		  
	  	  }
	  	  document.all.StopListLayer.innerHTML=tmps.join('');
	    }
	  }  
	}
}

function stopInfo(stationId,routename,goback)
{
	hl.SetLinkFinish=SetLinkFinish3;
	var SetPage='./ASPX/DStopInfo.aspx?StationId='+stationId+'&Routename='+routename+'&goback='+goback;
	hl.makeReques(SetPage,hl,'get',null,false);
}

function SetLinkFinish3()
{
	var Info = hl.HpptRequest.responseText.split('|_');
  if (Info[0].length > 0)
  {
  	for (var i=0;i<Info.length-1;i++)
    {
    	Info[i]=Info[i].split('&_');
    	for (var j=0;j<Info[i].length-1;j++)
    	{
    		Info[i][j]=Info[i][j].split(',_');
    	}
    }
    showInfo(Info[0][0][0],Info[0][0][1],Info[0][0][2],Info[0][0][3],Info[0][0][4],Info[0][0][5],Info[0][0][6]);
  }
}


function showInfo(route,stationname,goback,estimatetime,seq,cx,cy)
{
	alert(RouteShp[0]);
	var tmps = new Array();
	smalldivX=cx;smalldivY=cy;
	ScreenClientPt =gMapBase.FromMapPoint(RealToMapPosX(smalldivX),RealToMapPosY(smalldivY));
	if (estimatetime == 'null') estimatetime = '離站';
	if (estimatetime < 3 ) estimatetime = ' 即將到站';
	
  tmps.push('<TABLE WIDTH=146 BORDER=0 CELLPADDING=0 CELLSPACING=0 onmouseover="clearinfo()" ><TR>');
	tmps.push('<TD><IMG SRC="images/page/a_01.gif" WIDTH=117 HEIGHT=16 ALT=""></TD>');
	tmps.push('<TD><IMG SRC="images/page/a_02.gif" WIDTH=1 HEIGHT=16 ALT=""></TD>');
	tmps.push('<TD><IMG SRC="images/page/a_03.gif" onclick="clearinfo()" WIDTH=28 HEIGHT=16 ALT=""></TD></TR>');
	tmps.push('<TR><TD COLSPAN=3 background="images/page/a_04.gif">');
	
  tmps.push('<table width="140" border="0"><tr><td><table width="140" border="0">');
//	tmps.push('<tr><td>&nbsp;&nbsp;路線：'+route+'</td>');
//	tmps.push('<td>&nbsp;&nbsp;站序：'+seq+'</td></tr>');
	tmps.push('</table> <table width="140" border="0"><tr>');
  tmps.push('<td>&nbsp;&nbsp;車站：'+stationname+'</td>');
  tmps.push('</tr></table><table width="140" border="0"><tr>');
  tmps.push('<td>&nbsp;&nbsp;'+((goback==1)?'去程':'回程')+'(預估到站)：'+estimatetime+'</td>');
  tmps.push('</tr></table></td></tr></table></td></tr>');
  
    tmps.push('<TR><TD COLSPAN=3><IMG SRC="images/page/a_05.gif" WIDTH=146 HEIGHT=29 ALT=""></TD></TR></TABLE>');
       
    TabInfo.style.left = ScreenClientPt.X-50;
    TabInfo.style.top = ScreenClientPt.Y-100;
    TabInfo.style.zIndex=100;
    TabInfo.visibility = "visible";
    TabInfo.innerHTML = tmps.join('');
  
    this.clearinfo = function()
    {
      TabInfo.innerHTML ='';
    }
}


function CreateDynamicBus()
{
	var tmp=new String();
	for(var i=0;i<RouteShp.length;i++)
	{
	if(RouteShp[i].shp == -1)
		{
		tmp=RouteShp[i].n;
		while(tmp.indexOf('(') > -1 || tmp.indexOf(')') > -1 ||tmp.indexOf('-') > -1)
		tmp=tmp.replace('(','').replace(')','').replace("-","");
		RouteShp[i].shp=_LayerManager.AddRouteLayer(tmp,tmp,(RouteShp[i].c));
		//RouteShp[i].c=i%10;
		}
	else _LayerManager.HideLayer(RouteShp[i].shp);
	}
	
}

function removebusrouteshp(ifSearch)
{
	for(var i= RouteShp.length-1 ;i >= 0;i--)
	{
		  _LayerManager.RemovePointLayer(RouteShp[i].shp);
		  RouteShp.splice(i,1);
		  document.all.RouteListLayer.innerHTML = '';
		  document.all.StopListLayer.innerHTML = '';
		  clearTimeout(timeID);
		  ActionPOI='';  // 公車動態
      StopPOI='';  // 站牌
		  if (ifSearch == null)
		  {
		    parent.frames['Ifdynamic'].stoptime();
		    parent.frames['Ifdynamic'].location.href='about:blank';
		  }
		  document.all.TabInfo.innerHTML = '';
	}
}

