$(function() {
	
	var activeSubeMenu = null;
	
	if( $("body").hasClass("site-home") ) {
		$.getJSON("season.php",function(data) {
			$(".season-image").show().css({
				"background-image": "url('"+data[0]+"')"
			});
		});
	}
	
	/*$(".image-line .image").css("opacity","0.25").reflect();*/
	$("body").addClass("js-active").removeClass("js-not-active");
	$(".main-menu > ul > li").each( function( key ) {
		var list = $("> .submenu", this);
	
		list.data("id", key );
				
		if( list.length > 0 ) {
			//$("> a",this).click(function(event ) { event.preventDefault() });
			if( !$(this).hasClass("active") ) {
				list.hide();
			} else {
				activeSubeMenu = list;
			}
			$(this).mouseenter(function() {
				$(this).addClass("hover");
				if( activeSubeMenu && activeSubeMenu.data("id") != $(list).data("id") ) {
					 activeSubeMenu.hide();
				}
				list.fadeIn(400);
				/* @todo if a hide timer is set then clear it hide the current visible menu and show this one */
			});
			
			$(this).mouseleave(function() {
				$(this).removeClass("hover");
				if( activeSubeMenu ) {
					if( activeSubeMenu.data("id") != $(list).data("id") ) {
						list.hide();
					}
				} else {
					list.hide();
				}
				if( activeSubeMenu ) {
					 activeSubeMenu.fadeIn(400);
				}
				/* @todo set at time to hide this menu point and display the original if they are there */
			});
		}
		
	});
});
