var nIntervalID;
var nDirection;
var nGalleryLeft;

function ScrollLeft()
{
    nDirection = 5;
    nIntervalID = window.setInterval(StartScroll, 20);
}

function ScrollRight()
{
    nDirection = -5;
    nIntervalID =  window.setInterval(StartScroll, 20);
}

function StartScroll()
{
    var nXPos = 0;
    if(parseInt(document.getElementById('GalleryWrapper').style.left, 10))
    {
        nXPos = parseInt(document.getElementById('GalleryWrapper').style.left, 10); 
    }
    
    if((nDirection < 0 && nXPos > nGalleryLeft) || (nDirection > 0 && nXPos < 0))
    {        
        document.getElementById('GalleryWrapper').style.left = (nXPos + nDirection) + "px";
    }
}

function StopScroll()
{
    window.clearInterval(nIntervalID);
}

function InitGallery()
{
    var nGalleryWidth = 0; 
    for(var i=0; i<document.getElementById('GalleryWrapper').childNodes.length; i++)
    {
        if(document.getElementById('GalleryWrapper').childNodes[i].nodeName == "IMG")
        {
            nGalleryWidth = nGalleryWidth + 136;
        }
    }
    nGalleryLeft = (nGalleryWidth - 676 - 4) * -1;
}

function ShowImageGallery(strImageSrc, strTitle)
{
    document.getElementById('GalleryImage').src = strImageSrc;
    document.getElementById('GalleryImageTitle').innerHTML = strTitle;
}
