var headerSlider = {
	
	autoplay : false,
	interval : null,
	max : 0,
	current : 0,
	
	init : function( autoplay ) {
		this.max = jQuery( '#scroller img' ).length;
		
		for( i = 0; i < this.max; i++ ) {
			jQuery( '#numbers' ).append( '<span class="num" id="num_' + ( i+1 ) + '"><a href="javascript:;" onclick="headerSlider.goto( ' + i + ' )">' + ( i+1 ) + '</a></span>' );
			if( i != this.max-1 ) { jQuery( '#numbers' ).append( ' &bull; ' ); }
		}
		
		jQuery( '#num_1 a' ).addClass( 'active' );
		
		if( autoplay ) {
			this.autoplay = true;
			this.play();
		}
	},
	
	next : function() {
		if( this.current >= this.max-1 ) { this.current = -1; }
		this.current++;
		jQuery( '.num a' ).removeClass( 'active' );
		jQuery( '#num_' + ( this.current+1 ) + ' a' ).addClass( 'active' );
		jQuery( '#scroller' ).scrollTo( ( 917 * this.current ) + 'px', 800 );
	},
	
	prev : function() {
		this.current--;
		jQuery( '#scroller' ).scrollTo( '-=917px', 800 );
	},
	
	goto : function( num ) {
		this.current = num-1;
		if( this.autoplay ) {
			clearInterval( this.interval );
			this.play();
			this.next();
		}
		else {
			this.next();
		}		
	},
	
	play : function() {
		this.interval = setInterval( "headerSlider.next()", 4000 );
	}
	
};

var productSlider = {
	
	autoplay : false,
	interval : null,
	max: 0,
	current: 3,
	steps: 213,
	
	init : function( autoplay ) {
		this.max = jQuery( '#products .product' ).length;
	},
	
	next : function() {
		if( this.current < this.max ) {
			this.current++;
			jQuery( '#scroller_y' ).scrollTo( {top: '+=220px', left: 0 }, 800 );
		}
	},
	
	prev : function() {
		this.current--;
		jQuery( '#scroller_y' ).scrollTo( {top: '-=220px', left: 0 }, 800 );
	}
	
	
};
