/*
# ------------------------------------------------------------------------
# JA Megamenu module for Joomla 1.5
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license - PHP files are GNU/GPL V2. CSS / JS are Copyrighted Commercial,
# bound by Proprietary License of JoomlArt. For details on licensing, 
# Please Read Terms of Use at http://www.joomlart.com/terms_of_use.html.
# Author: JoomlArt.com
# Websites:  http://www.joomlart.com -  http://www.joomlancers.com
# Redistribution, Modification or Re-licensing of this file in part of full, 
# is bound by the License applied. 
# ------------------------------------------------------------------------
*/ 

window.addEvent ('domready', function() {
	var sfEls = $$('ul.ja-megamenu li');
	sfEls.each (function(li){
		li.addEvent('mouseenter', function(e) {
			clearTimeout(this.timer);
			jaMegaHoverOutOther (this);
			if(this.className.indexOf(" over") == -1)
				this.className+=" over";
		});
		li.addEvent('mouseleave', function(e) {
			this.timer = setTimeout(jaMegaHoverOut.bind(this, e), 1000);
		});
	});
	function jaMegaHoverOut(e) {
		clearTimeout(this.timer);
		this.className=this.className.replace(new RegExp(" over\\b"), "");
	}
	function jaMegaHoverOutOther(el) {
		sfEls.each (function(li) {
			if (li != el)
				li.className = li.className.replace(new RegExp(
								" over\\b"), "");
				});
	}
});
