<%@ Master Language="C#" AutoEventWireup="true" CodeFile="IronIntelMasterPage.master.cs" Inherits="IronIntelMasterPage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>Iron Intel</title>

    <link rel="shortcut icon" href="<%=GetUrl("favicon.ico") %>" />
    <link rel="stylesheet" href="<%=GetUrl("css/default.css")%>" type="text/css" />
    <link rel="stylesheet" href="<%=GetUrl("css/split_sub.css")%>" type="text/css" />
    <style type="text/css" runat="server" id="materStyle">
        /*table {
            font-size: 12px;
        }*/

        .smaller {
            font-size: 0.9em;
        }

        a {
            text-decoration: none;
            color: #2140fb;
        }

            a:hover {
                text-decoration: underline;
            }

            a:visited {
                color: #2140fb;
            }

        .lefttitle_title {
            width: 96%;
            height: 40px;
            font-size: 20px;
            line-height: 40px;
            padding-left: 10px;
            /*background-color: #0079c1;*/
            background: <%=MenuBackgroundColor %>;
            text-align: center;
        }

        #host_header {
            background: var(--title-bg-color);
            color: #000;
            height: 60px;
            min-width: 1280px;
            text-align: center;
            position: relative;
            /*box-shadow: 0 0 10px rgba(0,0,0,.4);*/
        }

            #host_header .logo {
                float: left;
                height: 60px;
                font-weight: bold;
                font-size: 1.7em;
                font-family: "Open Sans", Arial, sans-serif;
                /*max-width: 200px;*/
            }

            #host_header .logocenter {
                height: 60px;
                line-height: 60px;
                font-weight: bold;
                font-size: 2em;
                font-family: "Open Sans", Arial, sans-serif;
                /*max-width: 200px;*/
            }

            #host_header .logoright {
                float: right;
                height: 60px;
                margin: 0px 5px;
                font-weight: bold;
                font-size: 1.7em;
                font-family: "Open Sans", Arial, sans-serif;
                /*max-width: 200px;*/
            }

            #host_header .company_name {
                float: left;
                height: 60px;
                line-height: 60px;
                margin-left: 24px;
                font-weight: bold;
                font-size: 1.7em;
                font-family: "Open Sans", Arial, sans-serif;
            }

            #host_header .headernote {
                float: left;
                height: 59px;
                max-width: 300px;
                overflow: hidden;
            }

        #preheadernote {
            margin: 4px 10px;
            font-size: 14px;
            line-height: 14px;
            text-align: left;
            font-family: Calibri;
            position: absolute;
            height: 95%;
            overflow: hidden;
        }

        #host_header .user {
            float: left;
            line-height: 58px;
            max-width: 160px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        #host_header .button button {
            background-color: var(--title-bg-color);
        }

        /*#host_header .button button:hover,
            #host_header .button button.selected {
                background-color: <%=MenuBackgroundColor %>;
        }
        */

        .dialog-content .gridchartcontainer {
            border: 1px solid #A2ADB8;
            /*height: 100%;*/
        }

        #divTitleBorder {
            width: 100%;
            height: 2px;
            border: solid 0px;
            background-color: <%=TitleBarBorderColor %>;
            border-color: <%=TitleBarBorderColor %>;
        }

        #button_home:before {
            content: "\f015";
        }

        #button_sites:before {
            content: '\e601';
        }

        #userbutton_down:before {
            font-weight: 600;
            content: '\f0d7';
        }

        .fav {
            font-weight: 900;
            color: #1a73e8;
            cursor: pointer;
        }

        .unfav {
            font-weight: 200;
            color: black;
            cursor: pointer;
        }

        .nofav {
            font-weight: 200;
            color: lightgray;
            cursor: default;
        }

        .favicon {
            margin-left: 5px;
        }

            .favicon:before {
                content: '\f005';
            }

        .favmenu {
            line-height: 40px;
            font-family: CalciteWebCoreIcons, FontAwesome;
            padding: 0;
            font-size: 1.5em;
        }

        .favmenudown {
            font-weight: 600;
        }

            .favmenudown:before {
                content: '\f0da';
            }

        .setting:before {
            content: '\e670';
        }

        #version_info {
            text-wrap: none;
            font-size: 10px;
            height: 20px;
        }

        #divLeftTitle {
            background-color: #cbcbcb;
            height: 100%;
            width: 48px;
            float: left;
            top: 60px;
            bottom: 0;
            margin: 0;
            position: fixed;
        }

        #content {
            /*width: 100%;*/
            top: 60px;
            bottom: 0;
            left: 0;
            right: 0;
            margin: 0;
            margin-left: 48px;
            position: fixed;
            /*color: #6b6b6b;*/
            overflow: auto;
        }

            #content > h3 {
                margin: 16px 0 16px 18px;
            }

        .clear {
            display: block;
            clear: both;
            height: 0;
        }

        /*#button_changepass {
            font-size: 16px;
            cursor: pointer;
            margin-top: 2px;
            font-weight: 900;
        }*/

        #button_changepass:before {
            content: '\f084'; /*font-family: 'FontAwesome';*/
        }

        /*#button_logout {
            font-size: 16px;
            cursor: pointer;
            font-weight: 900;
        }*/

        #button_logout:before {
            content: '\f08b';
            /*font-family: 'FontAwesome';*/
        }

        .item_header {
            font-family: Arial;
            font-size: 1.1em;
            font-weight: bold;
            line-height: 24px;
            margin-top: 8px;
        }

        .item_label {
            line-height: 18px;
        }

        .item_text {
            line-height: 22px;
        }

            .item_text input {
                width: 286px;
                border: 1px solid #a9a9a9;
                padding: 2px;
            }

        .item_error {
            padding: 5px;
            margin-top: 5px;
            border: 1px solid #f00;
            color: #f00;
            width: 280px;
        }

        .item_strong {
            width: 292px;
            line-height: 17px;
        }

        #pass_progress label {
            margin: 2px 4px;
        }

        .non {
            background: none;
            color: rgb(115, 124, 133);
        }

        .weak {
            background: #f00;
            color: white;
            width: 33%;
        }

        .normal {
            background: #ec6b00;
            color: white;
            width: 66%;
        }

        .strong {
            background: #579705;
            color: white;
            width: 100%;
        }
    </style>
    <style type="text/css">
        :root { <%=StyleVariables%> }
        .data-grid {
            height: 100%;
            font-size: 12px !important;
            font-family: "Segoe UI","Segoe UI Web (West European)","Segoe UI",-apple-system,BlinkMacSystemFont,"Roboto","Helvetica Neue",sans-serif !important;
        }
    </style>
    <link type="text/css" href="<%=GetUrl("js/components/css/gridview.css") %>" rel="stylesheet" />
    <link type="text/css" href="<%=GetUrl("css/override.css") %>" rel="stylesheet" />
    <link href="<%=GetUrl("css/panel.css")%>" rel="stylesheet" type="text/css" />
    <script src="<%=GetUrl("js/vue.min.js")%>"></script>
    <script>Vue.config.productionTip = false; Vue.config.silent = true;</script>
    <script src="<%=GetUrl("js/jquery-" + (JQueryVersion ?? "3.6.0") + ".min.js")%>" type="text/javascript"></script>
    <script type="text/javascript" src="<%=GetUrl("js/cookie.js") %>"></script>
    <script type="text/javascript" src="<%=GetUrl("js/utility.js")%>"></script>
    <script type="text/javascript" src="<%=GetUrl("js/components/gridview.js") %>"></script>
    <script type="text/javascript" src="<%=GetUrl("js/language.js") %>"></script>
    <script type="text/javascript" src="<%=GetUrl("js/favorite.js") %>"></script>
    <script type="text/javascript" src="<%=GetUrl("js/modulelang.js") %>"></script>
    <script type="text/javascript" src="<%=GetUrl("js/usermessage.js") %>"></script>
    <script type="text/javascript">
        _network.root = '<%=Page.ResolveUrl("~/")%>';
        var isReadonlyUser =<%=IsReadonlyUser?"true":"false"%>;
        var canExport = <%= CanExportFile %>;
        var userData;

        var GridView = window.GridView || window['g5-gridview'];
        var appmoudulesdata;
        function doLogout() {
            $('#txtAction').val('logout');
            $('#formAction').submit();
            setCookie("ShowDealerLocations", "");
            setCookie("ShowTraffic", "");
            setCookie("ShowDealerLocations", "");
            setCookie("WorkOrderFilters_" + '<%=CompanyID%>', "", -1);
        }

        function logout() {
            if (typeof (_workspace) !== 'undefined') {
                if (_workspace.changed && _utility.CanSaveAccessByPersonalIsVisableWhenLogout()) {
                    $alertdialog.showConfirm(DEFAULT_LANG.FIC,
                        GetLanguageByKey("LHBIS_FIC_SILVERLIGHT_WSP_WORKSPACEPAGE_A004", 'The Workspace setting defaults have changed, do you want to save the changes?'), [
                        [DEFAULT_LANG.cancel],
                        [DEFAULT_LANG.no, LogoutSaveLayout],
                        [DEFAULT_LANG.yes, LogoutSaveWorkspace]
                    ]);
                } else {
                    LogoutSaveLayout();
                }
            }
            else {
                doLogout();
            }
        }

        function LogoutSaveWorkspace() {
            _utility.doSaveWorkspace(doLogout);
        }

        function LogoutSaveLayout() {
            _workspace.saveWorkspaceLayout(doLogout);
        }

        function changepassQuery(method, param, callback, error) {
            _network.request("ChangePassword.aspx?tp=ashx", -1, method, param, callback, error);
        }

        //******************************Start Change Password********************************//

        var iswrong = false;
        function openChangePassword() {
            iswrong = false;
            $('#txt_old_pass').val('');
            $('#txt_new_pass').val('');
            $('#txt_new_pass2').val('');
            $('#mask_bg').show();
            $('#dialog_changepassword .dialog-title span.title').text(GetTextByKey("P_CHANGEPASSWORD", 'Change Password'));
            //$('#mask_bg').show();
            $('#dialog_changepassword')
                .attr('act', 'edit')
                .css({
                    'width': 400,
                    'top': (document.documentElement.clientHeight - $('#dialog_changepassword').height()) / 4,
                    'left': (document.documentElement.clientWidth - $('#dialog_changepassword').width()) / 2
                })
                .showDialogfixed(false);//参数为了兼容inspection页面
        }

        function CheckIfEmpty(val, errid) {
            if (typeof val !== 'string' || val.length == 0) {
                $(errid).text(GetTextByKey("P_CP_PLEASEENTERTHEPASSWORD", 'Please enter the password.')).show();
                iswrong = true;
                return false;
            } else if (val[0] == ' ' || val[val.length - 1] == ' ') {
                $(errid).text(GetTextByKey("P_CP_THEHEADANDTAILOFTHEPASSWORDCANNOTBESPACES", 'The head and tail of the password cannot be spaces.')).show();
                iswrong = true;
                return false;
            } else {
                $(errid).hide();
            }
            iswrong = false;
            return true;
        }

        function CheckIfEmptyOrDismatch(val, v, errid) {
            if (typeof val !== 'string' || val.length == 0) {
                $(errid).text(GetTextByKey("P_CP_PLEASEENTERTHEPASSWORD", 'Please enter the password.')).show();
                iswrong = true;
                return false;
            } else if (val != v) {
                $(errid).text(GetTextByKey("P_CP_THEPASSWORDSYOUENTEREDDONOTMATCHCHECKYOURTYPINGANDTRYAGAIN", 'The passwords you entered do not match. Check your typing and try again.')).show();
                iswrong = true;
                return false;
            } else {
                $(errid).hide();
            }
            iswrong = false;
            return true;
        }

        function CheckInfo(e) {
            if (iswrong) {
                // has errors;
                return;
            }

            var oldpass = $('#txt_old_pass').val();
            if (oldpass.length == 0) {
                $('#old_pass_error').show();
                $('#txt_old_pass').focus();
                return false;
            } else {
                $('#old_pass_error').hide();
            }

            var newpass = $('#txt_new_pass').val();
            if (!CheckIfEmpty(newpass, '#pass_error')) {
                $('#txt_new_pass').focus();
                return false;
            }

            var newpass2 = $('#txt_new_pass2').val();
            if (!CheckIfEmptyOrDismatch(newpass2, newpass, '#pass_error2')) {
                $('#txt_new_pass2').focus();
                return false;
            }
            // strong test
            if (newpass.length < 8) {
                $('#pass_error').text(GetTextByKey("P_CP_PASSWORDTIPS", 'The password must be at least 8 characters.')).show();
                iswrong = true;
            }
            if (!iswrong && getStrength(newpass) < 2) {
                $('#pass_error').text(GetTextByKey("P_CP_PASSWORDTIPS1", 'The password must contain both uppercase and lowercase characters and at lease one number.')).show();
                iswrong = true;
            }

            if (iswrong) {
                $('#txt_new_pass').focus();
                return false;
            }


            DoChangePassword(htmlencode(oldpass), htmlencode(newpass));
            return true;
        }

        function enableUI(flag) {
            $('#txt_old_pass').prop('disabled', !flag);
            $('#txt_new_pass').prop('disabled', !flag);
            $('#txt_new_pass2').prop('disabled', !flag);
            $('#button_submit').prop('disabled', !flag);
        }

        function DoChangePassword(oldpass, newpass) {
            enableUI(false);

            changepassQuery('ChangePassword', oldpass + String.fromCharCode(170) + newpass, function (data) {
                if (!data || data.length == 0) {
                    $('#old_pass_error').hide();
                    $('#txt_old_pass').val('');
                    $('#txt_new_pass').val('');
                    $('#txt_new_pass2').val('');
                    $('#pass_progress').attr('class', 'non').children('label').text(GetTextByKey("P_CP_PASSWORDSTRENGTH", 'Password strength'));
                    alert(GetTextByKey("P_CP_PASSWORDSUCCESSFULLYCHANGED", 'Password successfully changed.'));
                    enableUI(true);
                    $('#dialog_changepassword').hideDialog();
                    $('#mask_bg').hide();
                } else {
                    enableUI(true);
                    //$('#pass_error2').text(data).show();
                    $('#old_pass_error').show();
                    $('#txt_old_pass').focus();
                }
            }, function (err) {
                $('#pass_error2').text(GetTextByKey("P_CP_UNKNOWNERROROCCURS", 'Unknown error occurs.')).show();
                enableUI(true);
            });
        }

        function ChangeStrength() {
            var pass = $(this).val();
            if (typeof pass !== 'string' || pass.length == 0) {
                $('#pass_progress').attr('class', 'non').children('label').text(GetTextByKey("P_CP_PASSWORDSTRENGTH", 'Password strength'));
            } else if (pass.length < 6) {
                $('#pass_progress').attr('class', 'weak').children('label').text(GetTextByKey("P_CP_WEAK", 'weak'));
            } else {
                var strength = getStrength(pass);
                if (strength == 2) {
                    $('#pass_progress').attr('class', 'strong').children('label').text(GetTextByKey("P_CP_STRONG", 'strong'));
                } else if (strength == 1) {
                    $('#pass_progress').attr('class', 'normal').children('label').text(GetTextByKey("P_CP_MEDIUM", 'medium'));
                } else {
                    $('#pass_progress').attr('class', 'weak').children('label').text(GetTextByKey("P_CP_WEAK", 'weak'));
                }
            }
        }

        //***********************************End Change Password****************************************//

        function GetLanguageByCookie() {
            var lang = getCookie('<%=Common.LanguageCookieName%>');
            if (lang == null) {
                return "en-us";
            } else {
                return lang;
            }
        }

        _fleet.currentLang = GetLanguageByCookie();
        var UserMessageObj;
        $(function () {
            InitDBGridData();
            if (typeof $.fn.applyFleetLanguageText === "function") {
                $("#content").applyFleetLanguageText(true);
                $("#host_main").applyFleetLanguageText(true);
                $(".panel_holder").applyFleetLanguageText(true);
                $("#dialog_favorite").applyFleetLanguageText(true);
                $("#dialog_dashboards").applyFleetLanguageText(true);
                $("#dialog_chartnotes").applyFleetLanguageText(true);
                $("#divLeftTitle").applyFleetLanguageText(true);
            }

            $('#dialog_changepassword').dialog(function () {
                $('#mask_bg').hide();
            });
            $('#dialog_dashboards').dialog(function () {
                $('#mask_bg').hide();
            });
            $('#dialog_chartnotes').dialog(function () {
                $('#mask_bgcn').hide();
            });
            $('#txt_new_pass')
                .bind('propertychange', ChangeStrength)
                .bind('input', ChangeStrength)
                .blur(function () {
                    var newpass = $(this).val();
                    CheckIfEmpty(newpass, '#pass_error');
                });
            $('#txt_new_pass2').blur(function () {
                var newpass = $('#txt_new_pass').val();
                var newpass2 = $(this).val();
                CheckIfEmptyOrDismatch(newpass2, newpass, '#pass_error2');
            });

            $('#txt_old_pass').val('');
            $('#button_submit').click(CheckInfo);

            var failcount = 0;

            function IAmAlive() {
                _network.commonpagequery(0, '', function (data) {
                    failcount = 0;
                    setTimeout(IAmAlive, 5 * 60 * 1000);
                }, function (err) {
                    if (err.status >= 400) {
                        failcount++;
                        if (failcount > 20) {
                            // logged out, refresh then it will go to the login page.
                            window.location = window.location;
                        } else {
                            //console.log(err);
                            setTimeout(IAmAlive, 15000);
                        }
                    }
                }, true);
            }

            function getAppModules() {
                var userid = '<%=UserID%>';
                var companyid = '<%=CompanyID%>';
                var modules = window.localStorage[companyid + "_" + userid + "_modules"];
                if (modules && modules != '')
                    applyAppModules(JSON.parse(modules));
                _network.mainpagequery("GetAppModules", "", function (data) {
                    if (typeof data === 'string') {
                        _dialog.showAlert(data, GetTextByKey("P_MODULE_GETAPPMODULES", 'Get AppModules'));
                    } else {
                        applyAppModules(data);
                        window.localStorage[companyid + "_" + userid + "_modules"] = JSON.stringify(data);
                    }
                });
            }

            function applyAppModules(modules) {
                setAppModulesLang(modules);
                onInitSites(modules);
                appmoudulesdata = modules;

                onInitTitleSites();
                refreshFavorites();
                if (typeof showAppModules === 'function') {
                    showAppModules(modules);
                }
                if (typeof initMapMenuItems === 'function') {//map menu
                    initMapMenuItems(modules);
                }
            }

            function getVersions() {
                _network.mainpagequery("GetVersions", "", function (data) {
                    if (typeof data === 'string') {
                        //_dialog.showAlert(data, 'Get Versions');
                    } else {
                        if (data[0] && data[0] != "") {
                            $("#liVersion").show();
                            $("#aVersion").text(GetTextByKey("P_MAIN_VERSION_COLON", "Version: ") + data[0]);
                        }
                        if (data[0] && data[1] != "") {
                            $("#liFICVersion").show();
                            $("#aFICVersion").text(GetTextByKey("P_MAIN_FICVERSION_COLON", "FIC Version: ") + data[1]);
                        }
                    }
                });
            }

            // init load sites panel
            function onInitSites(data) {
                if (data) {
                    var syspanel = $('<div class="panel_modules"></div>')
                        .css("max-height", $(window).height() - 120)
                        .css("float", 'left')
                        .mouseup(onopen);
                    var wsppanel = $('<div class="panel_modules"></div>')
                        .css("max-height", $(window).height() - 120)
                        .css("padding-left", 10)
                        .mouseup(onopen);


                    var titleFeatures = $("<div>" + GetTextByKey("P_MAIN_FEATURES", "Features") + "</div>").addClass("lefttitle_title").appendTo(syspanel);
                    var sysModules = $("<div class='div_modules'></div>").appendTo(syspanel);
                    var titleWSP = $("<div>" + GetTextByKey("P_MAIN_DASHBOARDS", "Dashboards") + "</div>").addClass("lefttitle_title").css("display", "none").appendTo(wsppanel);
                    var wspModules = $("<div class='div_modules'></div>").appendTo(wsppanel);
                    $('#sites_panel').empty().append(syspanel).append(wsppanel);
                    var ulFeatures = $('<ul class="lefttitlemenu_ul" style="line-height:32px;"></ul>');
                    sysModules.append(ulFeatures);
                    var ulWSP = $('<ul class="lefttitlemenu_ul" style="line-height:32px;"></ul>');
                    wspModules.append(ulWSP);
                    for (var i = 0; i < data.length; i++) {
                        var m = data[i];
                        if (!m.Visible) continue;
                        createMenuItem(m, (m.ModuleType == 0) ? ulFeatures : ulWSP);
                        if (m.ModuleType == 0) {
                            titleFeatures.show();
                        }
                        else if (m.ModuleType == 1) {
                            titleWSP.show();
                        }
                    }
                    //panel.append($('<div class="clear"></div>'))

                    $('#sites_panel')
                        .append('<div class="clear"></div>') // trigle
                        .append('<div class="trigle"></div>') // trigle
                        .append('<div class="trigle white"></div>');
                }
            }

            function onopen(e) {
                var etarget = $(e.target);
                if (!etarget.is('.module')) {
                    etarget = etarget.parents('.module');
                }
                if (!etarget.length) {
                    return;
                }
                var m = etarget.data('m');
                if (!m) {
                    return;
                }
                var url = m.Url.toLowerCase();
                if (url.length > 4 && url.substring(0, 4) == 'http') {
                } else if (url.length > 0 && url[0] == '/') {
                } else {
                    url = _network.root + url;
                }
                if (m.OpenInNewWindow) {
                    window.open(url, "_blank");
                } else {
                    window.location = url;
                }
            }


            $(window).resize(null, function () {
                $('#sites_panel .panel_modules').css("max-height", $(window).height() - 120);
                $('#favorite_panel .panel_favorites').css("max-height", $(window).height() - 180);
            })

            function getUserInfo() {
                $(".user").attr("src", _network.root + "titlelogo.ashx?tp=avatar&sn=" + Math.random());
                _network.mainpagequery("GetUserData", "", function (data) {
                    //$("#spanUserName").text(GetTextByKey("P_MAIN_WELCOME", "Welcome, ") + data);
                    userData = data;
                    $("#btnuser").attr("title", userData.UserName);
                    $("#spanusername").text(userData.UserName);
                });
            }

            getAppModules();
            getUserInfo();
            GetSiteHeaderNote();
            getVersions();
            $('#sites_panel').empty().html('<div class="panel_loading"></div>');

            $('#button_sites').click(function () {
                if ($('.panel_holder.sites').is(':visible')) {
                    return;
                }
                hidePanels();
                $('.panel_holder.sites').css({
                    'opacity': 0,
                    'left': 60,
                    'right': 'auto'
                }).show().animate({ 'opacity': 1 }, 100);
                var left = $(this).offset().left;
                var top = $(this).offset().top;
                $('.panel_holder.sites .trigle').css({
                    'left': left + 48 - $('.panel_holder.sites').offset().left,
                    'right': 'auto',
                    'top': top - 60
                });
                $('#button_sites').addClass('selected');
                return false;
            });

            //$('#button_fav').hide();
            $('#button_fav').click(function () {
                if (!navigate)
                    return;
                setFavorate();
                return false;
            });

            $('#button_favlist').click(function (ev) {
                if ($('.panel_holder.favorites').is(':visible')) {
                    return;
                }
                hidePanels();
                var left = $(this).offset().left;
                var top = $(ev.target).offset().top;
                $('.panel_holder.favorites').css({
                    'opacity': 0,
                    'left': 60,
                    'right': 'auto'
                }).show().animate({ 'opacity': 1 }, 100);
                $('.panel_holder.favorites .trigle').css({
                    'left': -10,// left - $('.panel_holder.favorites').offset().left,
                    'right': 'auto',
                    'top': top - 70
                });
                $('#button_favlist').addClass('selected');
                return false;
            });

            $('#btnuser').click(function (ev) {
                if ($('.panel_holder.usermenus').is(':visible')) {
                    return;
                }
                hidePanels();
                var left = $(this).offset().left;
                $('.panel_holder.usermenus').css({
                    'opacity': 0,
                    'left': left + $(this).width() - $('.panel_holder.usermenus').width(),
                    'right': 'auto'
                }).show().animate({ 'opacity': 1 }, 100);
                $('.panel_holder.usermenus .trigledown').css({
                    'left': left + $(this).width() - $('.panel_holder.usermenus').offset().left - 20,
                    'right': 'auto',
                });
                $('#userbutton_down').addClass('selected');
                return false;
            });

            $('#button_menu').click(function () {
                if ($('.panel_holder.menus').is(':visible')) {
                    return;
                }
                hidePanels();
                var left = $(this).offset().left;
                var top = $(this).offset().top;
                $('.panel_holder.menus').css({
                    'opacity': 0,
                    'right': 'auto',
                    'left': 60//left - 71
                }).show().animate({ 'opacity': 1 }, 100);
                $('.panel_holder.menus .trigle').css({
                    'left': left + 48 - $('.panel_holder.menus').offset().left,
                    'right': 'auto',
                    'top': top - 60
                });
                $('#button_menu').addClass('selected');
                return false;
            });

            $(document.body).click(function (e) {
                var etarget = $(e.target);
                //if (etarget.is('.button') || etarget.parent('.button').length)
                //    return;
                hidePanels();
            });

            // I am alive.
            var loc = window.location.href.toLowerCase();
            if (loc.indexOf('/mapview.aspx') < 0 &&
                loc.indexOf('/errorpage.aspx') < 0) {
                setTimeout(IAmAlive, 30000);
            }
            function GetSiteHeaderNote() {
                _network.mainpagequery("GetSiteHeaderNote", "", function (data) {
                    $("#preheadernote").text(data);
                    //$("#preheadernote").html(replaceHtmlText(data))
                });
            }

            $('#ipt_dashboardfilter').keydown(function (e) {
                if (e.keyCode == 13 || e.keyCode == 9) {
                    getDashboardList();
                }
            });
            $(window).resize(function () {
                $("#dashboardslist").css("height", 460 - $("#dashboardslist").offset().top - 4);
                grid_dbdt && grid_dbdt.resize();
            }).resize();

            UserMessageObj = new UserMessage();
        });

        function openFleetChart(chartiid, chartname) {
            if (!chartiid || chartiid == "")
                return;
            if (!$("#iffleetchart").attr("src")) {
                $("#iffleetchart").attr("src", _network.root + "chart.aspx?iid=" + chartiid + "&n=" + htmlencode(chartname));
            }
            else {
                execIframeFunc("changeChart", [chartiid, chartname], "iffleetchart");
            }
            $("#fleetchart").show();
        }

        function hideChartContainer() {
            $("#fleetchart").hide();
        }

        function setChartFavorite(isFavorite, navigate) {
            setFavoritesData(!isFavorite, navigate)
        }

        function UploadUserAvatar() {
            var filectrl = $('<input type="file" style="display: none;" accept="image/png,image/jpg,image/jpeg" />');
            filectrl.change(function () {
                var files = this.files;
                var img = files[0];
                if (img.size == 0) {
                    alert(GetTextByKey("P_IPT_FILETIPS", "File size is 0kb, uploading failed."));
                    return false;
                }
                if (img.size > 1024 * 1024 * 2) {
                    alert(GetTextByKey("P_IPT_FILETIPS1", "File is too large. Maximum size is 2MB."));
                    return false;
                }

                $(".user").attr('src', window.URL.createObjectURL(img));
                doUploadUserAvatar(img);
            }).click();
        }

        function doUploadUserAvatar(avatarFile) {
            var formData = new FormData();
            formData.append("iconFile", avatarFile);
            formData.append("MethodName", "UploadUserAvatar");
            var url = _network.root + 'IronIntelMain.aspx?tp=ashx';
            $.ajax({
                url: url,
                type: 'POST',
                dataType: 'json',
                processData: false,
                contentType: false,
                data: formData,
                async: true,
                success: function (data) {
                },
                error: function (err) {
                    _dialog.showAlert(GetTextByKey("P_MAIN_FAILEDTOUPLOADAVATAR", 'Failed to upload avatar.'), GetTextByKey("P_MAIN_UPLOADAVATAR", 'Upload avatar'));
                }
            });
        }
    </script>
    <asp:ContentPlaceHolder ID="holder_head" runat="server"></asp:ContentPlaceHolder>
</head>
<body>
    <div id="host_main">
        <div id="host_header">
            <%=Logo1 %>
            <div class="headernote">
                <pre id="preheadernote"></pre>
            </div>
            <%=Logo2 %>
            <%=Logo3 %>
            <div style="float: right;">
                <%if (CanSeeUserMessage)
                    {
                %>
                <div id="iconmessage" class="spanbtn iconmessage" style="display: none; position: relative; float: left; margin-right: 5px; line-height: 55px; font-size: 20px;">
                    <div id="divunreadcount" style="position: absolute; right: 0; top: 8px; border-radius: 50%; line-height: 18px; width: 18px; height: 18px; background-color: #45b854; font-size: 12px;"></div>
                </div>
                <%} %>
                <img class="user" id="btnuser" style="font-size: 16px; cursor: pointer; border-radius: 60px; width: 60px; height: 60px;" />
                <%--<div class="button" style="line-height: 60px;">
                    <button id="userbutton_down" style="width: unset;"></button>
                </div>--%>
            </div>
        </div>
    </div>
    <div id="divTitleBorder"></div>
    <div id="divLeftTitle">
        <div id="divhome" class="button" style="margin-top: 10px;" data-title-lgid="P_MAIN_HOME">
            <a href="<%=ResolveUrl("~/IronIntelMain.aspx")%>" target="_self" style="color: black; text-decoration: none;">
                <div class="titleicon">
                    <img id="button_home" class="titleimgicon" src="<%=ResolveUrl("~/img/modules/home.png?t=8")%>" />
                </div>
            </a>
        </div>
        <div id="divfav" class="button" style="width: 48px; display: none;" onclick="setFavorate(true)" data-title-lgid="P_MAIN_FAVORITE">
            <div class="titleicon">
                <img class="titleimgicon" src="<%=ResolveUrl("~/img/modules/favorites.png?t=0")%>" />
            </div>
            <%--   <span id="button_fav" class="favicon favmenu nofav"></span>
            <span id="button_down" class="favmenu favmenudown" style="font-size: 1.8em; margin-left: 5px;"></span>--%>
        </div>
        <div id="divfavadd" class="button" style="width: 48px; display: none;" onclick="setFavorate(false)" data-title-lgid="P_MAIN_ADDFAVORITE">
            <div class="titleicon">
                <img class="titleimgicon" src="<%=ResolveUrl("~/img/modules/favoriteadd.png?t=0")%>" />
            </div>
        </div>
        <div id="divfavmenu" class="button" style="width: 48px;" data-title-lgid="P_MYFAVORITES">
            <div class="titleicon">
                <img id="button_favlist" class="titleimgicon" src="<%=ResolveUrl("~/img/modules/favoritelist.png?t=0")%>" />
            </div>
        </div>
        <div class="button" data-title-lgid="P_MAIN_FULLMENU">
            <button id="button_sites" class="titleicon"></button>
        </div>
        <div class="button" data-title-lgid="P_MAIN_SETTINGS">
            <button id="button_menu" class="titleicon setting"></button>
        </div>
    </div>
    <div id="content" style="margin-top: 2px;">
        <asp:ContentPlaceHolder ID="holder_content" runat="server"></asp:ContentPlaceHolder>
    </div>
    <div class="panel_holder favorites">
        <div class="lefttitle_title" data-lgid="P_MYFAVORITES">My Favorites</div>
        <div id="favorite_panel" class="panel" style="min-width: 250px;">
        </div>
    </div>
    <div class="panel_holder sites">
        <div id="sites_panel" class="menupanel panel"></div>
    </div>
    <div class="panel_holder menus">
        <div class="lefttitle_title" data-title-lgid="P_MAIN_SETTINGS">Settings</div>
        <div id="menu_panel" class="menupanel panel" style="min-width: 250px;">
            <ul class="lefttitlemenu_ul">
                <li id="lisyssetting" style="line-height: 40px; padding-left: 0;"><a href="<%=ResolveUrl("~/SystemSettings/SystemSettings.aspx")%>" target="_self">
                    <div class="button setting" style="height: 40px; font-size: 24px; padding-left: 6px;"></div>
                    <span data-lgid="P_MAIN_SYSTEMSETTINGS">System Settings</span></a></li>
                <li id="liVersion" style="display: none; line-height: 40px; padding-left: 0;"><a style="cursor: default;">
                    <div style="height: 40px;"></div>
                    <span id="aVersion"></span></a></li>
                <li id="liFICVersion" style="display: none; line-height: 40px; padding-left: 0;"><a style="cursor: default;">
                    <div style="height: 40px;"></div>
                    <span id="aFICVersion"></span></a></li>
            </ul>
            <div class="trigle"></div>
            <div class="trigle white"></div>
        </div>
    </div>

    <div class="panel_holder usermenus">
        <div id="usermenu_panel" class="panel" style="min-width: 200px;">
            <ul class="lefttitlemenu_ul">
                <li style="height: 70px; cursor: default;">
                    <table>
                        <tr>
                            <td>
                                <img class="user" style="font-size: 16px; cursor: pointer; border-radius: 60px; width: 60px; height: 60px;" onclick="UploadUserAvatar()" /></td>
                            <td style="vertical-align: bottom;"><span id="spanusername" style="margin-left: 10px;"></span></td>
                        </tr>
                    </table>
                </li>
                <li onclick="openChangePassword();">
                    <table>
                        <tr>
                            <td>
                                <img style="width: 32px; height: 32px;" src='<%=ResolveUrl("~/img/modules/changepassword.png?t=0")%>' /></td>
                            <td><span data-lgid="P_MAIN_CHANGEPASSWORD">Change Password</span></td>
                        </tr>
                    </table>
                </li>
                <li onclick="logout();">
                    <table>
                        <tr>
                            <td>
                                <img style="width: 32px; height: 32px;" src='<%=ResolveUrl("~/img/modules/logout.png?t=0")%>' /></td>
                            <td><span data-lgid="P_MAIN_LOGOUT">Logout</span></td>
                        </tr>
                    </table>
                </li>
            </ul>
            <div class="trigledown"></div>
            <div class="trigledown white"></div>
        </div>
    </div>
    <%--<div class="maskbg" style="display: none;"></div>--%>
    <form id="formAction" action="<%=ResolveUrl("~/commonpage.aspx")%>" method="post" style="display: none;">
        <input type="hidden" id="txtAction" name="action" />
    </form>

    <div id="divmsgs" style="display: none; position: absolute; top: 60px; bottom: 0; right: 0; width: 400px; background-color: #f4f4f4; box-shadow: #CECACA -6px 0px 6px;">
        <div style="padding: 5px 0 5px 10px;">
            <span data-lgid="P_MAIN_MESSAGES" style="font-size: 18px; font-weight: bold;">Messages</span>
            <em class="spanbtn icondelete" style="float: right; margin-right: 5px; margin-top: 0; font-size: 16px;" v-on:click="closeMessage()" data-title-lgid="P_MAIN_CLOSE"></em>
            <em class="spanbtn icontrash" style="float: right; margin-right: 5px; margin-top: 0; font-size: 14px;" v-on:click="deleteMessage()" data-title-lgid="P_MAIN_REMOVE"></em>
            <em class="spanbtn iconopentext" style="float: right; margin-right: 5px; margin-top: 0; font-size: 14px;" v-on:click="readMessage(null,$event)" data-title-lgid="P_MAIN_MARKASREAD"></em>
            <em class="spanbtn iconrefresh" style="float: right; margin-right: 5px; margin-top: 0; font-size: 14px; display: none;" v-on:click="refreshMessage()" data-title-lgid="P_MAIN_XXXXXX"></em>
        </div>
        <div style="clear: both;"></div>

        <div style="line-height: 30px;">
            <div style="margin-left: 10px;">
                <input type="checkbox" id="chkSelectAll" style="height: 26px;" v-on:change="selectAll($event)" /><span data-lgid="P_MAIN_SELECTALL">Select All</span>
            </div>
            <div id="divmsgcontainer" style="overflow: auto; position: absolute; top: 60px; bottom: 0; width: 100%;">
                <div v-bind:style="bodyContainerStyle" style="position: relative">
                    <div v-bind:style="bodyContentStyle" style="position: absolute; width: 100%;">
                        <div class='msgitem' v-for="msg in innerMessages" v-bind:class="msg.Readed ?'': 'unreadmsg'" v-on:click="readMessage(msg,$event)">
                            <div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis;">
                                <input type='checkbox' v-model="msg.Selected" /><a href='javascript:void(0);' v-on:click="linkClick(msg)" style="margin-left: 5px;">{{msg.LinkText}}</a>
                            </div>
                            <div style="margin-left: 26px; word-break: break-word;">
                                <div v-html="msg.Message"></div>
                            </div>
                            <div style="text-align: right;">
                                <span style="margin-left: 10px; font-size: 12px; float: left;">{{msg.CreatedTimeStr}}</span>
                                <em class="spanbtn iconopentext" style="display: none; margin-right: 5px; margin-top: 0; font-size: 12px;" v-on:click="readMessage(msg)"></em>
                                <em class="spanbtn icondelete" style="margin-right: 5px; margin-top: 0; font-size: 14px;" v-on:click="deleteMessage(msg)"></em>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
    <div class="dialog" id="dialog_favorite" style="display: none;">
        <div class="dialog-title"><span class="title" data-lgid="P_FAV_EDITFAVORITES">Edit Favorites</span><em class="dialog-close"></em></div>
        <div class="dialog-content">
            <div id="favoritelist" style="height: 350px; width: 520px;"></div>
        </div>
        <div class="dialog-func">
            <input type="button" value="Cancel" data-lgid="P_FAV_CANCEL" class="dialog-close" tabindex="12" style="height: 26px;" />
            <input type="button" id="btnfavsave" onclick="onSaveFavoriteSort();" value="Save" data-lgid="P_FAV_SAVE" tabindex="11" />
            <div class="clear"></div>
        </div>
        <div id="favorites_mask_bg" class="maskbg" style="display: none;"></div>
    </div>


    <div class="dialog" id="dialog_changepassword" style="display: none; border-bottom: 0; border-top: 0;">
        <div class="dialog-title"><span class="title" data-lgid="P_CHANGEPASSWORD">Change Password</span><em class="dialog-close"></em></div>
        <div class="dialog-content" style="height: 340px;">
            <div class="cp_form" style="margin-left: 30px;">
                <div class="item_header" data-lgid="P_CP_USERID">User ID</div>
                <div class="item_label"><%=HttpUtility.HtmlEncode(UserID)%></div>
                <div class="item_header" data-lgid="P_CP_OLDPASSWORD">Old Password</div>
                <div class="item_text">
                    <input type="password" id="txt_old_pass" name="oldpass" autocomplete="off" />
                </div>
                <div id="old_pass_error" class="item_error" style="display: none;" data-lgid="P_CP_THEOLDPASSWORDISWRONG">The old password is wrong.</div>
                <div class="item_header" data-lgid="P_CP_NEWPASSWORD">New Password</div>
                <div class="item_text">
                    <input type="password" id="txt_new_pass" name="newpass" autocomplete="off" />
                </div>
                <div class="item_strong">
                    <div id="pass_progress" class="non">
                        <label data-lgid="P_CP_PASSWORDSTRENGTH">Password strength</label>
                    </div>
                </div>
                <div id="pass_error" class="item_error" style="display: none;"></div>
                <div class="item_header" data-lgid="P_CP_CONFIRMNEWPASSWORD">Confirm New Password</div>
                <div class="item_text">
                    <input type="password" id="txt_new_pass2" name="newpass2" autocomplete="off" />
                </div>
                <div id="pass_error2" class="item_error" style="display: none;"></div>
            </div>
        </div>
        <div class="dialog-func">
            <input type="button" value="Cancel" data-lgid="P_MV_CANCEL" class="dialog-close" tabindex="12" />
            <input type="button" id="button_submit" value="OK" data-lgid="P_CP_OK" tabindex="11" />
            <div class="clear"></div>
        </div>

    </div>

    <div class="dialog" id="dialog_dashboards" style="display: none; border-bottom: 0; border-top: 0;">
        <div class="dialog-title"><span class="title" data-lgid="P_MAIN_REPORTSDASHBOARDS">Reports & Dashboards</span><em class="dialog-close"></em></div>
        <div class="dialog-content" style="height: 500px;">
            <input id="ipt_dashboardfilter" autocomplete="off" style="width: 300px;" />
            <input class="search" type="button" onclick="getDashboardList();" value="" data-lgid="P_MA_SEARCH" />
            <input id="ipt_charts_notes" type="radio" name="search_filter" value="charts_notes" checked="checked" /><label for="ipt_charts_notes" data-lgid="P_MAIN_CHARTSANDNOTES">Charts & Notes</label>
            <input id="ipt_charts_only" type="radio" name="search_filter" value="charts" /><label for="ipt_charts_only" data-lgid="P_MAIN_CHARTSONLY">Charts Only</label>
            <input id="ipt_notes_only" type="radio" name="search_filter" value="notes" /><label for="ipt_notes_only" data-lgid="P_MAIN_NOTESONLY">Notes Only</label>
            <div class="clear"></div>
            <div id="dashboardslist" style="margin-top: 5px;">
            </div>
        </div>
        <div class="dialog-func">
            <input type="button" value="Cancel" data-lgid="P_MV_CANCEL" class="dialog-close" tabindex="12" />
            <input type="button" value="OK" data-lgid="P_CP_OK" onclick="openDashboard();" tabindex="11" />
            <div class="clear"></div>
        </div>
    </div>
    <div id="mask_bgcn" class="maskbg" style="display: none; z-index: 701;"></div>
    <div class="dialog" id="dialog_chartnotes" style="display: none; border-bottom: 0; border-top: 0; padding-bottom: 6px; z-index: 702;">
        <div class="dialog-title"><span class="title" data-lgid="P_MAIN_CHARTNOTES">Chart Notes</span><em class="dialog-close"></em></div>
        <div class="dialog-content" style="padding: 0;">
            <pre id="prechartnotes" style="height: 340px; margin: 5px; overflow-y: auto; overflow-wrap: break-word; white-space: pre-line; background-color: rgb(220, 221, 226); line-height: 1.3em;"></pre>
        </div>
        <div style="float: right;">
            <input type="button" value="Close" data-lgid="P_CP_CLOSE" class="dialog-close" tabindex="11" style="width: unset; height: unset; margin-right: 5px;" />
            <div class="clear"></div>
        </div>
    </div>
    <div id="mask_bg_ds" class="maskbg" style="display: none; z-index: 100;"><div class="loading c-spin"></div></div>
    <div class="form non-select" id="dialog_ds" style="display: none; z-index: 101;">
        <div class="form-head">
            <div class="form-close fa"></div>
            <div class="form-title"><span class="title" data-lgid="LHBIS_FIC_CLIENT_FICCONTROLS_PLUGINCTR_A003">Select Filter/Level Data Source Value</span></div>
        </div>
        <div class="dialog-content" style="height: 500px; width: 540px;">
            <div id="content_flatds">
                <table style="line-height: 20px; width: 100%;">
                    <tr>
                        <td data-lgid="LHBIS_FIC_CLIENT_FICCONTROLS_PLUGINCTR_A006">Available Values</td>
                        <td></td>
                        <td data-lgid="LHBIS_FIC_CLIENT_FICCONTROLS_PLUGINCTR_A007">Selected Values</td>
                    </tr>
                    <tr>
                        <td>
                            <div id="div_avas" style="height: 465px; width: 220px;"></div>
                        </td>
                        <td>
                            <div style="display: inline-grid;">
                                <input class="ctl_button" type="button" id="ctl_sel_add" style="margin-top: 5px; width: 70px" value=">" />
                                <input class="ctl_button" type="button" id="ctl_sel_addall" style="margin-top: 5px; width: 70px" value=">>" />
                                <input class="ctl_button" type="button" id="ctl_sel_remove" style="margin-top: 5px; width: 70px" value="<" />
                                <input class="ctl_button" type="button" id="ctl_sel_removeall" style="margin-top: 5px; width: 70px" value="<<" />
                            </div>
                        </td>
                        <td>
                            <div id="div_sels" style="height: 465px; width: 220px;"></div>
                        </td>
                    </tr>
                </table>
            </div>
            <div id="content_treeds" style="height: 100%;">
                <div class="treeds_content">
                    <ul id="ulDataSource"></ul>
                </div>
            </div>
        </div>
        <div class="form-func">
            <input data-lgid="LHBIS_MultiLanguage_Common_A006" type="button" value="Cancel" class="form-close" tabindex="10" />
            <input data-lgid="LHBIS_MULTILANGUAGE_LHBISMESSAGEBOX_A004" type="button" onclick="OnDSSelect();" value="OK" tabindex="9" />
            <div class="clear"></div>
        </div>
        <div class="mask_loading dialog" style="display: none;">
            <div class="loading_holder"></div>
        </div>
    </div>

    <div id="fleetchart" style="left: 0; top: 0; right: 0; bottom: 0; position: absolute; display: none; background-color: white; z-index: 500;">
        <iframe id="iffleetchart" style="width: 100%; height: 100%; display: block; border: none;"></iframe>
    </div>
</body>
</html>