/*
	   DynAPI Distribution
	   Browser Class
	
	   The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
	*/
	function Browser() {
		var b=navigator.appName;
		var agt=navigator.userAgent.toLowerCase();
		var ua=navigator.userAgent.toLowerCase();
		if (b=="Netscape") this.b="ns";
		else if ((b=="Opera") || (navigator.userAgent.indexOf("Opera")>0)) this.b = "opera";
		else if (b=="Microsoft Internet Explorer") this.b="ie";
		if (!b) alert('Unidentified browser./nThis browser is not supported');
		this.version=navigator.appVersion;
		this.v=parseInt(this.version);
		this.ns=(this.b=="ns" && this.v>=4);
		this.ns4=(this.b=="ns" && this.v==4);
		this.ns6=(this.b=="ns" && this.v==5 && (agt.indexOf("netscape6/6") != -1));
		this.ns6up=(this.b=="ns" && this.v>=5 && (agt.indexOf("netscape") != -1));
		this.ns7=(this.b=="ns" && this.v==5 && (agt.indexOf("netscape/7") != -1));
		this.ns7up=(this.ns6up && !this.ns6);
		this.ie=(this.b=="ie" && this.v>=4);
		this.ie4=(this.version.indexOf('MSIE 4')>0);
		this.ie5=(this.version.indexOf('MSIE 5')>0);
		this.ie55=(this.version.indexOf('MSIE 5.5')>0);
		this.ie6=(this.version.indexOf('MSIE 6')>0);
		this.opera=(this.b=="opera");
		this.aol=(agt.indexOf("aol") != -1);
		this.aol5=(agt.indexOf("aol 5") != -1);
		this.aol6=(agt.indexOf("aol 6") != -1);
		this.gecko = (agt.indexOf('gecko') != -1);
		this.win32=(ua.indexOf("win")>-1);
		this.mac=(ua.indexOf("mac")>-1);
		this.ff=(ua.indexOf("firefox")>-1);
	}
	is = new Browser();
	
	
	function Choice(arrayPosition) {
		if (arrayPosition < 0) return (true);
	
		if ( is.ff || is.ie && !(is.mac && (is.aol5||is.ie4 ))) {

			if (secondLevelDivs[arrayPosition].isHidden)
				showSec(arrayPosition);
			else 
				hideSec(arrayPosition);
			return (false);
		}
		else {
			return (true);
		}
	}
	
	// Function which assigns properties to the div objects in the array below
	function secSet(idName) {
		this.idName = idName;
		this.isHidden = true;
		this.xPos = 0;
		this.yPos = 0;
		this.thisTimeout = "";
	}
	
	// Create an array of objects - one for each div
	var secondLevelDivs = new Array();
	
	// Set up horizontal offset positions for each div
	var secxPos = new Array();
	secxPos[0] = 0;
	secxPos[1] = 0;
	secxPos[2] = 0;
	secxPos[3] = 0;
	secxPos[4] = 0; 
	
	function findPosX(obj)
	{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
	}
	
	// Set up vertical offset position for all divs
	//var secyPos = +101;
	var secyPos = +135; //header change for Bache
	
	// Function which ensures that the div is properly aligned each time the drop-down is called
	function fnGoExpress() {
		setSecondLevelDivArray();
		var secLeft = 0;
		var offsetNS6 = 0;
		for (i=0;i<secondLevelDivs.length;i++){
			secLeft = parseInt (secondLevelDivs[i].leftPos);
			
			// NS has an 8 pixel width differential from IE, due to a scrollbar issue with JavaScript
			// secLeft = (is.ie)?document.body.clientWidth/2 - document.all[secondLevelDivs[i].idName].offsetWidth/2 + secxPos[i]:window.innerWidth/2 - document.getElementById(secondLevelDivs[i].idName).offsetWidth/2 + secxPos[i] - 8;
			// NS6.x has a bug that adds a progressively increasing horizontal offset to the drop-downs.  To counter we subtract (in increasing 4px increments) from the value of secLeft
			// if (is.ns6) {offsetNS6 = i*4; secLeft -= offsetNS6;}
			
			// Set horizontal position of the drop-down <div> tags
			(is.ie4)?document.all[secondLevelDivs[i].idName].style.left=secLeft:document.getElementById(secondLevelDivs[i].idName).style.left=secLeft;
			(is.ie4)?document.all[secondLevelDivs[i].idName].style.top=secyPos:document.getElementById(secondLevelDivs[i].idName).style.top=secyPos;
		}
		
		
	}
	window.onload = ((is.ie||is.ns6up||is.gecko) && !(is.mac&&(is.aol5||is.ie4)))?fnGoExpress:null;
	window.onresize = ((is.ie||is.ns6up||is.gecko) && !(is.mac&&(is.aol5||is.ie4)))?fnGoExpress:null;
	
		
	// Function which hides all drop-downs
	function hideAllSec() {
		for (i=0;i<secondLevelDivs.length;i++){
			// All versions of IE benefit from using document.all 
			// using getElementByID for this creates 'sticky' drop-downs
			if (is.ie || is.ff) document.all[secondLevelDivs[i].idName].style.visibility = "hidden";
			else document.getElementById(secondLevelDivs[i].idName).visibility = "hide";
			secondLevelDivs[i].isHidden = true;
		}
	}
	
	
	// Function which tracks the page coordinates of the mouse
	var xMousePos = 0; 
	var yMousePos = 0; 
	
	if (is.ns) document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = captureMousePosition;
	
	function captureMousePosition(e) {
		if (is.ie){
			xMousePos = window.event.x+document.body.scrollLeft;
			yMousePos = window.event.y+document.body.scrollTop;
		} 
		else if (is.ns||is.gecko) {
			xMousePos = e.pageX+window.pageXOffset;
			yMousePos = e.pageY+window.pageYOffset;
		}
	}
	
	/****************************************************************
	*  Function called as part of countDown() function to determine *
	*  if the mouse is still hovering over the div.                 *
	*  This function is also called on each mouse onClick as part   *
	*  of the mouseClickCheck() function                            *
	****************************************************************/
	function mouseOverDiv(arrayPosition){
		// establish the height and width of the drop-down div
		divHeight = (is.ie4)?parseInt(document.all[secondLevelDivs[arrayPosition].idName].offsetHeight):parseInt(document.getElementById(secondLevelDivs[arrayPosition].idName).offsetHeight);
		divWidth = (is.ie4)?parseInt(document.all[secondLevelDivs[arrayPosition].idName].offsetWidth):parseInt(document.getElementById(secondLevelDivs[arrayPosition].idName).offsetWidth);
		
		// determine page coordinates of the div
		divLeft = (is.ie4)?parseInt(document.all[secondLevelDivs[arrayPosition].idName].style.left):parseInt(document.getElementById(secondLevelDivs[arrayPosition].idName).style.left);
		divTop = (is.ie4)?parseInt(document.all[secondLevelDivs[arrayPosition].idName].style.top):parseInt(document.getElementById(secondLevelDivs[arrayPosition].idName).style.top);
	
		divRight = divLeft + divWidth;
		divBottom = divTop + divHeight;
	
		//subtract the pixel height of the tabs to include them in the 'hover' area 
		topOfTabs = divTop - 20; 
		
		//determine whether mouse is over the div
		if (((divLeft < xMousePos)&&(divRight > xMousePos))&&((topOfTabs < yMousePos)&&(divBottom > yMousePos))) {
			return true;
		} else {
			return false;
		}
	}
	
	/****************************************************************
	*  Function which will automatically check each mouse click and *
	*  will close any open second-level navs should a user click    *
	*  anywhere else on the page.                                   *
	****************************************************************/
	if(is.ns) document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown = checkMousePosition;
	
	function checkMousePosition(e) {
		for(i=0;i<secondLevelDivs.length;i++){
			if(!secondLevelDivs[i].isHidden && !mouseOverDiv(i)){
				hideSec(i)
				break;
			}
		}	
	}
	
	
	/****************************************************************
	*  Function which hides a revealed drop-down after pre-         *
	*  determined time limit.  When the number of seconds specified *
	*  in the removeSec() function has passed, this funciton        *
	*  checks to see if the mouse if still hovering over the div.   *
	*  If so, it calls the removeSec() function all over again.     *
	*  If not, it hides the div from the user.                      *
	****************************************************************/
	function countDown(arrayPosition,seconds){
		if(seconds==0){
			if(!secondLevelDivs[arrayPosition].isHidden && !mouseOverDiv(arrayPosition)){
				if (is.ie4) document.all[secondLevelDivs[arrayPosition].idName].style.visibility = "hidden";
				else document.getElementById(secondLevelDivs[arrayPosition].idName).style.visibility = "hidden";
				secondLevelDivs[arrayPosition].isHidden = true;
			} else if (!secondLevelDivs[arrayPosition].isHidden && mouseOverDiv(arrayPosition)){
				removeSec(arrayPosition);
			}
		}else{
			seconds = --seconds;	
			clearTimeout(secondLevelDivs[arrayPosition].thisTimeout);
			secondLevelDivs[arrayPosition].thisTimeout = setTimeout("countDown("+arrayPosition+","+seconds+");",1000);
		}
	}
	
	/****************************************************************
	*  Function which calls the countDown() function after certain  *
	*  number of seconds.  This wrapper function was created so     *
	*  that the value of 'seconds' would be reset to 6 each time    *
	*  a new drop-down was revealed, and the count down would start *
	*  over.                                                        *
	****************************************************************/
	function removeSec(arrayPosition) {
		//set the number of seconds to keep the drop-down on the screen each time the drop-down is clicked on
		var seconds = 6
		countDown(arrayPosition,seconds);
	}
	
	// Function which reveals a specific drop-down and then triggers the countDown() function 
	function showSec(arrayPosition) { 
		if (arrayPosition < 0) return (true);	// no second level. Go where <a> points to
		hideAllSec();
		if (is.ie4) document.all[secondLevelDivs[arrayPosition].idName].style.visibility = "visible";
		else document.getElementById(secondLevelDivs[arrayPosition].idName).style.visibility = "visible";
		secondLevelDivs[arrayPosition].isHidden = false;
		removeSec(arrayPosition);
	}
	
	// Function which hides a specific drop-down
	function hideSec(arrayPosition) {
		if (is.ie4) document.all[secondLevelDivs[arrayPosition].idName].style.visibility = "hidden";
		else document.getElementById(secondLevelDivs[arrayPosition].idName).style.visibility = "hidden";
		secondLevelDivs[arrayPosition].isHidden = true;
	}
	
	// Functions that change tab colors on mouseOver and mouseOut
	function mouseOverFirstLevel(anchorTagID){
		if(is.ie) document.all[anchorTagID].className='firstLevelTextSelected';
		else if (is.ns6up) document.getElementById(anchorTagID).className='firstLevelTextSelected';
	}
	
	function mouseOutFirstLevel(anchorTagID){
		if(is.ie|| is.ff) document.all[anchorTagID].className='firstLevelText';
		else if (is.ns6up) document.getElementById(anchorTagID).className='firstLevelText';
	}
	
	function mouseOverSecondLevel(tableDataTag,otherTableDataTag,anchorTagID) {
		if(is.ie|| is.ff) {document.all[tableDataTag].className='secondLevelSelected';document.all[otherTableDataTag].className='secondLevelSelected';document.all[anchorTagID].className='secondLevelSelected';}
		else if(is.ns6up) {document.getElementById(tableDataTag).className='secondLevelSelected';document.getElementById(otherTableDataTag).className='secondLevelSelected';document.getElementById(anchorTagID).className='secondLevelSelected';}
	}
	
	function mouseOutSecondLevel(tableDataTag,otherTableDataTag,anchorTagID) {
		if(is.ie|| is.ff) {document.all[tableDataTag].className='secondLevel';document.all[otherTableDataTag].className='secondLevel';document.all[anchorTagID].className='secondLevel';}
		else if(is.ns6up) {document.getElementById(tableDataTag).className='secondLevel';document.getElementById(otherTableDataTag).className='secondLevel';document.getElementById(anchorTagID).className='secondLevel';}
	}
	
	function mClk(src) {
	 if(is.ie){
	  if(event.srcElement.tagName=='TD') {src.children.tags('A')[0].click();} 
	 }
	}
	
	/*
	function show(object) {
	    if (document.getElementById && document.getElementById(object) != null)
	         node = document.getElementById(object).style.visibility='visible';
	    else if (document.layers && document.layers[object] != null)
	        document.layers[object].visibility = 'visible';
	    else if (document.all)
	        document.all[object].style.visibility = 'visible';
	}
	
	function hide(object) {
	    if (document.getElementById && document.getElementById(object) != null)
	         node = document.getElementById(object).style.visibility='hidden';
	    else if (document.layers && document.layers[object] != null)
	        document.layers[object].visibility = 'hidden';
	    else if (document.all)
	         document.all[object].style.visibility = 'hidden';
	}
	
	
	// Show/Hide functions for non-pointer layer/objects
	function show1(id) {
		if (is.ns6up) document.layers[id].visibility = "show"
		else if (is.ie) document.all[id].style.visibility = "visible"
	}

	function hide1(id) {
		if (is.ns6up) document.layers[id].visibility = "hide"
		else if (is.ie) document.all[id].style.visibility = "hidden"
	}
	*/
	
	function findarraryIndex (idName) {
		var returnVal = -1;
		for (var i=0;i<secondLevelDivs.length; i++) {
			if (secondLevelDivs [i].idName == idName) returnVal = i;
		}
		return (returnVal)
	}

	
	//Search Form Addenda
function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   return temp;
}

function checkQueryTopband() {
 var query;
 query = document.frmSearchTopBand.QueryTextHome.value;
 query = trim(query);
 if (query == "") {
  alert ("Please enter one or more search terms.");
  return false;
 } 
 else {
  return true;
 }
}

/*
function Query() 
{
	var q = "";
	if(document.frmSearch.QueryText){
		q = document.frmSearch.QueryText.value;
		q = q.trim();
		document.frmSearch.QueryText.value = q;
		}	
	if (q == "") {
			alert ("Please enter one or more search terms.");
			return false;
		}
	else
		{
			if (document.frmSearch.qtype[0].checked)
				document.frmSearch.QueryType.value = 0;
			else if (document.frmSearch.qtype[1].checked)
				document.frmSearch.QueryType.value = 1;
			else if (document.frmSearch.qtype[2].checked)
				document.frmSearch.QueryType.value = 2;
			//document.frmSearch.st.value = document.frmResultParams.strST.value;
		}
	return true;
}
*/
function Query()
{
	var st = "";
	st = document.frmSearch.QueryText.value;
	//st = st.trim();
	document.frmSearch.QueryText.value = st;
	if (st == ""){
			alert ("Please enter one or more search terms.");
			document.frmSearch.QueryText.focus();
			return false;
		}
	else
	{
	  	document.seek1.submit();
		return true;
	}
}

function QueryTop()
{
	var st = "";
	st = document.seek1.QueryText.value;
	st = st.trim();
	document.seek1.QueryText.value = st;
	if (st == ""){
			alert ("Please enter one or more search terms.");
			return false;
		}
		
	return true;
}
function submitSearchQuery() {
	var st = "";
	st = document.seek1.QueryText.value;
	//st = st.trim();
	document.seek1.QueryText.value = st;
	if (st == ""){
			alert ("Please enter one or more search terms.");
			document.seek1.QueryText.focus();
		}
	else
	  	document.seek1.submit();
}
 
function go_search(form){

	function filterSC(str) {
		re = /\$|,|@|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\./g;
		// remove special characters
		return str.replace(re, "");
	}
	
	var query = filterSC(document.getElementById('headerQuery').value);
	
	var qt = document.getElementById('headerQt').value;
	
	var qtQ = qt + query;

	if ((query == "") || (query == "Search" )) {
	
		alert("Please enter one or more search terms.");
		document.getElementById('headerQuery').focus();
		//return false;
		
	} else {
		
		document.getElementById('headerQt').value = qtQ;
		document.headerSearchForm.submit();
		//return false;
	}
}
//End Of Search Form Addenda