var tID;
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight)=='number') {
		windowHeight = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function fillWindow() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var pageElement = document.getElementById('page');
			var pageHeight = pageElement.offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight = footerElement.offsetHeight;
			if (windowHeight > pageHeight) {
				pageElement.style.height = (windowHeight-footerHeight-1)+'px';
			} else {
				pageElement.style.height = "";
			}
		}
	}
}
window.onload = function() {
	fillWindow();
	if( readCookie("font") != null )
	{
		setFont(readCookie("font") );
	}
	if (document.getElementById) {
		var nav = document.getElementById("navBar");
		var cs = null;
		for (var i=0; i<nav.childNodes.length; i++) {
			node = nav.childNodes[i];
		
			if( node.className == "current" ){ cs = node; }

			if (node.nodeName == "LI") {
				node.onmouseover = function() {
					hideDropDowns();
					if( this.className ){
							if( this.className == "current" ){
								currentTarget = this;
								cID = setTimeout("currentTarget.className = 'over'", 190);
							}
					} else {
							currentTarget = this;
							cID = setTimeout("currentTarget.className = 'over'", 190);
					}
					clearTimeout(tID);
					with (this.parentNode) {
						for (var d=0; d<childNodes.length; d++) {
							if (childNodes[d].nodeName=="LI" && childNodes[d] != this) {
								childNodes[d].className = childNodes[d].className == "current" ? "current" : "";
							}
						}
					}
				}
	  			node.onmouseout = function() {
					showDropDowns()
					clearTimeout(cID);
					target = this;
	  				tID = setTimeout("target.className = target.className == 'current' ? 'current' : ''",800);
					if( cs != null ){ cs.className = "current"; }
				}
			}
		}
	}
}

function hideDropDowns()
{
	for( i=0; i<document.forms.length; i++ )
	{
		for(j=0; j<document.forms[i].elements.length; j++ )
		{
			if( document.forms[i].elements[j].type == "select-one" )
			{
				document.forms[i].elements[j].style.visibility = "hidden";
			}
		}
	}
}

function showDropDowns()
{
	for( i=0; i<document.forms.length; i++ )
	{
		for(j=0; j<document.forms[i].elements.length; j++ )
		{
			if( document.forms[i].elements[j].type == "select-one" )
			{
				document.forms[i].elements[j].style.visibility = "visible";
			}
		}
	}
}

function expandMenu(menuID){
	subMenu = document.getElementById(menuID);
	if( subMenu != null ){
		(subMenu.style.display == "block" ) ? subMenu.style.display = "none" : subMenu.style.display = "block";
	}
}

function showPrev(slideNext, slidePrev)
{
	hide = document.getElementById(slidePrev);
	show = document.getElementById(slideNext);

	hide.style.display = "none";
	show.style.display = "block";
}

function showNext(slideNext, slidePrev)
{
	hide = document.getElementById(slidePrev);
	show = document.getElementById(slideNext);

	hide.style.display = "none";
	show.style.display = "block";
}


function browserCheck(){
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent.toLowerCase()
	this.dom=document.getElementById?1:0
	this.op5=this.agent.indexOf("opera 5")>-1 && window.opera 
	this.op6=this.agent.indexOf("opera 6")>-1 && window.opera 
	this.ie5 = (this.agent.indexOf("msie 5")>-1 && !this.op5 && !this.op6)
	this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
	this.ie6 = (this.agent.indexOf("msie 6")>-1 && !this.op5 && !this.op6)
	this.ie4=(this.agent.indexOf("msie")>-1 && document.all &&!this.op5 &&!this.op6 &&!this.ie5&&!this.ie6)
	this.ie = (this.ie4 || this.ie5 || this.ie6)
	this.mac=(this.agent.indexOf("mac")>-1)
	this.ns6=(this.agent.indexOf("gecko")>-1 || window.sidebar)
	this.ns4=(!this.dom && document.layers)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6)
	this.usedom= this.ns6//Use dom creation
	return this
}

var browserVersion = new browserCheck();

window.onresize = fillWindow;

function contactForm(theForm){
	if( theForm.questioncomment.value == "" ){
		alert( "Please fill out the comments field" );
		return false;
	} 
	return true;
}

function setFont(size)
{
	bodyObj = document.getElementsByTagName("body").item(0);
	
	switch( size )
	{
		case "1":
			bodyObj.style.fontSize = ".75em";
			createCookie( "font", "1", 365);
			break;
		case "2":
			bodyObj.style.fontSize = ".8em";
			createCookie( "font", "2", 365);
			break;

		case "3":
			bodyObj.style.fontSize = ".85em";
			createCookie( "font", "3", 365);
			break;
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function findPos(obj) {
	        var curleft = curtop = 0;
	        if (obj.offsetParent) {
		        curleft = obj.offsetLeft
		        curtop = obj.offsetTop
		        while (obj = obj.offsetParent) {
			        curleft += obj.offsetLeft
			        curtop += obj.offsetTop
		        }
	        }
	        return [curleft,curtop];
        }

