function changeOpac(opacity, imgid) {
    var object = document.getElementById(imgid).style;
    object.opacity = opacity/100;
    object.MozOpacity = opacity/100;
    object.KhtmlOpacity = opacity/100;
    object.filter = "alpha(opacity="+opacity+")";
}

function fadeIn(imgid) {
	var timer = 0;
	for (k = 0; k <= 100; k++) {
		setTimeout("changeOpac("+k+",'"+imgid+"')", (timer*30));
		timer++;
	} 	
}

function step01() {
	document.getElementById('image_3_1').style.display = "none";
	document.getElementById('image_3_2').style.display = "none";
	document.getElementById('image_3_3').style.display = "none";
	document.getElementById('image_3_4').style.display = "none";
	changeOpac(0, 'image_1_1');
	document.getElementById('image_1_1').style.display = "block";
	fadeIn('image_1_1');
	setTimeout("step02()", 3000);
}
function step02() {
	changeOpac(0, 'image_1_2');
	document.getElementById('image_1_2').style.display = "block";
	fadeIn('image_1_2');
	setTimeout("step03()", 3000);
}
function step03() {
	changeOpac(0, 'image_1_3');
	document.getElementById('image_1_3').style.display = "block";
	fadeIn('image_1_3');
	setTimeout("step04()", 3000);
}
function step04() {
	changeOpac(0, 'image_1_4');
	document.getElementById('image_1_4').style.display = "block";
	fadeIn('image_1_4');
	setTimeout("step05()", 6000);
}
function step05() {
	Effect.Fade('index_1', { to: 0.0, duration: 3.0 });
	Effect.Appear('index_2', { duration: 3.0 });
	setTimeout("step06()", 3000);
}
function step06() {
	document.getElementById('image_1_1').style.display = "none";
	document.getElementById('image_1_2').style.display = "none";
	document.getElementById('image_1_3').style.display = "none";
	document.getElementById('image_1_4').style.display = "none";
	changeOpac(0, 'image_2_1');
	document.getElementById('image_2_1').style.display = "block";
	fadeIn('image_2_1');
	setTimeout("step07()", 3000);
}
function step07() {
	changeOpac(0, 'image_2_2');
	document.getElementById('image_2_2').style.display = "block";
	fadeIn('image_2_2');
	setTimeout("step08()", 3000);
}
function step08() {
	changeOpac(0, 'image_2_3');
	document.getElementById('image_2_3').style.display = "block";
	fadeIn('image_2_3');
	setTimeout("step09()", 3000);
}
function step09() {
	changeOpac(0, 'image_2_4');
	document.getElementById('image_2_4').style.display = "block";
	fadeIn('image_2_4');
	setTimeout("step10()", 6000);
}
function step10() {
	Effect.Fade('index_2', { to: 0.0, duration: 3.0 });
	Effect.Appear('index_3', { duration: 3.0 });
	setTimeout("step11()", 3000);
}
function step11() {
	document.getElementById('image_2_1').style.display = "none";
	document.getElementById('image_2_2').style.display = "none";
	document.getElementById('image_2_3').style.display = "none";
	document.getElementById('image_2_4').style.display = "none";
	changeOpac(0, 'image_3_1');
	document.getElementById('image_3_1').style.display = "block";
	fadeIn('image_3_1');
	setTimeout("step12()", 3000);
}
function step12() {
	changeOpac(0, 'image_3_2');
	document.getElementById('image_3_2').style.display = "block";
	fadeIn('image_3_2');
	setTimeout("step13()", 3000);
}
function step13() {
	changeOpac(0, 'image_3_3');
	document.getElementById('image_3_3').style.display = "block";
	fadeIn('image_3_3');
	setTimeout("step14()", 3000);
}
function step14() {
	changeOpac(0, 'image_3_4');
	document.getElementById('image_3_4').style.display = "block";
	fadeIn('image_3_4');
	setTimeout("step15()", 6000);
}
function step15() {
	Effect.Fade('index_3', { to: 0.0, duration: 3.0 });
	Effect.Appear('index_1', { duration: 3.0 });
	setTimeout("step01()", 3000);
}

function PadDigits(n, totalDigits) { 
	n = n.toString(); 
	var pd = ''; 
	if (totalDigits > n.length) { 
		for (i=0; i < (totalDigits-n.length); i++) { 
			pd += '0'; 
		} 
	} 
	return pd + n.toString(); 
} 

var maxPhoto = 20;

function nextPhoto() {
	var tourid = document.getElementById('tourid').value;
	if (tourid < maxPhoto) {
		document.getElementById('tourid').value = (1*tourid) + (1*1);
		var imageid = PadDigits((1*tourid) + (1*1), 2)
		document.getElementById('tour').src = 'images/tour/tour'+imageid+'.jpg';
		var text = document.getElementById('caption'+imageid).value;
		document.getElementById('captions').innerHTML = text;
	}
	else {
		document.getElementById('tourid').value = 1;
		document.getElementById('tour').src = 'images/tour/tour01.jpg';
		var text = document.getElementById('caption01').value;
		document.getElementById('captions').innerHTML = text;
	}
}

function prevPhoto() {
	var tourid = document.getElementById('tourid').value;
	if (tourid > 1) {
		document.getElementById('tourid').value = (1*tourid) - (1*1);
		var imageid = PadDigits((1*tourid) - (1*1), 2)
		document.getElementById('tour').src = 'images/tour/tour'+imageid+'.jpg';
		var text = document.getElementById('caption'+imageid).value;
		document.getElementById('captions').innerHTML = text;
	}
	else {
		document.getElementById('tourid').value = maxPhoto;
		document.getElementById('tour').src = 'images/tour/tour'+maxPhoto+'.jpg';
		var text = document.getElementById('caption'+maxPhoto).value;
		document.getElementById('captions').innerHTML = text;
	}
}