<%@ Page Language="C#" AutoEventWireup="true" UICulture="auto" Culture="auto" meta:resourcekey="PageResource1" %>

<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.Globalization" %>
<script runat="server">
//@Override this is suggested by Microsoft, overriding the initialize culture function (that is
//automatically called by the aspx.
//Checks if the cookie exists and sets the language correctly, otherwise will fall-back to the default language
//(English).
protected override void InitializeCulture()
{
    HttpCookie lang = Request.Cookies["siteLanguage"]; 
    
    String selectedLanguage = (lang != null) ? lang.Value : "en";
    UICulture = selectedLanguage ;
    Culture = selectedLanguage ;

    Thread.CurrentThread.CurrentCulture = 
        CultureInfo.CreateSpecificCulture(selectedLanguage);
    Thread.CurrentThread.CurrentUICulture = new 
        CultureInfo(selectedLanguage);
    base.InitializeCulture();
}
</script>
<%  
    //this prevents the browser from caching templates. (on IE the templates where cached with the old language
    //too, so the change language was not working, this is a workaround for that).
    
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.Cache.SetExpires(DateTime.Now.AddMinutes(-30)); %>

<%--view template starts here (will be appended inside a row-fluid)--%>
<script id="main_template" type="text/x-handlebars-template">
</script>

<script id="delay_info_modal_template" type="text/x-handlebars-template">
    <style>
        .modal-wider {
            width:90%;
            margin-left: -45% !important;
            height:90%;
            margin-top: -2.5% !important;
            /*width:780px;*/
            /*margin-left:-390px;*/
        }

        .clickeable-row{
            cursor:pointer; 
        }
    </style>
    <div style="height:5%;" class="modal-header noselect">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3><asp:Localize runat="server" meta:resourcekey="delay_info_modal_title" /></h3>
    </div>
    <div style="height:70%;max-height:70%;" class="modal-body noselect">
        <div class="row-fluid" style="font-size:12px;">
            <div class="row-fluid">
                <div style="display:inline-block;margin-right:20px;">
                    <span style="display:inline-block;"><asp:Localize runat="server" meta:resourcekey="line_label" /></span><span style="margin-left:8px;">{{line}}</span>
                </div>
                <div style="display:inline-block;margin-right:20px;">
                    <span style="display:inline-block;"><asp:Localize runat="server" meta:resourcekey="machine_label" /></span><span style="margin-left:8px;">{{productionItem}}</span>
                </div>
                {{#ifEquals batchNumber 0}}
                {{else}}
                <div style="display:inline-block;margin-right:20px;">
                    <span style="display:inline-block;"><asp:Localize runat="server" meta:resourcekey="batch_label" /></span><span style="margin-left:8px;">{{batchNumber}}</span>
                </div>
                {{/ifEquals}}
                <div style="width:100%;height:1px;background-color:#eeeeee;margin-top:4px;margin-bottom:6px;"></div>
            </div>
            <div class="row-fluid">
                <div style="display:inline-block;margin-right:20px;">
                    <span style="display:inline-block;"><asp:Localize runat="server" meta:resourcekey="start_label" /></span><span style="margin-left:8px;">{{startDate}} {{startTime}}</span>
                </div>
                <div style="display:inline-block;margin-right:20px;">
                    <span style="display:inline-block;"><asp:Localize runat="server" meta:resourcekey="duration_label" /></span><span style="margin-left:8px;">{{durationText}}</span>
                </div>
                <div style="width:100%;height:1px;background-color:#eeeeee;margin-top:4px;margin-bottom:6px;"></div>
            </div>
            <div class="row-fluid">
                <div style="display:inline-block;margin-right:20px;">
                    <span style="display:inline-block;"><asp:Localize runat="server" meta:resourcekey="sort_by_frequency_label" /></span><input type="checkbox" class="sortDelayCodesByFrequency-checkbox" {{#if sortDelayCodesByFrequency}}checked{{/if}} style="margin:0 0 0 8px;" />
                </div>
                <div style="width:100%;height:1px;background-color:#eeeeee;margin-top:4px;margin-bottom:6px;"></div>
            </div>
        </div>
        <div class="row-fluid">
            <div class="row-fluid pages-container" style="min-height:200px;">
                {{#each pages}}
                <div data-pageNum="{{pageNum}}" class="row-fluid hide">
                    {{#each rows}}
                    <div class="row-fluid text-center" style="margin-top:8px;">
                        {{#each columns}}
                            <div class="span3">
                                <button style="width:100%;min-height:80px;" 
                                    data-id="{{id}}" class="btn btn-delay-code">
                                    {{text}}
                                </button>
                            </div>
                        {{/each}}
                    </div>
                    {{/each}}
                </div>
                {{/each}}
            </div>
        </div>
    </div>
    <div style="height:10%;" class="modal-footer noselect">        
        <div class="row-fluid">
            <div class="span4">
                <div class="pull-left">
                    <button class="btn btn-default btn-arrow-left"><i class="fa fa-arrow-left fa-3x"></i></button>
                </div>
            </div>
            <div class="span4">
                <button style="height:52px;" class="btn-close btn-block btn btn-large"><asp:Localize runat="server" meta:resourcekey="close_label" /></button>
            </div>
            <div class="span4">
                <div class="pull-right">
                    <button class="btn btn-default btn-arrow-right"><i class="fa fa-arrow-right fa-3x"></i></button>
                </div>
            </div>
        </div>
    </div>
</script>

<script id="delay_info_modal_template_loading" type="text/x-handlebars-template">
    <div class="modal-header noselect">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3><asp:Localize runat="server" meta:resourcekey="delay_info_modal_title" /></h3>
    </div>
    <div style="max-height:450px;min-height:350px;" class="modal-body noselect">
        <div class="row-fluid">
            <div class="span12">
                <div style="text-align:center;margin-top:10px;">
                    <i class="fa fa-5x fa-cog fa-spin"></i><br />
                    <span style="font-size: 20px;top:3px;position:relative;"><asp:Localize runat="server" meta:resourcekey="loading_label" /></span>
                </div>
            </div>
        </div>
    </div>
</script>