//***************************************************************/
// 日期：2007-10-25 14：18
// 功能：创建蔗罩层效果
// 修改：修改日期,修改人加说明
//***************************************************************/
var bodyScrollWidth = 0;
var bodyScrollHeight = 0;
function getWidth() {
    var strWidth, clientWidth, bodyWidth;
    clientWidth = document.documentElement.clientWidth;
    bodyWidth = document.body.clientWidth;
    if (bodyWidth > clientWidth) {
        strWidth = bodyWidth + 20;
    } else {
        strWidth = clientWidth;
    }
    return strWidth;
}
function getHeight() {
    var strHeight, clientHeight, bodyHeight;
    clientHeight = document.documentElement.clientHeight;
    bodyHeight = document.body.clientHeight;
    if (bodyHeight > clientHeight) {
        strHeight = bodyHeight + 30;
    } else {
        strHeight = clientHeight;
    }
    /* 
    if(window.screen.height > strHeight)
    {
    strHeight = window.screen.height;
    }
    */
    return strHeight;
}
function reCalBodySize() {
    try {
        bodyScrollWidth = getWidth(); //document.body.scrollWidth;
        bodyScrollHeight = getHeight(); //document.body.scrollHeight;	
    }
    catch (e) {
    }

}
reCalBodySize();
if (navigator.appName.indexOf("Explorer") > -1) {//ie
    var exp = 1;
}
else {//for ff
    var exp = 2;
}
function buildGlobalDiv() {
    reCalBodySize();
    var globalDiv = document.createElement('div');
    globalDiv.id = 'globalDiv';
    globalDiv.style.display = 'none';
    globalDiv.style.zIndex = '98';
    globalDiv = set_div_style(globalDiv, 'globalDiv', '0px', '0px', bodyScrollWidth + 'px', bodyScrollHeight + 'px', "absolute", " #333333 0px solid", "default", "darkgray");
    globalDiv.onselectstart = function () { return false }
    if (1 == exp) {
        globalDiv.style.filter = "alpha(opacity=30)";
    }
    else {

        globalDiv.style.opacity = 30 / 100;
        //globalDiv.style.MozOpacity = '0.9';
    }
    document.body.appendChild(globalDiv);



}
function set_div_style(obj, id, top, left, width, height, position, border, cursor, background) {
    var obj = obj;
    obj.id = id ? id : null;
    obj.style.top = top ? top : '0px';
    obj.style.left = left ? left : '0px';
    obj.style.width = width ? width : '0px';
    obj.style.height = height ? height : '0px';
    obj.style.position = position ? position : "static";
    obj.style.border = border ? border : "1px #000 solid";
    obj.style.cursor = cursor ? cursor : "default";
    obj.style.background = background ? background : "";

    return obj
}
function synSizeByBody() {
    var argArr = synSizeByBody.arguments;
    for (var i = 0; i < argArr.length; i++) {
        if (document.getElementById(argArr[i]) != null) {

            document.getElementById(argArr[i]).style.width = (bodyScrollWidth) + 'px';
            document.getElementById(argArr[i]).style.height = (bodyScrollHeight) + 'px';
        }
    }
}
function hide() {
    buildGlobalDiv();
    synSizeByBody("globalDiv");
    document.getElementById("globalDiv").style.display = "block";
    if (1 == exp) {
        hideElementAll();
    }
}
function hideElementAll() {
    HideElement("SELECT");
    HideElement("OBJECT");
}

function showElementAll() {
    ShowElement("SELECT");
    ShowElement("OBJECT");
    ShowElement("IFRAME");
}
function HideElement(strElementTagName) {
    try {
        for (i = 0; i < window.document.all.tags(strElementTagName).length; i++) {
            var objTemp = window.document.all.tags(strElementTagName)[i];
            objTemp.style.visibility = "hidden";
        }
    } catch (e) {
        alert(e.message);
    }
}

function ShowElement(strElementTagName) {
    try {
        for (i = 0; i < window.document.all.tags(strElementTagName).length; i++) {
            var objTemp = window.document.all.tags(strElementTagName)[i];
            objTemp.style.visibility = "visible";
        }
    } catch (e) {
        alert(e.message);
    }
}

function GetCenterXY_ForLayer(objdiv) {
    //修改：涂才龙 2010.01.08  MSN:tcl-long@hotmail.com
    //使消息框兼容 IE6.7.8 firefox 浏览器 并使之总是在屏幕中上部位出现
    var scrollPos;
    if (typeof window.pageYOffset != 'undefined') {
        scrollPos = window.pageYOffset;
    }
    else if (typeof document.compatMode != 'undefined' &&
                document.compatMode != 'BackCompat') {
        scrollPos = document.documentElement.scrollTop;
    }
    else if (typeof document.body != 'undefined') {
        scrollPos = document.body.scrollTop;
    }

    var bodyScrollWidth = 0;
    var bodyScrollHeight = 0;

    objdiv.style.display = '';
    var styleWidth = objdiv.style.width.substring(0, objdiv.style.width.length - 2);
    var clientHeight = objdiv.firstChild.clientHeight;
    var objLeft = parseInt(document.body.scrollLeft + (document.body.clientWidth - styleWidth) / 2) + 'px';
    //	var relTop=(document.body.clientHeight-clientHeight)/2 > 0 ? (document.body.clientHeight-clientHeight)/2:0;
    //	var objTop = (parseInt(document.body.scrollTop+relTop))+'px';
    //	objdiv.style.top = objTop;
    objdiv.style.top = (scrollPos + 180) + 'px';
    objdiv.style.left = objLeft;
    checkAndResetStyleTop(objdiv);
}
function checkAndResetStyleTop(obj) {
    var clientHeight = obj.firstChild.clientHeight;
    var styleTop = parseInt(obj.style.top.substring(0, obj.style.top.length - 2));
    if (clientHeight + styleTop > bodyScrollHeight) {
        obj.style.top = (parseInt(bodyScrollHeight) - parseInt(clientHeight) - 100) + 'px';

    }
}


function cancel() {
    document.getElementById("globalDiv").style.display = "none";
    if (1 == exp) {
        showElementAll();
    }
}
