//stretches the page to the bottom of the browser
function fillPage() {
	//get height of display area of browser window (i.e. non-toolbar, etc. area; supported by higher browsers --> lower browsers return "0")
	var winHeight = document.documentElement.clientHeight;
	if(document.getElementById && document.getElementsByTagName) {
		//gets height of web page itself (area btw body tags; this area may be smaller or larger than winHeight)
		var bodyHeight = document.getElementsByTagName("body")[0].clientHeight
		//gets height of content area
		var contentHeight = document.getElementById("content").offsetHeight;
		//only apply correction if page isn't already filling browser window
		if(bodyHeight < winHeight) {
			//gets the height difference to be added to the content div (minus 1/15, as otherwise scrollbars appear)
			var newHeight = contentHeight + (winHeight-bodyHeight);
			newHeight = newHeight - newHeight/15;
			//adds difference calc'd above to the content div
			// minHeight used to ensure div can expand when other js fn's change size of elements w/in content div
			document.getElementById("content").style.minHeight = newHeight + "px";
			//checks for IE 6 - adds style as height (vs. minHeight) if found
			// navigator.appVersion for IE 4,5,6 = 4
			if(navigator.appName == "Microsoft Internet Explorer" && parseFloat(navigator.appVersion) < 5) {
				document.getElementById("content").style.height = newHeight + "px";
			}
		}
	}	
}

//centres page vertically based on window height - js must be after <body> tag + body tag must have id (here, it's 'body')
function centrePageVert() {
	//get height of window (supported by higher browsers --> lower browsers return "0")
	var winHeight = document.documentElement.clientHeight;
	//pageBG is div w/ all content except Header. 80px is height of header
	var contentHeight = document.getElementById('pageBG').clientHeight + 80;
	if(winHeight > contentHeight) {
		//gets a little less than 1/2 the difference btw window height and page height to top (looks better w/o full 1/2 added
		var addTop = Math.floor((winHeight-contentHeight)/2.8);
		//adds difference calc'd above to top body margin (checks if getElementById supported 1st to avoid errors)
		if(document.getElementById){
			document.getElementById('body').style.marginTop = addTop + "px";
		}
	}	
}

/*inserts Flash onto the page (used to avoid IE "Click to activate..." nag	
ran = total # of random #'s to choose from (0 = always)
flaFile = path to swf
w = swf width
h = swf height
fv = flashVars
div = div containing swf
killTime = time to keep fla onscreen (0 = permanent) */
function insertFla(ran, flaFile, w, h, fv, div, killTime) {
	//randomly adds fla
	//setTimeout used to delay this slightly to let FlashVars load
	if(Math.floor(Math.random()*ran) == 0) { window.setTimeout('addFla("' + flaFile + '",' + w + ',' + h + ',"' + fv + '","' + div + '",' + killTime +')',1); }
	//addFla(flaFile, w, h, fv, div, killTime
}

//uses swfobject (downloaded online)
function addFla(flaFile, w, h, fv, div, killTime) {
	var so1 = new SWFObject(flaFile, "swfHeader", w, h, "7", "#FFFFFF");
	so1.addParam("movie", flaFile); 
	so1.addParam("wmode", "transparent");
	so1.addParam("FlashVars", fv);  
	so1.write(div);
	window.setTimeout("killFla('" + div + "'," + killTime + ")",killTime);	
}

//added so user can still click on header after killTime seconds in FF
function killFla(div, killTime) {
	if(killTime > 0) {
		document.getElementById(div).innerHTML = "";
	}
}
