﻿function GetEvenData(RV)
{
  if(RV!=null)
  {
    MySpeedAndEven="Even";
  }
  
  if(MySpeedAndEven=="Even")
  { 
     var lt = gMapBase.ToMapPoint(0, 0);  
	 var ltX= parseInt(MapToRealPosX(lt.X));
     var ltY= parseInt(MapToRealPosY(lt.Y));
     
     var wt = gMapBase.ToMapPoint(gMapBase.getClientHeight(), gMapBase.getClientWidth());  
	 var wtX= parseInt(MapToRealPosX(wt.X));
     var wtY= parseInt(MapToRealPosY(wt.Y));
     document.getElementById('VmlPoiLayerObj').innerHTML ="";
              
       var SetPage="./ASPX/Geometry.aspx?Act=3&LX="+ltX+"&LY="+ltY+"&WX="+wtX+"&WY="+wtY+"&Lang="+Lang;
       hMyF1.SetLinkFinish=PushEvenVML;
       hMyF1.makeReques(SetPage,hMyF1,'post',null,false); 
       document.getElementById('RoadShowLayer').style.visibility='Hidden'; 
  }
}

function PushEvenVML()
{
  var tmps=new Array();
  var p = new String();
  var w = gMapBase.getClientWidth();
  var h = gMapBase.getClientHeight();
  var j=0;
  PushSpeedEvenVml=hMyF1.HpptRequest.responseText.split('&_');
  for (j=0;j<PushSpeedEvenVml.length-1;j++)
  {
    	PushSpeedEvenVml[j]=PushSpeedEvenVml[j].split(',_');
  }
    
  if(MySpeedAndEven=="Even")
  {  	
		tmps.push('<v:group style="WIDTH:100%px;HEIGHT:100%" coordsize = "'+ w +','+ h +'"></v:group>');
	    for(j=0;j<PushSpeedEvenVml.length-1;j++)
		{
		  p=LinePosition(PushSpeedEvenVml[j][2]);
		  if(checkline(p))
				tmps.push('<v:PolyLine onclick="WindowEvenShow('+PushSpeedEvenVml[j][0]+',\''+PushSpeedEvenVml[j][1]+'\');" title="'+ PushSpeedEvenVml[j][1] +'" StrokeWeight="6px" onmouseover="this.strokecolor=\'#CB0000\'" onmouseout="this.strokecolor=\'#00CB00\'" strokecolor="#00CB00" filled="false" Points="'+ p +'" style="position:absolute;filter:alpha(opacity=80)"/>');
		}
		document.getElementById('VmlPoiLayerObj').style.display='';
		document.getElementById('VmlPoiLayerObj').style.visibility='visible';  
		document.getElementById('VmlPoiLayerObj').innerHTML = tmps.join(''); 
  } 
}

function WindowEvenShow(Gid,Gstr)
{
  var tarry=new Array();
  var rs=0;
  
  tarry.push('<br />'+Gstr);
  //20091130以下新增
  tarry.push('<br /><br />提醒日期:<select id="RoadEvenS6"><option value="0">每天</option><option value="1">星期一</option><option value="2">星期二</option><option value="3">星期三</option><option value="4">星期四</option><option value="5">星期五</option><option value="6">星期六</option><option value="7">星期日</option></select>');
  //20091130以上新增
  tarry.push('<br /><br />提醒時間:<select id="RoadEvenS2"><option value="NO">時...</option>');
  for (rs = 1; rs < 24; rs++)
  {
    tarry.push('<option value=' + rs + '>' + rs + '</option>');
  }
  tarry.push('</select> : <select id="RoadEvenS3"><option value="NO">分...</option>');
  for (rs = 0; rs < 60; rs++)
  {
    tarry.push('<option value=' + rs + '>' + rs + '</option>');
  }            
  tarry.push('<br /><br /><table style="width:100%" border="1"><tr><td colspan="2" align="center">寄信通知</td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="RoadEvenS4" name="RoadEvenS4" value="1" onclick="document.getElementById(\'RoadEvenS4\').value=1;" />是&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="RoadEvenS4" name="RoadEvenS4" value="0" checked="checked" onclick="document.getElementById(\'RoadEvenS4\').value=0;" />否&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table>');
  //tarry.push('<br /><table style="width:100%" border="1"><tr><td colspan="2" align="center">簡訊通知</td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="RoadEvenS5" name="RoadEvenS5" value="1" onclick="document.getElementById(\'RoadEvenS5\').value=1;" />是&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="RoadEvenS5" name="RoadEvenS5" value="0" checked="checked" onclick="document.getElementById(\'RoadEvenS5\').value=0;" />否&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table>');
  
  tarry.push('<br />&nbsp;&nbsp;<input type="button" value="確定" onclick="AddRoadEven()" style="width:60px;" />');
  tarry.push('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
  tarry.push('<input type="button" value="取消" onclick="document.getElementById(\'RoadShowLayer\').style.visibility=\'Hidden\';document.getElementById(\'RoadShowLayer\').style.display=\'none\';" style="width:60px;" /><span id="RoadEvenS1" style="width:0px;height:0px;visibility:Hidden;">'+Gid+'</span>');
  
  document.getElementById('RoadShowLayerTD2').innerHTML=tarry.join('');
  document.getElementById('RoadShowLayerTD1').innerHTML="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;請選擇道路事件提醒時間:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  document.getElementById('RoadShowLayer').style.left="500px"; 
  document.getElementById('RoadShowLayer').style.top="200px"; 
  document.getElementById('RoadShowLayer').style.visibility='visible'; 
  document.getElementById('RoadShowLayer').style.display=''; 
  document.getElementById('RoadEvenS4').value=0;
  //document.getElementById('RoadEvenS5').value=0;
}

function AddRoadEven()
{
  var MFS1=document.getElementById('RoadEvenS1').innerHTML;   //道路ID
  var MFS2=document.getElementById('RoadEvenS2').value;   //時
  var MFS3=document.getElementById('RoadEvenS3').value;   //分
  var MFS4=document.getElementById('RoadEvenS4').value;   //MAIL
  var MFS5=0;  //document.getElementById('RoadEvenS5').value;   //MOBILE
  var MFS6=document.getElementById('RoadEvenS6').value;//20091130提醒星期
  
   if(MFS1=="NO")
   {
     alert('請選擇要預約到站提醒的站牌');
   }
   else if(MFS2=="NO"||MFS3=="NO")
   {
     alert('請選擇預約到站提醒的時間');
   } 
   else
   {   
     hMyF3.SetLinkFinish=AddRoadEvenOK;
     var SetPage="./ASPX/MyFavoriteStop.aspx?RoadID="+parseInt(MFS1)+"&Act=5&dimeH="+MFS2+"&dimeM="+MFS3+'&SendMail='+MFS4+'&SendMobile='+MFS5+'&AWeek='+MFS6+'&UserId='+LoginUserId+'&UserSu='+LoginUserSu+'&Lang='+Lang;//20091130
     hMyF3.makeReques(SetPage,hMyF3,'get',null,false); 	
   }  
}

function AddRoadEvenOK()
{
  var p= hMyF3.HpptRequest.responseText;
  p=="ok"?alert('成功加入預約道路'):p=="err1"?alert('發生錯誤'):p=="err2"?alert('預約道路提醒已達10筆'):alert('此預約道路提醒你已經加入過了');
  document.getElementById('RoadShowLayer').style.visibility='Hidden';  
  MyCollection();
}


function EditMyFavoriteEven(Gs1,Gs2,Gs3,Gs4,Gs5,Gs6,Gs7) //編輯路線  20091130加GS7
{	
// ID，路線名稱，時，分，True為要寄信通知，True為要簡訊通知，提醒星期
	
var i=1;
var tarry=new Array();
  
tarry.push('<table style="cellSpacing="0" cellPadding="3" width="200" border="0">');
tarry.push('<tr><td bgColor="#ffffff"><table style="BORDER-RIGHT: #3fb1d8 1px solid; BORDER-TOP: #3fb1d8 1px solid; BORDER-LEFT: #3fb1d8 1px solid; BORDER-BOTTOM: #3fb1d8 1px solid" cellSpacing="2" cellPadding="5" bgColor="#FFFFFF" border="0" >');
tarry.push('<tr><td bgColor="#ffffff"><P align="center">'+Gs2+'</P></td>');
tarry.push('<td align="right" bgColor="#ffffff" border="0" width="10px" style="width:10px;" >');
tarry.push('<img onclick="CustomizeDiv.style.display=\'none\';CustomizeNode.style.display=\'none\';" alt="關閉" src="./images/page/X.gif" width="10px" align="right" /></td></tr>');
//20091130以下新增
tarry.push('<tr><td>提醒日期:<select id="RoadEvenE6"><option value="0">每天</option><option value="1">星期一</option><option value="2">星期二</option><option value="3">星期三</option><option value="4">星期四</option><option value="5">星期五</option><option value="6">星期六</option><option value="7">星期日</option>');
tarry.push('</select></td><td>&nbsp;</td></tr>');
//20091130以上新增
tarry.push('<tr><td>提醒時間:<select id="RoadEvenE2"><option value="NO">時...</option>');
for (i = 1; i < 24; i++)
{
  tarry.push('<option value=' + i + '>' + i + '</option>');
}
tarry.push('</select> : <select id="RoadEvenE3"><option value="NO">分...</option>');
for (i = 0; i < 60; i++)
{
  tarry.push('<option value=' + i + '>' + i + '</option>');
}          
tarry.push('</select></td><td>&nbsp;</td></tr>');
tarry.push('<tr><td><table style="width:100%" border="1"><tr><td colspan="2" align="center">寄信通知</td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="RoadEvenE4" name="RoadEvenE4" value="1" onclick="document.getElementById(\'RoadEvenE4\').value=1;" '); 
if(Gs5=="True")
{
tarry.push('checked="checked"');
}
tarry.push('/>是&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" id="RoadEvenE4" name="RoadEvenE4" value="0" onclick="document.getElementById(\'RoadEvenE4\').value=0;" '); 
if(Gs5!="True")
{
tarry.push('checked="checked"');
}  
tarry.push('/>否&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table></td></tr>');
tarry.push('<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="確定" onclick="EditRoadEven();" style="width:60px;" width="60px" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="取消" style="width:70px;" width="70px" onclick="CustomizeDiv.style.display=\'none\';CustomizeNode.style.display=\'none\';"/></td><td>&nbsp;</td></tr>');
tarry.push('</table></td></tr><tr><td style="width:0px; height:0px; display:\'none\'; visibility:\'hidden\'"><div id="RoadEvenE1" style="width:0px; height:0px; display:\'none\'; visibility:\'hidden\'">'+Gs1+'</div></td></tr></table>');

	
	document.getElementById('CustomizeDiv').innerHTML=tarry.join('');
	
    for(i=0;i<document.getElementById('RoadEvenE2').options.length;i++)
    {
       if(parseInt(document.getElementById('RoadEvenE2').options[i].value)==parseInt(Gs3))
        {
           document.getElementById('RoadEvenE2').options[i].selected=true;
        }
    }
    for(i=0;i<document.getElementById('RoadEvenE3').options.length;i++)
    {
       if(parseInt(document.getElementById('RoadEvenE3').options[i].value)==parseInt(Gs4))
        {
           document.getElementById('RoadEvenE3').options[i].selected=true;
        }
    }
    if(Gs5=="True")
	{document.getElementById('RoadEvenE4').value=1;}
	else
	{document.getElementById('RoadEvenE4').value=0;}
    for(i=0;i<8;i++)  //20091130以下新增
    {
       if(parseInt(document.getElementById('RoadEvenE6').options[i].value)==parseInt(Gs7))
        {
           document.getElementById('RoadEvenE6').options[i].selected=true;
        }
    } //20091130以上新增	
	if(CusId=='')
	{
		if( confirm(lag[150]))
		LoginCheck();
	}
	else
	{
		document.getElementById('CustomizeNode').style.width=screen.width;
		document.getElementById('CustomizeNode').style.height=screen.height;
		document.getElementById('CustomizeDiv').style.left=screen.width/2-50;
		document.getElementById('CustomizeDiv').style.top=50;

		CustomizeNode.style.display='';
		document.getElementById('CustomizeDiv').style.display='';	
	}
}


function EditRoadEven()
{
  var MFS1=document.getElementById('RoadEvenE1').innerHTML; //id
  var MFS2=document.getElementById('RoadEvenE2').value; //dimeH
  var MFS3=document.getElementById('RoadEvenE3').value; //dimeM
  var MFS4=document.getElementById('RoadEvenE4').value; //寄信通知
  var MFS5=0; //document.getElementById('RoadEvenE5').value; //簡訊通知
  var MFS6=document.getElementById('RoadEvenE6').value;//20091130
  
   if(MFS1=="NO")
   {
     alert('發生錯誤');
   }
   else if(MFS2=="NO"||MFS3=="NO")
   {
     alert('請選擇預約到站提醒的時間');
   } 
   else
   {   
      hMyF3.SetLinkFinish=EditRoadEvenOK;
      var SetPage='./ASPX/MyFavoriteStop.aspx?Act=6&SID='+MFS1+'&dimeH='+MFS2+'&dimeM='+MFS3+'&SendMail='+MFS4+'&SendMobile='+MFS5+'&AWeek='+MFS6+'&Lang='+Lang;//20091130
      hMyF3.makeReques(SetPage,hMyF3,'get',null,false); 
   }	
}

function EditRoadEvenOK()
{
  var p= hMyF3.HpptRequest.responseText;
  p=="ok"?alert('修改成功'):alert('發生錯誤');
  
  document.getElementById('CustomizeDiv').style.display='none';
  document.getElementById('CustomizeNode').style.display='none';
  MyCollection();
}
