<!--

// ==========================================================================================================
// submenu functions 
// ==========================================================================================================

// ----------------------------------------------------------------------------------------------------------
function toggleSubMenu( id )
{
	// if the element at id is showing, hide it
	if( document.getElementById( id ).style.display == "block" )
	{
		document.getElementById( id ).style.display = "none";
	}
	// if the element at id is hidden, show it
	else
	{
		document.getElementById( id ).style.display = "block";
	}
}



// ==========================================================================================================
// rollover functions 
// ==========================================================================================================

// global variables
var interval;										// timing variable (so that the timer can be cleared)
var steps = 30;									// 30 steps for fading
var timeBuffer = 1200 / steps;  // seconds for fading out
var items = new Array();				// array for items that will be fading

// ----------------------------------------------------------------------------------------------------------
function subRollOver( id )
{
	var found = false;
	var i;

	// if the item already exists in the items array, set its time properity to -2 (stop fading)
	for( i = 0; i < items.length; i++ )
	{
		if( items[i].id == id )
		{
			found = true;
			items[i].time = -2;
			break;
		}
	}
	
	// if the item doesn't exist in the items array, create the item in the array
	if( found == false )
	{
		tempItem = new Object();
		tempItem.id = id;
		tempItem.time = -2;
		tempItem.type = "sub";
	
		items.push( tempItem );
	}
	// sets the item's class
	document.getElementById( id ).className = "subMenuOver";
}

// ---------------------------------------------------------------------------------------
function subRollOut( id )
{
	// time-stamp is generated at the time this function is called
	var Stamp = new Date();
	var Time = Stamp.getHours() * 3600 * 1000 + Stamp.getMinutes() * 60 * 1000 + Stamp.getSeconds() * 1000 + Stamp.getMilliseconds();


	// find the item in the array and set its time property to the time-stamp from above
	var i;
	for( i = 0; i < items.length; i++ )
	{
		if( items[i].id == id )
		{
			items[i].time = Time;
			resetTimeout();
			break;
		}
	}

}

// ---------------------------------------------------------------------------------------
function mainRollOver( id )
{
	var found = false;
	var i;

	// if the item already exists in the items array, set its time properity to -2 (stop fading)
	for( i = 0; i < items.length; i++ )
	{
		if( items[i].id == id )
		{
			found = true;
			items[i].time = -2;
			break;
		}
	}
	
	// if the item doesn't exist in the items array, create the item in the array
	if( found == false )
	{
		tempItem = new Object();
		tempItem.id = id;
		tempItem.time = -2;
		tempItem.type = "main";
	
		items.push( tempItem );
	}

	// set the item's class
	document.getElementById( id ).className = "mainMenuOver";
}

// ---------------------------------------------------------------------------------------
function mainRollOut( id )
{

	// time-stamp is generated at the time this function is called
	var Stamp = new Date();
	var Time = Stamp.getHours() * 3600 * 1000 + Stamp.getMinutes() * 60 * 1000 + Stamp.getSeconds() * 1000 + Stamp.getMilliseconds();
	
	// find the item in the array and set its time property to the time-stamp from above
	var i;
	for( i = 0; i < items.length; i++ )
	{
		if( items[i].id == id )
		{
			items[i].time = Time;
			resetTimeout();
			break;
		}
	}
}

// ---------------------------------------------------------------------------------------
function resetTimeout()
{
	// resets the timer to call the function executeTimer() every 5 ms
	clearTimeout( interval );
	interval = setTimeout( 'executeTimer()', 5 );
}

// ---------------------------------------------------------------------------------------
function executeTimer() 
{
	// time-stamp is generated at the time this function is called
	var Stamp = new Date();
	var Time = Stamp.getHours() * 3600 * 1000 + Stamp.getMinutes() * 60 * 1000 + Stamp.getSeconds() * 1000 + Stamp.getMilliseconds();

	var stepTime = 0;
	var classname = "";
	var done = true;
	var out = "";
	

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

		// set the current item's class accordingly if the mouse is currently rolling over it
		if( items[i].time == -2 )
		{
			classname = items[i].type + "MenuOver";
			document.getElementById( items[i].id ).className = classname;
		}

		// set the current item's class accordingly if total fade time has elapsed
		else if( items[i].time == -1 )
		{
			classname = items[i].type + "MenuOut";
			document.getElementById( items[i].id ).className = classname;
		}
		
		// set the current item's class according to what step the fade is on
		else
		{
			var j;
			for( j = 1; j <= steps; j++ )
			{
				stepTime = j * timeBuffer;
	
				if( ( Time - items[i].time ) < stepTime )
				{
					done = false;
					classname = items[i].type + "FadeOut" + j;
					document.getElementById( items[i].id ).className = classname;
					break;
				} 
			}

			if( done == true )
			{
				items[i].time = -1;
			}
		}//else
	}//for
	

	// if elements still need to fade, resetTimeout is called again
	if( done == false )
	{
		resetTimeout();
	}
}

//-->
