﻿/// <reference path="jquery-1.3.2-vsdoc2.js"/>

var totalWidth = 0; //total width of ONE image strip
var visibleWidth = 0; //the visible area on the page
var currentLeftPosition = 0; //current position of strip1
var currentLeftPosition2 = 0; //current position of strip2
var increment = -1;
var time = 50;
var imageWidth = 316; //width of all images

function SetBarGlobals() {
    $(".barImage").each(function() {
        //totalWidth += $(this).width()
        //bugfix for webkit browsers
        totalWidth += imageWidth;
    })

    //visibleWidth = $("#imageBarHolder").width();
    visibleWidth = 655;
    $("#barImageHolderTable2").css("left", totalWidth);
    $("#barImageHolderTable2").show();
    currentLeftPosition2 = totalWidth;
}

function SetStartPosition(imageNumber) {
    SetBarGlobals();
    var startPos = (imageNumber * imageWidth) - (imageWidth / 2);
    currentLeftPosition = -startPos;
    $("#barImageHolderTable").css("left", currentLeftPosition);
    currentLeftPosition2 = currentLeftPosition2 - startPos;
    $("#barImageHolderTable").fadeTo("slow", 1, function() {
        setTimeout("AnimateBar();", 1000);
    });
}

function AnimateBar() {
    currentLeftPosition = currentLeftPosition + increment;
    currentLeftPosition2 = currentLeftPosition2 + increment;
    $("#barImageHolderTable").css("left", currentLeftPosition)
    $("#barImageHolderTable2").css("left", currentLeftPosition2)
    if ((-currentLeftPosition) <= totalWidth) {
        setTimeout("AnimateBar();", time);
    }
    else {
        currentLeftPosition = totalWidth;
        $("#barImageHolderTable").css("left", currentLeftPosition)
        setTimeout("AnimateBar();", time);
    }
    if ((-currentLeftPosition2) > totalWidth)
        currentLeftPosition2 = totalWidth;
}
