{=include-block:Y_NI_Blocks.txt;head=}
<script type="text/javascript" src="/jquery/jquery.stickytableheaders.min.js"></script>
<script type="text/javascript" src="/Y_Baselib.js"></script>
<script type="text/javascript">
//<![CDATA[
/*sLog*/
var sLog_body;
var sLog_line_number;
var epg_data;
var epg_data_index=0;
function sLog_init()
{
	sLog_line_number = 0;
	sLog_body=document.getElementById("slog_list");
}
function sLog_clear()
{
	while(sLog_body.childNodes.length > 0){
		aChild=sLog_body.firstChild;
		sLog_body.removeChild(aChild);
	}
	sLog_line_number =  0;
}
function sLog_addRow(_body, _date, _rec, _zap, _start, _end, _title)
{
	sLog_line_number++;
	var mycurrent_row = y_add_row_to_table(_body, ((sLog_line_number % 2) ==0)?"a":"b" );

	y_add_html_cell_to_row(mycurrent_row, "rec", _rec);
	y_add_html_cell_to_row(mycurrent_row, "zap", _zap);
	y_add_html_cell_to_row(mycurrent_row, "date", _date);
	y_add_html_cell_to_row(mycurrent_row, "starttime", _start);
	y_add_html_cell_to_row(mycurrent_row, "endtime", _end);
	y_add_html_cell_to_row(mycurrent_row, "epgtitle", _title);
}
function set_timer_rec(_channel_id, _start, _stop)
{
	var res = dbox_set_timer_rec(_channel_id, _start, _stop);
	alert("{=L:epg.set_timer_rec=}");
}
function set_timer_zap(_channel_id, _start)
{
	var res = dbox_set_timer_zap(_channel_id, _start);
	alert("{=L:epg.set_timer_zap=}");
}
function show_info(_index)
{
	parent.epg_info.show_info(epg_data[_index][0], epg_data[_index][1], epg_data[_index][2]);
}
function check_logo()
{
	{=if-empty:{=logoid=}~~
		show_obj("logo",true);
	=}
}
function show_epg() {
	show_waitbox(true);
	window.setTimeout("_show_epg()",100);
}
function _show_epg()
{
	check_logo();
	sLog_init();
	sLog_clear();

	epg_data = new Array();
	epg_data_index=0;

	var weekday = new Array(7);
	weekday[0]=  "{=L:date.su=}";
	weekday[1] = "{=L:date.mo=}";
	weekday[2] = "{=L:date.tu=}";
	weekday[3] = "{=L:date.we=}";
	weekday[4] = "{=L:date.th=}";
	weekday[5] = "{=L:date.fr=}";
	weekday[6] = "{=L:date.sa=}";

	var now = new Date();
	var __d = new Date();
	var _starttime = Math.round(now/1000);
	var epg_xml = loadSyncURLxml("/control/epg?xml=true&channelid={=channel=}&details=true");
	if(epg_xml){
		var prog_list = epg_xml.getElementsByTagName('prog');
		for(i=0;i<prog_list.length;i++){
			var prog = prog_list[i];

			var _stop	= getXMLNodeItemValue(prog, "stop_sec");
			if(_stop > _starttime){
				var _start_t	= getXMLNodeItemValue(prog, "start_t");
				var _date	= getXMLNodeItemValue(prog, "date");
				var _start	= getXMLNodeItemValue(prog, "start_sec");
				var _stop_t	= getXMLNodeItemValue(prog, "stop_t");
				var _desc	= epg_de_qout(getXMLNodeItemValue(prog, "description"));
				var _info1	= epg_de_qout(getXMLNodeItemValue(prog, "info1"));
				var _info2	= epg_de_qout(getXMLNodeItemValue(prog, "info2"));

				__d.setTime(_start*1000);
				var _dow	= weekday[__d.getDay()];
				_date		= _dow + ", " + _date;

				var epg_obj= new Array(_desc, _info1, _info2, _start, _start_t, _stop.toString(), "{=channel=}");
				epg_data.push(epg_obj);

				var _rec = "<a title=\"record\" href=\"javascript:set_timer_rec('{=channel=}',"+_start+","+_stop+");\"><img src=\"images/record.png\"/></a>";
				var _zap = "<a title=\"zapping\" href=\"javascript:set_timer_zap('{=channel=}',"+_start+");\"><img src=\"images/zap.png\"/></a>";
				var _title = "<span onmouseover=\"show_info('"+epg_data_index+"')\">"+_desc+"</span>";
				sLog_addRow(sLog_body, _date, _rec, _zap, _start_t, _stop_t, _title);
				epg_data_index++;
			}
		}
	}
	show_waitbox(false);
	jQuery('table').stickyTableHeaders();
}
//]]>
</script>
</head>
<body onload="show_epg()" class="iframe">
{=var-set:wait_text={=L:epg.get_epg=}=}{=include-block:Y_Blocks.txt;snip_show_wait=}
	<table id="epglist" class="y_invisible_table" cellpadding="4" cellspacing="0" width="100%">
	<thead align="left">
	<tr>
		<th colspan="2"><img id="logo" src="{=func:get_logo_name {=channel=}=}" style="visibility:hidden; max-width: 50px;"/></th>
		<th>{=L:date=}</th><th>{=L:from=}</th><th>{=L:to=}</th><th>{=L:program=}</th>
	</tr>
	</thead>
	<tbody id="slog_list">
	</tbody>
	</table>
	<br />
</body>
</html>