itemForHide = new Array();
topitemForHide = new Array();

function hideItem() {
    for (var i=itemForHide.length-1; i>=0; i--) {
		if (itemForHide[i] != null) {
		    itemForHide[i].className=itemForHide[i].className.replace(new RegExp("sfhover", 'g'), "");
		    itemForHide[i] = null;
		}
    }
}

function hideTopItem() {
    for (var i=topitemForHide.length-1; i>=0; i--) {
		if (topitemForHide[i] != null) {
		    topitemForHide[i] = null;
		}
    }
}

function showhideHeadermenuItem(obj, key) {
	if (obj) {
		var tel;
		for (i=0; i<obj.childNodes.length; i++) {
			if (obj.childNodes[i].className == 'headermenulidiv') {
				tel = obj.childNodes[i];
				break;
			}
		}
		for (i=0; i<tel.childNodes.length; i++) {
			if (tel.childNodes[i] != null && tel.childNodes[i].id != null && tel.childNodes[i].id != 'undefined') {
				if (tel.childNodes[i].id == 'headermenuspacerleftid')
					tel.childNodes[i].className = (key == '1' ? "headermenuspacerleftact" : "headermenuspacerleft");
				if (tel.childNodes[i].id == 'headermenupositionid')
					tel.childNodes[i].className = (key == '1' ? "headermenupositionact" : "headermenuposition");
				if (tel.childNodes[i].id == 'headermenuspacerrightid')
					tel.childNodes[i].className = (key == '1' ? "headermenuspacerrightact" : "headermenuspacerright");
			}
		}
	}
}

function showhideTopmenuItem(obj, key) {
	if (obj) {
		var tel;
		for (i=0; i<obj.childNodes.length; i++) {
			if (obj.childNodes[i].className == 'topmenulidiv') {
				tel = obj.childNodes[i];
				break;
			}
		}
		for (i=0; i<tel.childNodes.length; i++) {
			if (tel.childNodes[i] != null && tel.childNodes[i].id != null && tel.childNodes[i].id != 'undefined') {
				if (tel.childNodes[i].id == 'topmenuspacerleftid')
					tel.childNodes[i].className = (key == '1' ? "topmenuspacerleftact" : "topmenuspacerleft");
				if (tel.childNodes[i].id == 'topmenupositionid')
					tel.childNodes[i].className = (key == '1' ? "topmenupositionact" : "topmenuposition");
				if (tel.childNodes[i].id == 'topmenuspacerrightid')
					tel.childNodes[i].className = (key == '1' ? "topmenuspacerrightact" : "topmenuspacerright");
			}
		}
	}
}

sfHover = function() {	
	if (document.getElementById("header_menu") == null)
		return;

	var sfEls = document.getElementById("header_menu").getElementsByTagName("LI");	
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			for (var i=topitemForHide.length-1; i>=0; i--) {
			    if (topitemForHide[i] == this)
					topitemForHide[i] = null;				
			}
			showhideHeadermenuItem(this, 1);
		}
		sfEls[i].onmouseout=function() {
			topitemForHide[topitemForHide.length] = this;
		    setTimeout('hideTopItem()', 5);
		    showhideHeadermenuItem(this, 0);
		}
	}

	if (document.getElementById("top_menu") == null)
		return;
		
	var sfEls = document.getElementById("top_menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			for (var i=itemForHide.length-1; i>=0; i--) {
			    if (itemForHide[i] == this)
					itemForHide[i] = null;				
			}
			showhideTopmenuItem(this, 1);
		}
		sfEls[i].onmouseout=function() {
			itemForHide[itemForHide.length] = this;
		    setTimeout('hideItem()', 5);
		    showhideTopmenuItem(this, 0);
		}
	}
}

window.onload = sfHover;
