//The variable used to keep track of the timeout for the hover
//(allows you to have the delay on the hover of the menu, so that the menu sticks around after you moved off the li's)
var currentTimeout;

//an array to hold the li's that you want held in hover mode
var LIs_To_Hover = new Array();

var browser=navigator.appName;
var b_version=navigator.appVersion;
/*

function hideFormInIE()
{
	if(browser=="Microsoft Internet Explorer" && b_version.indexOf('MSIE 6.0')!=-1)
	{
		var form_wrapper = document.getElementById('form_wrapper_inner');
		
		if(form_wrapper)
		{
			form_wrapper.className = form_wrapper.className.replace("visible","hidden");
		}
	}

}

function showFormInIE()
{
	if(browser=="Microsoft Internet Explorer" && b_version.indexOf('MSIE 6.0')!=-1)
	{
		var form_wrapper = document.getElementById('form_wrapper_inner');
		
		if(form_wrapper)
		{
			form_wrapper.className = form_wrapper.className.replace("hidden","visible");
		}
	}

}

*/

//sets up the functions for the mouseover and mouse out for the li's with class of 'top_li' and a parent container with the id 'nav'
function enableMenuImageRollovers()
{
	//get the surrounding container with the id of 'nav'
	var container = document.getElementById('Nav');

	//return if the id is not found
	if (!container)
	{
		return;
	}

	//get a list of all the li's in that surrounding div
	var lis = container.getElementsByTagName('li');


	for(x=0; x< lis.length; x++)
	{
		var li=lis[x];

		//indexOf is the same as str_pos in php (this is looking to see if the string "top_li" is in the class name of the li)
		//this is to make sure the li that are under the top level li's are not given these functions
		if(li.className.indexOf("top_li")!=-1)
		{
			//push the li's id onto the array of li's able to be hovered
			LIs_To_Hover.push(li.id);
			
			li.onmouseover=function()
			{
				RollOver(this);
			}
			
			li.onmouseout=function()
			{
				RollOff(this);
			}
		}
	}
}

//what do do when the li is rolled over
function RollOver(li)
{
	//go through the list of lis that can be hovered and turn off hover
	TurnOffAll();
	clearTimeout(currentTimeout);

	li.className=li.className.replace("hover_off","hover_on");

	//RollOverImages(li)
	//hideFormInIE();

}

function RollOverImages(li)
{
	var img_list = li.getElementsByTagName('img');

	img_list[0].src = img_list[0].src.replace("normal", "rollover");
}

function RollOffImages(li)
{
	var img_list = li.getElementsByTagName('img');

	img_list[0].src = img_list[0].src.replace("rollover", "normal");

}

//what do do when the li is rolled off
function RollOff(li)
{
	currentTimeout = setTimeout("RemoveSynHover('" + li.id + "')",500);
}

//remove the hover attributes of an li
function RemoveSynHover(LI_Id)
{
	var li = document.getElementById(LI_Id);

	li.className=li.className.replace("hover_on","hover_off");
	//RollOffImages(li)
	//showFormInIE();
}

//go through each li in the list of "hoverable" li's and remove their hover attributes
function TurnOffAll()
{
	for(var i = 0; i < LIs_To_Hover.length; i++)
	{
		RemoveSynHover(LIs_To_Hover[i]);
	}
}











function bindBehaviors()
{



 // quit if this function has already been called
 if (arguments.callee.done) return;

 // flag this function so we don't do the same thing twice
 arguments.callee.done = true;

 enableMenuImageRollovers();
}


if (window.addEventListener)
{
 window.addEventListener('load', bindBehaviors, false);

}
else if (window.attachEvent)
{
 window.attachEvent('onload',bindBehaviors);

}
