// Refrenced from original work at http://www.lastwater.net

function initImgJS() {
	initScrollee();	
}
	
// div scroller
// scrolls a div up or down a specified amount
// global vars
var rows = 0;
var rowHeight = 130; //#pixels to scroll
var rowCurrent = 1;
var frameHeight = 5; //#pixels to scroll per animation frame
var framePause = 10; // nanoseconds between animation frame
var scrollId = 'thumbs';
var scrollee; //set = document.getElementById('thumbs') in scrollinit function
var topCurrent;
var itt = 0;
var direction = 0;
var timer = null;
var results = '';
			
function scrollIt(dir) {       
	if(timer) return false;
	if((dir == 'dn' && rowCurrent == rows) || (dir == 'up' && rowCurrent == 1)) return false;
	direction = (dir == 'up') ? 1 : (dir == 'dn') ? -1 : 0;
	rowCurrent += direction * -1;/**/
	timer = setInterval("animate()", framePause);
}

function animate() {
	topCurrent += direction * frameHeight;
	scrollee.style.marginTop = topCurrent + "px";
	if(++itt>rowHeight/frameHeight) {
		clearInterval(timer);
		timer=null;
		itt=0;
		
		//if( rowCurrent == 1)
		//    scrollee.style.marginTop = "-10px";
	}	
}

function initScrollee() {
	scrollee = document.getElementById(scrollId);
	scrollee.style.marginTop = (scrollee.style.marginTop) ? scrollee.style.marginTop : 0 + "px";
	topCurrent = parseInt(scrollee.style.marginTop)? parseInt(scrollee.style.marginTop) : 0;	
	rows = Math.floor(numOfPics/4);
	var remainder = ((numOfPics%4)>0) ? 1 : 0;//compute rows based on # images
	rows += remainder;
}
