	
if(typeof ($.omar) == "undefined") {
    $.omar = Object;
}
/*
-----------------------------------------------------------------------------------------
Gallery class
-----------------------------------------------------------------------------------------
*/

$.omar.Work = {
	
	current: 0,
	target: null,
	scrollSpeed: 800,
	fadeSpeed: 1200,
	numItems: 0,
	easing: 'easeInOutQuad',
	captionOpacity: '0.0',
	imgOpacity: '0.2',
	
	init: function() {
		var c = $.omar.Work;
		
		c.numItems = $('.cella').length;
		
		if(c.numItems > 1) {
			
			$('#contents').append('<div id="navlist"><a class="prev"></a><a class="next"></a></div>');			
			//$('.cella p.caption').not('.cella:nth-child(1) p.caption').css({'opacity':c.captionOpacity});
			$('.cella h2').css({'opacity':'0'});
			//$('.cella h2').not('.cella:nth-child(1) h2').css({'opacity':'0.8'});
			$('.cella h2').css({'opacity':'0.8'});
			$('.cella img').not('.cella: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 = $.omar.Work;
		
		c.current = i;
		c.target = target;
		
		if(c.numItems > c.target ) {
			/*
			$('.cella:nth-child(' + (i + 1 ) + ') p.caption').animate({'opacity':c.captionOpacity},c.fadeSpeed);
			$('.cella:nth-child(' + (target + 1) + ') p.caption').animate({'opacity':'1.0'},c.fadeSpeed);
			*/
			
			$('.cella:nth-child(' + (i + 1 ) + ') img').animate({'opacity':c.imgOpacity},c.fadeSpeed);
			$('.cella:nth-child(' + (target + 1) + ') img').animate({'opacity':'1.0'},c.fadeSpeed);
			
			$('.cella:nth-child(' + (i + 1 ) + ') h2').animate({'opacity':'0.8'},c.fadeSpeed);
			$('.cella:nth-child(' + (target + 1) + ') h2').not('.cella:nth-child(1) h2').animate({'opacity':'0.0'},c.fadeSpeed-400);
		}
		
	},	
	doneMove: function(i) {
		var c = $.omar.Work;		
		c.current = i;		
	}	
}

$(document).ready(function() {	
	$.omar.Work.init();	
});	
