// Rollover Button code

//

// This code automatically generates the rollover code necessary for each menu item.

// In addition, the code figures out which button is in the pressed state, and 

// Doesn't roll the button over if it is. 

// For imformation on how to use this code, please read "RollOver-Documentation.txt".



// ________Menu Creation (MODIFIABLE)______________________________________________________________

// ________Constants_______________

//  Button Image Sizes

var BUTTON_WIDTH = 192, BUTTON_HEIGHT = 24;





//  Paths

var buttonPath_ForwardSlash = "graphics/homepage/nav/";  // Must include '/' at the end of the path

var buttonPath_BackSlash = "graphics\\homepage\\nav\\";   // Must include '\\' at the end of the path

								// Use '\\' for a backSlash 

								// This is only used for searching 

//  Subpaths

var normalButtonSubPath = "normal";  // If using the "buttonPaths for one of the subpaths, set it to: ""

var hoverButtonSubPath= "rollover";

var pressedButtonSubPath = "rollover";   // NOTE: you need to specify BOTH hover and pressed



//  Names of the buttons

//  Must be the same as the "name" parameters in the anchor tags for the menu buttons.

var buttonNames = new Array("about_us", 
							"course_registration", 
							"discussion_board", 
							"gdapft", 
							"help_plug_ins", 
							"index_search", 
							"main_page", 
							"resource_tools", 
							"submitting", 
							"udm_research_portal", 
							"urban_health_topics")



// _______End of Constants__________

// _______Code for Menu Creation_____

if (((navigator.appName.charAt(0)=="N") && (navigator.appVersion.charAt(0)>=3))

	|| (navigator.appVersion.charAt(0)>=4)) 

{

	// This is where the buttons are created. 

	for (var i = 0; i < buttonNames.length; ++i) {

		createButtonVar(buttonNames[i], buttonPath_ForwardSlash, BUTTON_WIDTH, BUTTON_HEIGHT);

	}



	// CUSTOM SIZE BUTTON CREATION:

	// sample:

	// createButtonVar("back", buttonPath_ForwardSlash, 55, 23); // NOTE: must use button paths with 

											 //       FORWARD SLASHES

}



// _______End of Menu Creation__________________________________________







//________BEGINNING OF NON_MODIFIABLE CODE_______________________________________________



// activeButton_Name variable created if using Method 2 (findPressedButtton).

if (!window.activeButton_Name) {

	eval('var activeButton_Name = "NONE";');

}







// _______Helper Functions_______________________________________________



function createButtonVar(name, buttonPath_ForwardSlash, width, height)

{
	eval("window." + name + "_Norm = new Image(" + width + ", " + height + ");");

	// adding path to normal image to src

	var temp1 = name + '_Norm.src = "'+ buttonPath_ForwardSlash;

	if (normalButtonSubPath != "")

		temp1 += normalButtonSubPath + '/';

	temp1 += name + '.jpg";';

	eval(temp1);

//debug(temp1);
	

	eval("window." + name + "_Act = new Image(" + width + ", " + height + ");");

	var temp2 = name + '_Act.src = "'+ buttonPath_ForwardSlash;

	if (hoverButtonSubPath != "")

		temp2 += hoverButtonSubPath + '/' ;

	temp2 += name + '.jpg";';

	eval(temp2);

//debug(temp2);

}



function img_on(buttonName, actionType)
{
	//debug("mo: " + buttonName);
	
	if (((navigator.appName.charAt(0)=="N") && (navigator.appVersion.charAt(0)>=3))

   		|| (navigator.appVersion.charAt(0)>=4)) 

	{

		 if (buttonName != activeButton_Name) {

	 		imgOn = eval(buttonName + actionType + ".src");
			document[buttonName].src = imgOn;

		}

	 }

}





// This is an OPTIONAL function to use!!!

// It looks for the pressed image in the images array, and sets the activeButtonName to the one found



//*****

// PROBLEM: IE can only use '/' for its paths, but  image.src uses '\'



function findPressedButton(activeButtonName)

{

	var pressedButtonPath_BackSlash = buttonPath_BackSlash + pressedButtonSubPath + '\\';

	var pressedButtonPath_ForwardSlash = buttonPath_ForwardSlash + pressedButtonSubPath + '/';

	var pathLength = pressedButtonPath_BackSlash.length;

	

	var j = 0;



	mw.Msg(pressedButtonPath_BackSlash + "<br>" + pressedButtonPath_ForwardSlash +"<p>");



	// Look for paths with both forward and backward slashes

	for(j = 0;

		document.images[j] && 

		(-1 == (document.images[j].src).indexOf(pressedButtonPath_BackSlash) &&

		 -1 == (document.images[j].src).indexOf(pressedButtonPath_ForwardSlash) ); 

		++j){

		//mw.Msg("  :" + 	document.images[j].src +"<br>");

	}

	



	window[activeButtonName] = "NONE";

	

	if (document.images[j]) {

		var index = (document.images[j].src).indexOf(pressedButtonPath_BackSlash);

		index += (document.images[j].src).indexOf(pressedButtonPath_ForwardSlash);



		

		if (index != -2) {

			var tempStr =(document.images[j].src).substring(index + pathLength + 1);

			window[activeButtonName] = tempStr.substring(0, tempStr.length - 4);

//mw.Msg("SET " + activeButtonName + " to " + window[activeButtonName] + " from " + tempStr +"<br>");

		} else {

			//mw.Msg("NO PRESSED IMAGE FOUND!! <BR>");

		}

	} else {

		//mw.Msg("NO PRESSED IMAGE FOUND <BR>");

	}



}


  function showDiv(whichDiv) {
  	if (document.getElementById) {
  		document.getElementById(whichDiv).style.visibility='visible';
  	} else if (document.layers) {
  		document.layers[whichDiv].visibility='show';
  	} else {
  		document.all[whichDiv].style.visibility='visible';
  	}
  }
  
  function hideDiv(whichDiv) {
  	if (document.getElementById) {
  		document.getElementById(whichDiv).style.visibility='hidden';
  	} else if (document.layers) {
  		document.layers[whichDiv].visibility='hidden';
  	} else {
  		document.all[whichDiv].style.visibility='hidden';
  	}
  }