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


var Slideshow = {
	
	current : 0,
	time : 5000,
	steps : 980,
	items : 0,
	element : '',
	autoplay : true,
	interval : null,
	
	init : function( el ) {
		this.element 	= $( el );
		this.items 		= $( el + ' .item' ).length;
	},
	
	next : function()
	{
		if( this.current+1 < this.items ) {
			this.current++;			
		}
		else {
			this.current = 0;
		}
		
		return this.animate( Math.round( this.current * this.steps ) );
	},
	
	prev : function()
	{
		if( this.current > 0 )
		{
			this.current--;
		}
		else
		{
			this.current = this.items-1;
		}
		
		this.animate( Math.round( this.current * this.steps ) );
	},
	
	animate : function( xPos ) {
		this.element.scrollTo( xPos + 'px', 1000 );
		return true;
	},
	
	play : function()
	{
		this.interval = setInterval( 'Slideshow.next()', this.time );
	},
	
	stop : function()
	{
		this.interval = null;
	}
};
