// Jason's Hovering Submenu Code
// NEW n-tier menu popup code - 2006-10-06

var jsmLastPop = new Array();
var jsmSrc = new Array();
var jsmHide = new Array();

// utility functions - jason
function get(name) { return byId(name); }
function byId(name) { return document.getElementById(name); }
function addClass(element, classname) { if(element != null) element.className += ' ' + classname; }
function remClass(element, classname) { if(element != null) { while(element.className.indexOf(classname) != -1) { element.className = element.className.replace(classname, ""); } } }
function getRealPosition(element) { /* calculate the absolute position of element relative to all parent elements returns a string containing "left|top|width|height" */ if(element != null) { var x = element.offsetLeft; var y = element.offsetTop; offset = element.offsetParent; while(offset.offsetParent) { x += offset.offsetLeft; y += offset.offsetTop; offset = offset.offsetParent; } var h = element.offsetHeight; var w = element.offsetWidth; } return (x + "|" + y + "|" + w + "|" + h); }

	function hover (src) { addClass(src, 'menu_hover'); }
	function unhover(src) { remClass(src, 'menu_hover'); }

	function pop(src, popup) {
		var max = jsmLastPop.length;
		var current = 0;
		// check if the current menu is a child of a previous menu
		for(i=0;i<max;i++) { if(src.parentNode == jsmLastPop[i]) { current = i+1; break; } }
		if(jsmLastPop[current] != null) { 
			jsmLastPop[current].style.display = 'none';
			unhover(jsmSrc[current]);
		}
		jsmHide[current] = false;
		jsmLastPop[current] = get(popup);
		jsmLastPop[current].style.display = 'block';
		jsmSrc[current] = src;
		hover(src);
	}
	
	function unpop(src, popup) {
		var max = jsmLastPop.length;
		var current = 0;
		// check if the current menu is a child of a previous menu
		for(i=0;i<max;i++) { if(src.parentNode == jsmLastPop[i]) { current = i+1; break; } }
		jsmHide[current] = true;
		setTimeout("hidePop('" + current + "');", 750);
/* 		unhover(src); */
	}
	
	function hidePop(index) {
		if (jsmHide[index]) {
			if (jsmLastPop[index] != null) {
				jsmLastPop[index].style.display = 'none';
			}
			unhover(jsmSrc[index]);
		}
	}