function VerticalInfiniteScroller(containerId,normalSlideSpeed,buttonSlideSpeed,delay,div_size)
{
	//this.slideTimeBetweenSteps = 30;	// General speed variable (Lower = slower)
	
	var scrollingContainer = document.getElementById(containerId);
	scrollingContainer.vertical_infinite_scroller=this;
	var scrollingContent = scrollingContainer.getElementsByTagName('DIV')[0];
		
	scrollingContainer.style.position = 'relative';
	scrollingContainer.style.overflow = 'hidden';
	scrollingContent.style.position = 'relative';
	scrollingContent.style.top = '0px';
	
	this.slidelock=0;
	this.autoslidelock=0;
	
	this.products=new Array();
	var content=scrollingContent.getElementsByTagName('DIV');
	for (var i=0; i<content.length; i++)
	{
		if (content[i].className=='element_div')
		{
			this.products.push(content[i]);
			content[i].style.position = 'relative';
			content[i].style.height = div_size + 'px';
		}
	}
	
	var ctop=0;		
	/*
	for (var i=0; i< this.products.length; i++)
		{
			cleft+=this.products[i].offsetWidth;
		}
	*/
	ctop=this.products.length * div_size;
	//scrollingContent.style.width = ctop+'px';

	
	this.containerId=containerId;
	this.objRef = scrollingContent;
	this.contentHeight = scrollingContent.offsetHeight;
	this.containerHeight = scrollingContainer.clientHeight;
	this.slideSpeed = normalSlideSpeed;
	this.originalSlideSpeed = normalSlideSpeed;
	this.buttonSlideSpeed = buttonSlideSpeed;
	this.divSize=div_size;
	this.delay=delay;
	this.autosliding=false;
	this.currentProductIndex=0;
	
	if (this.products.length < 2 || this.containerHeight >= this.contentHeight)
	{
		this.originalSlideSpeed=0;
		this.buttonSlideSpeed=0;
		this.slideSpeed=0;
	}
	else
	{
		this.autoSlideStart();
	}
}

VerticalInfiniteScroller.prototype.autoSlideStart = function()
{
	this.autosliding=true;
	
	this.autoslidelock++;
	
	if (this.autoslidelock == 1 && this.delay > 0)
	{
		setTimeout('document.getElementById("'+this.containerId+'").vertical_infinite_scroller.autoSlideContinue()',this.delay*1000);
	}
	else
	{
		this.autoslidelock--;
	}
}

VerticalInfiniteScroller.prototype.autoSlideStop = function()
{
	this.autosliding=false;
}

VerticalInfiniteScroller.prototype.autoSlideContinue = function()
{
	this.autoslidelock--;

	if (this.autosliding)
	{
		this.restartSliding(-1,true);
	}
}

VerticalInfiniteScroller.prototype.slideContent = function()
	{
		if (this.slidelock ==0)

		{
		this.slidelock++;
		
		var topPos = this.objRef.style.top.replace(/[^\-0-9]/g,'');
		topPos = topPos - this.slideSpeed;
		var reordered=false;
		
		if (this.slideSpeed != 0)
		{
		
		while (topPos < -this.products[this.currentProductIndex].offsetHeight)
		{
			topPos+=this.products[this.currentProductIndex].offsetHeight;
			this.currentProductIndex++;
			
			if (this.currentProductIndex >= this.products.length)
			{
				this.currentProductIndex=0;
			}
			
			reordered=true;
		}
		
		while (topPos > 0)
		{
			topPos-=this.products[this.currentProductIndex].offsetHeight;
			this.currentProductIndex--;
			
			if (this.currentProductIndex < 0)
			{
				this.currentProductIndex=this.products.length-1;
			}
			
			reordered=true;
		}
		
		}
		
		if (reordered)
		{
			var ctop=0;
			var cbottom=0;
			
			for (var i=0; i< this.products.length; i++)
			{
				if (i < this.currentProductIndex)
				{
					ctop+=this.products[i].offsetHeight;
				}
				else
				{
					cbottom+=this.products[i].offsetHeight;
				}
			}
			
			var ctotal=ctop+cbottom;
			ctop=ctop%ctotal;
			cbottom=cbottom%ctotal;
			
			for (var i=0; i< this.products.length; i++)
			{
				if (i >= this.currentProductIndex)
				{
					this.products[i].style.top=(-ctop)+'px';
				}
				else
				{
					this.products[i].style.top=cbottom+'px';
				}
			}
			
		}
		
		if (this.autosliding && reordered)
		{
			topPos=0;
			this.stopSliding();
		}
		
		if(topPos/1 + this.contentHeight/1<0 && this.slideSpeed != 0)
		{
			topPos = this.containerHeight;
			
		}
		this.objRef.style.top = topPos + 'px';

		if (this.slideSpeed != 0)
		{
			var cdelay=this.buttonSlideSpeed;
			if (this.autosliding)
			{
				cdelay=this.normalSlideSpeed;
			}
			setTimeout('document.getElementById("'+this.containerId+'").vertical_infinite_scroller.slideContinue()',cdelay);
		}
		else
		{
			this.slidelock--;
		}
		}
	}
	
VerticalInfiniteScroller.prototype.slideContinue = function()
{

	this.slidelock--;
	this.slideContent();

}
	
VerticalInfiniteScroller.prototype.stopSliding = function()
	{
		this.slideSpeed = 0;
		this.autoSlideStart();
	}
	
VerticalInfiniteScroller.prototype.mouseStopSliding = function()
    {
        this.slideSpeed = 0;
        this.autoSlideStop();
    }

	
VerticalInfiniteScroller.prototype.restartSliding = function(direction,autospeed)
	{
		if (this.products.length > 1)
		{
			this.slideSpeed = -direction * this.originalSlideSpeed; //this.divSize;
			this.slideContent();
		}
	}
	
VerticalInfiniteScroller.prototype.startSliding = function(direction)
	{
		this.autoSlideStop();
		this.restartSliding(direction);
	}
