<%pre>
#include <string>
#include <vdr/menu.h>
#include <vdr/epg.h>
#include "tools.h"
#include "i18n.h"
#include "timers.h"

using namespace std;
using namespace vdrlive;

</%pre>

<# ---------------------------------------------------------------------- #>

<%def doc_type>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
</%def>

<# ---------------------------------------------------------------------- #>

<%def logo>
<div class="page_header">
	<img src="logo.png" alt="VDR Live!" class="logo"></img>
	<& infobox &>
</div>
<div style="clear: both"></div>
</%def>

<# ---------------------------------------------------------------------- #>

<%def infobox>
<div id="infobox">
	<div class="statuscontent">
		<div class="st_header">
			<div id="infobox_caption" class="caption"><$ tr("retrieving status ...") $></div>
			<div id="infobox_timenow" class="now">--:--</div>
		</div>
		<div class="st_content">
			<div id="infobox_name" class="name"></div>
			<div id="infobox_duration" class="duration">--:--</div>
		</div>
		<div class="st_controls">
			<div class="st_btns">
				<a href="javascript:LiveStatusToggleUpdate()" <& tooltip.hint text=(tr("Stop updates")) &>><img id="statusReloadBtn" src="stop.png" alt="" /></a>
				<span id="infobox_recording_buttons" style="display: none"></span>
				<span id="infobox_channel_buttons">
					<& ajax_action_href action=("switch_channel") id=("infobox_prevchan") image=("one_downarrow.png") tip=(tr("previous channel")) &>
					<& ajax_action_href action=("switch_channel") id=("infobox_nextchan") image=("one_uparrow.png") tip=(tr("next channel")) &>
				</span>
			</div>
			<div class="st_pbar">
				<& progressbar id=("infobox_elapsed") &>
			</div>
		</div>
	</div>
</div>
</%def>

<# ---------------------------------------------------------------------- #>

<%def infobox_start_update>
<%cpp> { </%cpp>LiveStatusRequest('ibox.xml', 'infobox')<%cpp> } </%cpp>
</%def>

<# ---------------------------------------------------------------------- #>

<%def hide_element>
<%args>
	bool hide = true;
</%args>
<%cpp> if (hide) { </%cpp>style="visibility: hidden"<%cpp> } </%cpp>
</%def>

<# ---------------------------------------------------------------------- #>

<%def progressbar>
<%args>
	string progress = "0";
	string id;
</%args>
<div class="__progress"><div class="__elapsed" <? !id.empty() ? "id=" + id ?> style="width: <$ progress $>px"></div></div>
</%def>

<# ---------------------------------------------------------------------- #>

<%def event_timer>
<%args>
	tChannelID channelid;
	tEventID eventid;
</%args>
<%cpp>	const cTimer* timer = LiveTimerManager().GetTimer(eventid, channelid);
	if (timer) { 
</%cpp>
	<a href="edit_timer.html?timerid=<$ LiveTimerManager().GetTimers().GetTimerId(*timer) $>">
		<img src="record_timer.png" alt="" <& tooltip.hint text=(tr("Edit this")) &> />
<%cpp> } else { </%cpp>
	<a href="edit_timer.html?channelid=<$ channelid $>&eventid=<$ eventid $>">
		<img src="record.png" alt="" <& tooltip.hint text=(tr("Record this")) &> />
<%cpp> } </%cpp>
	</a>
</%def>

<# ---------------------------------------------------------------------- #>

<%def ajax_js>
	<script type="text/javascript" language="javascript" src="ajax.js"></script>
	<script type="text/javascript" language="javascript" src="vdr_status.js"></script>
</%def>

<# ---------------------------------------------------------------------- #>

<%def ajax_action_href>
<%args>
	string action;
	string tip;
	string param;
	string image;
	string alt;
	string id;
</%args>
<%cpp> { </%cpp> <a <? !id.empty() ? "id=" + id ?> <& hide_element hide=(!id.empty()) &> href="javascript:LiveSimpleAjaxRequest('<$ action $>.xml', 'param', '<$ param $>');" <%cpp>if (!tip.empty()) { </%cpp><& tooltip.hint text=(tip) &> <%cpp> } </%cpp>><img src="<$ image $>" alt="<$ alt $>"></img></a> <%cpp> } </%cpp>
</%def>

<# ---------------------------------------------------------------------- #>

<%def epg_tt_box>
<%args>
	string boxId;
	string caption;
	string tools_comp;
	string time;
	string title;
	string short_descr;
	string long_descr;
	int elapsed = -1;
</%args>
	<div class="epg_description" id="<$ (boxId) $>">
		<div class="station">
			<div class="boxheader"><div><div><$ (caption) $><& tooltip.close domId=(boxId) &></div></div></div>
		</div>
		<div class="epg_content">
			<div class="epg_tools">
		 		<& (tools_comp) id=(boxId) &>
			</div>
		 	<div>
				<div class="info"><$ (time) $></div>
%	if (elapsed >= 0) {
				<div class="progress"><div><& pageelems.progressbar progress=(elapsed) &></div></div>
%	}
		 		<div class="title"><$ (title) $></div>
				<div class="short"><$ (short_descr) $></div>
				<div class="description">
					<{ reply.out() << StringEscapeAndBreak(long_descr); }>
				</div>
			</div>
		</div>
	</div>
</%def>

<# ---------------------------------------------------------------------- #>

<%def status_box>
<%args>
	string type;
	string currentTime;
	string caption;
	string title;
	string duration;
	int elapsed;
	string prev_chan;
	string next_chan;
</%args>
	<div class="statuscontent">
		<div class="st_header">
			<div class="caption"><$ caption $></div>
			<div class="now">&nbsp;<$ currentTime $></div>
		</div>
		<div class="st_content">
			<div class="name"><$ title $></div>
			<div class="duration">&nbsp;<$ duration $></div>
		</div>
		<div class="st_controls">
			<div class="st_btns"><a href="javascript:LiveStatusToggleUpdate()" <& tooltip.hint text=(tr("Stop updates")) &>><img id="statusReloadBtn" src="stop.png" alt=""></img></a><%cpp>if (!prev_chan.empty()) { </%cpp><& ajax_action_href action=("switch_channel") param=(prev_chan) image=("one_downarrow.png") tip=(tr("previous channel")) &><%cpp> } if (!next_chan.empty()) { </%cpp><& ajax_action_href action=("switch_channel") param=(next_chan) image=("one_uparrow.png") tip=(tr("next channel")) &><%cpp> } </%cpp></div>
%			if (elapsed >= 0) {
			<div class="st_pbar"><& pageelems.progressbar progress=(elapsed) &></div>
%			}
		</div>
	</div>
</%def>