var galleryHeight = 60;
var currentImage = 0;
var currentOffset = 0;
var timeout = 6500; // Time between jump of picture A and picture B
var delayRoll = 750; // Time to wait for rolling down a high image
var rollingTime = 5500; // Time it takes for a big image to roll down

var gallery;
var images;
/*
function toggleFunction() {
			var check = document.getElementById('submenulist').style;
			
			if(check.display == 'none')
			{
				check.display = 'block';
			}
			else
			{
				check.display='none';
			}
			
			}*/
				
		
function startGallery() {
	gallery = document.getElementById('galleryholder');
	if (gallery != null) {
	
		images = gallery.getElementsByTagName('img');
		if (images.length > 1) {
		
			if (images[currentImage].height > galleryHeight) {
				// start a horizontal show all interval first
				setTimeout("showVerticalImage()", delayRoll);
			} else {
				// wait and to to the next image
				setTimeout("nextImage()", timeout);
			}
			
		} else {
			if (images[currentImage].height > galleryHeight) {
				// start a horizontal show all interval first
				setTimeout("showVerticalImage()", delayRoll);
			}
		}
	}
}

function showVerticalImage() {
	offset = images[currentImage].height - galleryHeight;
	currentOffset = currentOffset - offset;
	
	var myFx = new Fx.Tween(gallery, {duration: rollingTime, transition: Fx.Transitions.Cubic.easeInOut});
	myFx.start('top', currentOffset);
	
	setTimeout("nextImage()", timeout);
}

function nextImage() {
	
	if (currentImage < images.length - 1) {
		currentOffset = currentOffset - galleryHeight;
	
		var myFx = new Fx.Tween(gallery, {duration: '600', transition: Fx.Transitions.Cubic.easeInOut});
		myFx.start('top', currentOffset);
	
		currentImage++;
	
		if (images[currentImage].height > galleryHeight) {
			
			// start a horizontal show all interval first
			setTimeout("showVerticalImage()", delayRoll);
		} else {
			setTimeout("nextImage()", timeout);
		}
	} else {
		setTimeout("goUpAgain()", 1000);
	}
	
	
	
}

function goUpAgain() {
	currentImage = 0;
	currentOffset = 0;
	
	var myFx = new Fx.Tween(gallery, {duration: '50', transition: Fx.Transitions.Cubic.easeInOut});
	myFx.start('top', currentOffset);
	
	if (images[currentImage].height > galleryHeight) {
		// start a horizontal show all interval first
		setTimeout("showVerticalImage()", delayRoll);
	} else {
		setTimeout("nextImage()", timeout);
	}
}
