﻿
var scrolling;
var featureBar;
var timer, speed = 5;
var incr, pixelLeft, rightBound;

window.onload = function()
{    
    InitScroll();    
}

function InitScroll()
{    
    featureBar = document.getElementById('FeatureBar');
    rightBound = 808 - featureBar.clientWidth;
    featureBar.style.pixelLeft = "0px";
    document.onmouseup = StopScroll;    
    clearTimeout(timer);
    scrolling = false;
}

function StartScroll(dir)
{
    if (scrolling)
        return;
        
    clearTimeout(timer);
    scrolling = true;
    incr = dir * speed;
    
    timer = setInterval(Scroll, 20);
}

function Scroll()
{
    pixelLeft = parseInt(featureBar.style.left) + incr;
    
    if (pixelLeft > 0)
        pixelLeft = 0;
    if (pixelLeft < rightBound)
        pixelLeft = rightBound;
        
    featureBar.style.left = pixelLeft + "px";               
}

function StopScroll()
{    
    clearInterval(timer);
    scrolling = false;
}