var imageScrollClass = Class.create();
imageScrollClass.prototype = {
    initialize: function() 
    {
    },
    
    init: function ()
	    {
        var block = $('prd-thumbs');
        
        if ( typeof block == "undefined" || !block ) { return false; }
        
        this.links = block.getElementsBySelector('a');
        this.linksNum = this.links.length;

        this.scrollLeft = 0;
		this.scrollRight = 0;
        
        for (var i=0; i < this.linksNum; i++)
        {
        if ( i < 3 )
        	{
            this.links[i].className = 'visible';
        	}
        else
        	{
        	this.scrollRight = this.scrollRight + 1;
			this.links[i].className = 'hidden';
        	}
        }
        
        
        this.prdNext = $('prd-thumbs-next');
        this.prdPrev = $('prd-thumbs-prev');

		this.prdPrev.className = 'disabled';
		this.prdNext.className = 'disabled';
        
		this.prdPrev.onclick = function() { imageScroll.prev(); return false; }
        this.prdNext.onclick = function() { imageScroll.next(); return false; }
        
        if ( this.linksNum > 3 )
	        {
			this.prdNext.className = 'enabled';
	        }
    	},
    
    next: function()
	    {
    	if ( this.scrollRight < 1 ) { return false; }
    	
        this.scrollLeft = this.scrollLeft + 1;
		this.scrollRight = this.scrollRight - 1;
    	
        for ( var i = 0; i < this.linksNum; i++ )
	        {
	        if ( i >= this.scrollLeft && i < ( this.scrollLeft + 3 ) )
	        	{
	            this.links[i].className = 'visible';
	        	}
	        else
	        	{
				this.links[i].className = 'hidden';
	        	}
	        }
    	
    	if ( this.scrollRight == 0 )
    		{
    		this.prdNext.className = 'disabled';
    		}
   	
   		this.prdPrev.className = 'enabled';
   		
	    },
    
    prev: function()
    	{
    	if ( this.scrollLeft < 1 ) { return false; }
    	
        this.scrollLeft = this.scrollLeft - 1;
		this.scrollRight = this.scrollRight + 1;
    	
        for ( var i = 0; i < this.linksNum; i++ )
	        {
	        if ( i >= this.scrollLeft && i < ( this.scrollLeft + 3 ) )
	        	{
	            this.links[i].className = 'visible';
	        	}
	        else
	        	{
				this.links[i].className = 'hidden';
	        	}
	        }
    	
    	if ( this.scrollLeft == 0 )
    		{
    		this.prdPrev.className = 'disabled';
    		}
   	
   		this.prdNext.className = 'enabled';
   		
	    }
	}

var imageScroll = new imageScrollClass();
imageScroll.init();


function ooze( elem ) 
	{
	alert( elem.offsetWidth );
	}

