var isCSS, isW3C, isIE4, isNN4, isIE6CSS;

if (document.images){

	isCSS = (document.body && document.body.style) ? 1 : 0;
	isW3c = (isCSS && document.getElementByID) ? 1 : 0;
	isIE4 = (isCSS && document.all) ? 1 : 0;
	isNN4 = (document.layers) ? 1 : 0;
	isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? 1: 0;
	
}


function getWindowWidth(){

	if (window.innerWidth){
		return window.innerWidth;
	} else if (isIE6CSS){
		return document.body.parentElement.clientWidth;
	} else if (document.body && document.body.clientWidth){
		return document.body.clientWidth;
	}
	
} 

function getWindowHeight(){

	if (window.innerHeight){
		return window.innerHeight;
	} else if (isIE6CSS){
		return document.body.parentElement.clientHeight;
	} else if (document.body && document.body.clientHeight){
		return document.body.clientHeight;
	}
	
} 

function setMainDiv(w,h,divID){


	var leftPosition = (getWindowWidth() - w)/2;
	var topPosition = (getWindowHeight() - h)/2;
	
	
	if (isNN4){
	
		document.layers['mainDiv'].moveTo(leftPosition,topPosition);
		document.layers['mainDiv'].visibility = 'show';
		
	} else if (document.all){
	
		document.all[divID].style.pixelTop = topPosition;
		document.all[divID].style.pixelLeft = leftPosition;
		document.all[divID].style.visibility = 'visible';

	}
	
	else {
	
		document.getElementById(divID).style.top = topPosition + "px";
		document.getElementById(divID).style.left = leftPosition + "px";
		document.getElementById(divID).style.visibility = 'visible';

	}
	

}

function reload(w,h,divID){

	if (document.layers){
	
		location.reload();
	
	} else {
	
		setMainDiv(w,h,divID);
	
	}
	
}

// This is a simple mouseover function which allows for an image swap
function switchImg(imgName, state)
{	
	if (document.images){
		var imageSwitch
		imageSwitch = imgName + "_" + state;
		document.images[imgName].src = eval(imageSwitch + ".src");
	}

}

// pass along the path where you can find the graphic, the width of the 
// image/popup, the height of the image/popup, and whether or not is scrolls
// with the "s" variable.
function popUpWin(page, h, w){
    
    leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    topPosition = (screen.height) ? (screen.height-h)/2 : 0;
    
    var win = null;
 
    win = window.open(page, "popUpWin","width="+w+",height="+h+",top="+topPosition+",left="+leftPosition+",resizable=1,scrollbars=0,toolbar=0,location=0,menubar=0,status=0");

    if (win && win.open){
    
    win.resizeTo(h,w);
    win.location.href = page;
    
    }
    
}