
function ImgScrollerHScroll(hPosition, containerDivId) {
    var actualHPosition = document.getElementById(containerDivId).scrollLeft;
    var tmp = 10;

    if (actualHPosition > hPosition) {
        document.getElementById(containerDivId).scrollLeft -= tmp;
        var code = 'ImgScrollerHScroll(';
        code += hPosition;
        code += ', "' + containerDivId;
        code += '");'
        if (document.getElementById(containerDivId).scrollLeft > hPosition) {
            setTimeout(code, 10);
            return;
        }
    }
    else {
        document.getElementById(containerDivId).scrollLeft += tmp;
        var code = 'ImgScrollerHScroll(';
        code += hPosition;
        code += ', "' + containerDivId;
        code += '");';
        if (document.getElementById(containerDivId).scrollLeft < hPosition) {
            setTimeout(code, 10);
            return;
        }
    }
    document.getElementById(containerDivId).scrollLeft = hPosition;
    myMarketImgScroller.Scrolling = false;
}


MarketImgScroller = function(containerDivId, nbImage, imageWidth, imageHeight) {
    this.myContainer = document.getElementById(containerDivId);
    this.ContainerDivId = containerDivId;
    this.ImageWidth = imageWidth;
    this.NbImage = nbImage;
    this.Scrolling = false;
    this.ActualScreenNo = 1;
    this.myTimer = null;

    this.GoToScreen = function(ScreenNo) {
        if (this.Scrolling) return false;
        this.Scrolling = true;
        this.ActualScreenNo = ScreenNo;
        ImgScrollerHScroll((ScreenNo - 1) * this.ImageWidth, this.ContainerDivId);
        return true;
    }

    if (this.myTimer == null) {
        this.myTimer = setInterval('myMarketImgScroller.Annim()', 5500);
    }

    this.Annim = function() {
        if (this.ActualScreenNo == nbImage) this.GoToScreen(1);
        else this.GoToScreen(this.ActualScreenNo + 1);
    }
}


