var displaymode = 0;
var StyleSheetPath, _BasePath, _adminPath, _adminName, _CheckNewVersionJSUrl;
function setStyleSheetPath(path) { StyleSheetPath = path; }
function setBasePath(basepath, adminpath) { _BasePath = basepath; _adminPath = adminpath; }
function setAdminName(adminname) { _adminName = encodeURI(adminname); }
function setCheckNewVersionJSUrl(checkNewVersionJSUrl) { _CheckNewVersionJSUrl = checkNewVersionJSUrl; }
//修改IE下document.getElementById在id和name同名时的bug
if (/msie/i.test(navigator.userAgent)) //根据userAgent确定用户使用IE浏览器
{
    document.nativeGetElementById = document.getElementById;
    document.getElementById = function (id) {
        var elem = document.nativeGetElementById(id);
        if (elem) {              //修改后的确认能得到id属性方法 
            if (elem.attributes['id'].value == id) {
                return elem;
            } else {                  //如果没有ID相同的,那么就遍历所有元素的集合找到id相同的元素
                for (var i = 1; i < document.all[id].length; i++) {
                    if (document.all[id][i].attributes['id'].value == id) {
                        return document.all[id][i];
                    }
                }
            }
        }
        return null;
    };
}

$(document).ready(function () {
    $("#info").ajaxComplete(function (whoareyou, request, settings) {
        clearTimeout(clock);
        if (isShowPop) {
            clock = setTimeout("showPop()", timeOut());
        }
    });
    if (isShowPop)
        showPop();
    HelpTipsCheck();
    //setTimeout("ClosePop()", 30000);
    //快捷导航
    ShowQuickNavigation();

    if (tID == 'ChannelMenu_MenuMyDeskTop') {
        tID = "";
        ShowHideLayer('ChannelMenu_MenuMyDeskTop');
    }
    //备忘录
    $("#OpenMemorandum").click(function () { document.getElementById("IframeMemorandum").contentWindow.location.reload(true); lock("Memorandum"); });
    //检查版本更新
    var script = '<script type="text/javascript" src="' + _CheckNewVersionJSUrl + '"></script>';
    setTimeout("$('head').eq(0).append('" + script + "'); ", 3000); //延时3秒
});

function compiler() {

    $("#Indexbody").prepend('<div id="ProgressBarSide" style="width:100px;border-width:1px; border-style:Solid;position:absolute;top:25px;right:10px;"> \
    <div align="center" style="width:100px;">正在加载预编译：</div>  \
    <div id="ProgressBar" align="center" style="height:10px; width:0px; background-color:#316AC5;"></div> \
    </div>');
    var compilerlist = new Array(
    "Accessories/Author.aspx",
    "ADZone/ADGuide.aspx",
    "Analytics/CodeReference.aspx",
    "Blog/Blog.aspx",
    "Collection/CollectionFilter.aspx",
    "CommonModel/Field.aspx",
    "Configuration/Choiceset.aspx",
    "Contents/AddContentToNode.aspx",
    "Crm/AddIncome.aspx",
    "CustomForm/CustomForm.aspx",
    "Government/AdminNameList.aspx",
    "Profile/ChangeManage.aspx",
    "Promotion/Account.aspx",
    "QA/BatchAddQAPoint.aspx",
    "Recruitment/CareersGuide.aspx",
    "Search/SearchGuide.aspx",
    "ServiceCenter/EditQuestion.aspx",
    "Shop/AddProductToNode.aspx",
    "SiteGroup/ShareDataAdd.aspx",
    "SMS/SmsGuid.aspx",
    "Ssms/AdminNameList.aspx",
    "Statistics/SiteCount.aspx",
    "Survey/AnswerList.aspx",
    "Template/CodeSnippet.aspx",
    "User/AddIncome.aspx",
    "Vote/Vote.aspx",
    "Work/Work.aspx");
    var setW = 1;
    for (var i = 0; i < compilerlist.length; i++) {
        $.ajax({
            type: "GET",
            cache: false,
            url: compilerlist[i],
            error: function (msg) {
                $("#ProgressBar").css("width", (100 / compilerlist.length * setW) + "px");
                setW++;
                if (setW > compilerlist.length) {
                    $("#ProgressBarSide").remove();
                }
            },
            success: function (xml) {
                $("#ProgressBar").css("width", (100 / compilerlist.length * setW) + "px");
                setW++;
                if (setW > compilerlist.length) {
                    $("#ProgressBarSide").remove();
                }
            }
        });
    }
}

function jumpto(inputurl) {
    if (document.getElementById && displaymode == 0)
        document.getElementById("main_right").src = inputurl
    else if (document.all && displaymode == 0)
        document.all.external.src = inputurl;
    else {
        if (!window.win2 || win2.closed)
            win2 = window.open(inputurl);
        else {
        }
    }
}

function ShowMain(FileName_Left, FileName_Right) {
    var temp;
    if (FileName_Left != "") {
        var checkLeftUrl = CheckCurrentLeftUrl(FileName_Left);
        if (checkLeftUrl == "false") {
            //增加新建项的时候隐藏左侧的iframe，不放在FrameTab.js去中去实现了，那样会刷新左侧，影响性能
            jQuery("#frmTitle > iframe").hide();
            temp = document.getElementById("left");
            temp.src = FileName_Left + GetUrlParm(FileName_Left);
            temp.contentWindow.window.name = "left";
            frames["left"] = temp.contentWindow.window;
            jQuery("#frmTitle > #left").show(); //让当前的左侧的iframe可见
        }
    }
    if (FileName_Right != "") {
        temp = document.getElementById("main_right");
        temp.src = FileName_Right + GetUrlParm(FileName_Right);
        temp.contentWindow.window.name = "main_right";
        frames["main_right"] = temp.contentWindow.window;
    }
    initSideBarState();
}

function CheckCurrentLeftUrl(leftUrl) {
    var src = document.getElementById("left").src;
    var regex = /\s*[\?&]{1,1}t=[0-9]{1,}$/;
    var currentLeftUrl = src.replace(regex, '');
    if (currentLeftUrl.lastIndexOf(leftUrl) >= 0) {
        if (currentLeftUrl.lastIndexOf(leftUrl) == (currentLeftUrl.length - leftUrl.length)) {
            return "true";
        }
    }
    return "false";
}

function GetUrlParm(url) {
    var urlparm = "?";
    if (url.indexOf('?') >= 0) {
        urlparm = "&";
    }
    urlparm = urlparm + "t=" + GetRandomNum();
    return urlparm;
}

function GetRandomNum() {
    var Range = 1000;
    var Rand = Math.random();
    return (Math.round(Rand * Range));
}

function switchSysBar() {

    var obj = document.getElementById("switchPoint");
    if (obj.alt == "关闭左栏") {
        obj.alt = "打开左栏";
        obj.src = "" + StyleSheetPath + "Images/butOpen.gif";
        document.getElementById("frmTitle").style.display = "none";
        var width, height;
        width = document.body.clientWidth - 12;
        height = document.body.clientHeight - 70;
        document.getElementById("main_right").style.height = height;
        document.getElementById("main_right").style.width = width;
        document.getElementById("FrameTabs").style.width = width;
        if (CheckFramesScroll) { CheckFramesScroll(); }
    }
    else {
        obj.alt = "关闭左栏";
        obj.src = "" + StyleSheetPath + "Images/butClose.gif";
        document.getElementById("frmTitle").style.display = "";
        onload();
    }
    createSideBarCookie();
}

var tID = "ChannelMenu_MenuMyDeskTop";

function ShowHideLayer(ID) {
    if (ID != tID) {
        var triangle = document.getElementById("MenuMyDeskTopMore_Triangle");
        if (tID != "") {
            document.getElementById(tID).style.display = "none";
            document.getElementById("A" + tID).style.backgroundImage = "url(" + StyleSheetPath + "Images/digital_left.gif)";
            if (document.getElementById("A" + tID).childNodes.length < 2) {
                document.getElementById("Span" + tID).style.backgroundImage = "url(" + StyleSheetPath + "Images/digital_side.gif)";
            } else {
                document.getElementById("Span" + tID).style.backgroundImage = "none";
                if (triangle) { triangle.style.backgroundImage = "none"; }
            }
            document.getElementById("Span" + tID).className = "digitaltext";
        }
        document.getElementById(ID).style.display = "";
        document.getElementById("A" + ID).style.backgroundImage = "url(" + StyleSheetPath + "Images/seg_left.gif)";
        if (document.getElementById("A" + ID).childNodes.length < 2) {
            document.getElementById("Span" + ID).style.backgroundImage = "url(" + StyleSheetPath + "Images/seg_side.gif)";
            if (tID != "" && document.getElementById("A" + tID).childNodes.length >= 2) {
                if (triangle) { triangle.style.backgroundImage = "url(" + StyleSheetPath + "Images/digital_side.gif)"; }
            }
        } else {
            document.getElementById("Span" + ID).style.backgroundImage = "none";
            if (triangle) { triangle.style.backgroundImage = "url(" + StyleSheetPath + "Images/seg_side.gif)"; }
        }
        document.getElementById("Span" + ID).className = "segtext";
        tID = ID;
    }
}

var message = 0, order = 0, time = 0, uncheckarticle = 0, remindItemCount = 0;
var unsigninarticle = 0, stockalarm = 0, noconsignment = 0, noconfirmcount = 0;
var mintime = 5000, addtime = 1000, maxtime = 50000;
var clock,hideclock;
function timeOut() {
    if (time >= (maxtime - mintime) / addtime)
        time = (maxtime - mintime) / addtime;
    return mintime + addtime * time;
}
function OpenLink(FileName_Left, FileName_Right) {
    if (parent.document.getElementById("left").src != FileName_Left) {
        parent.document.getElementById("left").src = FileName_Left;
    }
    var mr = parent.document.getElementById("main_right");
    mr.src = FileName_Right;
    mr.contentWindow.window.name = "main_right";
    frames["main_right"] = mr.contentWindow.window;
}
function openMessageManage()
{ OpenLink('Profile/MyMessageManageGuide.aspx', 'Profile/MyMessageManage.aspx?ManageType=0'); }
function openOrderList()
{ OpenLink('Shop/OrderGuide.aspx', 'Shop/OrderList.aspx?SearchType=4'); }
function openContentManage() {
    var cookiesName = _adminName + "_ContentManage_ShowType";
    setCookie(cookiesName, "101", null, "/");
    OpenLink('Contents/NodeTree.aspx', 'Contents/ContentManage.aspx');
}
function openCommentManage()
{ OpenLink('Contents/CommentGuide.aspx', 'Contents/CommentManage.aspx?Enquiries=true&SearchType=2'); }
function openContentSignin() {
    window.open('../User/Content/Signin.aspx');
}
function openProductManage(type)
{ OpenLink('Shop/ShopNodeTree.aspx', 'Shop/ProductManage.aspx?SearchType=SpeedSearch&Keyword=' + type.toString()); }
function openNoConsignment()
{ OpenLink('Shop/OrderGuide.aspx', 'Shop/OrderList.aspx?SearchType=7'); }
function openNoConfirm()
{ OpenLink('User/BankrollItemListGuide.aspx', 'User/BankrollItemList.aspx?Action=NoConfirm'); }
function openClientShow(id)
{ OpenLink('Crm/ClientGuide.aspx', 'Crm/ClientShow.aspx?ClientId=' + id.toString()); }
function openMyRemindItem()
{ OpenLink('Crm/RemindItemGuide.aspx', 'Crm/RemindItemManage.aspx?SearchType=7'); }
function showPop() {
    $.post(_BasePath + 'ajax.aspx?HandlerName=AdminAjaxHandler', "<?xml version='1.0' encoding='utf-8'?><root><type>showPop</type></root>", function (s) {
        var ms = $("messagecount", s).text();
        var o = $("ordercount", s).text();
        var unch = $("articlestatuscount", s).text();
        var unsignin = $("articlesignincount", s).text();
        var sa = $("productstockalarmcount", s).text();
        var noc = $("ordercountbynoconsignment", s).text();
        var commentcount = $("commentcount", s).text();
        var noconfirm = $("noconfirmcount", s).text();
        var remindItemArray = eval($("reminditemarray", s).text());
        if (remindItemArray == undefined) {
            remindItemArray = [];
        }
        if (message == ms && order == o && uncheckarticle == unch && unsigninarticle == unsignin && stockalarm == sa && noconsignment == noc && noconfirm == noconfirmcount && remindItemArray.length == remindItemCount) {
            time++; //没改变时就加1，用于增长向服务器询问间隔
        }
        else {
            if (time > 0)
                time--; //有改变时就减1，用于减少向服务器询问间隔
            message = ms;
            order = o;
            uncheckarticle = unch;
            unsigninarticle = unsignin;
            stockalarm = sa;
            noconsignment = noc;
            noconfirmcount = noconfirm;
            remindItemCount = remindItemArray.length;
            var html = "";
            var htmlArray = new Array();

            if (ms > 0) {
                htmlArray[htmlArray.length] = "<span style='cursor: pointer;' onclick='javascript:openMessageManage();'>您有 <span style='color:red'>" + ms + "</span> 条站内短消息待读</span><br/>";
            }
            if (o > 0)
                htmlArray[htmlArray.length] = "<span style='cursor: pointer;' onclick='javascript:openOrderList();'>您有 <span style='color:red'>" + o + "</span> 个订单待确认</span><br/>";
            if (noc > 0)
                htmlArray[htmlArray.length] = "<span style='cursor: pointer;' onclick='javascript:openNoConsignment();'>您有 <span style='color:red'>" + noc + "</span> 个订单待发货</span><br/>";
            if (unch > 0)
                htmlArray[htmlArray.length] = "<span style='cursor: pointer;' onclick='javascript:openContentManage();'>您有 <span style='color:red'>" + unch + "</span> 篇内容待审核</span><br/>";
            if (commentcount > 0)
                htmlArray[htmlArray.length] = "<span style='cursor: pointer;' onclick='javascript:openCommentManage();'>您有 <span style='color:red'>" + commentcount + "</span> 篇评论待审核</span><br/>";
            if (unsignin > 0)
                htmlArray[htmlArray.length] = "<span style='cursor: pointer;' onclick='javascript:openContentSignin();'>您有 <span style='color:red'>" + unsignin + "</span> 篇内容待签收</span><br/>";
            if (sa > 0)
                htmlArray[htmlArray.length] = "<span style='cursor: pointer;' onclick='javascript:openProductManage(31);'>您有 <span style='color:red'>" + sa + "</span> 个库存报警的商品需要处理</span><br/>";
            if (noconfirm > 0)
                htmlArray[htmlArray.length] = "<span style='cursor: pointer;' onclick='javascript:openNoConfirm();'>您有 <span style='color:red'>" + noconfirm + "</span> 笔汇款待确认</span><br/>";

            if (remindItemArray.length > 0) {
                for (var i in remindItemArray) {
                    if (htmlArray.length < 15) {
                        var item = remindItemArray[i];
                        if (item.ClientID > 0) {
                            htmlArray[htmlArray.length] = "<span>提醒：请及时联系客户<span style='cursor:pointer;color:red' onclick='javascript:openClientShow(" + item.ClientID.toString() + ");'>" + item.Contacter + "</span></span><br/>";
                        }
                        else {
                            htmlArray[htmlArray.length] = "<span>提醒：请及时联系客户<span style='cursor:pointer;color:red'>" + item.Contacter + "</span></span><br/>";
                        }
                    }
                    else {
                        htmlArray[htmlArray.length] = "<span>提醒：更多<span style='cursor:pointer;color:red' onclick='javascript:openMyRemindItem();'>我的预约提醒记录</span></span><br/>";
                        break;
                    }
                }
            }

            for (var i in htmlArray) {
                html += htmlArray[i];
            }

            $("#info").html(html);
            $("#iframe_ShowPop").height($("#showPop").height());
            if (ms != "0" || o != "0" || unch != "0" || unsignin != "0" || sa != "0" || noc != "0" || noconfirm != "0" || remindItemArray.length != 0)
               { 
               $("#showPop").show("slow");
               hideclock = setTimeout("HidePop()", 20000);
               }
            else $("#showPop").hide("slow");
        }
    });
}
var isShowPop = true;
function ClosePop() {
    $('#showPop').hide('slow');
    isShowPop = false;
}

function HidePop() {
    $('#showPop').hide('slow');
    clearTimeout(hideclock);
}

//弹出帮助部份
var IsHelpShowCheck = false;

function HelpTipsCheck() {
    $.post(_BasePath + 'ajax.aspx?HandlerName=AdminAjaxHandler', "<?xml version='1.0' encoding='utf-8'?><root><type>HelpShow</type></root>", function (s) {

        var HelpShow = $("HelpShow", s).text();
        if (HelpShow == "true") {
            lock("HelpTips");
            GetHelpContent();
        }
    });
}

function lock(id) {
    $("#" + id).css("left", (document.body.clientWidth - 500) / 2 + document.body.scrollLeft)
        .css("top", (document.body.clientHeight - 300) / 2 + document.body.scrollTop)
        .css("display", "block");
    $("#ly").css("display", "block")
        .css("width", document.body.clientWidth)
        .css("height", document.body.clientHeight)
        .unbind().click(function () { $("#" + id).hide(); $(this).hide(); });
    $(parent["ifly"].document).click(function () { if (document.getElementById('ly')) { jQuery('#ly').click(); } });
}

function dosomething() {
    $.post(_BasePath + 'ajax.aspx?HandlerName=AdminAjaxHandler', "<?xml version='1.0' encoding='utf-8'?><root><type>SetHelpShow</type><helpset>" + IsHelpShowCheck + "</helpset></root>");
    $("#ly").css("display", "none");
    $("#HelpTips").css("display", "none");
}

function HelpShowCheck() {
    if (IsHelpShowCheck)
    { IsHelpShowCheck = false; }
    else {
        IsHelpShowCheck = true;
    }
}

function HelpShow() {
    $.post(_BasePath + 'ajax.aspx?HandlerName=AdminAjaxHandler', "<?xml version='1.0' encoding='utf-8'?><root><type>HelpShow</type></root>", function (s) {
        var HelpShow = $("HelpShow", s).text();
        if (HelpShow == "false") {
            IsHelpShowCheck = true;
            $('input[name=HelpShowFalse]').attr('checked', true);
        }
    });
    lock("HelpTips");
    GetHelpContent();
}

function GetHelpContent() {
    $.ajax({
        url: _BasePath + _adminPath + '/Common/AjaxProxy.aspx',
        type: 'GET',
        dataType: 'xml',
        error: function (xml) {
            $.ajax({
                url: _BasePath + _adminPath + '/Common/HelpLinks.xml',
                type: 'GET',
                dataType: 'xml',
                error: function (xml) {
                    $("#HelpInfo").html("Error loading XML,检查XML文件是否存在!");
                },
                success: function (xml) {
                    var HtmlStr = "";
                    $(xml).find("Link").each(function (i) {
                        var title = $(this).children("title").text();
                        var url = $(this).children("url").text();
                        HtmlStr = HtmlStr + "<li> <a href=\"" + url + "\" target=\"_blank\">" + title + "</a></li>";
                    });
                    HtmlStr = HtmlStr + "<li><a href=\"http://tech.powereasy.net/\" target=\"_blank\">更多......</a></li>";
                    HtmlStr = "<ul style=\"line-height: 20px;\">" + HtmlStr + "</ul>";
                    $("#HelpInfo").html(HtmlStr);
                }
            });
        },
        success: function (xml) {
            var HtmlStr = "";
            $(xml).find("Link").each(function (i) {
                var title = $(this).children("title").text();
                var url = $(this).children("url").text();
                HtmlStr = HtmlStr + "<li> <a href=\"" + url + "\" target=\"_blank\">" + title + "</a></li>";
            });
            HtmlStr = HtmlStr + "<li><a href=\"http://tech.powereasy.net/\" target=\"_blank\">更多......</a></li>";
            HtmlStr = "<ul style=\"line-height: 20px;\">" + HtmlStr + "</ul>";
            $("#HelpInfo").html(HtmlStr);
        }
    });
}


function HelpQuicklyShow() {
    lock("HelpQuickly");
    GetQuicklyHelpContent();
}

/*快速上手div读取XML文件方法 卢然2009-08-26加 */
function GetQuicklyHelpContent() {
    $("#HelpQuickly").css("top", (document.body.clientHeight - 400) / 2 + document.body.scrollTop);
    $.ajax({
        url: _BasePath + 'Admin/Common/QuicklyHelpLinks.xml',
        type: 'GET',
        dataType: 'xml',
        error: function (xml) {
            $("#QuicklyInfo").html("Error loading XML,检查XML文件是否存在!");
        },
        success: function (xml) {
            var HtmlStrSell = "";
            $(xml).find("Sell").each(function (i) {
                var title = $(this).children("title").text();
                var remark = $(this).children("remark").text();
                var url = $(this).children("url").text();
                var setInfo = $(this).children("setInfo").text();
                HtmlStrSell = HtmlStrSell + "<li style=\"font-size: 14px; font-weight: bold; margin-bottom:10px;\">" +
                               title + "<br/>" +
                               "<span style=\"font-size:12px; font-weight:normal\">" + remark + "</span>" +
                               "<a href=\"" + url + "\" target=\"_blank\"  style=\"color:#FF0000; text-decoration:underline\">教程</a>" + "&nbsp;" +
                               "<a href=\"javascript:\" onclick=\"" + setInfo + "\" style=\"color:#0000FF; text-decoration:underline\">操作</a>" +
                               "</li>";
            });
            HtmlStrSell = "<span style=\"color:#0000FF; font-size: 16px; font-weight: bold; margin-bottom:10px;\">我要卖</span>" + "<ol style=\"line-height: 20px;margin-top:0;\">" + HtmlStrSell + "</ol>";

            var HtmlStrBuy = "";
            $(xml).find("Buy").each(function (i) {
                var title = $(this).children("title").text();
                var remark = $(this).children("remark").text();
                var url = $(this).children("url").text();
                HtmlStrBuy = HtmlStrBuy + "<li style=\"font-size: 14px; font-weight: bold; margin-bottom:10px;\">" +
                               title + "<br/>" +
                               "<span style=\"font-size:12px; font-weight:normal\">" + remark + "</span>" +
                               "<a href=\"" + url + "\" target=\"_blank\"  style=\"color:#FF0000; text-decoration:underline\">示范一下</a>" + "&nbsp;" +
                               "</li>";
            });
            HtmlStrBuy = "<span style=\"color:#FF0000; font-size: 16px; font-weight: bold; margin-bottom:10px;\">我要买</span>" + "<ol style=\"line-height: 20px;margin-top:0;\">" + HtmlStrBuy + "</ol>";

            var HtmlStr = HtmlStrSell + HtmlStrBuy;
            $("#QuicklyInfo").html(HtmlStr);
            HtmlTipsb = "&nbsp;<a href=\"javascript:\" onclick=\"$('#ly').click();HelpShow();\" style=\"color:#0000FF;position:absolute;right:2px;\">详细教程......</a>";
            $("#QuicklyTipsb").html(HtmlTipsb);
        }
    });
}


/*快捷导航开始*/
function ShowQuickNavigation() {
    window.isQuicknavigationShow = false;
    jQuery("#MenuMyDeskTopMore_Triangle").click(function (e) {
        e.stopPropagation();
        if (!window.isQuicknavigationShow) {
            var offset = jQuery(this).offset();
            offset.top += 20;
            var qnDiv = $("#quicknavigation").css({ top: offset.top, left: offset.left });
            if (qnDiv.length > 0) {
                qnDiv.show();
            } else {
                var template = '<div id="quicknavigation"><dl class="Content"><dt class="Border Title"><ul class="UpDown">';
                template += '<li><a title="向上滚动"  class="up" href="javascript:"  onmouseover="this.className=\'up_hover\'"  onmouseout="this.className=\'up_out\'"></a></li><li><a title="向下滚动"  class="dn" href="javascript:"  onmouseover="this.className=\'dn_hover\'"  onmouseout="this.className=\'dn_out\'"></a></li>';
                template += '</ul>快捷导航(<a class="refreshQN" href="javascript:">刷新</a>)</dt><dd class="Border List"><img src="' + _BasePath + 'Admin/Images/loading.gif" /><br/>数据加载中...</dd></dl><iframe id="qnIframe_IE6_Z-Index" width="100%" frameborder="0" height="0" style="position:absolute; top:0px; z-index:-1; border-style:none;"></iframe></div>';
                jQuery(template).appendTo("body");
                qnDiv = jQuery("#quicknavigation").css({ top: offset.top, left: offset.left })
                    .show()
					.bind("mouseleave", function (event) {
					    //if (event.target == this) {
					    jQuery(this).hide();
					    window.isQuicknavigationShow = false;
					    //jQuery("#ShowQuickNavigation").show();
					    //}
					}).find(".Title .refreshQN").click(function () {
					    GetQuickNavigation();
					});
                GetQuickNavigation(qnDiv, offset);
            }
            window.isQuicknavigationShow = true;
        } else {
            $("#quicknavigation").hide();
            window.isQuicknavigationShow = false;
        }
    });
}

function GetQuickNavigation() {
    qnDiv = jQuery("#quicknavigation");
    qnDiv.find(".List").html('<img src="' + _BasePath + 'Admin/Images/loading.gif" /><br/>数据加载中...');
    jQuery.ajax({
        url: _BasePath + _adminPath + "/Profile/QuickLinks.aspx",
        type: "GET",
        cache: false,
        success: function (data) {
            qnDiv.find(".List").html(jQuery(data).find("#Guide_box .guide").html());
            if (qnDiv.find("#Links").height() > 390) {
                qnDiv.find(".List").css("overflow", "hidden").height(390);
                qnDiv.find(".UpDown").css("display", "block");
                qnDiv.find(".up").click(function () { ScrollList(qnDiv.find("#Links")[0], null, 110); });
                qnDiv.find(".dn").click(function () { ScrollList(qnDiv.find("#Links")[0], null, -110); });
                if (jQuery.browser.mozilla) {
                    qnDiv.bind("DOMMouseScroll", function (e) {
                        ScrollList(qnDiv.find("#Links")[0], e);
                    });
                } else {
                    qnDiv.bind("mousewheel", function (e) {
                        ScrollList(qnDiv.find("#Links")[0], e);
                    });
                }
            } else { qnDiv.find(".UpDown").css("display", "none"); }
            qnDiv.find("#qnIframe_IE6_Z-Index").height(qnDiv.height());
        },
        error: function () {
            qnDiv.find(".List").html('请求出错，请' + '<a href="javascript:void(0)" onclick="GetQuickNavigation()">重试</a>.');
        }
    });
}

function ScrollList(list, event, y) {
    if (!y) {
        if (event.wheelDelta) {
            y = event.wheelDelta / 3;
        } else if (event.detail) {
            y = -event.detail * 10;
        }
    }
    var jList = jQuery(list);
    var mt = jList.css("margin-top");
    mt = Number(mt.toLowerCase().replace("px", ""));
    if ((mt < 0 && y > 0) || (mt - jList.parent().height() > -jList.height()) && y < 0) {
        mt = mt + y;
        if (mt > 0) { mt = 0; }
        if (mt - jList.parent().height() < -jList.height()) { mt = jList.parent().height() - jList.height(); }
        jList.css("margin-top", mt);
    }
}
/*快捷导航结束*/