/* functions */
function playShow() {
	stopShow();
	div = getPicDiv();
	
	if (div && (div.childNodes.length > 1)) {
		showTimer = setTimeout('playShow()', 4000);
		nextImg();
	}
}

function stopShow() {
	try {
		clearTimeout(showTimer);
	} catch (e) {}
}

function nextImg() {
	act = hideAll();
	div = getPicDiv();
	
	swtichTo((Number(act)+1) % div.childNodes.length);
}

function showImg(nr) {
	if (firstRun || document.getElementById('pict'+nr).style.display == 'none') {
		hideAll();
		swtichTo(nr);
	}
}

function swtichTo(nr) {
	$('img#pict'+nr).fadeIn(1500);
	
	document.getElementById('text'+nr).style.display = 'block';
	document.getElementById('link'+nr).style.color = '#FFFFFF';
}

function getPicDiv() {
	return document.getElementById('pictures');
}

function hideAll() {
	div = getPicDiv();
	act = (div.childNodes.length-1);
	
	try {
		if (div.childNodes && div.childNodes.length > 0) {
			for (var nr = 0; nr < div.childNodes.length; nr++) {
				
				if (!firstRun && $('img#pict'+nr).css('display') == 'block') {
					
					startFade(nr);
					act = nr;
					
				} else if (!firstRun && nr != 0){
					
					document.getElementById('pict'+nr).style.display = 'none';
				}
				
				document.getElementById('text'+nr).style.display = 'none';
				document.getElementById('link'+nr).style.color = '#CCCCCC';
			}
		}
	} catch (e) {}
	
	firstRun = false;
	
	return act;
}

/* helper */
function startFade(nr) {
	fadeTimer = setTimeout('fadeImg('+nr+')', 0);
}
function fadeImg(nr) {
	clearTimeout(fadeTimer);
	$('img#pict'+nr).fadeOut(1500);
}

/* start */
firstRun = true;
playShow();

/* http://www.script-inside.de/Java/Sonst/scroll.php || s.u.i.t.e. */