(function($) {
 
$(document).ready(function() {


	$(function() {
		// OPACITY OF BUTTON SET TO 50%
		$(".fade").css("opacity","1.0");
				
		// ON MOUSE OVER
		$(".fade").hover(function () {
												  
		// SET OPACITY TO 100%
		$(this).stop().animate({
		opacity: 0.7
		}, "quick");
		},
				
		// ON MOUSE OUT
		function () {
					
		// SET OPACITY BACK TO 50%
		$(this).stop().animate({
		opacity: 1.0
		}, "quick");
		});
		
		$('a').smoothScroll({
			easing: 'easeOutExpo',
			speed: 1000
		});
		
		$('#logo a').jrumble({
			x: 2,
			y: 2,
			rotation: 1
		});
		
		
		function first_time_animation(){
			windoww = $(window).width();
			pos = (windoww / 2) - 128;
			$('.wraphook').hide().delay(5000).fadeIn();
			$('#logo')
				.css({
					left: 		   pos,
				})
				.hide()
				.delay(1000)
				.fadeIn(500)
				.delay(1000)
				.animate(
				{
					left: 0
				},
				1000, 'easeOutBounce');
			$('#menu ul')
				.hide()
				.delay(3500)
				.slideDown(1500, 'easeOutBounce')
			;
			$('#content').hide().delay(5000).fadeIn(1000);
			$('#footer').hide().delay(7000).fadeIn(1000);
			$.cookie('b!', true);
		}
		
		if(!$.cookie('b!')){
			first_time_animation();
		} else {
			seen_it();
		}
		
		function seen_it(){
			$('#content, #aside').hide().delay(500).fadeIn(1000);
			$('#footer').hide().delay(1500).fadeIn(1000);
		}
		
		$(window).scroll(function () { 

			h = $(document).height();
			
			s = $(window).scrollTop();
			w = $(window).height();
			ww = $(window).width();
			
			n = s / h * 100;
			if(ww >=421){
				$("#menu").css({top: Math.round(n*2.8)}); 
   			}
  
    	});
		
		
		$('#logo a').hover(function(){
			$(this).trigger('startRumble');
		}, function(){
			$(this).trigger('stopRumble');
		});
		
		
	});
	
});
	


// End of closure & jquery wraping
})(jQuery);

