///////////////////////////////////////////////////////////////////////

// TEXTUAL DROPDOWN MENU

// WRITTEN BY TREVOR NIELSON : JULY 24, 2002

// ************* MODIFIED BY JMARR 081502

// PLATFORMS: IE 4.0+, NETSCAPE 4+, MOZILLA, OPERA

//

// NETSCAPE ISSUES:	ROLLOVERS FOR TABLE CELLS DO NOT SHOW UP IN NETSCAPE VERSION UNDER 6

// ISSUES:			OPERA HIDES THE MENUS PREMATURELY - NEED TO ADD A LITTLE MORE LOGIC 

//					TO TELL OPERA THAT THE USER IS OVER THE MENU

///////////////////////////////////////////////////////////////////////



///////////////////////////////////////////////////////////////////////

//

// DO NOT MAKE CHANGES BELOW THIS LINE!!



var timer;					// Used for the setTimeout() so we will be able to clear it with clearTimeout()

var prevLayer;				// Holds the previous layer shown

var windowWidth;			// Holds the available width of the window

var isOver = false;			// Used to show the rollover image and hide the previous rolled over image once per menu

						



///////////////////////////////////////////////////////////////////////

// BROWERS DETECTION:

//

// Is this Netscape version 4 or earlier?

var v4 =(parseInt(navigator.appVersion) < 5) ? 1 : 0;

var ns =(navigator.appName.match(/Netscape/) && v4) ? 1 : 0;

// Is this Netscape 6+ or Mozilla?

var ns6 = (navigator.appName.match(/Netscape/) && !v4) ? 1 : 0;

// Is this Opera?

var opera = (navigator.userAgent.indexOf("Opera") != -1 ? 1 : 0);

// Is this Mozilla only?

var mozilla = (navigator.userAgent.indexOf("Gecko") != -1 && navigator.userAgent.indexOf("Netscape") == -1? 1 : 0);

// Is this IE 4? - Not used

var ie = (navigator.appName.match(/Microsoft Internet Explorer/) && v4) ? 1 : 0;



///////////////////////////////////////////////////////////////////////

// FUNCTION(S): 	tdState(td,over)

// PARAMETER(S): 	td = the table cell / over = is over the cell

// PURPOSE:			To change the td color of the table (Does not work in NS 4)

//

function tdState(td,over){

	td.style.backgroundColor = (over ? tdOn : tdOff);

}



///////////////////////////////////////////////////////////////////////

// FUNCTION(S): 	updateLayers()

// PARAMETER(S): 	NONE

// PURPOSE:			Updates the layers position when the page is resized and loaded

//



function updateLayers(){

	// Check if browser is wider than the menu table (760 width)

	windowWidth = (ns || opera || ns6 ? window.innerWidth : document.body.clientWidth);

	//alert (windowWidth);	

	// This prevents the layers from redrawing incorrectly if the window size is less than the layout size

	if (windowWidth < layoutSize+16) {

		if (ns) windowWidth = layoutSize + 16;

		else windowWidth = layoutSize;

	}else{

		if (ns6) windowWidth -= 16;

	}



	// Update all layers positions

	for (var i=0; i<dropDownArray.length; i++){

		var layerObj = MM_findObj("layer" + i);

		//alert (layerObj.style.left);

		if (ns) layerObj.left = dropDownArray[i][0];

		else layerObj.style.left = dropDownArray[i][0];

	}

	

	if (opera) resizeHandler();

}



///////////////////////////////////////////////////////////////////////

// FUNCTION(S): 	resizeHandler()

// PARAMETER(S): 	NONE

// PURPOSE:			Updates the layers position when the page is resized and loaded

//					Opera does not recognize the onresize event so you need to

//					check for updates periodically to update the layers positions

//

function resizeHandler() {

	var winWidth = window.innerWidth;



	for (var i=0; i<dropDownArray.length; i++){

		var layerObj = MM_findObj("layer" + i);

		layerObj.style.left = dropDownArray[i][0];

	}



	setTimeout("resizeHandler()",500);	// Check if change in window size every 1/2 of second

}

///////////////////////////////////////////////////////////////////////

// FUNCTION(S): 	show(num)

// PARAMETER(S): 	num = number of layer to show

// PURPOSE:			Shows the drop down layer for the rollover

//					as well as hides the previous layer shown

//

OutOnArray = new Array('0','1','2','3','4','5')

	

function show(num){

   if(isLoaded){

	 clearTimeout(timer);

	

	// Hide the previous layer

	if (ns) prevLayer.visibility = "hide";

	else prevLayer.style.visibility = "hidden";

	

	// Show the layer and get set the previous layer

	layerObj = MM_findObj("layer" + num);

	prevLayer = layerObj;

	if (ns) layerObj.visibility = "show"; 

	else layerObj.style.visibility = "visible";

	}

}





///////////////////////////////////////////////////////////////////////

// FUNCTION(S): 	hide(num)

// PARAMETER(S): 	num = number of layer to hide

// PURPOSE:			Hides the drop down layer for the rollover

//

function hide(num){

    if(isLoaded){

	// Hide the layer

			layerObj = MM_findObj("layer" + num);

			

		if (ns){

			timer = setTimeout("layerObj.visibility='hide';isOver=false",delay);

		}

		else{

			timer = setTimeout("layerObj.style.visibility='hidden';isOver=false",delay);	

		}			

	}

}		



///////////////////////////////////////////////////////////////////////

// FUNCTION(S): 	initMenus(num)

// PARAMETER(S): 	num = number of drop down layers

// PURPOSE:			Creates the events for the drop down layers

//

var isLoaded;

function initMenus(){

	// Set the previous shown layer to layer0 on load

	prevLayer = MM_findObj("layer0");

	

	// Set the mouse events for all of the layers

	for (var i=0; i<dropDownArray.length; i++){

		layerObj = MM_findObj("layer" + i);

		layerObj.onmouseover = new Function("show(" + i + ")");

		layerObj.onmouseout = new Function("hide(" + i + ")");

	}

	isLoaded=true;

}



///////////////////////////////////////////////////////////////////////

// FUNCTION(S): 	createDropDowns()

// PARAMETER(S): 	NONE

// PURPOSE:			Creates the drop down layers and fills them with

//					the text from the drop down array (dropDownArray)

//					Also, sets the styles for the layers  - Required for Netscape

//

function createDropDowns(){

	var display = "";	// This will hold the drop down layers



	for (var i=0; i<dropDownArray.length; i++){

		if (i == 7)

		{

			display += "<div id=\"layer" + i + "\" class=\"dropdown7\">\n";

		}

		else

		{

			display += "<div id=\"layer" + i + "\" class=\"dropdown\">\n";

		}		



		if (border){	// Create the tables used for the border

			display += "\t<table border=0 cellpadding=0 cellspacing=0 bgcolor=" + borderColor + " width=" + dropDownArray[i][2] + ">\n";

			display += "\t\t<tr>\n";

			display += "\t\t\t<td>\n";

			display += "\t<table border=0 cellpadding=0 cellspacing=1>\n";

			display += "\t\t<tr>\n";

			display += "\t\t\t<td>\n";

		}

		display += "\t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"" + tdOff + "\" width=\"" + dropDownArray[i][2] + "\">\n";

		

		for (var j=0; j<dropDownArray[i][1].length; j++){

			var URL = dropDownArray[i][1][j][1];

			display += "\t\t<tr>\n";

			if (!ns){

				display += "\t\t\t<td class=\"droptd\" onClick=\"window.location='" + URL + "'\" onMouseOver=\"tdState(this,true); window.status='" + URL + "';return true\" onMouseOut=\"tdState(this,false); window.status='';return true\" style='cursor:hand'>";				

			} else {

				display += "\t\t\t<td class=\"droptd\">";

			}

			

			display += "<a class='dropLinks' href=\"" + URL + "\" onMouseOver=\"window.status='" + dropDownArray[i][1][j][0] + "';return true\"" + ">" + dropDownArray[i][1][j][0] + "</a></td>\n";

			display += "\t\t</tr>\n";

			

			if (j < dropDownArray[i][1].length - 1){

				display += "\t\t<tr bgcolor=\"" + lineSeperatorColor + "\">\n";

				//display += "\t\t\t<td><a href=\"javascript://\" onMouseOver=\"changeImage('img" + i +"','img"+ i +"_on','layer" + i +"');return true\" onMouseOut=\changeImage('img" + i +"','img"+ i +"_off','layer" + i +"'); return true;\"><image src=\"spacer.gif\" width=\"100\" height=\"1\" border=\"0\"></a></td>\n";

				display += "\t\t\t<td><image src=\"/img/ub/clear.gif\" width=\"1\" height=\"1\" border=\"0\"></td>\n";				

				display += "\t\t</tr>\n";

			}

		}

		

		display += "\t</table>\n";

		

		if (border){	// Close the tables used for the border

			display += "\t\t\t</td>\n";

			display += "\t\t</tr>\n";

			display += "\t</table>\n";

			display += "\t\t\t</td>\n";

			display += "\t\t</tr>\n";

			display += "\t</table>\n";

		}

		display += "</div>\n";

	}



	//alert(display);

	document.write(display);



	// Netscape requires that you set the style tags after the layer is written to the document

	for (var i=0; i<dropDownArray.length; i++){

		var layerObj = MM_findObj("layer" + i);

		if (ns) {

			layerObj.left = dropDownArray[i][0];

			layerObj.width = dropDownArray[i][2];

		} else {

			layerObj.style.left = dropDownArray[i][0];

			layerObj.style.width = dropDownArray[i][2];

		}

	}

}



function MM_findObj(n, d) { //v4.0

  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 && document.getElementById) x=document.getElementById(n); return x;

}



function MM_reloadPage(init) {  //reloads the window if Nav4 resized

  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {

    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}

  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

}

MM_reloadPage(true);
