/** 
 * Setup for the Menu and banner
 * Requires jQuery, innerFade, easing
 * Author: Joel Pittet
 * Setup jQuery
 */
(function($){
	$(function(){
		
    // Fade in banner image
    $('#banner img').css({opacity:0}).delay(500).animate({opacity:1, duration:1500});
    
    // Run Cycle
    $('#banners').innerfade({
      speed: 1000,
      timeout: 6000,
      type: 'random',
      containerheight: '198px'
    });

		
		$("#navigation>ul li.expanded ul").each(function(i, el){
			$(this).data('originalHeight', $(this).height());
			$(this).css('width', $(this).width());
		})
		$("#navigation>ul li.expanded ul").css({height: '0px'});
		$("#navigation>ul li.expanded").hover(
			function () {
				$(this).addClass("hover");
				$(this).children('ul').eq(0)
					.css({visibility: 'visible', zIndex: 1000})
					.stop()
					.animate({
				  	  height: $(this).children('ul').eq(0).data('originalHeight') + 'px'
					  }, {queue:false, duration:500, easing: 'easeOutSine'});
			
			}, function() {
				$(this);
				$(this).delay(200)
					.removeClass("hover")
					.children('ul').eq(0)
					.css({zIndex: 999})
					.stop()
					.animate({
						height: '0px'
						},{
							queue:false, 
							duration:300, 
							easing: 'easeInSine',
							complete: function() {
								$(this).css({visibility: 'hidden'});
							}
						}
					);
			
			}
		);
	
	});
})(jQuery);
