var showad = true;
var Toppx = 60;//上端位置
var winWidth; //窗口宽度
var PageWidth;//由SessionMgr输出，在此声明防止已生成静态页报错
//var MinScreenW = 0; //显示广告的最小屏幕宽度象素 
function scall() {
    //获取窗口宽度
    if (window.innerWidth) {
        winWidth = window.innerWidth;
    }
    else if ((document.body) && (document.body.clientWidth)) {
        winWidth = document.body.clientWidth;
    }
    /*nasty hack to deal with doctype swith in IE*/
    //通过深入Document内部对body进行检测，获取窗口大小
    if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
        winHeight = document.documentElement.clientHeight;
        winWidth = document.documentElement.clientWidth;
    }
    if (winWidth < AdDivW * 2) {
        document.getElementById("Javascript.LeftDiv").style.display = "none";
        document.getElementById("Javascript.RightDiv").style.display = "none";
        return;
    }
    if (!showad) { return; }
    if (winWidth > PageWidth + 2 * AdDivW) {
        Borderpx = ((winWidth - PageWidth) / 2 - AdDivW) / 2;
    }
    else {
        Borderpx = 0
    }
    if (l == "top" || r == "top") {
        document.getElementById("Javascript.LeftDiv").style.display = "";
        document.getElementById("Javascript.LeftDiv").style.top = document.body.scrollTop + Toppx;
        document.getElementById("Javascript.LeftDiv").style.left = document.body.scrollLeft + Borderpx;
        document.getElementById("Javascript.RightDiv").style.display = "";
        document.getElementById("Javascript.RightDiv").style.top = document.body.scrollTop + Toppx;
        document.getElementById("Javascript.RightDiv").style.left = document.body.scrollLeft + document.body.clientWidth - document.getElementById("Javascript.RightDiv").offsetWidth - Borderpx;
    }
    else {
        document.getElementById("Javascript.LeftDiv").style.display = "";
        document.getElementById("Javascript.LeftDiv").style.top = document.body.scrollTop + (document.documentElement.offsetHeight - AdDivH - Toppx);
        document.getElementById("Javascript.LeftDiv").style.left = document.body.scrollLeft + Borderpx;
        document.getElementById("Javascript.RightDiv").style.display = "";
        document.getElementById("Javascript.RightDiv").style.top = document.body.scrollTop + (document.documentElement.offsetHeight - AdDivH - Toppx);
        document.getElementById("Javascript.RightDiv").style.left = document.body.scrollLeft + document.body.clientWidth - document.getElementById("Javascript.RightDiv").offsetWidth - Borderpx;
    }
}

function hidead() {
    showad = false;
    document.getElementById("Javascript.LeftDiv").style.display = "none";
    document.getElementById("Javascript.RightDiv").style.display = "none";
}
