Event.observe($('products-menu'),"mouseover",function(event){

	/* Get the element from where event is generated*/
	var elt = $(Event.element(event)); 
	
	/*Be sure that it under our unordered list*/
	if (elt && elt.descendantOf($('products-menu')) && elt.nodeName=='LI'){
		
		/*Stop the bubling of the event */
		Event.stop(event);
		
		/*	Get the child elements of the already expanded menu,
			which is not parent of currently selected menu or a child of it */
		var its=$$('.selected_item').findAll(function(e){
			return !elt.descendantOf(e) && !e.descendantOf(elt) && e!=elt
		});
		
		/*Add this special tracking class name*/
		elt.addClassName("selected_item"); 							

		/*Hide them all*/
		its.each(function(e){e.select("ul").invoke('hide')});
		
		/*remove the tracker class off them  them all*/
		its.invoke("removeClassName","selected_item");
		
		/*Collect the UL i.e child menu container  and display them*/
		var ul=elt.childElements().find(function(e){return e.nodeName=='UL';});
		if (ul) {
			ul.setStyle({"display":"block"});					
		}	
	}		
});

Event.observe($('company-menu'),"mouseover",function(event){

	/* Get the element from where event is generated*/
	var elt = $(Event.element(event)); 
	
	/*Be sure that it under our unordered list*/
	if (elt && elt.descendantOf($('company-menu')) && elt.nodeName=='LI'){
		
		/*Stop the bubling of the event */
		Event.stop(event);
		
		/*	Get the child elements of the already expanded menu,
			which is not parent of currently selected menu or a child of it */
		var its=$$('.selected_item').findAll(function(e){
			return !elt.descendantOf(e) && !e.descendantOf(elt) && e!=elt
		});
		
		/*Add this special tracking class name*/
		elt.addClassName("selected_item"); 							

		/*Hide them all*/
		its.each(function(e){e.select("ul").invoke('hide')});
		
		/*remove the tracker class off them  them all*/
		its.invoke("removeClassName","selected_item");
		
		/*Collect the UL i.e child menu container  and display them*/
		var ul=elt.childElements().find(function(e){return e.nodeName=='UL';});
		if (ul) {
			ul.setStyle({"display":"block"});					
		}	
	}		
});