/*
# ------------------------------------------------------------------------
# JA Halite - Version 1.0 - Licence Owner JA130162
# ------------------------------------------------------------------------
# Copyright (C) 2004-2009 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
# @license - Copyrighted Commercial Software
# Author: J.O.O.M Solutions Co., Ltd
# Websites:  http://www.joomlart.com -  http://www.joomlancers.com
# This file may not be redistributed in whole or significant part.
# ------------------------------------------------------------------------
*/ 

window.addEvent ('domready', function() {
	var sfEls = $$('.ja-megamenu li.mega');
	sfEls.each (function(li){
		li.addEvent('mouseenter', function(e) {
				clearTimeout(this.timer);
				jaMegaHoverOutOther (this);
				if(this.className.indexOf("haschild-over") == -1) {
					if (this.hasClass ('haschild')) this.removeClass ('haschild').addClass ('haschild-over');
					else {this.addClass ('over'); }
					if ((a = this.getElement('a.mega')) && this.hasChild (a)) {
						a.addClass ('over');
					}
				}
		});
		li.addEvent('mouseleave', function(e) {
				this.timer = setTimeout(jaMegaHoverOut.bind(this, e), 500);
				if ((a = this.getElement('a.mega')) && this.hasChild (a)) {
					a.removeClass ('over');
				}
		});
	});
	function jaMegaHoverOut(e) {
		clearTimeout(this.timer);
		if (this.hasClass ('haschild-over')) this.removeClass ('haschild-over').addClass ('haschild');
		else this.removeClass ('over');
	}
	function jaMegaHoverOutOther(el) {
		sfEls.each (function(li) {
			if (li != el && !li.hasChild (el)) {
				if (li.hasClass ('haschild-over'))
					li.removeClass ('haschild-over').addClass ('haschild');
				else
					li.removeClass ('over');
				if ((a = li.getElement('a.mega')) && li.hasChild (a)) {
					a.removeClass ('over');
				}
			}
		});
	}
});

function open_list_menu(){ 
	var m_obj = $("menu550").getParent();

	if (m_obj.hasClass ('haschild-over')) 
		m_obj.removeClass ('haschild-over').addClass ('haschild');
	else 
		m_obj.removeClass ('over');
	
	if(m_obj.className.indexOf("haschild-over") == -1) {
		if (m_obj.hasClass ('haschild')) m_obj.removeClass ('haschild').addClass ('haschild-over');
		else {m_obj.addClass ('over'); }
		if ((a = m_obj.getElement('a.mega')) && m_obj.hasChild (a)) {
			a.addClass ('over');
		}
	}
	/*alert("Перечень услуг находиться в пункте меню Услуги");
		document.getElementById('megamenu_id').style.display = "block";
		document.getElementById('megamenu_id_').style.display = "block";
		document.getElementById('megamenu_id__').style.display = "block";
		document.getElementById('megamenu_id___').style.display = "block";
		document.getElementById('menu550').style.color = "red"; */
	return false;
		}
