// function scrollBy(frm,inc,dir) {
testing=true;
function ensureLoaded(s) {
	whichWindow=Math.floor(s/diff)+2;
	firstImage=whichWindow*thumbnailsAcross;
	maxImages=(firstImage+thumbnailsAcross);
	if (top.preLoading.length<maxImages) maxImages=preLoading.length;
	testing=false;
	for (imageNumber=firstImage;imageNumber<=maxImages;imageNumber++) {
		if (top.preLoading[imageNumber-1]!="") {
			o=eval("top.scr1.thumbnail"+(imageNumber-1));
			o=MM_findObj("thumbnail"+(imageNumber-1)+"?scr1");
			if (o) {
				o.src="createthumbnail.php?whichFile="+top.preLoading[imageNumber-1]+"&newSize="+thumbnail_size;
				top.preLoading[imageNumber-1]="";
			}
		}
	}
}

function startScrolling(dir) {
	if (isscrolling) return;
	if (Math.abs(dir)!=1){
		diff=dir*diff;
		dir=1;
	}
	if (dir==-1) {
		window.status='Hover or click here to scroll left.'; 
	} else {
		window.status='Hover or click here to scroll right.'; 
	}
	isscrolling=true;
	juststarted=true;
	expr="scrollFrameBy("+Math.floor(dir*scrollamount)+")";
	if (timer_id) clearInterval(timer_id);
	timer_id=setInterval(expr,15);
}

function scrollFrameBy(inc) {
//	alert(inc);
// new lines to simplify single-scroll code
	frm="scr1";
	dir="h";
// end new lines
//	if (!window.frames[frm]) return;
	if (juststarted) {
		if ((inc>0) && (clipStart>maxscroll)) { tmpstop("You are at the end of this category"); return; }
		if ((inc<0) && (clipStart<0)) { tmpstop("You are at the start of this category"); return; }
	}
	clipStart+=inc;
	if (inc>0) {
		ensureLoaded(clipStart);
	}
//	timer_id = setTimeout("scroll_iframe('" + frm + "'," + inc + ",'" + dir + "')", 20);

	val=(clipStart / diff) - inc;

	if (dir == "v") {
		window.frames[frm].scrollBy(0, inc);
	} else {
		window.frames[frm].scrollBy(inc, 0);
	}

	if (!(juststarted)) {
//		alert(val+" "+clipStart+" "+diff+" "+inc);
		if (val==Math.floor(val)) {
			tmpstop("");
			diff=keepdiff;
			return;
		}
	}
	
	juststarted=false;
}

function tmpstop(e) {
	if (isscrolling==false) return
	isscrolling=false;
	clearInterval(timer_id);
	if (e!="") alert(e);
}

function stopScroll() { 
	tmpstop("");
}

function tryTmpStop() {
}