var slideSpeed = 10;	// Speed of thumbnail slide - Lower = faster
	var slideSteps = 3;	// Also speed of thumbnail slide - Higher = faster
	/* Don't change anything below here */
	var scroll_slideWidth = false;
	var scroll_thumbTotalWidth = false;
	var scroll_viewableWidth = false;
	
	var scroll_thumbDiv = false;
	var scroll_thumbSlideInProgress = false;
	var leftArrowObj;
	var rightArrowObj;
	var thumbsLeftPos = false;
	var num_cols;
	var max_movement;
	
	function initGalleryScript()
	{
		//alert('inside init script function slidvar');
		leftArrowObj = document.getElementById('ab-arrow-left');
		//alert('leftArrowObj'+leftArrowObj);		
		rightArrowObj = document.getElementById('ab-arrow-right');	
		leftArrowObj.style.cursor = 'pointer';	
		rightArrowObj.style.cursor = 'pointer';	
		leftArrowObj.onmouseover = moveleft;
		rightArrowObj.onmouseover = moveright;
		var innerDiv = document.getElementById('ab-images-inner');
		scroll_thumbDiv = document.getElementById('ab-images-inner');
		//alert('scroll_thumbDiv'+scroll_thumbDiv);		
		scroll_thumbDiv.style.left = '0px';
		scroll_slideWidth = innerDiv.getElementsByTagName('div')[0].offsetWidth;
		
		//place thumbnails at their position absolute and dynamically calculate scroll_thumbTotalWidth = total width of thumbnails 
		var subDivs = scroll_thumbDiv.getElementsByTagName('div');
		scroll_thumbTotalWidth = 0;
		var tmpLeft = 0;
		num_cols=subDivs.length;
		//alert('num_cols'+num_cols);
		for(var no=0;no<subDivs.length;no++){//alert(subDivs[no].className=='ab-image-box');
			if(subDivs[no].className=='ab-image-box'){
				scroll_thumbTotalWidth = scroll_thumbTotalWidth + scroll_slideWidth;
				subDivs[no].style.left = tmpLeft + 'px';
				subDivs[no].style.top = '0px';
				tmpLeft = tmpLeft + subDivs[no].offsetWidth;
			}
		}
		scroll_viewableWidth = document.getElementById('ab-images').offsetWidth;
		max_movement = scroll_viewableWidth-scroll_thumbTotalWidth; 
		//alert('scroll_viewableWidth'+scroll_viewableWidth+'  scroll_thumbTotalWidth'+scroll_thumbTotalWidth+'max_movement'+max_movement);
	}
	
	function moveleft(){
		//alert('inside move left');
		//alert('scroll_thumbDiv.style.left'+scroll_thumbDiv.style.left);
		var scroller_left = scroll_thumbDiv.style.left.replace('px','')/1;
		//alert('scroller_left'+scroller_left);
		if( scroller_left<=0) {
			var leftPos;
			if(thumbsLeftPos){
				leftPos= thumbsLeftPos;
			}else{
				var leftPos = scroll_thumbDiv.style.left.replace('px','')/1;
			}
			//alert('leftPos'+leftPos);
			leftPos +=  slideSteps;
			thumbsLeftPos = leftPos;
			scroll_thumbDiv.style.left = leftPos + 'px';
			slidevar=setTimeout("moveleft()",slideSpeed);
		}
	}
	function moveright(){
		//alert('inside move right');
		//alert('scroll_thumbDiv.style.left'+scroll_thumbDiv.style.left);
		var scroller_left = scroll_thumbDiv.style.left.replace('px','')/1;
		if(max_movement<=scroller_left ) { 
			var leftPos;
			if(thumbsLeftPos){
				leftPos= thumbsLeftPos;
			}else{
				var leftPos = scroll_thumbDiv.style.left.replace('px','')/1;
			}
			leftPos -=  slideSteps;
			thumbsLeftPos = leftPos;
			scroll_thumbDiv.style.left = leftPos + 'px';
			slidevar=setTimeout("moveright()",slideSpeed);
		}
	}
	initGalleryScript();	// Initialize script