var ScrollerV_h = 250;
var ScrollerH_w = 410;
var timer;
var AllowScroll;

//Set variables for the scrollers
var CategoryProducts = 8; //<< - Amount of products on the bottom
var CategoryProductWidth = 102;

var RelatedProducts = 5; //<< - Amount of related products on the right
var RelatedProductHeight = 102;

var InnerScrollerH_w = CategoryProducts * CategoryProductWidth;
var InnerScrollerV_h = RelatedProducts * RelatedProductHeight ;

//var InnerScrollerV_h = document.getElementById("InnerScrollerV").offsetHeight;
//var InnerScrollerH_w = document.getElementById("InnerScrollerH").offsetWidth;

//ALLOW OR DISABLE SCROLL

//Horizontal
function startScrollLeft()
{
	AllowScroll = 1;
	moveLeft();
}
function startScrollRight()
{
	AllowScroll = 1;
	moveRight();
}
//Vertical
function startScrollUp()
{
	AllowScroll = 1;
	moveUp();
}
function startScrollDown()
{
	AllowScroll = 1;
	moveDown();
}
//Stop
function stopScroller()
{
	AllowScroll = 0;
}



//MOVE H SCROLLER TO THE LEFT
function moveLeft()
{
		var DifferenceH = (InnerScrollerH_w - ScrollerH_w) * (-1);
		var CurrentPosition = document.getElementById("InnerScrollerH").style.left;
		var CurrentPositionH = CurrentPosition.split("px");
		CurrentPositionH = CurrentPositionH.join("");
				
		if(CurrentPositionH > DifferenceH)
		{
			if(AllowScroll == 1)
			{
				$("#InnerScrollerH").animate({"left": "-=10px"}, 1);
				timer=setTimeout("moveLeft()",50);
			}
		}
}
//MOVE H SCROLLER TO THE RIGHT
function moveRight()
{
		var DifferenceH = (InnerScrollerH_w - ScrollerH_w) * (-1);
		var CurrentPosition = document.getElementById("InnerScrollerH").style.left;
		var CurrentPositionH = CurrentPosition.split("px");
		CurrentPositionH = CurrentPositionH.join("");
	
		if(CurrentPositionH < -1)
		{
			if(AllowScroll == 1)
			{
				$("#InnerScrollerH").animate({"left": "+=10px"}, 1);
				timer=setTimeout("moveRight()",50);
			}
		}
}

//MOVE V SCROLLER UP
function moveUp(){
		var DifferenceV = (InnerScrollerV_h - ScrollerV_h) * (-1);
		var CurrentPosition = document.getElementById("InnerScrollerV").style.top;
		var CurrentPositionV = CurrentPosition.split("px");
		CurrentPositionV = CurrentPositionV.join("");
		
		if(CurrentPositionV > DifferenceV)
		{
			if(AllowScroll == 1)
			{
				$("#InnerScrollerV").animate({"top": "-=10px"}, 1);
				timer=setTimeout("moveUp()",50);
			}
		}
}

//MOVE V SCROLLER DOWN
function moveDown(){
		var DifferenceV = (InnerScrollerV_h - ScrollerV_h) * (-1);
		var CurrentPosition = document.getElementById("InnerScrollerV").style.top;
		var CurrentPositionV = CurrentPosition.split("px");
		CurrentPositionV = CurrentPositionV.join("");
		
		if(CurrentPositionV < -1)
		{
			if(AllowScroll == 1)
			{
				$("#InnerScrollerV").animate({"top": "+=10px"}, 1);
				timer=setTimeout("moveDown()",50);
			}
		}
}
