// -------------------------------------------------
//
// Cross-browser script to center a <DIV> container 
// element called 'maindiv' in the browser window.
// Also handles the Netscape resize bug to ensure 
// that the content remains centered when the 
// browser window has been resized.
//
// -------------------------------------------------

//browser detection
var isNS4 = false;
var isNS6 = false;
var isIE = false;

if (document.layers) isNS4 = true// netscape 4
else if ((document.getElementById) && (!document.all)) isNS6 = true// netscape 6+
else isIE = true // ie4+


//function to place content at top-center of browser 
function placeContent (xWidth) {
 //find available browser dimensions
 if (isIE) {
intWinWidth = document.body.clientWidth;
 intWinHeight = document.body.clientHeight;
 } else {
 intWinWidth = window.innerWidth;
intWinHeight = window.innerHeight;
 }
 
 //find left browser co-ordinates for content
 intLeft = Math.round((intWinWidth/2) - (xWidth/2));
 
 //move content to top-center of browser
 if (isIE) {
document.all.maindiv.style.pixelLeft = intLeft;
 document.all.maindiv.style.pixelTop = 0;
 document.all.maindiv.style.visibility = "visible";
 } else if (isNS6) {
 document.getElementById("maindiv").style.left = intLeft + "px";
document.getElementById("maindiv").style.top = 0 + "px";
 document.getElementById("maindiv").style.visibility = "visible";
 } else {
 document.maindiv.moveTo(intLeft,0);
document.maindiv.visibility = "visible";
 }
}



//function to render screen properly when browser window has been resized
function handleResize(x) {
if (isNS4) location.reload()
else placeContent(x,0)
}