﻿// Author: Kieran Iles
// Date Created: 8 Mar 2007
// Description: Scrolls <a> elements within a div with the id 'scrollingDiv'. The links must be in a table with 
// the ID 'scrollerTable'

var scrollSpeed = 20;
var baseIntMarginMove = 1;
var intMarginMove = baseIntMarginMove;
var intBaseMarginLeft = 220;
var intMarginLeft = intBaseMarginLeft;
var intStartLeft, intStartWidth

// Needs to be called on the body tag's onload event.
function initScroller () {
    window.setTimeout("HorizontalScrollTimer();", scrollSpeed);
    objScollerTable = document.getElementById("scrollerTable");
    
    if (objScollerTable != null)
    {
        intStartWidth = objScollerTable.offsetWidth
        intStartLeft = objScollerTable.offsetLeft;
    }
}
function HorizontalScrollTimer () {
    var objDiv = document.getElementById("scrollingDiv");
    intMarginLeft = intMarginLeft - intMarginMove;
    objDiv.style.margin = "0 0 0 " + intMarginLeft + "px";
    if (objScollerTable != null)
    {
        if ((objScollerTable.offsetLeft + objScollerTable.offsetWidth + 100) < 0)
        {
            intBaseMarginLeft = 450;
            intMarginLeft = intBaseMarginLeft;
        }
    }
    window.setTimeout("HorizontalScrollTimer();", scrollSpeed);
}

// Needs to be called on the <a> tags onmouseover event
function stopScrolling () {
    intMarginMove = 0;
}

// Needs to be called on the <a> tags onmouseout event
function startScrolling () {
    intMarginMove = baseIntMarginMove;
}