/**
 * used as vertical slider on product detail view, 
 * iff data is generated from prudsys recommendation engine
 */
prudsysSlider = Class.create({
    initialize:function(page, amount, id) {
        this.pageSize	= 4;						       // number of results per page
        this.id			= id;
        this.page		= page;							   // current page number
        this.pageMax	= Math.ceil(amount/this.pageSize)-1; // max page number retrieved
        
        this.displayItems();
        this.initObservation();
    },
    
    initObservation:function() {
    	$(this.id).down('.navigation .navLeft').observe('click', this.moveLeft.bind(this));
    	$(this.id).down('.navigation .navRight').observe('click', this.moveRight.bind(this));
    },
    
    displayItems:function() {
    	//: hide all items
    	$(this.id).select('li.item').each(function(obj){
    		$(obj).removeClassName('show');
    	});
    	
    	//: display the current page
    	var from = this.pageSize * this.page;
    	var to   = from + this.pageSize;
    	$(this.id).select('li.item').each(function(obj,key){
    		if (key >= from && key < to) $(obj).addClassName('show');
    	});
    },
    
    moveLeft:function() {
    	if (this.page == 0) return ;
    	this.page--;
    	this.displayItems();
    },
    
    moveRight:function() {
    	if (this.page >= this.pageMax) return ;
    	this.page++;
    	this.displayItems();
    }
});
