var isIE6 = false;
var isIE7 = false;
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { //test for MSIE x.x;
    var ieversion = new Number(RegExp.$1) // capture x.x portion and store as a number
    if (ieversion <= 6) {
        var isIE6 = true;
    }
    if (ieversion > 6) {
        var isIE7 = true;
    }
}
function returnObjById(id) {
    var returnVar = null;
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}


function number_check(value) {
    return (1 - (value % 2))
}
function fixCentreDiv() {
    var getWinWidth = alertSize("width");
    var getWinHeight = alertSize("height");
    var getOutput = returnObjById("output")
    var baseDiv = returnObjById("baseDiv")
    var centerDiv = returnObjById("centerDiv")
    var getBody = returnObjById("body")
    var getFooterWrapper = returnObjById("footerWrapper")
    var minWidth = 930; //1035
    //set init values
    centerDiv.style.width = "2402px";
    centerDiv.style.backgroundPosition = "0 0";
    centerDiv.style.position = "absolute";
    baseDiv.style.backgroundPosition = "0 0";
    baseDiv.style.position = "absolute";
    baseDiv.style.top = "0px";
    //baseDiv.style.left = "0px"; //"685px";
    baseDiv.style.margin = "0px";
    baseDiv.style.width = "1032px";
    var newLeft = Math.round((getWinWidth / 2) - (centerDiv.offsetWidth / 2))
    centerDiv.style.height = getWinHeight + "px";
    var clipSize = getWinWidth + Math.abs(newLeft) + "px";
    var newLeft2 = Math.round((getWinWidth / 2) - (baseDiv.offsetWidth / 2))
    var modWidth = minWidth; //-95;
    if (getWinWidth > modWidth) {
        //centre the centre div
        centerDiv.style.left = newLeft + 2 + "px";
        if (!isIE6) {
            baseDiv.style.left = newLeft2 - newLeft + "px";
        } else {
            //ie6only
            baseDiv.style.left = parseInt(newLeft2 - newLeft + 39) + "px";
        }
    } else {
        centerDiv.style.left = "-730px";
        baseDiv.style.left = "685px";
    }
    //set min width to activate scrollbars, otherwise hide them
    if (getWinWidth < minWidth) {
        getBody.style.overflow = "auto";
        centerDiv.style.width = Math.abs(newLeft) + minWidth + "px";
    } else {
        getBody.style.overflow = "hidden";
        //centerDiv.style.width = clipSize;
    }
    getFooterWrapper.style.height = "100px";
    if (getWinHeight < baseDiv.offsetHeight) {
        getBody.style.overflow = "auto";
        centerDiv.style.height = baseDiv.offsetHeight + "px";
    } else {
        if (getWinWidth < minWidth) {
            getBody.style.overflow = "auto";
        } else {
            getBody.style.overflow = "hidden";
        }
        centerDiv.style.height = getWinHeight + "px";
        var footDiff = getWinHeight - baseDiv.offsetHeight;
        var getFootHeight = getFooterWrapper.offsetHeight;
        getFooterWrapper.style.height = getFootHeight + footDiff + "px";
    }
    /*getOutput.innerHTML = "windwidth: " + getWinWidth + "<br>";	getOutput.innerHTML += "centerwidth: " + centerDiv.offsetWidth + "<br>";	getOutput.innerHTML += "newLeft: " + newLeft +"<br>";	getOutput.innerHTML += "newLeft2: " + newLeft2 +"<br>";	getOutput.innerHTML += "overflow: " + getBody.style.overflow +"<br>";*/
    fixLeaderBoard()
}


function fixLeaderBoard() {
    var leaderBoard = returnObjById("wbcLD_Leaderboard")
    var skyScraper = returnObjById("wbcSK_Skyscraper")

    if (leaderBoard != null || skyScraper != null) {
    
	    var ldBOT = leaderBoard.offsetTop + leaderBoard.offsetHeight;
	    var skBOT = skyScraper.offsetTop + skyScraper.offsetHeight;
	    //alert("leaderBoard.offsetTop: " + leaderBoard.offsetTop + " leaderBoard.offsetHeight: " + leaderBoard.offsetHeight + "skyScraper.offsetTop: " + skyScraper.offsetTop + " skyScraper.offsetHeight: " + skyScraper.offsetHeight +" ldBOT: " + ldBOT + " skBOT:" + skBOT);
	    //alert("ldBOT: " + ldBOT + " skBOT:" + skBOT);
	    if (ldBOT < skBOT) {
	        var ldTopPos = leaderBoard.offsetTop; //getStyle("leaderBoard","offsetTop")
	        //ldTopPos = ldTopPos.substring(0,ldTopPos.length-2);
	        //alert("ltop: " + ldTopPos);
	        var diff = skBOT - ldBOT + 30//;+parseInt(ldTopPos);
	        //var curMgTop = getStyle("leaderBoard","margin-top") //leaderBoard.style.marginTop;
	        //leaderBoard.marginTop = curMgTop + diff ;//+ "px";
	        leaderBoard.style.top = diff + "px";
	    }
	    //alert("ldBOT: " +ldBOT + " skBOT: " +skBOT + " Top: " + leaderBoard.style.top + " diff: " + diff);
	    //var ldBOT = leaderBoard.offsetTop + leaderBoard.offsetHeight;
	    //alert("ldBOT: " + ldBOT);
	}}function getStyle(el,styleProp){	var x = document.getElementById(el);	if (x.currentStyle)		var y = x.currentStyle[styleProp];	else if (window.getComputedStyle)		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);	return y;}function alertSize(retType) {  var myWidth = 0, myHeight = 0;  if( typeof( window.innerWidth ) == 'number' ) {    //Non-IE    myWidth = window.innerWidth;    myHeight = window.innerHeight;  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {    //IE 6+ in 'standards compliant mode'    myWidth = document.documentElement.clientWidth;    myHeight = document.documentElement.clientHeight;  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {    //IE 4 compatible    myWidth = document.body.clientWidth;    myHeight = document.body.clientHeight;  }  //window.alert( 'Width = ' + myWidth );  //window.alert( 'Height = ' + myHeight );  if(retType=="width"){	return myWidth;	} else if(retType=="height"){	return myHeight;	}}function moveCentreBack(){	var centerDiv = returnObjById("centerDiv")	//var getBack	//set init values	//centerDiv.style.width = "2402px";	//centerDiv.style.backgroundPosition = "0 0"; 	var baseDiv = returnObjById("baseDiv")	var centerDiv = returnObjById("centerDiv")		//baseDiv.style.backgroundPosition = "0 0"; 	//baseDiv.style.position = "absolute"; 	//baseDiv.style.top = "0px";		//ie7 fix	//baseDiv.style.left = "1px"; //"685px";	//ie6 fix	if(isIE6){		baseDiv.style.left = "1px"; //"39px"; 	}	if(isIE7){		baseDiv.style.left = "1px"; 	}	//baseDiv.style.margin = "4px";	//baseDiv.style.width = "1032px";				}function runALL(){		moveCentreBack();	if(!returnObjById("HOME")){		//subpage		fixLeaderBoard();	} else {		//homepage		//loadFlashFile();	}}window.onload = runALL;//window.onresize = fixCentreDiv;