/* Home page swaps periodically featured product */
NewProductHandler = Class.create();
NewProductHandler.prototype = {
	initialize: function(timer) {
		this.numberfeatured = 2;
	
		this.featuredProducts   = $$('.new-product');	

		this.currentIndex = Math.floor(Math.random()*2); // initialise the product index to display
		
		for (i=0;i<this.numberfeatured;i++) {
			$(this.featuredProducts[i]).hide();
		}
		this.swap();
    	},
	
	swap: function() {
		for (i=0;i<this.numberfeatured;i++) {
			if (this.currentIndex % 2==i) {				
				$(this.featuredProducts[i]).show();
			} else {
				$(this.featuredProducts[i]).hide();
			}	
		} 
		
		this.currentIndex++; 
			
		setTimeout('FeaturedProduct.swap()', 10000); // should not be FeaturedProduct hard-coded but I have not founf the correct way to trigger the event without hard coding
	}
}

