window.onload=show;

// function that gets all elements from a given class
function getElementsByClass(searchClass) {
	var classElements = new Array();
	
	node = document;
	tag = '*';
	
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	var j = 0;
	for (i = 0; i < elsLen; i++) {
		if (pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}


// function that makes the animation of mouse over menu items. As mouse
// passes over menu items the corresponding submenu appears.
function show_submenu(submenu_id,menu_id){				
	// hide all submenus
	var submenu_items = getElementsByClass('submenu');
	for (i = 0; i < submenu_items.length; i++){
		submenu_items[i].style.display  = "none";
	}
	
	// reset background color of all menus
	var main_menu_items = getElementsByClass('main_menu_item');
	for (i = 0; i < main_menu_items.length; i++){
		main_menu_items[i].style.background  = "none";
	}
	
	// change the background of menu
	document.getElementById(menu_id).style.background  = "rgb(255,0,0)";
	// show the corresponding submenu
	document.getElementById(submenu_id).style.display  = "block";
}


function hide_info_column(element_id){
	document.getElementById(element_id).style.display  = "none";
}

function show(menu_id,submenu_id) {
	var d = document.getElementById(submenu_id);
	
	var submenu_items = getElementsByClass('submenu');
	for (i = 0; i < submenu_items.length; i++){
		submenu_items[i].style.display  = "none";
	}
	if (d) {d.style.display='block';}
	
	menu_item_border(menu_id)
}

// function that shows the correponding content and hides all others
function show_content(content_id) {
	// hide all contents
	var content_items = getElementsByClass('content');
	for (i = 0; i < content_items.length; i++){
		content_items[i].style.display  = "none";
	}
	
	// show corresponding content
	document.getElementById(content_id).style.display = "block";				
}

// function that shows border around a menu item with id id and hides the borders of all other menu items
function menu_item_border(id) {
	var d = document.getElementById(id);
	
	var menu_items = getElementsByClass('menu_item');
	for (i = 0; i < menu_items.length; i++){
		menu_items[i].style.borderRight='0px solid rgb(0,0,0)';
		menu_items[i].style.borderBottom='0px solid rgb(0,0,0)';
	}
	
	d.style.borderRight='1px solid rgb(0,0,0)';
	d.style.borderBottom='1px solid rgb(0,0,0)';
}