/* just a bit of browser sniffing is necessary. */

var ie = (document.all) ? true: false; 

function getElementsByClassName(tagname, classname) {
	/* only execute in 5+ browsers. */
	if (!document.getElementById) return false;
	
	/* get all elements with the tag name tagname. */
	var TagElements = document.getElementsByTagName(tagname);
	
	/* define an array which will hold the elements with the class name classname. */
	var elementsByClassName = new Array();
	
	/* Look at all the elements in TagElements, and find the ones with the class name classname. */
	for (i=0; i<TagElements.length; i++) {
		if (TagElements[i].className == classname) {
			elementsByClassName[elementsByClassName.length] = TagElements[i];
		}
	}
	return elementsByClassName;
}

function changeclassstyle(tagname,classname,styleproperty,newstyle) {
	var tochange = getElementsByClassName(tagname,classname);
	for (k=0; k < tochange.length; k++) {
		eval("tochange[k].style." + styleproperty + " = " + "'" + newstyle + "'");
	}
}

//show or hide an element
function showhide(elem,state) {
	if (ie) 
		document.all[elem].style.visibility = state;
	else 
		document.getElementById(elem).style.visibility = state;
}

// showMenu: first hide all submenu's, then show the configured one.

function meShow(elem) {
	meClTo();
	changeclassstyle('div', 'popup', 'visibility', 'hidden');
	showhide(elem, 'visible');
}

function meClTo() {
	if (window.menuHideMenuTimer) clearTimeout(menuHideMenuTimer);
	window.menuHideMenuTimer = null;
}

function meDoHide() {
	meClTo();
	changeclassstyle('div', 'popup', 'visibility', 'hidden');
}

function meStTo() {
	meClTo();
	window.menuHideMenuTimer = setTimeout("meDoHide()", 1000);
}

function init() {
	window.menuHideMenuTimer = null;
}
