<?php header("Content-type: text/javascriipt"); ?>

// Variables needed for Rollovers
var finished = 'yes';
var over = 'no';

var styleSheetElement;
var oldElement;
var mainMenu = 'none';
var subOne = 'none';
var subTwo = 'none';
var subElement;
var oldSub;
var initial = 0;
var currentTop;
var lastDisplayedMenu;
currentMenus = new Array(2)
lastDisplayed = new Array(2)
var subLevels = 3;
var beenCalled;

// Function to Assign the relative path to images and links
if (whichLevel == 0) {
	var path = '';
} else if (whichLevel == 1) {
	var path = '../';
} else if (whichLevel == 2) {
	var path = '../../';
} else if (whichLevel == 3) {
	var path = '../../../';
}

<? if ($whichSection == $item[title]) { ?>

nav1On = new Image();
nav1On.src = ""+ path + "images/nav1_on.png";
nav1Off = new Image();
nav1Off.src = ""+ path + "images/nav1_on.png";

nav2On = new Image();
nav2On.src = ""+ path + "images/nav2_on.png";
nav2Off = new Image();
nav2Off.src = ""+ path + "images/nav2_on.png";

nav3On = new Image();
nav3On.src = ""+ path + "images/nav3_on.png";
nav3Off = new Image();
nav3Off.src = ""+ path + "images/nav3_on.png";

nav4On = new Image();
nav4On.src = ""+ path + "images/nav4_on.png";
nav4Off = new Image();
nav4Off.src = ""+ path + "images/nav4_on.png";

nav5On = new Image();
nav5On.src = ""+ path + "images/nav5_on.png";
nav5Off = new Image();
nav5Off.src = ""+ path + "images/nav5_on.png";

nav6On = new Image();
nav6On.src = ""+ path + "images/nav6_onr.png";
nav6Off = new Image();
nav6Off.src = ""+ path + "images/nav6_on.png";

nav7On = new Image();
nav7On.src = ""+ path + "images/nav7_on.png";
nav7Off = new Image();
nav7Off.src = ""+ path + "images/nav7_on.png";

nav8On = new Image();
nav8On.src = ""+ path + "images/nav8_on.png";
nav8Off = new Image();
nav8Off.src = ""+ path + "images/nav8_on.png";

nav9On = new Image();
nav9On.src = ""+ path + "images/nav9_onr.png";
nav9Off = new Image();
nav9Off.src = ""+ path + "images/nav9_on.png";

<? } else { ?>

nav1On = new Image();
nav1On.src = ""+ path + "images/nav1_over.png";
nav1Off = new Image();
nav1Off.src = ""+ path + "images/nav1.png";

nav2On = new Image();
nav2On.src = ""+ path + "images/nav2_over.png";
nav2Off = new Image();
nav2Off.src = ""+ path + "images/nav2.png";

nav3On = new Image();
nav3On.src = ""+ path + "images/nav3_over.png";
nav3Off = new Image();
nav3Off.src = ""+ path + "images/nav3.png";

nav4On = new Image();
nav4On.src = ""+ path + "images/nav4_over.png";
nav4Off = new Image();
nav4Off.src = ""+ path + "images/nav4.png";

nav5On = new Image();
nav5On.src = ""+ path + "images/nav5_over.png";
nav5Off = new Image();
nav5Off.src = ""+ path + "images/nav5.png";

nav6On = new Image();
nav6On.src = ""+ path + "images/nav6_over.png";
nav6Off = new Image();
nav6Off.src = ""+ path + "images/nav6.png";

nav7On = new Image();
nav7On.src = ""+ path + "images/nav7_over.png";
nav7Off = new Image();
nav7Off.src = ""+ path + "images/nav7.png";

nav8On = new Image();
nav8On.src = ""+ path + "images/nav8_over.png";
nav8Off = new Image();
nav8Off.src = ""+ path + "images/nav8.png";

nav9On = new Image();
nav9On.src = ""+ path + "images/nav9_over.png";
nav9Off = new Image();
nav9Off.src = ""+ path + "images/nav9.png";

<? } ?>

// function that turns on the main nav graphics as well as the menus
function menuOn(menu0, menu1, menu2) {
	// Make sure the page has loaded
	if (finished == 'yes') {
	
		//gather the names of all the menus that you want on into the currentMenus Array
		for (var i = 0; i < subLevels; i++) {
			eval('currentMenus[' + i + '] = menu' + i + ';');
		}

		// set over to show that the user is now over a menu
		over = 'yes';
		
			// This section of code is executed for wc3 css compliant browsers
			
			// Execute the following if this is not the first time this function has been called
			if (beenCalled == 'yes')  {
			
				// Loop used to turn on all menus held within the currentMenus array
				for (var i = 0; i < subLevels; i++) {
					
					if((lastDisplayed[i]) && (lastDisplayed[i] != 'none')) {
						if ((i == 0) && (menu0 != lastDisplayed[0]) || (i != 0)) { 
							
							// These lines gather the menu element which we want to access
							lastDisplayedMenu = lastDisplayed[i] + 'Menu';
							oldElement = document.getElementById(lastDisplayedMenu);
							
							// Turn off any currently displayed menu
							oldElement.style.visibility = "hidden";	
							eval('document.images[lastDisplayed[i]].src = ' + lastDisplayed[i] + 'Off.src');
						}
					}
				}
			}
			
			// Loop used to turn on all menus held within the currentMenus array
			for (var i = 0; i < subLevels; i++) {
				if(currentMenus[i] != 'none') {
				
					// These lines gather the menu element which we want to access
					layerName = currentMenus[i] + 'Menu';
					
					styleSheetElement = document.getElementById(layerName);	
					
					// Turn on the menu(s) which need now need to be displayed		
					styleSheetElement.style.visibility = "visible";
					eval('document.images[currentMenus[i]].src = ' + currentMenus[i] + 'On.src');	
					
				
				}
				
				// set lastDisplayed Array to hold names of menus turned on for use next time function is called
				lastDisplayed[i] = currentMenus[i];	
			}	
		}
		beenCalled = 'yes';
	}



// Timer function that is run to give the user time to get to the menu from the button
function overChecker(menu0, menu1, menu2) {
	// alert('overchecker');
	if ((over == 'yes') && (finished == 'yes')) {
	
		//gather the names of all the menus that you want on into the currentMenus Array
		for (var i = 0; i < subLevels; i++) {
			eval('lastDisplayed[' + i + '] = menu' + i + ';');
		}
		over = 'no';
		setTimeout("menuOff()", 300);
	}
}

// function that turns off the main nav graphics as well as the menus
function menuOff() {
	
	if (over == 'no')  {
			
			for (var i = 0; i < subLevels; i++) {
				if((lastDisplayed[i]) && (lastDisplayed[i] != 'none')) {
					// These lines gather the menu element which we want to access			
					lastDisplayedMenu = lastDisplayed[i] + 'Menu';
					// alert(lastDisplayedMenu);
					oldElement = document.getElementById(lastDisplayedMenu);
					eval('document.images[lastDisplayed[i]].src = ' + lastDisplayed[i] + 'Off.src');		
					// Turn off any currently displayed menu
					oldElement.style.visibility = "hidden";	
				}
			}
		}
	}	



// Image replace On Function	
function on(pic) {
	eval('document.images[pic].src = ' + pic + 'On.src');
}
        

// Image replace Off Function	
function off(pic) {
	eval('document.images[pic].src = ' + pic + 'Off.src');
}

// Toggle Hide/Show div

function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}

// Hide div

function hide_visibility(id) {
for (var i = 0; i < id.length; i++) {
	var e = document.getElementById(id[i]);
e.style.display = 'none';
} 
}

// Show div

function show_visibility(id) {
for (var i = 0; i < id.length; i++) {
	var e = document.getElementById(id[i]);
e.style.display = 'inline';
}
}

// Variables needed for Rollovers
var over = 'no';
var whichOne = ' ';
var styleSheetElement;
var oldElement;

// Function to Assign the relative path to images and links
if (whichLevel == 0) {
	var path = '';
} else if (whichLevel == 1) {
	var path = '../';
} else if (whichLevel == 2) {
	var path = '../../';
} else if (whichLevel == 3) {
	var path = '../../../';
}

function changeClass(elem, className1,className2)
{
    elem.className = (elem.className == className1)?className2:className1;
}

/* function to change a class */
function setClass(objectID,newClass) {
	var object = document.getElementById(objectID);
	if (object) {
		object.className = newClass;
	}
}

function autotab(original,destination){
	if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
	destination.focus()
}
