﻿var Scrolling = false;

function GetLeftScroll(DivTag, ImgScroll)
{
    Scrolling = true;
    setTimeout("ContLeftScroll('" + DivTag + "', '" + ImgScroll + "')",1);
}

function ContLeftScroll(DivTag, ImgScroll)
{

	if(navigator.appName == "Microsoft Internet Explorer")
	{
		$get(DivTag).scrollLeft -= 2;
	}
	else
	{
		$get(DivTag).scrollLeft -= 1;
	}	
     
    if($get(DivTag).scrollLeft <= 0)
    {
		$get("RelatedProdCont").insertBefore($get("RelatedProdCont").childNodes[$get("RelatedProdCont").childNodes.length-1], $get("RelatedProdCont").childNodes[0]);
		$get(DivTag).scrollLeft = $get("RelatedProdCont").childNodes[$get("RelatedProdCont").childNodes.length-1].offsetWidth;
	}

    
    if(Scrolling == true) { setTimeout("ContLeftScroll('" + DivTag + "', '" + ImgScroll + "')",1); } 
}

function GetRightScroll(DivTag, ImgScroll)
{
    Scrolling = true;
    setTimeout("ContRightScroll('" + DivTag + "', '" + ImgScroll + "')",1);
}

function ContRightScroll(DivTag, ImgScroll)
{
	var sScroll = $get(DivTag).scrollLeft;
	
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		$get(DivTag).scrollLeft += 2;
	}
	else
	{
		$get(DivTag).scrollLeft += 1;
	}
    
    
	if (sScroll == $get(DivTag).scrollLeft)
	{
		$get("RelatedProdCont").appendChild($get("RelatedProdCont").childNodes[0]);
		$get(DivTag).scrollLeft -= $get("RelatedProdCont").childNodes[$get("RelatedProdCont").childNodes.length-1].offsetWidth;
	}
    
    if(Scrolling == true) { setTimeout("ContRightScroll('" + DivTag + "', '" + ImgScroll + "')",1); } 
}

function StopScroll()
{
    Scrolling = false; 
}
