// JavaScript Document

function init()
{
	var id = document.getElementById("laufschrift");	// DIV "laufschrift" referenzieren
	
	for (i = 0; i < len; i++)							// initialisiert die texte per javascript
		document.getElementById('text' + i).firstChild.nodeValue = ' ';		// mit Leerstrings
//		document.getElementById('text' + i).firstChild.nodeValue = txt[i];	// mit den Texten aus dem Array

	id.style.top = "26px";								// Startposition, d.h erste Textzeile sichtbar
	i = j = 0;											// Indexvariablen initialisieren

	setTimeout("laufschrift()", timeoutStart);			// Laufschrift starten
}

function laufschrift()									// Zeigt bei jedem Durchlauf ein Zeichen mehr an...
{
	if (i < len)										// Schleife über die Texte
	{
		dummy = txt[i].slice(0, j);						// Teil der Zeichenkette extrahieren
		document.getElementById('text' + i).firstChild.nodeValue = dummy;

		if (j < txt[i].length)
		{
			++j;										// wenn noch nicht alle Zeichen angezeigt, Index inkrementieren
			setTimeout("laufschrift()", timeout);
		}
		else											// sonst...
		{
			i++;										// nächste Zeile
			j = 0;										// Buchstaben-Index auf 0 setzen
			setTimeout("scroll(i)", timeout);			// scrolle Zeile nach oben
		}
	}
}

function move(pos)
{
	var id = document.getElementById("laufschrift");		// DIV "laufschrift" referenzieren
	id.style.top = eval("\"" + pos +"px\"");				// versetzen
}


function scroll(idx)
{
	var id = document.getElementById("laufschrift");		// DIV "laufschrift" referenzieren

	pos = id.style.top.slice(0, id.style.top.length - 2);	// aktuelle position, z.B. "180px" ohne die letzten zwei Zeichen
	id.style.top = eval("\"" + --pos +"px\"");				// um ein Pixel nach oben scrollen

															// Verschiebung um 18px (normaler Text)
	if (idx == 1 && pos > 6)								// Index 1 und Position Zeile 2 noch nicht erreicht
		setTimeout("scroll(i)", timeoutScroll);				// ...weiter scrollen
	else if (idx == 2 && pos > -14)							// Index 2 und Position Zeile 3 noch nicht erreicht
		setTimeout("scroll(i)", timeoutScroll);				// ...weiter scrollen
	else if (idx == 3 && pos > -34)							// Index 3 und Position Zeile 4 noch nicht erreicht
		setTimeout("scroll(i)", timeoutScroll);				// ...weiter scrollen
	else if (idx == 4 && pos > -54)							
		setTimeout("scroll(i)", timeoutScroll);				// ...weiter scrollen
	else if (idx == 5 && pos > -74)							
		setTimeout("scroll(i)", timeoutScroll);				// ...weiter scrollen
	else if (idx == 6 && pos > -112)							// Verschiebung um 16px (kleiner Text)
		setTimeout("scroll(i)", timeoutScroll);				// ...weiter scrollen
	else if (idx == 7 && pos > -130)
		setTimeout("scroll(i)", timeoutScroll);				// ...weiter scrollen
	else if (idx == 8 && pos > -148)
		setTimeout("scroll(i)", timeoutScroll);				// ...weiter scrollen
	else if (idx == 9 && pos > -166)
		setTimeout("scroll(i)", timeoutScroll);				// ...weiter scrollen
	else if (idx == 10 && pos > -184)
		setTimeout("scroll(i)", timeoutScroll);				// ...weiter scrollen
	else if (idx == 11 && pos > -202)
		setTimeout("scroll(i)", timeoutScroll);				// ...weiter scrollen
	else if (idx == 12 && pos > -220)
		setTimeout("scroll(i)", timeoutScroll);				// ...weiter scrollen
	else if (idx == 13 && pos > -238)
		setTimeout("scroll(i)", timeoutScroll);				// ...weiter scrollen
	else if (idx == len)									// nach letztem Eintrag
	{
		init();												// neu starten
		setTimeout("top.location.href = relocate;", timeoutExit);	//Weiterleitung zur Indexseite
	}
	else													// sonst
		setTimeout("laufschrift()", timeout);				// nächsten Text anzeigen
}
