<!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"
      eventCookie="@@@eventCookie@@@" dtvPlatform="@@@dtvPlatform@@@">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Democracy Channel View</title>

    <link href="resource:css/main.css" rel="stylesheet" type="text/css" />
    <t:include filename="dynamic.js" />
    <t:include filename="settings.js" />
    <script type="text/javascript" src="resource:templates/shide.js" />

    <t:execOnLoad><![CDATA[
global searchFilter
searchFilter = lambda x: filters.matchingItems(x, None)

feed = app.controller.currentSelectedTab.obj

allItems = views.items.filterWithIndex(indexes.itemsByFeed, feed.getID())
matchingItems = allItems.filter(lambda x: searchFilter(x))

newUnseenItems = matchingItems.filter(filters.unviewedItems).sort(sorts.item)
newItems = matchingItems.filter(filters.viewedItems).sort(sorts.item)
downloadingItems = matchingItems.filter(filters.downloadingItems).sort(sorts.item)
unwatchedItems = matchingItems.filter(filters.unwatchedItems).sort(sorts.item)
expiringItems = matchingItems.filter(filters.expiringItems).sort(sorts.item)
savedItems = matchingItems.filter(filters.oldItems).sort(sorts.item)

def updateSearchString(newSearch):
    global searchFilter
    if len(newSearch) == 0:
        searchFilter = lambda x: filters.matchingItems(x, None)
    else:
        searchFilter = lambda x: filters.matchingItems(x, newSearch)
    allItems.recomputeFilter(matchingItems)

]]>
    </t:execOnLoad>
    <t:execOnUnload><![CDATA[
# This should unlink matchingItems and all of it's children
matchingItems.unlink()
]]>
    </t:execOnUnload>

</head>

<body onload="toggleLayer('main-newlyavailable'); toggleLayer('main-unwatched'); toggleLayer('main-expiring'); toggleLayer('main-saved'); toggleLayer('show-more-videos-label');toggleLayer('no-new-videos-label');">
    
<!-- TITLE BAR ************************************************************ -->
<div id="main-titlebar">
	<div id="main-titlebar-avatar"><img src="***feed.getThumbnail()***" alt="" style="background-color:#FFFFFF;" /></div>
	<div id="main-titlebar-channelname">
		<h1 t:replaceMarkup="feed.getTitle()" />
		<div id="main-titlebar-autodownload">
            <form name="setAuto" >
                <input type="hidden" name="feed" value="@@@feed.getID()@@@" />
                <input type="checkbox" name="automatic" value="1" checked="checked" onClick="javascript:setAutoDownloadableFeed()" t:hideIf="not feed.isAutoDownloadable()" />
                <input type="checkbox" name="automatic" value="1"                   onClick="javascript:setAutoDownloadableFeed()" t:hideIf="feed.isAutoDownloadable()" />
                <span class="auto_link" i18n:translate="">Auto Download</span>
            </form>
		</div>
	</div>
	<div id="main-titlebar-tasks">
		<div id="main-titlebar-tasks-settings">
			<p><a href="#" 
onclick="eventURL('template:feed-settings');"><span 
i18n:translate="">Settings</span></a></p>
		</div>
		<div id="main-titlebar-tasks-recommend">
		    <p><a href="mailto:?subject=@@@feed.getTitle()@@@&amp;body=%0D%0A%0D%0AYou should check out the Internet TV channel &quot;@@@feed.getTitle()@@@&quot;. If you don't have the Democracy Player, you can get it here:%0D%0A%0D%0Ahttp://www.getdemocracy.com/%0D%0A%0D%0AAnd then subscribe to this channel:%0D%0A%0D%0A@@@feed.getURL()@@@" class="recommend_link" i18n:translate="">Recommend</a></p>
		</div>
		<div id="main-titlebar-tasks-search">
		    <input type="search" placeholder="Search Channel" class="main-titlebar-tasks-search" onfocus="startEditSearch(this)" onblur="endEditSearch()" />
		</div>
	</div>
</div>
<!-- / TITLE BAR -->

<!-- CHANNEL CONTAINER **************************************************** -->
<div id="main-container">





    <!-- DOWNLOADS ******************************************************** -->
    <span t:hideIf="downloadingItems.len()==0" t:updateHideOnView="downloadingItems">
        <div class="main-channelbar-hitbox"><a href="javascript:toggleLayer('main-downloads');">#&nbsp;</a></div>
        <div id="main-channelbar" class="main-channelbar-download">
        	<h1 t:updateForView="downloadingItems">

<!-- THIS IS SUPPOSED TO HAVE A TRIANGLE OPEN AND CLOSE, FIX WHEN YOU CAN <span id="triangle" class="triangle">&nbsp;</span><span id="triangledown" class="triangledown" style="display: none;">&nbsp;</span> -->

<span t:hideIf="downloadingItems.len()==1"><span i18n:translate="">
<span t:replace="downloadingItems.len()" i18n:name="count"/> Downloads in Progress</span></span>
<span t:hideIf="downloadingItems.len()!=1"><span i18n:translate="">1 Download in Progress</span></span>
                </h1>
        </div>
        <div id="main-downloads">
            <span t:repeatForView="downloadingItems">
                <t:includeTemplate filename="download-item" />
            </span>
        </div>
    </span>
    <!-- / DOWNLOADS -->




    <!-- NEWLY AVAILABLE ************************************************** -->

  <div class="main-channelbar-hitbox"><a href="javascript:toggleLayer('main-newlyavailable');">#&nbsp;</a></div>
 <div id="main-channelbar-available" class="main-channelbar" style="display: none;">
    	<h1><span i18n:translate="">On This Channel</span></h1>
    	<h2 t:updateForView="allItems"><span t:replace="allItems.len()" /></h2>
    </div>


    <div id="main-newlyavailable">
        <span t:repeatForView="newUnseenItems">
            <t:includeTemplate filename="download-item" />
        </span>
        <span id="no-new-videos-label">
        <span t:hideIf="newUnseenItems.len()>0"  t:updateHideOnView="newUnseenItems">

        </span>
        </span>
        <span t:hideIf="newItems.len()==0" t:updateHideOnView="newItems">
            <span id="show-more-videos-label" class="main-content">								
				<a href="javascript:toggleLayer('main-newlyavailable-seen');toggleLayer('show-more-videos-label');toggleLayer('no-new-videos-label');toggleLayer('main-channelbar-available');" style="color:#FFFFFF; text-decoration:none;" class="main-notification-nonew">
    				<div class="main-notification"><span 
t:updateForView="newItems" class="video-count"><span t:replace="newItems.len()" 
/></span><span i18n:translate="">Videos on this Channel</span> &gt;&gt;</div>
    				<div class="main-notification-right">&nbsp;</div>
    				<br clear="left" />
				</a>
            </span>
            <span id="main-newlyavailable-seen">
                <span t:repeatForView="newItems">
                    <t:includeTemplate filename="download-item" />
                </span>
            </span>
        </span>
    </div>		


    <!-- UNWATCHED ******************************************************** -->
    <span t:hideIf="unwatchedItems.len()==0" t:updateHideOnView="unwatchedItems">
        <div class="main-channelbar-hitbox"><a href="javascript:toggleLayer('main-unwatched');">#&nbsp;</a></div>
        <div id="main-channelbar" class="main-channelbar">
        	<h1 i18n:translate="">Unwatched</h1>
        	<h2 t:updateForView="unwatchedItems"><span t:replace="unwatchedItems.len()" /></h2>
        </div>

        <div id="main-unwatched">
            <span t:repeatForView="unwatchedItems">
                <t:includeTemplate filename="download-item" />
            </span>
        </div>
    </span>
    <!-- / UNWATCHED -->

    <!-- EXPIRING ********************************************************* -->
    <span t:hideIf="expiringItems.len()==0" t:updateHideOnView="expiringItems">
        <div class="main-channelbar-hitbox"><a href="javascript:toggleLayer('main-expiring');">#&nbsp;</a></div>
        <div id="main-channelbar" class="main-channelbar">
        	<h1 i18n:translate="">Watched</h1>
        	<h2 t:updateForView="expiringItems"><span t:replace="expiringItems.len()" /></h2>
        </div>

        <div id="main-expiring">
            <span t:repeatForView="expiringItems">
                <t:includeTemplate filename="download-item" />
            </span>
        </div>
    </span>
    <!-- / EXPIRING -->

    <!-- SAVED ************************************************************ -->
    <span t:hideIf="savedItems.len()==0" t:updateHideOnView="savedItems">
        <div class="main-channelbar-hitbox"><a href="javascript:toggleLayer('main-saved');">#&nbsp;</a></div>
        <div id="main-channelbar" class="main-channelbar">
        	<h1 i18n:translate="">Saved</h1>
        	<h2 t:updateForView="savedItems"><span t:replace="savedItems.len()" /></h2>
        </div>

        <div id="main-saved">
            <span t:repeatForView="savedItems">
                <t:includeTemplate filename="download-item" />
            </span>
        </div>
    </span>
    <!-- / SAVED -->
</div>
<!-- / CHANNEL ITEMS LIST -->

<t:triggerActionOnUnload url="action:markFeedViewed?feed=@@@feed.getID()@@@" />
<t:triggerActionOnLoad url="action:updateIcons?feed=@@@feed.getID()@@@" />

</body>
</html>
