    
/** Gallery Scroller  **/

var scrollInterval;
var scrollPosition = 0;
var scrollSpeed = 10;
var scrollWidth = 50;
var scrollLength = 583;

function scrollStart( scrollDirection ){    
	clearInterval(scrollInterval);

	if( scrollDirection == 'scrollLeft' ){
		scrollPosition =  document.getElementById('scroller').scrollLeft - scrollLength;
		scrollInterval = setInterval("scrollToLeft()", scrollSpeed);
	}else{
		scrollPosition =  document.getElementById('scroller').scrollLeft + scrollLength;
		scrollInterval = setInterval("scrollToRight()", scrollSpeed);
	}
}

function scrollEnd(){
	clearInterval(scrollInterval);

	if( document.getElementById('scroller').scrollLeft == 0 ){
    	document.getElementById('scrollerLeftArrow').src = 'images/space.gif';
        document.getElementById('scrollerLeftArrow').onclick= function scrollClick(){ return ''; }
    }else{
    	document.getElementById('scrollerLeftArrow').src = 'images/spotArrowLeft.gif';
        document.getElementById('scrollerLeftArrow').onclick= function scrollClick(){ return scrollStart('scrollLeft'); }
    }
    
    if( document.getElementById('scroller').scrollLeft == (document.getElementById('seeMore').getAttribute('numSlides')-1) * scrollLength ){
    	document.getElementById('scrollerRightArrow').src = 'images/space.gif';
        document.getElementById('scrollerRightArrow').onclick= function scrollClick(){ return ''; }
    }else{
    	document.getElementById('scrollerRightArrow').src = 'images/spotArrowRight.gif';
        document.getElementById('scrollerRightArrow').onclick= function scrollClick(){ return scrollStart('scrollRight'); }
    }
}

function scrollToLeft(){
	document.getElementById('scroller').scrollLeft = document.getElementById('scroller').scrollLeft - scrollWidth;
	if( document.getElementById('scroller').scrollLeft <= scrollPosition ) scrollEnd();
}

function scrollToRight(){
	document.getElementById('scroller').scrollLeft = document.getElementById('scroller').scrollLeft + scrollWidth;
	if( document.getElementById('scroller').scrollLeft >= scrollPosition ) scrollEnd();	
}

function scrollTo( slideNum ){
	clearInterval(scrollInterval);
	
    var scrollTo = scrollLength * (slideNum - 1);
    
    if( scrollPosition != scrollTo ){
    	scrollPosition = scrollTo;
        
        if( scrollPosition < document.getElementById('scroller').scrollLeft )
            scrollInterval = setInterval("scrollToLeft()", scrollSpeed);
        else
            scrollInterval = setInterval("scrollToRight()", scrollSpeed);
	}
}

/** End Scroller **/

