var isIE  = (navigator.appVersion.indexOf("MSIE") != -1);
var resizeTimeout = undefined;
var resizeInProgress = false;
var topReservered=218;     //顶部预留的高度
var bodyOverflowx,bodyOverflowy;
var minheight=630;    //applet最小高度

function getHeight() {
    var clientHeight, height;
    var gap=topReservered+1;
    if (isIE) {
        clientHeight = document.body.clientHeight;
        height = clientHeight - gap;
        if (height < minheight) {
            height = minheight;
            bodyOverflowy=true;
        }
    } else {
        clientHeight = window.innerHeight;
        height = clientHeight - gap;
        if (height < minheight) {
            height = minheight;
            bodyOverflowy=true;
        }
    }
    return height;
}
function getWidth() {
    var clientWidth, width;
    var gap=1;
    var minwidth=970;     //applet最小宽度
    if (isIE) {
        clientWidth = document.body.clientWidth;
        width = clientWidth - gap;
        if (width < minwidth) {
            width = minwidth;
            bodyOverflowx=true;
        }
    } else {
        clientWidth = window.innerWidth;
        width = clientWidth - gap;
        if (width < minwidth) {
            width = minwidth;
            bodyOverflowx=true;
        }
    }
    return width;
}
function resizeComplete()
{
    clearTimeout(resizeTimeout);
    resizeInProgress = false;
}

function resetHandler() {
    if (isIE && !resizeInProgress) {
        if (resizeTimeout != undefined) {
            clearTimeout(resizeTimeout);
        }
        resizeTimeout = setTimeout("resetSize();", 500);
    } else if (!isIE) {
        resetSize();
    }
}
function resetSize() {
    var vert=document.getElementById("vert");
    if(vert!=null && vert.clientHeight>10) {
        topReservered=vert.clientHeight;
    }
    bodyOverflowx=bodyOverflowy=false;
    resizeInProgress = true;
    var myWidth = getWidth();
    var myHeight = getHeight();
    var flashControl = document.getElementById("main");
    flashControl.width = myWidth;
    flashControl.height = myHeight;
    flashControl.style.position="absolute";
    flashControl.style.width = myWidth;
    flashControl.style.height = myHeight;
    flashControl.style.left = 0;
    flashControl.style.top = topReservered;
    if (isIE) {
        if(bodyOverflowx) {
            document.body.style.overflowX="scroll";
        } else {
            document.body.style.overflowX="visible";
        }
        if(bodyOverflowy) {
            document.body.style.overflowY="scroll";
        } else {
            document.body.style.overflowY="visible";
        }
    } else {
        //firefox also works but splash
    }
    resizeComplete();
}
function resizeHook() {    
    var oldResizeHandler=window.onresize;
    if(oldResizeHandler) {
        window.onresize=function(){
            oldResizeHandler.apply(this);
            resetHandler();
        };
    } else {
        window.onresize = resetHandler;
    }
    resetHandler();
}
var tabTypes=["dde_banner","cw_banner","sv_banner"];
function setTabIndex(index) {
    if(index==2) {
        minheight=740;
    } else {
        minheight=630;
    }
    loadBanner(tabTypes[index]);
}
