﻿var keepMoving = true;

function moveLeft() {
    if (keepMoving) {
        var scroller = document.getElementById('scroller');
        if (typeof (scroller.style.pixelRight) !== 'undefined') {
            if (scroller.style.pixelRight < containerWidth) {
                scroller.style.pixelRight += speed;
            }
        }
        else {
            if (scroller.runtimeLeft > (0 - containerWidth)) {
                scroller.runtimeLeft -= speed;
                scroller.style.left = scroller.runtimeLeft + 'px';
            }
        }
        setTimeout("moveLeft();", 50);
    }
}
function moveRight() {
    if (keepMoving) {
        var scroller = document.getElementById('scroller');
        if (typeof (scroller.style.pixelRight) !== 'undefined') {
            if (scroller.style.pixelRight > 0) {
                scroller.style.pixelRight -= speed;
            }
        }
        else {
            if (!scroller.runtimeLeft) scroller.runtimeLeft = 0;
            if (scroller.runtimeLeft < 0) {
                scroller.runtimeLeft += speed;
                scroller.style.left = scroller.runtimeLeft + 'px';
            }
        }
        setTimeout("moveRight();", 50);
    }
}
function stopMove() {
    keepMoving = false;
}
function SwapImage(imgObj) {
    if (document.getElementById('imgHolder')) {
        var imgName = imgObj.src.split('_')[0];
        document.getElementById('imgHolder').src = imgName + ".jpg";
        window.location.href = window.location.href.replace(/(#.*)?$/, "#") + imgName.substr(imgName.lastIndexOf('/')+1);
    }
}

function SetScroller() {
    var scroller = document.getElementById('scroller');
    if (typeof (scroller.style.pixelRight) !== 'undefined') {
        scroller.style.pixelRight = 480;
    }
    else {
        scroller.runtimeLeft = -180;
        scroller.style.left = scroller.runtimeLeft + 'px';
    }
    var parts = window.location.href.split('#');
    if (parts.length > 1) {
        if (document.getElementById('imgHolder')) {
            var imgName = parts[1];
            document.getElementById('imgHolder').src = "thanx/" + imgName + ".jpg";
        }
    }
}
            