document.observe('dom:loaded', function(){
    new PeriodicalExecuter(moveTourAuto,10)
})

function moveTour(elt,link)
{
    var xPosScroller = findHPos($('tourHolder'));
    var xPosItem = findHPos($(elt));
    var amount  = xPosScroller - xPosItem;
    new Effect.Move('tourScroller', {
        x: amount,
        y: 0,
        mode: 'relative',
        duration: 0.5
    });
    $$('.activeTourLink').each(function(item) {
        item.removeClassName("activeTourLink");
        item.addClassName("tourLink");
    });
    $(link).addClassName("activeTourLink");
}

function findHPos( oElement ) {
    if( typeof( oElement.offsetParent ) != 'undefined' ) {
        for( var posX = 0; oElement; oElement = oElement.offsetParent ) {
            posX += oElement.offsetLeft;
        }
        return posX;
    } else {
        return oElement.x;
    }
}

function moveTourAuto()
{
    var currentPostion = findHPos($('tourScroller'));
    if(currentPostion > -8000)
    {
        new Effect.Move('tourScroller', {
            x: -1000,
            y: 0,
            mode: 'relative',
            duration: 0.5
        });
    }
    else
    {
        new Effect.Move('tourScroller', {
            x: 9000,
            y: 0,
            mode: 'relative',
            duration: 1
        });
    }
}