/// JavaScript Document
/*  This file is to carry most if not all of JavaScript functions that might
 *  might needed in the HTML files
*/

//  function for image roll-overs
function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on' + ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}


/*
 *  The following functions are used to expand and retract the State 
 *  Government Menu specifically.
 */
function Toggle(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   key=document.getElementById("x" + item);
   if (visible) {
     obj.style.display="none";
   	 key.innerHTML="<img src='../Eeohhs/images/navigation/govbranch_carrot.gif' border='0'>";
   } else {
      obj.style.display="block";
      key.innerHTML="<img src='../Eeohhs/images/navigation/govbranch_carrot_active.gif' border='0'>";
      HideAllElse(item);
   }
}

function ToggleExec() {
   obj=document.getElementById("executive");
   visible=(obj.style.display!="none");
   key=document.getElementById("xexecutive");
   if (visible) {
     obj.style.display="none";
     key.innerHTML="<img src='../Eeohhs/images/navigation/govbranch_carrot.gif' border='0'>";
   } else {
      obj.style.display="block";
      key.innerHTML="<img src='../Eeohhs/images/navigation/govbranch_carrot_active.gif' border='0'>";
   }
}

function Expand() {
   divs=document.getElementsByTagName("DIV");
   for (i=0;i<divs.length;i++) {
     divs[i].style.display="block";
     key=document.getElementById("x" + divs[i].id);
     key.innerHTML="<img src='../Eeohhs/images/navigation/govbranch_carrot_active.gif' border='0'>";
   }
}

function Collapse() {
   divs = document.getElementsByTagName("DIV");
   for (i=0;i<divs.length;i++) {
     divs[i].style.display="none";
     key=document.getElementById("x" + divs[i].id);
     key.innerHTML="<img src='../Eeohhs/images/navigation/govbranch_carrot.gif' border='0'>";
   }
}

function HideAllElse(item) {
   divs=document.getElementsByTagName("DIV");
   for (i=0;i<divs.length;i++) {
		if (item != divs[i].id && divs[i].id != "executive"){
			divs[i].style.display="none";
			key=document.getElementById("x" + divs[i].id);
			key.innerHTML="<img src='../Eeohhs/images/navigation/govbranch_carrot.gif' border='0'>";
		}
	}
}

//  End here the State Government Menu specifications

/*  Following functions are for the arrow to get displayed next to module
 *  headers.  The module headers are composed of text hyperlinks that 
 *  change in color and change the arrows image next to them when rolled
 *  over.
 *
 *  Implementation: changeImage(item), putImage(item):
 *		item:	id of the image to be changed which is in a column next
 *				to the rolled over column.
 *  Those two functions could be use with all modules regardless of what
 *  level they are in.
 *
 *  Functions changeStaeImage() and putStateImage() are exlusively for the 
 *  State Government module.
 */
function changeImage(item)
{
	if ( document.getElementById )
	{
		var changedColumn = document.getElementById(item);
		changedColumn.style.backgroundColor = "#EFEFF7";

		var tempID = item + "Img";
		var arrowImage = document.getElementById(tempID);
		var src = arrowImage.getAttribute('src');
		var ftype = src.substring(src.lastIndexOf('.'), src.length);
		var hsrc = src.replace(ftype, '_on' + ftype);

		arrowImage.setAttribute('src', hsrc);
	}
}

function putImage(item)
{
	if ( document.getElementById )
	{
		var changedColumn = document.getElementById(item);
		if ( item == "conductbusiness" || item == "info" )
			changedColumn.style.backgroundColor = "#E79A42";
		else
			changedColumn.style.backgroundColor = "#BDC7D6";

		var tempID = item + "Img";
		var arrowImage = document.getElementById(tempID);
		var src = arrowImage.getAttribute('src');
		var removedPart = src.substring(src.lastIndexOf('_on'), src.length);
		var ftype = src.substring(src.lastIndexOf('.'), src.length);
		var hsrc = src.replace(removedPart, ftype);

		arrowImage.setAttribute('src', hsrc);
	}
}

//  For the State Government Module
function changeStateImage(item)
{
	if ( document.getElementById )
	{
		var changedColumn = document.getElementById(item);

		var imageID = item + "Img";
		var arrowImage = document.getElementById(imageID);
		var src = arrowImage.getAttribute('src');
		var ftype = src.substring(src.lastIndexOf('.'), src.length);
		var hsrc = src.replace(ftype, '_on' + ftype);

		arrowImage.setAttribute('src', hsrc);
	}
}

function putStateImage(item)
{
	if ( document.getElementById )
	{
		var changedColumn = document.getElementById(item);

		var imageID = item + "Img";
		var arrowImage = document.getElementById(imageID);
		var src = arrowImage.getAttribute('src');
		var removedPart = src.substring(src.lastIndexOf('_on'), src.length);
		var ftype = src.substring(src.lastIndexOf('.'), src.length);
		var hsrc = src.replace(removedPart, ftype);

		arrowImage.setAttribute('src', hsrc);
	}
}

//  End functions for module arrow image

/*
 *   DisplayDate function calculates the date and displays it in a certain
 *   space on the page.  It should be invoked on page loading.
 */
function displayDate()
{
	//  To display greeting
	date = new Date();
	var day_of_week_number = date.getDay();
	var day_of_month = date.getDate();
	var month_number = date.getMonth();
	var hour_of_day = date.getHours();
	var minutes_of_day = date.getMinutes();

/*     var year = date.getYear() - 100;  // This code is for 1999 and before 
*/
	var year = date.getYear();  // This code is for the year 2000

	var day_of_week = '';
	var month = ''

	if(month_number == 0){month = 'Jan.';}
	if(month_number == 1){month = 'Feb.';}
	if(month_number == 2){month = 'March';}
	if(month_number == 3){month = 'April';}
	if(month_number == 4){month = 'May';}
	if(month_number == 5){month = 'June';}
	if(month_number == 6){month = 'July';}
	if(month_number == 7){month = 'Aug.';}
	if(month_number == 8){month = 'Sept.';}
	if(month_number == 9){month = 'Oct.';}
	if(month_number == 10){month = 'Nov.';}
	if(month_number == 11){month ='Dec.';}

	if(day_of_week_number == 0){day_of_week = 'Sun';}
	if(day_of_week_number == 1){day_of_week = 'Mon';}
	if(day_of_week_number == 2){day_of_week = 'Tues';}
	if(day_of_week_number == 3){day_of_week = 'Wed';}
	if(day_of_week_number == 4){day_of_week = 'Thu';}
	if(day_of_week_number == 5){day_of_week = 'Fri';}
	if(day_of_week_number == 6){day_of_week = 'Sat';}

	var appname = navigator.appName;
	var appversion = parseInt(navigator.appVersion);
	if (appname == "Netscape" && appversion >= 3)
	{
		// At this time, we want to show the date in the form: July 12, 2003.
		var temp = parseInt(year);
		year = temp + 1900;
		// var date_to_show = day_of_week + ', ' + month + ' ' + day_of_month + ', ' + year;
		var date_to_show = month + ' ' + day_of_month + ', ' + year; 
	}
	else
	{
		// At this time, we want to show the date in the form: July 12, 2003.
		// var date_to_show = day_of_week + ', ' + month + ' ' + day_of_month + ', ' + year;
		var date_to_show = month + ' ' + day_of_month + ', ' + year;

	}

	 var d = document.getElementById("DateLayer");
	 d.innerHTML = date_to_show;
}

//For DTA Office Location Lookupfunction jumpTo(optionObj) 
{
	window.location.href = optionObj.options[optionObj.selectedIndex].value;
}

function selected_index ( strFieldName) 
{ 
		 
  var li_counter 
  if ( strFieldName.selectedIndex < 0 ||  strFieldName.value == "") { 
	return false
  } 
  else 
    return true
}

//////////////////////////

