@using System.Configuration;
@using SharpConnector.Models;
@using SharpConnector.Constants;

@{
    bool isHomePage = ViewContext.RouteData.Values["Controller"].ToString().Equals("Home", StringComparison.OrdinalIgnoreCase)
                        && ViewContext.RouteData.Values["Action"].ToString().Equals("Index", StringComparison.OrdinalIgnoreCase);

    var user = (User)Session[Const.User];
    string username = user?.Username;

    var recipients = (List<Recipient>)Session[Const.Recipients] ?? new List<Recipient>();

    var message = (Tuple<string, string>) TempData[Const.Message] ?? new Tuple<string, string>("", "");

    bool isSupportDomainAddressBookEnabled =
    bool.TryParse(ConfigurationManager.AppSettings["SupportDomainAddressBook"], out var parsed) && parsed;
    }
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <base href='@Url.Content("~/")'>
        <title>@ConfigurationManager.AppSettings["FXC:name"]</title>
        @Styles.Render("~/Content/css/style.css")
        @Scripts.Render("~/scripts/mfp.js?v=1")
        @Scripts.Render("~/scripts/script.js?v=1")
        @Scripts.Render("~/scripts/json2.js")
    </head>
    <body>
        <!-- HEADER START -->
        <div id="header">
            <div id="logo">
                <img src="@Url.Content("~/Content/Images/small_logo.png")" width="40" />
            </div>
            <div id="user">
                <span id="username">@username</span>
                <a href="@Url.Action("Logout", "Login")"><img src="@Url.Content("~/Content/Images/signout.png")" width="22" /></a>
            </div>
        </div>
        <!-- HEADER END -->
        <!-- BODY START -->
        <div id="body_wrapper" class="@(!isHomePage ? "small-navigation" : "")">
            <!-- CONTENT START -->
            <div id="main" class="full-height">
                <div id="wrapper">
                    @RenderBody()
                </div>
            </div>
            <!-- CONTENT END -->
            <!-- NAVIGATION START -->
            <div id="aside" class="full-height">
                <div class="aside_content">
                    <div class="aside_option">
                        <div>
                            <button type="button" onclick="navigateTo('@Url.Action("FaxOptions", "Home")');">
                                <img src="@Url.Content("~/Content/Images/fax-option.png")" width="30" />
                                <span>Fax Options</span>
                            </button>
                        </div>
                        <div>
                            <button type="button" onclick="navigateTo('@Url.Action("Index", "CoverPage")');">
                                <img src="@Url.Content("~/Content/Images/cover-page.png")" width="30" />
                                <span>Cover Page</span>
                            </button>
                        </div>
                        <div>
                            <button type="button" onclick="navigateTo('@(isSupportDomainAddressBookEnabled
        ? Url.Action("Type", "AddressBook")
        : Url.Action("Index", "AddressBook"))');">
                                <img src="@Url.Content("~/Content/Images/address-book.png")" width="30" />
                                <span>Address Book</span>
                            </button>
                        </div>
                        <div>
                            <button type="button" onclick="navigateTo('@Url.Action("Index", "Inbox")');">
                                <img src="@Url.Content("~/Content/Images/inbox.png")" width="30" />
                                <span>Inbox</span>
                            </button>
                        </div>
                        @if (recipients.Count > 0)
                        {
                            <div>
                                <button id="menu_recipients" type="button" onclick="navigateTo('@Url.Action("Recipients", "AddressBook")');">
                                    <img src="@Url.Content("~/Content/Images/recipients.png")" width="30" />
                                    <span>Recipients <span id="totalRecipients">(@recipients.Count)</span></span>
                                </button>
                            </div>
                        }
                    </div>
                    @if (isHomePage)
                    {
                        <div id="btn_submit_wrapper">
                            <button type="button" id="btn_submit" onclick="sendMessage();">
                                <span>SCAN </span> <img src="@Url.Content("~/Content/Images/ico-continue.png")" width="20" />
                            </button>
                        </div>
                    }
                </div>
            </div>
            <!-- NAVIGATION END -->
        </div>
        <!-- BODY END -->
        <!-- CUSTOM SCRIPTS -->
        <script type="text/javascript">
            var _projectURl = '@ConfigurationManager.AppSettings["MFP:projectUrl"]';

            cAlert("@message.Item1", "@message.Item2");

            window.onload = function () {
                commonInit();
            };
        </script>
        @RenderSection("scripts", required: false)
    </body>
</html>
