﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link rel="stylesheet" type="text/css" href="css/Gridstyle.css" media="all" />
<script type="text/javascript" src="js/jquery-1.5.1.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.js"></script> 
</head>

<script language=JavaScript>
	document.onkeydown = function ()
	{
		if(event.keyCode == 8)         //鍵盤按下"Backspace"
		{
			if (document.all)
				window.parent.parent.location.reload();
		}
	}
	
	function BackToIndex()
	{
		window.parent.location.reload();
	}
	
	document.oncontextmenu = function() {return false;};
</script>

<script type="text/javascript">
$(function () {
    $("#myTable").tablesorter({widgets: ['zebra']});
    this.gridFlag = 1;
});

//--------------------------------------------------------
// Function Name : SetChannelHour
// Purpose       : 輸入table中的id 來得知哪一時段錄影
// Input         : 選擇的頻道及第幾小時
// Output        : None
// return value  : None
// Modified Date : 2011/10/24 by Neil Li
//--------------------------------------------------------	
function SetChannelHour(Select_CH_Hour)
{
	//alert(this.ChannelHour.length);
	
	//======回復預設table顏色======begin
	for (var i=0; i < this.DataNumber; i++) {
		var tableRowID = "tableRow" +i;
		document.getElementById(tableRowID).style.background = 	"#616161";
	}
	document.getElementById(Select_CH_Hour).style.background = "RGB(168,150,212)"; //淡紫色
	//======回復預設table顏色======end
	
	Select_CH_Hour = Select_CH_Hour.split("tableRow");  //Select_CH_Hour[1]是table 中的index

	parent.document.getElementById("SetHour").value = this.SetHour[Select_CH_Hour[1]];  		 //所選的時段
	parent.document.getElementById("ChannelNO1").value = this.SetChannel[Select_CH_Hour[1]];	 		 //所選的channel 下拉式選單的更換
	parent.document.getElementById("SelectedChannel").value = this.SetChannel[Select_CH_Hour[1]];	 	 //所選的channel 搜尋用的channel number
	parent.document.getElementById("SelectCorrectChannel").value = this.SetChannel[Select_CH_Hour[1]];	 //所選的channel 顯示給影像下方channel number
}

</script>
<style type="text/css">
	.over
	{
		background-color: RGB(125,186,194);  //淡藍色
		cursor: hand;
	}
	.out
	{
		background-color: #616161;
	}
	td
	{
		background-color: #616161;
	}
</style>

<body style="background:#F0F0F6" oncontextmenu="window.event.returnValue=false">

<table id="myTable" class="tablesorter" style="color:white;position:absolute;top:0px;left:0px;" border="1" sborderColor="white">
<thead> 
<tr>
	<th scope="col" style="text-align:left;">NO.</th>
	<th scope="col" style="text-align:left;">Date</th> 
    <th scope="col" style="text-align:left;">Time</th>
    <th scope="col" style="text-align:left;">CH</th>  
</tr> 
</thead> 
<tbody style="background:#616161"> 
	<script language="JavaScript" type="text/javascript">
		var tmp = 0;
		this.DataNumber = 0;
		this.SetHour = new Array();  	//table中的hour array
		this.SetChannel = new Array();	//table中的channel array
		this.SelectedChannel = parent.document.getElementById("SelectedChannel").value;
		this.ChannelHour = parent.document.getElementById("ChannelHour").value;
		
		this.ChannelHour = this.ChannelHour.split(",");

		parent.document.getElementById("SelectCorrectYear").value  = parent.document.getElementById("currentYear").value;
		parent.document.getElementById("SelectCorrectMonth").value = parent.document.getElementById("currentMonth").value;
		parent.document.getElementById("SelectCorrectDay").value   = parent.document.getElementById("currentDay").value;
		
		if(this.SelectedChannel>0 && this.ChannelHour.length>0)  //選取單一channel 並且有錄影資料
		{
			for(var i=0;i< this.ChannelHour.length ;i++)
			{
				this.ChannelHour[i] = this.ChannelHour[i].split("-");
			}
			
			for (var i=0; i < this.ChannelHour.length; i++)
			{
				if(this.SelectedChannel == this.ChannelHour[i][0] && this.SelectedChannel!="")
				{
					var tableRowID = "tableRow" +this.DataNumber;
		            document.writeln("<tr id=");
		            document.writeln(tableRowID);
		            document.writeln(" onmouseover=this.className='over' onmouseout=this.className='out' onclick='SetChannelHour(this.id)'>");
		            
		            document.writeln("<th>");
		            document.writeln(i+1);							//NO.
		            document.writeln("</th><th>");
		            
		            document.writeln(parent.document.getElementById("SelectCorrectYear").value +"/"+ parent.document.getElementById("SelectCorrectMonth").value +"/"+ parent.document.getElementById("SelectCorrectDay").value);					//Date
		            document.writeln("</th><th>");
		            document.writeln(this.ChannelHour[i][1]+":00");	//Time
		            document.writeln("</th><th>");
		            document.writeln(this.SelectedChannel);			//CH
		            document.writeln("</th></tr>");
		            
		            this.SetChannel[this.DataNumber] = this.ChannelHour[i][0];  //加入channel array
	            	this.SetHour[this.DataNumber] = this.ChannelHour[i][1];		//加入hour array
		            this.DataNumber ++;
				}
				
			}
		}else if(this.ChannelHour[0]!="")						//選取全部channel 並且有錄影資料
		{
			for(var i=0;i< this.ChannelHour.length ;i++)
			{
				this.ChannelHour[i] = this.ChannelHour[i].split("-");
			}
			
			for (var i=0; i < this.ChannelHour.length; i++)
			{
				var tableRowID = "tableRow" +this.DataNumber;
	            document.writeln("<tr id=");
	            document.writeln(tableRowID);
	            document.writeln("onmouseover=this.className='over' onmouseout=this.className='out' onclick='SetChannelHour(this.id)'>");
		
	            document.writeln("<th>");
	            document.writeln(i+1);							//NO.
	            document.writeln("</th><th>");
	            document.writeln(parent.document.getElementById("SelectCorrectYear").value +"/"+ parent.document.getElementById("SelectCorrectMonth").value +"/"+ parent.document.getElementById("SelectCorrectDay").value);					//Date
	            document.writeln("</th><th>");
	            document.writeln(this.ChannelHour[i][1]+":00");	//Time
	            document.writeln("</th><th>");
	            document.writeln(this.ChannelHour[i][0]);		//CH
	            document.writeln("</th></tr>");
	            
	            this.SetChannel[this.DataNumber] = this.ChannelHour[i][0];  //加入channel array
	            this.SetHour[this.DataNumber] = this.ChannelHour[i][1];		//加入hour array
	            
	            this.DataNumber ++;
			}
		}else
		{
			for(var i=0;i<6;i++)
			{
				document.writeln("<tr>  <th>&nbsp;</th> <th>&nbsp;</th> <th>&nbsp;</th> <th>&nbsp;</th>  </tr>");
			}
		}
		
	</script>
</tbody> 
</table> 

</body>
</html>