
window.addEvent('domready', function() {
	// Make sure menu is present
	if ($$('ul.slidingmenu').length < 1) { return; }
	
	$$('ul.slidingmenu a.topl').each(function(a) {
		$(a).addEvent('mouseover', function(e) {
			navCloseAllMenus();
		});
	});
	$$('ul.slidingmenu li ul.sub').each(function (ul) {
		parentLI = $(ul).getParent();
		$(parentLI).addClass('navParent');
		$(parentLI).addEvent('mouseenter', function(e) {
			try {	$(e.target).getNext().addClass('showMenu');		} catch(e) { }
		});
		$(parentLI).addEvent('mouseleave', function(e) {
//			navCloseAllMenus();
			try {
				$(e.target).removeClass('showMenu');
				$(e.target).getNext().removeClass('showMenu');	
			} catch(e) { }
		});
	});
	$$('body').each(function(el) {
		el.addEvent('click', function() { 
			navCloseAllMenus();
		});
	});
});


function navCloseAllMenus() {
	$$('.navOpen').each(function(el) {
		$(el).removeClass('navOpen');
	});
	$$('.showMenu').each(function(el) {
		$(el).removeClass('showMenu');
	});
	
}