// JavaScript Document
//BUILT-IN MM functionality for preloading images
//Images are passed as arguments to this function in
//the onLoad statement from within the body tag


var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
var strCode;
var strSUP, strUL, strLI

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


//BUILT-IN MM functionality for restoring moused over images
//Used to swap images back to their original state
//after mouse rollover
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

//BUILT-IN MM functionality for finding objects within a document
//This function is primarily used by the other MM built in functions
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

//BUILT-IN MM functionality for preloading images
//Used to swap images back to their original state
//after mouse rollover
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}






////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
///
///      NAME: getBottomCoords()
///
///   PURPOSE: Auto adjust the bottom of all pages to fit the
///            exact size of the content window, whatever height
///            that might be.
///
/// ARGUMENTS: n/a
///
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
function getBottomCoords(intNum)
{
	var intAdjust_1, intAdjust_2
	
	intAdjust_1 = -55;
	intAdjust_2 = -88;
	
	//declare are variables
	var content_top, content_height, left_height, right_height, divider_top, bottomnav_top, content_total
	
	//grab the top offset and the height of the content div
	content_top = document.getElementById('main_content_div').offsetTop;
	
	if(browser == "Internet Explorer")
	{
		content_height = document.getElementById('main_content_div').offsetHeight;
	}
	else
	{
		content_height = document.getElementById('detection').offsetTop;		
	}

	
	//grab the height of Left and Right side nav bars
	left_height = document.getElementById('leftnav_content_div').offsetHeight;

	if(intNum == 1)
	{
		right_height = document.getElementById('right_nav_box').offsetHeight;
	}

	//grab the top offset of the line divider and the bottomnav
	//divider_top = document.getElementById('base_divider_line').offsetTop
	bottomnav_top = document.getElementById('bottomnav').offsetTop;
	
	//grab the height of the white background mask
	bg_mask_height = document.getElementById('white_bg_mask').offsetHeight;
	
	//get the total height of content window, including the top space
	content_total = content_top + content_height;
	
	//figure out the differnece in height from content to side navs
	left_diff = content_total - left_height;
	
	right_diff = content_total - right_height;
	

	if(content_height > 300)
	{
		document.getElementById('leftnav_content_div').style.height = (left_height + left_diff+intAdjust_1+300);
		if(intNum == 1)
		{
			document.getElementById('right_nav_box').style.height = (right_height + left_diff+intAdjust_2);
		}
		//alert(bottomnav_top);
		//alert(left_diff);
		document.getElementById('bottomnav').style.top = (bottomnav_top + left_diff+intAdjust_1);

		//alert(document.getElementById('bottomnav').style.top);
		document.getElementById('white_bg_mask').style.height = (bg_mask_height + left_diff+intAdjust_1);
		
	}
	else
	{
		heightCheck(300);
	}
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
///
///      NAME: widthCheck()
///
///   PURPOSE: 
///
/// ARGUMENTS: n/a
///
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
function widthCheck(intNum)
{
	var screenW = 640, screenH = 480, num = 21; num2 =301;
	if (parseInt(navigator.appVersion)>3)
	{
		screenW = screen.width;
		screenH = screen.height;

	}
	else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)==3 && navigator.javaEnabled()) 
	{
		 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
		 var jScreenSize = jToolkit.getScreenSize();
		 screenW = jScreenSize.width;
		 screenH = jScreenSize.height;
	}
	centerScreen()
	 //document.getElementById('topnav').style.width = screenW-num;
  	 //document.getElementById('header_banner').style.width = screenW-num;
}

function widthCheckHome(intNum)
{
	var screenW = 640, screenH = 480, num = 21; num2 =301;
	if (parseInt(navigator.appVersion)>3)
	{
		 screenW = screen.width;
		 screenH = screen.height;
	}
	else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)==3 && navigator.javaEnabled()) 
	{
		 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
		 var jScreenSize = jToolkit.getScreenSize();
		 screenW = jScreenSize.width;
		 screenH = jScreenSize.height;
	}
	centerScreen()
	 //document.getElementById('topnav').style.width = screenW-num;
  	 //document.getElementById('top_banner').style.width = screenW-num;
   	 //document.getElementById('body_content').style.width = screenW-num;
   	 //document.getElementById('body_bottom').style.width = screenW-num;

	//heightCheck(intNum);
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
///
///      NAME: heightCheck()
///
///   PURPOSE: 
///
/// ARGUMENTS: n/a
///
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
function heightCheck(intNum)
{
	var screenW = 640, screenH = 480, num = intNum;
	if (parseInt(navigator.appVersion)>3)
	{
		 screenW = screen.width;
		 screenH = screen.height;
	}
	else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)==3 && navigator.javaEnabled()) 
	{
		 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
		 var jScreenSize = jToolkit.getScreenSize();
		 screenW = jScreenSize.width;
		 screenH = jScreenSize.height;
	}
    document.getElementById('leftnav_content_div').style.height = screenH-num;
}




function formCheck()
{
	var intCount = document.forms[0].length;
	var i = 0;
	
	while(i != intCount)
	{
		if(document.forms[0].elements[i].value == "")
		{
				var strName = document.forms[0].elements[i].name;
				
				if(strName.indexOf("*") != -1)
				{
					var iLength = strName.length;
					strName = strName.substring(1, iLength);
					strName = strName.replace("_", " ");
					
					var obj = window.parent.document.getElementById("error_message");
	
						obj.innerHTML = '<span class="error">Please fill in the ' + strName + ' field.</span>';
						
						document.forms[0].elements[document.forms[0].elements[i].name].focus();
						break;
				}
				i = i+1;
		}
		else
		{
			i = i+1;
		}
		
	}
}

function centerScreen()
{
	var screenW = 640, screenH = 480, num = 21; num2 =653;
	if (parseInt(navigator.appVersion)>3)
	{
		screenW = document.documentElement.clientWidth;
		screenH = document.documentElement.clientHeight;
	}
	else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)==3 && navigator.javaEnabled()) 
	{
		 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
		 var jScreenSize = jToolkit.getScreenSize();
		 screenW = jScreenSize.width;
		 screenH = jScreenSize.height;
	}

	 document.getElementById('body_container').style.left = (screenW - 1000)/2;
	 document.getElementById('body_container').style.visibility = "visible";
}

function login()
{
	alert(document.location.href);
	window.open("login/login.asp", "login", "height=257, width=320, toolbars=0");
}


//allows all text to be selectable within absolute positioned layers
//IE6 has a huge problem with this when the layer is positioned absolute
if (window.createPopup && document.compatMode && document.compatMode=="CSS1Compat")
{
  document.onreadystatechange = onresize = function fixIE6AbsPos()
  {
    if (!document.body) return;
    if (document.body.style.margin != "0px") document.body.style.margin = 0;
    onresize = null;
    document.body.style.height = 0;
    setTimeout(function(){ document.body.style.height = document.documentElement.scrollHeight+'px'; }, 1);
    setTimeout(function(){ onresize = fixIE6AbsPos; }, 100);
  }
}



if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (checkIt('fire')) browser = "Fire Fox"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
