$(document).ready(function() {

	var browserHeight = $(window).height();
		browserWidth = $(window).width();
		prevButton = $('.prev');
		nextButton = $('.next');
		images = $('.backgroundimage img');
		art = $('.art img');
		imagesWidth = images.width();
		imagesHeight = images.height();
		activeImg = 0;
		prevActiveImg = 0;
		dotMatrix = $('.dot-matrix');
		logo = $('#header h1');
		about = $('.about');
		
	
	images.css({"width":browserWidth, "height":browserHeight })
	art.css({"width":browserWidth, "height":browserHeight })

	
	
	function resetGallery() {
		images = $('.backgroundimage img');
		images.css({"width":browserWidth, "height":browserHeight});
		activeImg = 0;
		prevActiveImg = 0;
		$('.backgroundimage img:first').fadeIn(500);
	}
	
	$(window).resize(function() {
		browserWidth = $(window).width();
		browserHeight = $(window).height();
		images.css({"width":browserWidth, "height":browserHeight});
		art.css({"width":browserWidth, "height":browserHeight});
	
	})

	
//Add Handlers
	nextButton.click(function() {
		swapImage('next');
	});
	prevButton.click(function() {
		swapImage('prev');
	})
	
//Actual Swaps
	function swapImage(direction) {
		//save the previous image location
		prevActiveImg = activeImg;
		
		//determine direction and set image index values
        if(direction == "next") {
            activeImg++
            if(activeImg == images.length) {
                activeImg = 0;
            }
        } else if(direction == "prev") {
            activeImg--
            if(activeImg < 0) {
                activeImg = images.length-1;
            }
        } 
	
		//animate the switch
		images.eq(prevActiveImg).fadeOut(300, function() {
			images.eq(activeImg).fadeIn(500);
		});
	}
	
	
//Logo Flip to About
	logo.click(function() {
		$(this).animate({"left":"-150px"}, 100, function() {
			about.animate({"left":0}, 200)
		})
	});
	$('.about .close').click(function() {
		about.animate({"left":"-280px"}, 100, function() {
			logo.animate({"left":0}, 200)
		})
	});
		swapImage('next');
	
});


$(document).ready(function(){

$('#header').hover(function(){
$("#bg-shadow").stop().fadeTo(500, 1);
},function() {
$("#bg-shadow").stop().fadeTo(500, 0);
});

 $('#nav ul li').hover(function() {
$(this).addClass("active");
$(this).find('ul').stop(false, true).slideDown();
},function() {
$(this).removeClass("active");        
$(this).find('ul').stop(false, true).slideUp('fast');
});

 $(window).load(function(){
$("#preloader").fadeOut(500,function(){$(this).remove();});

});


$(".pattern-1").animate({right:'-173px', top:"-104px"},{ duration:2000, easing: 'easeInOutCubic'});
$(".pattern-2").delay(300).animate({right:'-193px', top:"-198px"},{ duration:2000, easing: 'easeInOutCubic'});
$(".pattern-3").delay(600).animate({right:'-116px', top:"-147px"},{ duration:2000, easing: 'easeInOutCubic'});
$(".pattern-4").delay(900).animate({right:'56px', top:"-18px"},{ duration:2000, easing: 'easeInOutCubic'});
$(".pattern-5").delay(1200).animate({right:'40px', top:"-140px"},{ duration:2000, easing: 'easeInOutCubic'});
$(".pattern-6").delay(1500).animate({right:'110px', top:"0"},{ duration:2000, easing: 'easeInOutCubic'});
$(".pattern-7").delay(1800).animate({right:'100px', top:"-140px"},{ duration:2000, easing: 'easeInOutCubic'});
$(".pattern-8").delay(2100).animate({right:'160px', top:"-193px"},{ duration:2000, easing: 'easeInOutCubic'});
$(".pattern-9").delay(2400).animate({right:'220px', top:"-60px"},{ duration:2000, easing: 'easeInOutCubic'});

$(window).load(function(){
$("#slogan").delay(2000).animate({left:'-740px'}, { duration:1000, easing: 'easeInOutSine'});
});

 
$("#slogan").mouseover(function(){
	$(this).stop().animate({left:"0px"}, { duration:1000, easing: 'easeOutSine'} );
});
    
$("#slogan").mouseout(function(){
	$(this).stop().animate({left:"-740px"},{ duration:1500, easing: 'easeInSine'} );
}); 
   
});




    


