// Easing equation, borrowed from jQuery easing plugin
// http://gsgd.co.uk/sandbox/jquery/easing/
jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

jQuery(function( $ ){


	var $pane = $('.scrollbox');
	var $prev = $('.prev');
	var $next = $('.next');
	


	$pane.serialScroll({
		items:'li',
		prev:$prev,
		next:$next,
		offset:-50, //when scrolling to photo, stop 230 before reaching it (from the left)
		start:0, //as we are centering it, start at the 2nd
		duration:600,
		force:true,
		stop:true,
		lock:false,
		cycle:false, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: false //click on the images to scroll to them
	});
	
	
	/* mousewheel */
	
	$('body').mousewheel(function(event, delta) {
										 
		if (delta < 0){
		$pane.trigger('next');       
		}else if (delta > 0){
		$pane.trigger('prev');
		}
		});
		
	/* extras */
	
		$('.content li').hide();
		$(window).bind('load', function() {
	 	var i = 1;
	 	var imgs = $('.content li').length;
	 	var int = setInterval(function() {
		//console.log(i); check to make sure interval properly stops
		if(i >= imgs) clearInterval(int);
		$('.content li:hidden').eq(0).fadeIn(400);
		 i++;
	 	}, 100);
		});
		
		var imageLi = $('.content li.project > div.imageWrap img');
		var imageLiHide = $('.content li.project > div.imageWrap img:hidden');
		
		$(imageLi).hide();
		$(window).bind('load', function() {
	 	var i = 1;
	 	var imgs = $(imageLi).length;
	 	var int = setInterval(function() {
		//console.log(i); check to make sure interval properly stops
		if(i >= imgs) clearInterval(int);
		$('.content li.project > div.imageWrap img:hidden').eq(0).fadeIn(400);
		 i++;
	 	}, 200);
		});
		
		
		
		
		$(".content li").hover(function(){
		$(this).animate({marginRight:'10px',marginLeft:'10px',borderLeft:'1px solid #000',paddingLeft:'10px'},'fast');
		}, function() {
		$(this).animate({ marginRight:'0px',marginLeft:'0px',borderLeft:'0',paddingLeft:'0px'},'fast');
		});	
		
		$(".content li").click(function(){
		window.location=$(this).find("a").attr("href");
     	return false;
		});
		
		
	
});
