var ImageScroller = function(_imageScrollerParentDivID, _imageScrollerChildDivID) {
    _imageScrollerParentDivID = getElem(_imageScrollerParentDivID);
    _imageScrollerChildDivID = getElem(_imageScrollerChildDivID);
	
    var prImages = new Array();
    var prImagePaths = new Array();
    var prImageAltText = new Array();
    var prImageClicks = new Array();
    var prImageDescription = new Array();
	
    var iNumOfThumbsShown = 1;
    var iNumOfThumbsShownWidthTotal = 0;
    var iNumOfThumbsShownHeightTotal = 0;
    var iNumOfImages;
	
    var iTallestThumbHeight = 0;
    var iWidestThumbHeight = 0;
    var iAllThumbsWidthTotal = 0;
    var iAllThumbsHeightTotal = 0;
    
    
    var bAutoScroll = 0;
    //0=false, 1=true
    var iAutoScrollDelay = 2000;
    var bAutoScrollDirection = 1;
    //0=back, 1=forward
    var bAutoReverse = 1;
    //0=false, 1=true
    var iScrollType = 1;
    //0=horizontal, 1=vertical
    var bEnableThumbBorder = 0;
    //0=no, 1=yes
    var bEnableCurrentCount = 0;
    //0=no, 1=yes
    var bEnableThumbDescription = 0;
    //0=no, 1=yes
    var bClickOpenType = 0;
    //0=same window, 1=new window
    var iImageScrollAmount = 1;
    //number of images to scroll
    var bMultiSizeThumbs = false;
    
    var objCounterDiv = "";
    var objDescriptionDiv = "";
    var iSmoothSlideInterval = 3;
    var iSmoothSlideAmount = 7;
    var moveTimer;
    
    this.THUMB_HEIGHT = 80;
    this.THUMB_WIDTH = 80;
    this.THUMB_PADDING = 4;
    
    var CURRENT_THUMB_INDEX = 1;
    var NEW_REVERSE_OFFSET = 0;
    var MAX_REVERSE_OFFSET = 0;
    var NEW_FORWARD_OFFSET = 0;
    var IS_SCROLLING = false;
	
    //* BEGIN FUNCTIONS *//
    this.enableMultiSizeThumbnails = function() {
        bMultiSizeThumbs = true;
    };
    this.setNumOfImageToScroll = function(_NumOfImagesToScroll) {
        iImageScrollAmount = parseInt(_NumOfImagesToScroll);
    };
    this.enableThumbnailDescription = function(_descriptionDivID) {
        bEnableThumbDescription = 1;
        objDescriptionDiv = _descriptionDivID;
    };
    this.setScrollType = function(_iType) {
        if (_iType == 0) {
            iScrollType = 0;
        }
        else {
            iScrollType = 1;
        }
    };
    this.setScrollSpeed = function(_iSpeed) {
        if (_iSpeed > 0 || _iSpeed < 1000) {
            iSmoothSlideInterval = _iSpeed;
        }
        else {
            iSmoothSlideInterval = 7;
        }
    };
    this.setScrollAmount = function(_iAmount) {
        if (_iAmount > 0 || _iAmount < 1000) {
            iSmoothSlideAmount = _iAmount;
        }
        else {
            iSmoothSlideAmount = 7;
        }
    };
    this.setClickOpenType = function(_openType) {
        if (_openType == 0 || _openType == 1) {
            bClickOpenType = _openType;
        }
    };
    this.enableCurrentCount = function(_counterDivID) {
        bEnableCurrentCount = 1;
        objCounterDiv = _counterDivID;
    };
    this.enableThumbBorder = function(_boolean) {
        bEnableThumbBorder = _boolean;
    };
    this.setThumbsShown = function(_newNumOfThumbsShown) {
        iNumOfThumbsShown = parseInt(_newNumOfThumbsShown);
    };
    this.addThumbnail = function(_thumbnailURL, _fullClickURL, _thumbnailAlt, _thumbnailDescription) {
        prImagePaths[prImagePaths.length] = _thumbnailURL;
        prImageClicks[prImageClicks.length] = _fullClickURL;
        prImageAltText[prImageAltText.length] = _thumbnailAlt;
        prImageDescription[prImageDescription.length] = _thumbnailDescription;
    };
    this.setThumbnailHeight = function(_newThumbHeight) {
        this.THUMB_HEIGHT = _newThumbHeight;
    };
    this.getThumbnailHeight = function() {
        return this.THUMB_HEIGHT;
    };
    this.setThumbnailWidth = function(_newThumbWidth) {
        this.THUMB_WIDTH = _newThumbWidth;
    };
    this.getThumbnailWidth = function() {
        return this.THUMB_WIDTH;
    };
    this.setThumbnailPadding = function(_newThumbPadding) {
        this.THUMB_PADDING = _newThumbPadding;
    };
    this.getThumbnailPadding = function() {
        return THUMB_PADDING;
    };
    this.getCurrentThumbIndex = function() {
        return CURRENT_THUMB_INDEX;
    };
    this.getThumbnailCount = function() {
        return iNumOfImages;
    };
    this.renderScroller = function() {
        iNumOfImages = prImagePaths.length;
        if (iNumOfThumbsShown > iNumOfImages) {
            iNumOfThumbsShown = iNumOfImages;
        }
        
        //*** [Begin] Image Cacheing code ***//
        var oHref;
        var oImage;
        oHref = document.createElement("a");
        oImage = document.createElement("img");
        
        for (i = 0; i < iNumOfImages; i++) {
            oHref = document.createElement("a");
            oHref.href = prImageClicks[i];
            oHref.title = prImageAltText[i];
            
            if (bClickOpenType == 1) {
                oHref.target = "_blank";
            }
            
            oImage = document.createElement("img");
            oImage.src = prImagePaths[i];
            oImage.alt = prImageAltText[i];
            oImage.border = 0;
		
			oImage.width = this.THUMB_WIDTH;
			oImage.height = this.THUMB_HEIGHT;
            
            if (document.all) {
                oImage.style.padding = this.THUMB_PADDING;
                } else {
                oImage.style.padding = this.THUMB_PADDING + "px";
            }
            
            if (oImage.height > iTallestThumbHeight) {
                iTallestThumbHeight = oImage.height;
            }
            if (oImage.width > iWidestThumbHeight) {
                iWidestThumbHeight = oImage.width;
            }
            
            iAllThumbsWidthTotal = iAllThumbsWidthTotal + (0 + oImage.width);
            if (i < iNumOfThumbsShown) {
                iNumOfThumbsShownWidthTotal = iNumOfThumbsShownWidthTotal + (0 + oImage.width);
            }
            iAllThumbsHeightTotal = iAllThumbsHeightTotal + (0 + oImage.height);
            if (i < iNumOfThumbsShown) {
                iNumOfThumbsShownHeightTotal = iNumOfThumbsShownHeightTotal + (0 + oImage.height);
            }
            
            oHref.appendChild(oImage);
            oImage.style.verticalAlign = "middle";
            oImage.style.align = "center";
            
            //**thumbframe border code for multisize thumbs***/
            if (bMultiSizeThumbs == true) {
                _tbl = document.createElement("table");
                _body = document.createElement("tbody");
                _row = document.createElement("tr");
                _cell = document.createElement("td");
                _div = document.createElement("div");
                
                _imageScrollerChildDivID.appendChild(oHref);
                //**thumbframe border code for multisize thumbs***/
                } else {
                _imageScrollerChildDivID.appendChild(oHref);
            }
            
        }
        //*** [End]   Image Cacheing code ***//
        
        var browserAdjust = 2;
        if (document.all) { browserAdjust = 4; };
        
        iNumOfImages = prImagePaths.length;
        
        if (iNumOfThumbsShown > iNumOfImages) {
            iNumOfThumbsShown = iNumOfImages;
        }
        
        iAllThumbsWidthTotal = iAllThumbsWidthTotal + ((this.THUMB_PADDING * 2) * iNumOfImages);
        iNumOfThumbsShownWidthTotal = iNumOfThumbsShownWidthTotal + ((this.THUMB_PADDING * 2) * iNumOfThumbsShown);
        
        iAllThumbsHeightTotal = iAllThumbsHeightTotal + ((this.THUMB_PADDING * 2) * iNumOfImages);
        iNumOfThumbsShownHeightTotal = iNumOfThumbsShownHeightTotal + ((this.THUMB_PADDING * 2) * iNumOfThumbsShown);
        
        if (iScrollType == 0) {
            MAX_REVERSE_OFFSET = (iNumOfThumbsShownWidthTotal - iAllThumbsWidthTotal);
			
			if (document.all) {
			//	MAX_REVERSE_OFFSET = MAX_REVERSE_OFFSET - (iNumOfImages);
			}
            
            _imageScrollerParentDivID.style.width = iNumOfThumbsShownWidthTotal + "px";
            if (bEnableThumbBorder == 1) {
                _imageScrollerParentDivID.style.width = (parseInt(_imageScrollerParentDivID.style.width) + (iNumOfImages * 4)) + "px";
            }
            
            _imageScrollerParentDivID.style.height = (iTallestThumbHeight + (this.THUMB_PADDING * 2)) + "px";
            if (bEnableThumbBorder == 1) {
                _imageScrollerParentDivID.style.height = (parseInt(_imageScrollerParentDivID.style.height) + 4) + "px";
            }
            
            _imageScrollerChildDivID.style.width = iAllThumbsWidthTotal + "px";
            if (bEnableThumbBorder == 1) {
                _imageScrollerChildDivID.style.width = (parseInt(_imageScrollerChildDivID.style.width) + (iNumOfImages * 4)) + "px";
            }
            
            
            }  else if (iScrollType == 1) {
            MAX_REVERSE_OFFSET = 0 - ((iAllThumbsHeightTotal - iNumOfThumbsShownHeightTotal));
            
            _imageScrollerParentDivID.style.width = (iWidestThumbHeight + (this.THUMB_PADDING * 2)) + "px";
            if (bEnableThumbBorder == 1) {
                _imageScrollerParentDivID.style.width = (parseInt(_imageScrollerParentDivID.style.width) + (4)) + "px";
            }
            
            _imageScrollerParentDivID.style.height = iNumOfThumbsShownHeightTotal + "px";
            if (bEnableThumbBorder == 1) {
                _imageScrollerParentDivID.style.height = (parseInt(_imageScrollerParentDivID.style.height) + (iNumOfThumbsShown * 4)) + "px";
            }
            
            _imageScrollerChildDivID.style.width = (iWidestThumbHeight + (this.THUMB_PADDING * 2)) + "px";
            if (bEnableThumbBorder == 1) {
                _imageScrollerChildDivID.style.width = (parseInt(_imageScrollerChildDivID.style.width) + 4) + "px";
            }
        }
        
        
        if (bEnableCurrentCount == 1) {
            addAnEvent(window, "load", this.updateCurrentCount);
        }
        if (bEnableThumbDescription == 1) {
            addAnEvent(window, "load", this.updateCurrentDescription);
        }
    };
    this.smoothScrollUp = function() {
        _origOffset = parseInt(_imageScrollerChildDivID.style.top);
        _currentOffset = parseInt(_imageScrollerChildDivID.style.top);
        _newOffset = _currentOffset - iSmoothSlideAmount;
        if (this.THUMB_PADDING > 0) {
            _newOffset = _newOffset - (2 * this.THUMB_PADDING);
        }
        if (bEnableThumbBorder == 1) {
            _newOffset = _newOffset - 4;
        }
        if (IS_SCROLLING == false && _newOffset >= MAX_REVERSE_OFFSET) {
            NEW_FORWARD_OFFSET = _newOffset;
            smoothMoveScrollerUp();
        }
    };
    this.scrollUp = function() {
        _origOffset = parseInt(_imageScrollerChildDivID.style.top);
        _currentOffset = parseInt(_imageScrollerChildDivID.style.top);
        _newOffset = _currentOffset - (this.THUMB_HEIGHT * iImageScrollAmount);
        if (this.THUMB_PADDING > 0) {
            _newOffset = _newOffset - (2 * this.THUMB_PADDING);
        }
        if (bEnableThumbBorder == 1) {
            _newOffset = _newOffset - 4;
        }
        if (IS_SCROLLING == false && _newOffset >= MAX_REVERSE_OFFSET) {
            NEW_FORWARD_OFFSET = _newOffset;
            moveScrollerUp();
        }
    };
    this.smoothScrollDown = function() {
        _origOffset = parseInt(_imageScrollerChildDivID.style.top);
        _currentOffset = parseInt(_imageScrollerChildDivID.style.top);
        _newOffset = _currentOffset + iSmoothSlideAmount;
        if (this.THUMB_PADDING > 0) {
            _newOffset = _newOffset + (2 * this.THUMB_PADDING);
        }
        if (bEnableThumbBorder == 1) {
            _newOffset = _newOffset + 4;
        }
        if (_newOffset <= 0) {
            if(_currentOffset > (_origOffset - this.THUMB_HEIGHT)) {
                if (IS_SCROLLING == false && _newOffset >= MAX_REVERSE_OFFSET) {
                    NEW_REVERSE_OFFSET = _newOffset;
                    smoothMoveScrollerDown();
                }
            }
        }
    };
    this.scrollDown = function() {
        _origOffset = parseInt(_imageScrollerChildDivID.style.top);
        _currentOffset = parseInt(_imageScrollerChildDivID.style.top);
        _newOffset = _currentOffset + (this.THUMB_HEIGHT * iImageScrollAmount);
        if (this.THUMB_PADDING > 0) {
            _newOffset = _newOffset + (2 * this.THUMB_PADDING);
        }
        if (bEnableThumbBorder == 1) {
            _newOffset = _newOffset + 4;
        }
        if (_newOffset <= 0) {
            if(_currentOffset > (_origOffset - this.THUMB_HEIGHT)) {
                if (IS_SCROLLING == false && _newOffset >= MAX_REVERSE_OFFSET) {
                    NEW_REVERSE_OFFSET = _newOffset;
                    moveScrollerDown();
                }
            }
        }
    };
    this.scrollTop = function() {
        if (IS_SCROLLING == false) {
            NEW_FORWARD_OFFSET = (MAX_REVERSE_OFFSET);
            CURRENT_THUMB_INDEX = iNumOfImages - iNumOfThumbsShown;
            moveScrollerUp();
        }
    };
    this.scrollBottom = function() {
        if (IS_SCROLLING == false) {
            NEW_REVERSE_OFFSET = 0;
            CURRENT_THUMB_INDEX = iNumOfImages - iNumOfThumbsShown;
            moveScrollerDown();
        }
    };
    this.smoothScrollReverse = function() {
        _origOffset = parseInt(_imageScrollerChildDivID.style.left);
        _currentOffset = parseInt(_imageScrollerChildDivID.style.left);
        _newOffset = _currentOffset + iSmoothSlideAmount;
        if (this.THUMB_PADDING > 0) {
            _newOffset = _newOffset + (this.THUMB_PADDING * (2 * iImageScrollAmount));
        }
        if (bEnableThumbBorder == 1) {
            _newOffset = _newOffset + 4;
        }
        if (_newOffset <= 0) {
            if(_currentOffset > (_origOffset - (this.THUMB_WIDTH * iImageScrollAmount))) {
                if (IS_SCROLLING == false) {
                    NEW_REVERSE_OFFSET = _newOffset;
                    smoothMoveScrollerRight();
                }
            }
        }
    };
    this.scrollReverse = function() {	
		if (iScrollType == 0) {
	        _origOffset = parseInt(_imageScrollerChildDivID.style.left);
	        _currentOffset = parseInt(_imageScrollerChildDivID.style.left);
	        _newOffset = _currentOffset + (this.THUMB_WIDTH * iImageScrollAmount);
	        if (this.THUMB_PADDING > 0) {
	            _newOffset = _newOffset + (this.THUMB_PADDING * (2 * iImageScrollAmount));
	        }
	        if (bEnableThumbBorder == 1) {
	            _newOffset = _newOffset + 4;
	        }
	        if (_newOffset <= 0) {
	            if(_currentOffset > (_origOffset - (this.THUMB_WIDTH * iImageScrollAmount))) {
	                if (IS_SCROLLING == false) {
	                    NEW_REVERSE_OFFSET = _newOffset;
	                    moveScrollerRight();
	                }
	            }
	        }
		} else {
			this.scrollDown();
		}
    };
    this.smoothScrollForward = function() {
        _origOffset = parseInt(_imageScrollerChildDivID.style.left);
        _currentOffset = parseInt(_imageScrollerChildDivID.style.left);
        _newOffset = _currentOffset - iSmoothSlideAmount;
        if (this.THUMB_PADDING > 0) {
            _newOffset = _newOffset - ((2 * iImageScrollAmount) * this.THUMB_PADDING);
        }
        if (bEnableThumbBorder == 1) {
            _newOffset = _newOffset - 4;
        }
        if (IS_SCROLLING == false && _newOffset >= MAX_REVERSE_OFFSET) {
            NEW_FORWARD_OFFSET = _newOffset;
            smoothMoveScrollerLeft();
        }
    };
    this.scrollForward = function() {	
		if (iScrollType == 0) {
	        _origOffset = parseInt(_imageScrollerChildDivID.style.left);
	        _currentOffset = parseInt(_imageScrollerChildDivID.style.left);
	        _newOffset = _currentOffset - (this.THUMB_WIDTH * iImageScrollAmount);
	        if (this.THUMB_PADDING > 0) {
	            _newOffset = _newOffset - ((2 * iImageScrollAmount) * this.THUMB_PADDING);
	        }
	        if (bEnableThumbBorder == 1) {
	            _newOffset = _newOffset - 4;
	        }
	        if (IS_SCROLLING == false && _newOffset >= MAX_REVERSE_OFFSET) {
	            NEW_FORWARD_OFFSET = _newOffset;
	            moveScrollerLeft();
	        }
		} else {
			this.scrollUp();
		}
    };
    this.scrollEnd = function() {	
		if (iScrollType == 0) {
	        if (IS_SCROLLING == false) {
	            NEW_FORWARD_OFFSET = MAX_REVERSE_OFFSET;
	            CURRENT_THUMB_INDEX = iNumOfImages - iNumOfThumbsShown;
	            moveScrollerLeft();
	        }
		} else {
			this.scrollTop();
		}
    };
    this.scrollBegin = function() {
		if (iScrollType == 0) {
	        if (IS_SCROLLING == false) {
	            NEW_REVERSE_OFFSET = 0;
	            CURRENT_THUMB_INDEX = 2;
	            moveScrollerRight();
	        }
		} else {
			this.scrollBottom();
		}
    };
    this.stopSmoothScroll = function() {
        IS_SCROLLING = false;
        window.clearTimeout(moveTimer);
    };
    this.updateCurrentDescription = function() {
        getElem(objDescriptionDiv).innerHTML = prImageDescription[CURRENT_THUMB_INDEX - 1];
    };
    this.updateCurrentCount = function() {
        getElem(objCounterDiv).innerHTML = CURRENT_THUMB_INDEX + "/" + iNumOfImages;
    };
    function smoothMoveScrollerUp() {
        _ElementObj = _imageScrollerChildDivID;
        _currentOffset = parseInt(_ElementObj.style.top);
        if (_currentOffset > MAX_REVERSE_OFFSET && (_currentOffset - iSmoothSlideAmount) >= MAX_REVERSE_OFFSET) {
            _ElementObj.style.top = _currentOffset - iSmoothSlideAmount + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(smoothMoveScrollerUp, iSmoothSlideInterval);
        }
        else if (_currentOffset > MAX_REVERSE_OFFSET) {
            _ElementObj.style.top = _currentOffset - 1 + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(smoothMoveScrollerUp, iSmoothSlideInterval);
        }
        else {
            IS_SCROLLING = false;
            window.clearTimeout(moveTimer);
        }
    };
    function moveScrollerUp() {
        _ElementObj = _imageScrollerChildDivID;
        _currentOffset = parseInt(_ElementObj.style.top);
        if (_currentOffset > NEW_FORWARD_OFFSET && (_currentOffset - iSmoothSlideAmount) >= NEW_FORWARD_OFFSET) {
            _ElementObj.style.top = _currentOffset - iSmoothSlideAmount + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(moveScrollerUp, iSmoothSlideInterval);
        }
        else if (_currentOffset > NEW_FORWARD_OFFSET) {
            _ElementObj.style.top = _currentOffset - 1 + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(moveScrollerUp, iSmoothSlideInterval);
        }
        else {
            IS_SCROLLING = false;
            CURRENT_THUMB_INDEX++;
            window.clearTimeout(moveTimer);
            if (bEnableThumbDescription == 1) {
                getElem(objDescriptionDiv).innerHTML = prImageDescription[CURRENT_THUMB_INDEX - 1];
            }
            if (bEnableCurrentCount == 1) {
                getElem(objCounterDiv).innerHTML = CURRENT_THUMB_INDEX + "/" + iNumOfImages;
            }
        }
    };
    function smoothMoveScrollerDown() {
        _ElementObj = _imageScrollerChildDivID;
        _currentOffset = parseInt(_ElementObj.style.top);
        if (_currentOffset < 0 && (_currentOffset + iSmoothSlideAmount) <= 0) {
            _ElementObj.style.top = _currentOffset + iSmoothSlideAmount + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(smoothMoveScrollerDown, iSmoothSlideInterval);
        }
        else if (_currentOffset < 0) {
            _ElementObj.style.top = _currentOffset + 1 + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(smoothMoveScrollerDown, iSmoothSlideInterval);
        }
        else {
            IS_SCROLLING = false;
            window.clearTimeout(moveTimer);
        }
    };
    function moveScrollerDown() {
        _ElementObj = _imageScrollerChildDivID;
        _currentOffset = parseInt(_ElementObj.style.top);
        if (_currentOffset < NEW_REVERSE_OFFSET && (_currentOffset + iSmoothSlideAmount) <= NEW_REVERSE_OFFSET) {
            _ElementObj.style.top = _currentOffset + iSmoothSlideAmount + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(moveScrollerDown, iSmoothSlideInterval);
        }
        else if (_currentOffset < NEW_REVERSE_OFFSET) {
            _ElementObj.style.top = _currentOffset + 1 + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(moveScrollerDown, iSmoothSlideInterval);
        }
        else {
            IS_SCROLLING = false;
            CURRENT_THUMB_INDEX--;
            window.clearTimeout(moveTimer);
            if (bEnableThumbDescription == 1) {
                getElem(objDescriptionDiv).innerHTML = prImageDescription[CURRENT_THUMB_INDEX - 1];
            }
            if (bEnableCurrentCount == 1) {
                getElem(objCounterDiv).innerHTML = CURRENT_THUMB_INDEX + "/" + iNumOfImages;
            }
        }
    };
    function smoothMoveScrollerRight() {
        _ElementObj = _imageScrollerChildDivID;
        _currentOffset = parseInt(_ElementObj.style.left);
        if (_currentOffset < 0 && (_currentOffset + iSmoothSlideAmount) <= 0) {
            _ElementObj.style.left = _currentOffset + iSmoothSlideAmount + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(smoothMoveScrollerRight, iSmoothSlideInterval);
        }
        else if (_currentOffset < 0) {
            _ElementObj.style.left = _currentOffset + 1 + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(smoothMoveScrollerRight, iSmoothSlideInterval);
        }
        else {
            IS_SCROLLING = false;
            window.clearTimeout(moveTimer);
        }
    };
    function moveScrollerRight() {
        _ElementObj = _imageScrollerChildDivID;
        _currentOffset = parseInt(_ElementObj.style.left);
        if (_currentOffset < NEW_REVERSE_OFFSET && (_currentOffset + iSmoothSlideAmount) <= NEW_REVERSE_OFFSET) {
            _ElementObj.style.left = _currentOffset + iSmoothSlideAmount + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(moveScrollerRight, iSmoothSlideInterval);
        }
        else if (_currentOffset < NEW_REVERSE_OFFSET) {
            _ElementObj.style.left = _currentOffset + 1 + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(moveScrollerRight, iSmoothSlideInterval);
        }
        else {
            IS_SCROLLING = false;
            CURRENT_THUMB_INDEX--;
            window.clearTimeout(moveTimer);
            if (bEnableThumbDescription == 1) {
                getElem(objDescriptionDiv).innerHTML = prImageDescription[CURRENT_THUMB_INDEX - 1];
            }
            if (bEnableCurrentCount == 1) {
                getElem(objCounterDiv).innerHTML = CURRENT_THUMB_INDEX + "/" + iNumOfImages;
            }
        }
    };
    function smoothMoveScrollerLeft() {
        _ElementObj = _imageScrollerChildDivID;
        _currentOffset = parseInt(_ElementObj.style.left);
        if (_currentOffset > MAX_REVERSE_OFFSET && (_currentOffset - iSmoothSlideAmount) >= MAX_REVERSE_OFFSET) {
            _ElementObj.style.left = _currentOffset - iSmoothSlideAmount + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(smoothMoveScrollerLeft, iSmoothSlideInterval);
        }
        else if (_currentOffset > MAX_REVERSE_OFFSET) {
            _ElementObj.style.left = _currentOffset - 1 + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(smoothMoveScrollerLeft, iSmoothSlideInterval);
        }
        else {
            IS_SCROLLING = false;
            window.clearTimeout(moveTimer);
        }
    };
    function moveScrollerLeft() {
        _ElementObj = _imageScrollerChildDivID;
        _currentOffset = parseInt(_ElementObj.style.left);
        if (_currentOffset > NEW_FORWARD_OFFSET && (_currentOffset - iSmoothSlideAmount) >= NEW_FORWARD_OFFSET) {
            _ElementObj.style.left = _currentOffset - iSmoothSlideAmount + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(moveScrollerLeft, iSmoothSlideInterval);
        }
        else if (_currentOffset > NEW_FORWARD_OFFSET) {
            _ElementObj.style.left = _currentOffset - 1 + "px";
            IS_SCROLLING = true;
            moveTimer = window.setTimeout(moveScrollerLeft, iSmoothSlideInterval);
        }
        else {
            IS_SCROLLING = false;
            CURRENT_THUMB_INDEX++;
            window.clearTimeout(moveTimer);
            if (bEnableThumbDescription == 1) {
                getElem(objDescriptionDiv).innerHTML = prImageDescription[CURRENT_THUMB_INDEX - 1];
            }
            if (bEnableCurrentCount == 1) {
                getElem(objCounterDiv).innerHTML = CURRENT_THUMB_INDEX + "/" + iNumOfImages;
            }
        }
    };
    
    var iRetryAttempt = 0;
    var iMaxAttachRetry = 3;
    function addAnEvent(_obj, _eventName, _functionName) {
        if (_obj != null && _obj != "undefined") {
            if (window.addEventListener) {
                _obj.addEventListener(_eventName, _functionName, false);
            }
            else {
                _obj.attachEvent("on" + _eventName, _functionName);
            }
            iRetryAttempt = 0;
        }
        else {
            if (iRetryAttempt < iMaxAttachRetry) {
                try {
                    iRetryAttempt++;
                    window.setTimeout(addAnEvent(_obj, _eventName, _functionName), 1000);
                }
                catch(Exceptions) {
                    return;
                }
            }
        }
    };
    
    function getElem(_elemID) {
        return document.getElementById(_elemID);
    };
};
