// JS für Bildwechsel

// Bildwechsel alle x sekunden
$i=1;
firstimage = true;

function init(n) {
	if ($('hauptbild1')) {
		var aktiv = window.setInterval("wechselbild("+n+")", 6000);
	}
}

function wechselbild(n) {
	
	var pos = $('hauptbild1').src.lastIndexOf("/");
	var path = $('hauptbild1').src.substring(0, pos);
	
	if ($i == n) {$i=0;}
	
	if (firstimage) {
		$('hauptbild2').hide();
		$('hauptbild1').style.zIndex = 1;
		$('hauptbild2').style.zIndex = 10;
		$('hauptbild2').src = path + "/0"+ $i + ".jpg";
		Effect.Appear('hauptbild2', { duration: 3.0 });
		firstimage = false;
	}
	else {
		$('hauptbild1').hide();
		$('hauptbild2').style.zIndex = 1;
		$('hauptbild1').style.zIndex = 10;
		$('hauptbild1').src = path + "/0"+ $i + ".jpg";
		Effect.Appear('hauptbild1', { duration: 3.0 });
		firstimage = true;
	}
	
	$i++;
}
