var i = 0;
var myInterval;
function scrollNext() {
	clearInterval(myInterval);
	myInterval = setInterval(runLeft, 1);
	var thumbsWidth = Element.getWidth('imgThumbs');
	function runLeft() {
		i = i - 10;
		offset = thumbsWidth + i;
		if (offset < 100) {
			clearInterval(myInterval);
		}
		else 
		{
			$('imgThumbs').style.marginLeft= i + "px";
		}
	}
}

function scrollPrev() {
	clearInterval(myInterval);
	myInterval = setInterval(runRight, 1);
	function runRight() {
		i = i + 5;
		var leftMargin = $('imgThumbs').style.marginLeft;
		newLeftMargin = leftMargin.replace("px","");
		if ((newLeftMargin + i) > 0) {
			clearInterval(myInterval);
			$('imgThumbs').style.marginLeft = "0px";
		}
		else 
		{
			$('imgThumbs').style.marginLeft= i + "px";
		}
	}
}
window.onload = previewImg;
function previewImg() {
	var galleryEntry = document.getElementsByClassName("gallery-entry");
	for(x = 0; x < galleryEntry.length; x++) {
		galleryObj = galleryEntry[x];
		galleryObj.onmouseover = function() {clearInterval(myInterval);}
		galleryObj.onclick = function() {
			var gallerySrc = this.getAttribute('href');
			//new Effect.Opacity("preview", {duration:2.0, from:1.0, to:0.0, });
			new Effect.Opacity('preview', {duration:2.0, from:0.0, to:1.0,beforeStart: function(){
					document.images.previewImg.src = gallerySrc;
					new Effect.Appear("preview", {duration:1}) } });return false;
			
			/*new Effect.BlindUp('preview', {duration: 1.0, 
				afterFinish: function(){
					document.images.previewImg.src = gallerySrc;
					new Effect.BlindDown('preview', {duration: 2.0})
				}
			});
			return false
*/		}
	}
}