﻿function $(id) { var obj = document.getElementById(id); if (obj == "undifined") obj = null; return obj; }
String.prototype.Trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); }
var __IsIE = (navigator.userAgent.indexOf(' MSIE ') > -1 ? true : false);
function $intval$(v) { v = parseInt(v); return isNaN(v) ? 0 : v; }
function $Enter$(event, objId) {
    var keycode;
    if (window.event)
        keycode = event.keyCode;
    else
        keycode = event.which;
    if (keycode == 13 || keycode == 108) {
        var obj = $(objId);
        if (obj) {
            obj.focus();
        }
        return false;
    }
    return true;
}
function getPageScroll() {
    var yScroll, xScroll, winW;
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
        xScroll = self.pageXOffset;
        winW = self.innerWidth;
    } else if (document.documentElement && document.documentElement.scrollTop) {
        yScroll = document.documentElement.scrollTop;
        xScroll = document.documentElement.scrollLeft;
        winW = document.documentElement.clientWidth;
    } else if (document.body) {
        yScroll = document.body.scrollTop;
        xScroll = document.body.scrollLeft;
        winW = document.body.clientWidth;
    }
    //arrayPageScroll = new Array(xScroll, yScroll, winW)
    return new Array(xScroll, yScroll, winW); //arrayPageScroll;
}
function getPageSize() {
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) {
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else {
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) {
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) {
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    if (yScroll < windowHeight) pageHeight = windowHeight;
    else pageHeight = yScroll;
    if (xScroll < windowWidth) pageWidth = windowWidth;
    else pageWidth = xScroll;
    return new Array(pageWidth, pageHeight, windowWidth, windowHeight);
}
function addBookMark(url, name) {
    if (document.all) {
        window.external.addFavorite(url, name);
    } else if (window.sidebar) {
        window.sidebar.addPanel(name, url, "");
    } else {
        alert("你的浏览器不支持此事件！");
    }
}
function setHomepage(url) {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage(url);
    } else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            } catch (e) {
                alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true");
            }
        } else {
            alert("你的浏览器不支持此事件！");
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', url);
    } else {
        alert("你的浏览器不支持此事件！");
    }
}
function $ShowLayout$(objId) {
    _Center($(objId));
    $ShowBG$(true);
}
function $CloseLayout$(objId) {
    $ShowBG$(false);
    $(objId).style.display = "none";
}
/*消息框*/
document.write("<div id='$MsgBox$' style='position:absolute;top:0px;left:0px;display:none;z-index:100;background-color:#ccc;'><div class='piclock_title'><div class='piclock_title_l' id='$Title$'>错误！</div><div class='piclock_title_r'><a href='javascript:void(0)' onclick='EndMsgBox()'>关闭</a></div></div><div class='piclock'><div class='' id='$Message$'></div><a id='$OnClick$' href='javascript:void(0)' onclick='EndMsgBox()'>确认</a></dd></div></div>");
var MsgBoxObj = $('$MsgBox$');
function ShowMsgBox(title, message, width, callBack) {
    if (width) MsgBoxObj.style["width"] = width + "px"; else MsgBoxObj.style["width"] = "200px";
    $('$Message$').innerHTML = message;
    if (title) $('$Title$').innerHTML = title;
    if (callBack) $("$OnClick$").onclick = callBack;
    _Center(MsgBoxObj);
    $ShowBG$(true);
}
function EndMsgBox() {
    $ShowBG$(false);
    MsgBoxObj.style["display"] = "None";
}
function _Center(objDiv) {
    objDiv.style["position"] = "absolute";
    objDiv.style["z-index"] = "1000";
    objDiv.style["display"] = "block";
    var pScroll = getPageScroll();
    var pSize = getPageSize();
    objDiv.style["left"] = ((pScroll[0] + (pSize[2] - MsgBoxObj.offsetWidth) / 2)) + "px";
    objDiv.style["top"] = ((pScroll[1] + (pSize[3] - MsgBoxObj.offsetHeight) / 2)) + "px";
}
function $ShowBG$(visible) {
    var obj = $("$BackgroundDiv$");
    var oIfrm = $("$BackgroundDivShim$");
    if (obj == null) {
        var oDiv;
        try { oDiv = document.createElement("<div>") } catch (e) { oDiv = document.createElement("div") }
        oDiv.id = "$BackgroundDiv$";
        document.body.appendChild(oDiv);
        obj = $("$BackgroundDiv$");
        obj.style["backgroundColor"] = "#333";
        obj.style["opacity"] = "0.5";
        obj.style["filter"] = "alpha(opacity=80)";
        obj.style["-moz-opacity"] = "0.80";
        if (__IsIE) {
            obj.innerHTML = "<iframe id='$BackgroundDivShim$' scrolling='no' frameborder='0' style='position:absolute; top:0px; left:0px; display:none;filter=progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0);'></iframe>";
            oIfrm = $("$BackgroundDivShim$");
        }
    }
    obj.style["z-index"] = "500";
    obj.style["width"] = "100%";
    obj.style["position"] = "absolute";
    obj.style["left"] = "0px";
    obj.style["top"] = "0px";
    obj.style["height"] = getPageSize()[1] + "px";
    obj.style["display"] = visible ? "block" : "none";
    if (__IsIE) {
        oIfrm.style["z-index"] = "300";
        oIfrm.style["width"] = "100%";
        oIfrm.style["height"] = obj.offsetHeight;
        oIfrm.style["display"] = visible ? "block" : "none";
    }
}
function $NoComplete$() { var flag = false; if (document.readyState) { if (document.readyState != "complete") flag = true; } return flag; }
