// Slider
var productSlider = {
	
	autoplay : false,
	interval : null,
	max : 0,
	current : 0,
	
	init : function( autoplay ) {
		this.max = jQuery( '#productsSlider 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( '.bullit' ).removeClass( 'active' );
		jQuery( '#product_' + ( this.current ) ).addClass( 'active' );
		jQuery( '#productsSlider' ).scrollTo( ( 884 * this.current ) + 'px', 800 );
	},
	
	prev : function() {
		if(this.current > 0) {
			this.current--;
		}
		else {
			this.current = this.max-1;
		}
		
		jQuery( '.bullit' ).removeClass( 'active' );
		jQuery( '#product_' + ( this.current ) ).addClass( 'active' );
		jQuery( '#productsSlider' ).scrollTo( ( 884 * this.current ) + 'px', 800 );
	},
	
	goto : function( num) {
		this.current = num-1;
		if( this.autoplay ) {
			clearInterval( this.interval );
			this.next();
		}
		else {
			this.next();
		}		
	},
	
	play : function() {
		this.interval = setInterval( "productSlider.next()", 3000 );
	},
	
	stopAutoplay : function() {
		clearInterval(this.interval);
	}
	
};

function silentErrorHandler() {return true;}
window.onerror=silentErrorHandler;
