
// globale Variable für aktuelle Nummer
var nummer = 1;
// globale Variablen für Anzahl je Modelltyp
var maxH0 = 1873;
var maxUSA = 11;
var maxZ = 56;
var maxN = 73;
var maxTT = 6;
var maxKFZ = 36;
var max0 = 5;
var wartezeit = 2000;
// globale Variable für Modelltyp
var modelltyp = "HO-Modelle";
// globale Variable als Kennung für Modelltyp im Bildnamen
var typ = "h0";
// globale Variable für letzte Nummer
var maxnummer = maxH0;
// globale Variable für aktuelle Anzeigeart  {"klein"|"gross"}
var anzeige = "gross";

//
function GrossAnzeige() {
	if (nummer < 1000) MeinFenster = window.open("/" + typ +"/mod" + nummer + ".gif","Ansicht");
	if (nummer > 999)  MeinFenster = window.open("/" + typ +"/mod" + nummer + ".jpg","Ansicht");
	MeinFenster.focus();
}

function NeuerTyp() {
	switch(typ)
	{
	case "h0":
		modelltyp = "H0-Modelle USA Bausätze";
		typ = "USA";
		document.images[5].src = "/spur_h0.gif";
		maxnummer = maxUSA;
		break;
	case "USA":
		modelltyp = "märklin miniclub";
		typ = "z";
		document.images[5].src = "/spur_z.gif";
		maxnummer = maxZ;
		break;
	case "z":
		modelltyp = "Spur N Modelle";
		typ = "n";
		document.images[5].src = "/spur_n.gif";
		maxnummer = maxN;
		break;
	case "n":
		modelltyp = "TT-Modelle";
		typ = "tt";
		document.images[5].src = "/spur_tt.gif";
		maxnummer = maxTT;
		break;
	case "tt":
		modelltyp = "KfZ-Modelle";
		typ = "kfz";
		document.images[5].src = "/spur_kfz.gif";
		maxnummer = maxKFZ;
		break;
	case "kfz":
		modelltyp = "Spur 0-Modelle";
		typ = "0";
		document.images[5].src = "/spur_0.gif";
		maxnummer = max0;
		break;
	case "0":
		modelltyp = "H0-Modelle";
		typ = "h0";
		document.images[5].src = "/spur_h0.gif";
		maxnummer = maxH0;
		break;
	}
	nummer = 1;
}


function initBild() {
   if (anzeige = "klein") document.images[0].src = "/" + typ + "/mod" + nummer + "s.jpg";
   if (anzeige = "gross")
	{
	   if (nummer < 1000) document.images[0].src = "/" + typ + "/mod" + nummer + ".gif";
	   if (nummer >  999) document.images[0].src = "/" + typ + "/mod" + nummer + ".jpg";
	}
   einer = nummer % 10;
   zehner = ((nummer - einer) / 10 ) % 10;
   hunderter = ((nummer - einer) - 10 * zehner) / 100 % 10;
   tausender = (((nummer - einer) - 10 * zehner) - 100 * hunderter) / 1000;
   document.images[1].src = "/ziffer" + tausender + ".gif";
   document.images[2].src = "/ziffer" + hunderter + ".gif";
   document.images[3].src = "/ziffer" + zehner + ".gif";
   document.images[4].src = "/ziffer" + einer + ".gif";
}

function rotate() {
   if (++nummer > maxnummer)  NeuerTyp();
   initBild();
   window.setTimeout('rotate();',wartezeit);
}

function SetzeNummer() {
   nummer = prompt("Bitte Nummer zwischen 1 und "+maxnummer+" eingeben:","");
   if (nummer > maxnummer)  nummer = 1;
   if (nummer < 1)  nummer = 1;
}

function SetzeSpur() {
   nummer = maxnummer + 1;
   initBild();
}

function Tempo(Wert) {
    wartezeit = wartezeit + Wert;
    if (wartezeit < 500) wartezeit = 500;
}


