





// GLOBAL VARIABLES TO STORE ALL MENU ITEM INFO THAT IS PERTINENT:
var all_menu_items_ids = new Array();
var all_menu_items = new Array();
var all_menu_layers = new Array();



// MENU ITEM CLASS:
function menu_item(id, has_children, default_img, over_img, default_bound_img, over_bound_img, default_bg_class, over_bg_class)
{
	this.id = id;
	this.has_children = has_children;
	this.default_img = default_img;
	this.over_img = over_img;
	this.default_bound_img = default_bound_img;
	this.over_bound_img = over_bound_img;
	this.default_bg_class = default_bg_class;
	this.over_bg_class = over_bg_class;
}



// MENU LAYER CLASS:
function menu_layer(id, mother_menu_id)
{
	this.id = id;
	this.mother_menu_id = mother_menu_id;
}




// FUNCTION TO SWAP IMAGE FOR A PARTICULAR MENU ITEM ID:
function change_img(id, which_one)
{
		document.getElementById(id).src = (which_one == 'over') ? (all_menu_items[id].over_img) : (all_menu_items[id].default_img); 
		document.getElementById(id+'_cell').className = (which_one == 'over') ? (all_menu_items[id].over_bg_class) : (all_menu_items[id].default_bg_class); 
		document.getElementById(id+'_left').src = (which_one == 'over') ? (all_menu_items[id].over_bound_img) : (all_menu_items[id].default_bound_img) ; 
		document.getElementById(id+'_right').src = (which_one == 'over') ? (all_menu_items[id].over_bound_img) : (all_menu_items[id].default_bound_img) ; 
}


// FUNCTION TO SHOW OR HIDE A LAYER GIVEN ITS ID:
function show_hide_menu(id, value)
{
	document.getElementById(id).style.visibility = value;	
}


// FUNCTION TO SHOW OR HIDE ALL PARENT LAYERS OF A GIVEN IN A MENU LAYER TREE:
function show_hide_all_parents(id, value)
{
	var which_one = (value == 'visible')? 'over':'default';
	change_img(id.replace('_menu_layer', ''), which_one);
	document.getElementById(id).style.visibility = value;
	var cur_layer_id = all_menu_layers[id].mother_menu_id;
	while(cur_layer_id)
	{
		change_img(cur_layer_id.replace('_menu_layer', ''), which_one);
		document.getElementById(cur_layer_id).style.visibility = value;
		cur_layer_id = all_menu_layers[cur_layer_id].mother_menu_id;
	}
}




// FUNCTION TO SET THE POSITIONS OF NAV SUB MENUS:
function setNavPositions()
{
	var id;
	var H_V;
	for (var i=0; i < all_menu_items_ids.length; i++)
	{
		id = all_menu_items_ids[i];
		if(all_menu_items[id].has_children)
		{
			H_V = 'VERT';
			if(!(all_menu_layers[id + '_menu_layer'].mother_menu_id) && (horiz_or_vert == 'HORIZ')) H_V = 'HORIZ';
			setNavHeaderMenus(id, id+'_menu_layer', H_V);
		}
	}
}

