<%
/*
*   This file loads detail for one particular video.
*
**/

"use strict";

import "/js/utility.js"

    var id=-1;
    if (getArg("Id"))
        id = getArg("Id");


    if(id!=-1)
    {

        var video = new Video();
        var thisVideo = video.GetVideo(id);
        var artworkURL = "/video/images/unknown.png";

        if(thisVideo)
        {
            var artworkLength = thisVideo.Artwork.ArtworkInfos.length;

            if( artworkLength > 0)
            {
                for(var artworkIdx=0; artworkIdx < artworkLength; artworkIdx++)
                {
                    if(thisVideo.Artwork.ArtworkInfos[artworkIdx].Type == "coverart")
                    {
                        artworkURL = thisVideo.Artwork.ArtworkInfos[artworkIdx].URL + "&Width=200";
                    }
                }
            }

            //NOTE: REMOVING THIS FOR NOW, CAUSES SERVER TO CRASH?
            //var myth = new Myth();
            //var date = myth.ParseISODateString(thisVideo.ReleaseDate);

            var rating = thisVideo.UserRating.toFixed(1);
            var director = thisVideo.Director;
            var length = thisVideo.Length;
            var filmRating = thisVideo.Certification;
            var subtitle = thisVideo.SubTitle;


            if(subtitle!="")
                subtitle=" - " + subtitle;
%>
        <div class="detailTitle">
           <%=thisVideo.Title %><%= subtitle%>
        </div>
        <div class="detailCoverart">
            <img src="<%=artworkURL%>" />
        </div>
        <div class="detailText">
            <%=thisVideo.Description %>
        </div>
        <div class="detailFineDetail">

            <div class="detailDirector">
                <span style="font-weight: bold;">Director: </span> <%= director%>
            </div>

            <!--<div class="detailYear">
                <span style="font-weight: bold;">Year:</span>
            </div>-->
            <div class="detailRuntime">
                <span style="font-weight: bold;">Runtime: </span> <%= length%> minutes
            </div>
            <div class="detailUserRating">
                <span style="font-weight: bold;">User Rating: </span> <%= rating%>
            </div>
            <div class="detailFilmRating">
                <span style="font-weight: bold;">Rated: </span> <%= filmRating%>
            </div>

        </div>
        <div class="detailButtonContainer">
            <div class="detailDoneButton">
                <button id="doneButton">Done</button>
            </div>
            <div class="detailPlayButton">
                <form method= "GET" action="/Content/GetVideo">
                    <input type="hidden" name="Id" value="<%= id%>" />
                    <button id="playButton" onclick="submit()">Download/Play</button>
                </form>
            </div>
         </div>

<%
        }
    }

%>


