//FUNCTIONS FOR PRELOADING
var Preload = new Array('login_button');
		for (var n = 0; n < Preload.length; n++) {
			var each = new Image();
			each.src="images/" + Preload[n] + "_ov.gif";
		}


 if (document.images)
    {
      preload_image_obj = new Image();
      // set image url
      image_pre = new Array();
      image_pre[0] = "../images/ul_bullet.gif";
      image_pre[1] = "../images/leftnav_home_ov.gif";
      image_pre[2] = "../images/body_bg.jpg";
      image_pre[3] = "../images/login_ov.gif";
       image_pre[4] = "../images/banner_bg.gif";
	  image_pre[5] = "../images/login.gif";
      image_pre[6] = "../images/right_bg.gif";
      image_pre[7] = "../images/banner_logo.gif";
      image_pre[8] = "../images/leftnav_corner_top.gif";
       image_pre[9] = "../images/leftnav_corner_bottom.gif";
      image_pre[10] = "../images/but_video_ov.gif"; 
 	  image_pre[11] = "images/video_00.jpg";
      image_pre[12] = "images/video_01.jpg";
      image_pre[13] = "images/video_02.jpg";
      image_pre[14] = "images/video_03.jpg";
     
       var i = 0;
       for(i=0; i<=3; i++) 
         preload_image_obj.src = image_pre[i];
    }

//FUNCTIONS FOR ROLLOVERS
function on(name) {
			document[name].src="images/" + name + "_ov.gif";
		}
		
		function off(name) {
			document[name].src="images/" + name + ".gif";
		}
function Hilite(name,over) {

	var name = arguments[0];
	var over = arguments[1];
	var img_name;

	if (arguments[2]) {
		img_name = arguments[2];
	} else {
		img_name = arguments[0];
	}

	if(over)
		window.document.images[img_name].src = "../images/" + name +"_ov.gif";
	else
		window.document.images[img_name].src =  "../images/" + name + ".gif";
	}

//FUNCTIONS FOR DROP-DOWN
function toggle(id){
	if (id.className=='answer') id.className='hide';
	else id.className='answer';
}
var flipped = new Array();
function swapped(pic){
	if (flipped[pic.name]==null){
		flipped[pic.name]=false;
	}
	if (flipped[pic.name]==false){
		pic.src=pic.src.replace('but_rarrow','but_darrow');
		flipped[pic.name]=true;
	}
	else{
		pic.src=pic.src.replace('but_darrow','but_rarrow');
		flipped[pic.name]=false;
	}
}
function rollover(pic){
	pic.src=pic.src.replace('arrow.gif','arrow_ov.gif');
}

function rollout(pic){
	pic.src=pic.src.replace('arrow_ov.gif','arrow.gif');
}

function over(thistag) {
thistag.style.color="#F25100";
}
function out(thistag) {
thistag.style.color="#336699";
}
function closeAns(answer, arrow, back) {
		  var ans = document.getElementById(answer);
		  var arr = document.getElementById(arrow);
		  var bac = document.getElementById(back);
		  ans.className="hide";
		  swapped(arr);
		  bac.src = bac.src.replace('_ov.gif','.gif');
		}
function closeAns2(answer, arrow, back) {
		  var ans = document.getElementById(answer);
		  var arr = document.getElementById(arrow);
		  var bac = document.getElementById(back);
		  ans.className="hide";
		  swapped(arr);
		  bac.src = bac.src.replace('_ov.gif','.gif');
		}
		
		
//FUNCTIONS FOR POPUPS
function launchPopup(page) {
	howTall = (screen.availHeight - 450)/2;
	howWide = (screen.availWidth - 600)/2;
	popupWindow = window.open(page+'.htm','new','width=600,height=400,screenX=100,screenY=100,top='+howTall+',left='+howWide+'menubar=yes,resizable=yes,titlebar=no,status=no,toolbar=no,scrollbars=yes');
	if (window.focus) {popupWindow.focus()}
	}
function launchLarge(page) {
	howTall = (screen.availHeight - 450)/2;
	howWide = (screen.availWidth - 600)/2;
	largeWindow = window.open(page+'.htm','new','width=700,height=420,screenX=100,screenY=100,top='+howTall+',left='+howWide+'menubar=yes,resizable=yes,titlebar=no,status=no,toolbar=no,scrollbars=yes');
	if (window.focus) {largeWindow.focus()}
	}	
function launchVideo(page) {
	howTall = (screen.availHeight - 450)/2;
	howWide = (screen.availWidth - 600)/2;
	videoWindow = window.open('00_video.htm','new','width=600,height=400,screenX=100,screenY=100,top='+howTall+',left='+howWide+'menubar=yes,resizable=yes,titlebar=no,status=no,toolbar=no,scrollbars=yes');
	if (window.focus) {videoWindow.focus()}
	}	

function launchInfo(page) {
	howTall = (screen.availHeight - 450)/2;
	howWide = (screen.availWidth - 600)/2;
	infoWindow = window.open(page+'.htm','new','width=380,height=240,screenX=100,screenY=100,top='+howTall+',left='+howWide+'menubar=yes,resizable=yes,titlebar=no,status=no,toolbar=no,scrollbars=yes');
	if (window.focus) {infoWindow.focus()}
	}
function launchTour(page) {
	howTall = (screen.availHeight - 450)/2;
	howWide = (screen.availWidth - 600)/2;
	tourWindow = window.open(page+'.htm','new','width=700,height=500,screenX=100,screenY=100,top='+howTall+',left='+howWide+'menubar=yes,resizable=no,titlebar=no,status=no,toolbar=no,scrollbars=no');
	if (window.focus) {tourWindow.focus()}
	}	
	
	
	
	
//FUNCTIONS FOR ADVANCED DROP DOWN
function toggle2(id){
	if (id.className=='option') id.className='hide';
	else id.className='option';
}
var flip = null;
var stayon = new Array();
function swap(pic){
	if (!flip){
		document.getElementById(pic).src=document.getElementById(pic).src.replace('but_rarrow','but_oarrow');
		flip=true;
	}
	else{
		document.getElementById(pic).src=document.getElementById(pic).src.replace('but_oarrow','but_rarrow');
		flip=null;
	}
	if (!stayon[document.getElementById(pic).name]){
		stayon[document.getElementById(pic).name]=true;
	}
	else{
		stayon[document.getElementById(pic).name]=null;
	}
}

function delineate(str) {
	theleft = str.indexOf("but_") + 4;
	theright = str.lastIndexOf("arrow");
	return(str.substring(theleft, theright));
}



function rollov(pic, tag){
	document.getElementById(pic).src=document.getElementById(pic).src.replace('arrow.gif','arrow_ov.gif');
	document.getElementById(tag).style.color="#F67A00"; //over color
}

function rollou(pic, tag){
	document.getElementById(pic).src=document.getElementById(pic).src.replace('arrow_ov.gif','arrow.gif');
	if(!stayon[document.getElementById(pic).name]){
		document.getElementById(tag).style.color="#325D9C"; //off state color
	}
	else document.getElementById(tag).style.color="#288BD8"; //on state color
}

var opened = null;
var openeda = null;
var openedq = null;
function switchItem(pic, answer, question) {
	if(opened==null){
	//nothing is open
		if(delineate(document.getElementById(pic).src)=="r")
		flip = null;				
		else if(delineate(document.getElementById(pic).src)=="o")
		flip=true;
		swap(pic);			
		opened = pic;		
		toggle2(document.getElementById(answer));		
		
	} else if(opened!=pic) {		
	//something opened but not the item clicked
		if(delineate(document.getElementById(pic).src)=="r")
		flip = null;				
		else if(delineate(document.getElementById(pic).src)=="o")
		flip=true;
		swap(pic);
		toggle2(document.getElementById(answer));
		opened = pic;
		
	} else { 
	//the open question was clicked
		if(delineate(document.getElementById(pic).src)=="r")
		flip = null;				
		else if(delineate(document.getElementById(pic).src)=="o")
		flip = true;
		swap(pic);
		toggle2(document.getElementById(answer));
		opened = null;
		
	}
}	


// FUNCTIONS FOR BROWSER DETECTION

var detect = navigator.userAgent.toLowerCase();
var OS,browser,total,thestring;
var version = 0;

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('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;
}




// FUNCTIONS FOR LOGIN
function submitUserIDForm() {
	document.frmUserIDLogin.hidPass.value = document.frmPasswordLogin.hidPass.value;
//	document.frmPasswordLogin.USERID.value = document.frmUserIDLogin.USERID.value;
	if (validateForm())	{
	  //document.frmUserIDLogin.submit();
	  return true;	}
	else {
		return false;	}
}
function submitPasswordForm() {
	if (submitUserIDForm())	{
		document.frmUserIDLogin.submit();	}
	return false; 
}
function goBtnOnClick() {
	submitPasswordForm();
}
function isBlank(l) {
	var s  = new String(l);
	var len=s.length;
	var i;
	for (i=0;i<len;++i)	{
		if (s.charAt(i)!= " ") {
				return false;	}
		}
		return true; }
function validate(fieldName,fieldValue) {
	if (isBlank(fieldValue)) {
		alert(fieldName+" cannot be left blank. ");
		return false;	}
		return true; 
}
function validateForm() {
	if(!validate("User ID",document.frmUserIDLogin.USERID.value))	{
		document.frmUserIDLogin.USERID.value = "";
		document.frmUserIDLogin.USERID.focus();
		return false;	}
	if(!validate("Password",document.frmUserIDLogin.hidPass.value))	{
		document.frmPasswordLogin.hidPass.value = "";
		document.frmPasswordLogin.hidPass.focus();
		return false;	}
	return true;
}
NS4 = (document.layers) ? true : false;
function checkEnter(event) {
	var code = 0;
	
	
	if (NS4)
		code = event.which;
	else if (browser == 'An unknown browser')  {
		code = event.which; }
	else
		code = event.keyCode;
	if (code==13)
		document.loginForm.submit();
}

