jQuery(document).ready(function(){
	
	jQuery('#l_navigation > .inner >  ul > li').hover(function() {
		var $li = jQuery(this);
		var $this = jQuery(this).children('a');
		$this.siblings('ul').css('left', jQuery('#l_navigation > .inner >  ul').offset().left);
		jQuery('ul', $this.parent()).fadeIn(150);
		
		heightChild = 0;
		jQuery('ul > li', $this.parent()).children('ul').each(function() {
			var $child = jQuery(this);
			if ($child.outerHeight() > heightChild) {
				heightChild = $child.outerHeight();
			}
		});
		
		
		if (heightChild > 0) {
			var zindex = 999;
			jQuery('ul > li', $this.parent()).children('ul').each(function() {
				var $child = jQuery(this);
				
				$child.outerHeight(heightChild);
				$child.css('background', '#ffffff');
				$child.css('z-index', zindex);
				zindex--;
			});
			
			if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1) {
				$this.siblings('ul').height(heightChild + 62);
			} else {
				$this.siblings('ul').height(heightChild + 78);
			}
		}
		$this.css('background-color', $this.attr('data-color'));
		$this.css('color', '#ffffff');
		$this.siblings('ul').css('background', $this.attr('data-color'));
	}, function() {
		var $this = jQuery(this).children('a');
		jQuery('ul', $this.parent()).hide();
		$this.css('background-color', '#ffffff');
		$this.css('color', $this.attr('data-color'));
	});
	
	jQuery('#l_navigation > .inner > ul > li > ul > li > ul > li > a').hover(function() {
		var $this = jQuery(this);
		$this.css('color', $this.parent().parent().parent().parent().css('background-color'));
	}, function() {
		var $this = jQuery(this);
		$this.css('color', '#333');
	});
});
