/* var number_object = 0;  //old debug variable
var timer_object; */       //old debug varialbe
var t;                     //variable to hold setTimeout object for clearing
timer = new collector();   //creates a new collector object for controlling the smart hide and show functions

// initialization function that should be set to called when the document loads
function init_menu(){
	if (navigator.appName == "Opera") {
		document.getElementsByClassName('sub_menu_container').style.cssfloat = 'right'; //needed for opera 
	}
}
//optional function for changing background and text colors on mousever 
function rollover_menu(var_id, var_color) 
{	
	document.getElementById(var_id).style.backgroundColor = var_color;
	document.getElementById(var_id).style.cursor = 'pointer'; //changes cursor to 'pointer' when moused over
}
//optional function for changing background and text colors on mouseout
function rollout_menu(var_id, var_color)
{
	document.getElementById(var_id).style.backgroundColor = var_color;		
}
//takes an id and sets its visibility to 'hidden' after 3 seconds
function smartHide(var_id){ 
	/*if (var_id == 'menu') {
		counter();  old debug function call
		document.getElementById('top_menu_box').style.backgroundColor = '#f00'; old debug expresion
	} */

	clearTimeout(t); //stops the timeout previously set during smartHide();
	var item = "document.getElementById('" + var_id + "').style.visibility = 'hidden'"; //creates a variable 'item' to add to the collector object to hide the id passed to smartHide
	timer.addItem(item); //adds the expresion to hide the passed varialble to the collector object
	t = setTimeout("timer.run();", 1500);
											 //sets a timer to execute any expresion in the timer object after a set number of miliseconds
}
//takes an id and sets is visibility to 'hidden'
function Hide(var_id){
	clearInterval(t); 																	//stops the timeout previously set during smartHide();
	document.getElementById(var_id).style.visibility = 'hidden';						//sets the var_id visibility to 'hidden'
}
//takes an id and sets its visibility to 'visible' after clearing the timer object and removing all items from the collector object
function smartShow(var_id){ 
	// clearInterval(timer_object); */ //old debug function call 
	clear();														//removes all items from the collector object
	Show(var_id);																		//calls the Show fucntion
}
//takes an id and changes the visibility to 'visible'
function Show(var_id){ 
	document.getElementById(var_id).style.visibility = 'visible';
} 
//takes an id equal to element that should stay visible, and hides all other "main_menu_container" class objects, used for mousing over another main menu before 3 seconds
function clearVisible(var_id){
	clear_sub_menu();
	var myarray = new Array;											//prototype methods to get an array of all elements
	myarray = document.getElementsByClassName('main_menu_container');	//with the class "main_menu_container
	for (i = 0; i < myarray.length; i++) {								//sets all items in the array to hidden
		myarray[i].style.visibility = 'hidden';							
	}
	Show(var_id);														//displays the correct element
}
function clear(){
	timer.flush();
	clearTimeout(t);
}
function smartClear(var_id){
	if(timer.stack[0].style.visibility = 'hidden'){
		
	}
	else{
		clear();
	}
}
function clear_sub_menu(var_id){
	myarray = new Array;
	myarray = document.getElementsByClassName('sub_menu_container_ul');
	for (i = 0; i < myarray.length; i++) {	
		myarray[i].style.visibility = 'hidden';
	}
}
/*  old debug functions
function counter(){
	number_object = 0;
	timer_object = setInterval("increase();", 1000);
}
function increase(){ 
		if(document.getElementById('menu').style.visibility == 'hidden'){
		document.getElementById('top_menu_box').style.backgroundColor = '#000';
		clearInterval(timer_object);
		return
	}
	number_object++;
	document.getElementById('top_menu_number').innerHTML = number_object;
	
}
*/