	
if(typeof ($.chase) == "undefined") {
    $.chase = Object;
}
/*
-----------------------------------------------------------------------------------------
Gallery class
-----------------------------------------------------------------------------------------
*/


$.chase.Work = {
	
	current: 0,
	target: null,
	scrollSpeed: 800,
	fadeSpeed: 1200,
	numItems: 0,
	easing: 'easeInOutQuad',
	captionOpacity: '0.0',
	imgOpacity: '0.2',
	
	init: function() {
		var c = $.chase.Work;
		
		c.numItems = $('.figure').length;
		
		if(c.numItems > 1) {
			
			$('#navcontainer').append('<ul id="navlist"><li><a class="prev">&lt;</a></li><li><a class="next">&gt;</a></li></ul>');
			
			$('.figure p.caption').not('.figure:nth-child(1) p.caption').css({'opacity':c.captionOpacity});
			$('.figure h2').css({'opacity':'0'});
			//$('.figure h2').not('.figure:nth-child(1) h2').css({'opacity':'0.8'});
			$('.figure h2').css({'opacity':'0.8'});
			$('.figure img').not('.figure:nth-child(1) img').css({'opacity':c.imgOpacity});
			var slider = $('#scrollable').scrollable(
				{keyboard: true
				,speed: c.scrollSpeed
				,easing: c.easing
				,onBeforeSeek: function(evt,index) {
					c.startMove(this.getIndex(),index)
				}
				,onSeek: function() { c.doneMove(this.getIndex()) }
				}
			);
			
		}
		
		
		
	},
	
	startMove: function(i,target) {
		var c = $.chase.Work;
		
		c.current = i;
		c.target = target;
		
		if(c.numItems > c.target ) {
			$('.figure:nth-child(' + (i + 1 ) + ') p.caption').animate({'opacity':c.captionOpacity},c.fadeSpeed);
			$('.figure:nth-child(' + (target + 1) + ') p.caption').animate({'opacity':'1.0'},c.fadeSpeed);
			
			$('.figure:nth-child(' + (i + 1 ) + ') img').animate({'opacity':c.imgOpacity},c.fadeSpeed);
			$('.figure:nth-child(' + (target + 1) + ') img').animate({'opacity':'1.0'},c.fadeSpeed);
			
			$('.figure:nth-child(' + (i + 1 ) + ') h2').animate({'opacity':'0.8'},c.fadeSpeed);
			$('.figure:nth-child(' + (target + 1) + ') h2').not('.figure:nth-child(1) h2').animate({'opacity':'0.0'},c.fadeSpeed-400);
		}
		
	},
	
	
	doneMove: function(i) {
		var c = $.chase.Work;
		
		c. current = i;
		
	}
	
}

$(document).ready(function() {
	
	$.chase.Work.init();
	
});
