var galleryInterval;

function fuc_galleryInterval() {
	galleryInterval = setInterval("fuc_galleryMove()", 10);
}

function fuc_galleryRewind() {
	var gallery = document.getElementById("gallery");
	galleryPosition = parseInt(gallery.style.left.substr(0, gallery.style.left.indexOf("px")));
	galleryPosition += 25;
	gallery.style.left = galleryPosition + "px";
	if (galleryPosition >= 0) {
		gallery.style.left = "0px";
		clearInterval(galleryInterval);
	}
}

function fuc_galleryMove() {
	var galleryPosition = 0;
	var gallery = document.getElementById("gallery");
	if (gallery.style.left != "") {
		galleryPosition = parseInt(gallery.style.left.substr(0, gallery.style.left.indexOf("px")));
	}
	galleryPosition -= 1;
	gallery.style.left = galleryPosition + "px";
	if (galleryPosition % 240 == 0) {
		clearInterval(galleryInterval);
		setTimeout("fuc_galleryInterval()", 5000);
	}
	if (galleryPosition <= (240 - galleryWidth)) {
		clearInterval(galleryInterval);
		galleryInterval = setInterval("fuc_galleryRewind()", 10);
	}
}