/*
*	Copyright Tell Ltd 06/2005
*
*	
*/

/*
*	Event handlers
*/
function mouseover_handler(e){

	var src = window.event ? e.srcElement : e.target;
	
	while( src && !src._menuActionHandler) src = src.parentNode;
	
	if(src){
		// First, change the class
//		if( src.className != 'XA' )
//			src.className = src.className.substring(0,src.className.length - 1) + "B";
	
		// OK, next we do the show/hide up and down the id hierarchy as appropriate
		var sName = src.id;
		for(var i=0;i<window._menuActionHandlers.length;i++){
		
			var oNode = window._menuActionHandlers[i];
			if( oNode.className != 'XA' ){
				var bIsB = false;
			
		
				// Test if this is a parent element
					
				if( oNode.id == sName ){
					bIsB = true;
				}else if( oNode.id + ":" == sName.substring(0, oNode.id.length + 1) ){
					bIsB = true;
				}else{
			
					// If this node is a direct child we also show it
					if(oNode.id.substring(0,sName.length + 1) == sName + ":"){
						var sTail = oNode.id.substring(sName.length+1);
						bIsB = sTail && sTail.indexOf(":") < 0;
					}
					
				
				}
				
				// Now update the classname
				oNode.className = ( bIsB ?
					oNode.className.substring(0,oNode.className.length - 1) + "B" :
					oNode.className.substring(0,oNode.className.length - 1) + "A");
			}			
		
		}
	}

}





/*
*	Initialisation functions
*/
function init(){
	window._menuActionHandlers = Array();
	_setHandlers(window.document.documentElement);
}


function _setHandlers(oNode){

	try{
	
		if(oNode.className && oNode.className.substring(oNode.className.length-1,oNode.className.length) == "A" ){
			oNode.onmouseover = function(e){ mouseover_handler(e ? e : event) };
			oNode._menuActionHandler = true;
			window._menuActionHandlers[window._menuActionHandlers.length] = oNode;
		}
	
		for(var i=0;i<oNode.childNodes.length;i++){
			_setHandlers(oNode.childNodes[i]);
		}
	}catch(e){}

}

window.onload = init;
