var Keno_Price_bearbeitungsgebuehr = 25;var Keno_Price_plus5_einsatz       = 75;/*var Keno_feldLeft  = 135;var Keno_feldWidth = 77;var Keno_feldTop   = 48;var Keno_kaestchenWidth  = 9;var Keno_kaestchenHeight = 11;*/var Keno_anzahlFelder = 5;var Keno_maxKreuze    = 10;function KenoState() {}/* Laden und Speichern des Zustandes */KenoState.prototype.load = function (form) {		this.kasten = [];	for(var i = 0; i< Keno_anzahlFelder; i++) {		var name = "f" + (i+1);		this.kasten[i] = new KenoKasten();		this.kasten[i].load(form[name].value)	}		this.plus5_teilnahme   = NDS_parseBool(0)	this.anzahl_ziehungen  = NDS_parseInt(form.az.value)	this.einsatz           = NDS_parseInt(form.ept.value)	this.name       = form.name.value}KenoState.prototype.save = function (form) {	for(var i = 0; i< Keno_anzahlFelder; i++) {		var f = "f" + (i+1);		var kt = "kt" + (i+1);		form[f].value = this.kasten[i].save();		form[kt].value = this.kasten[i].kenotyp();	}		form["to"].value = document.to;	form["price"].value = this.scheinEinsatz();	if (this.plus5_teilnahme) {		form["plus5jn"].value = '1';	} else {		form["plus5jn"].value = '0';	}	form["plus5n"].value = this.spielscheinnummer;	form["az"].value = this.anzahl_ziehungen;	form["ept"].value = this.einsatz;}KenoState.prototype.getEinsatzIndex = function () {	var e = this.einsatz;		if(e == 100) return 1;	if(e == 200) return 2;	if(e == 500) return 3;	if(e == 1000) return 4;	alert("unknown einsatz: " + this.einsatz)}/* business logik */KenoState.prototype.clear = function () {	if (document.Keno_tempKasten) {		document.Keno_tempKasten = new KenoKasten();		document.Keno_tempKasten.newKasten([]);		document.Keno_tempKasten.drawClose();	} else {		for(var i = 0; i < Keno_anzahlFelder; i++) {			this.kasten[i] = new KenoKasten();			this.kasten[i].newKasten([])		}	}}KenoState.prototype.quicktipp = function (kenotyp) {	for(var i = 0; i < Keno_anzahlFelder; i++) {		var k = new KenoKasten();		k.should_typ = kenotyp		k.quicktipp();		this.kasten[i] = k	}}KenoState.prototype.scheinEinsatz = function () {	var laufzeit_index = this.anzahl_ziehungen - 1;	var plus5 = 0;	if(this.plus5_teilnahme) {		plus5 =  NDS_sumArrayToIndex(document.Keno_einsatzPlus5, laufzeit_index);		plus5 += document.Keno_gebuehrPlus5[laufzeit_index]	}		var subprice = 0;	var anzahl_felder = 0;	for(var i = 0; i< Keno_anzahlFelder; i++) {		if(this.kenotyp(i) > 0) {			subprice += this.einsatz			anzahl_felder++		}	}		if(anzahl_felder == 0) {		return 0	} 		var price = 0		if(!document.gebuehrgutschrift){		price += document.Keno_gebuehr[laufzeit_index];	}		price += subprice * this.anzahl_ziehungen + plus5;		return price}KenoState.prototype.kenotyp = function (which) {	return this.kasten[which].kenotyp()}KenoState.prototype.anzahlFelder = function () {		var n = 0;		for(var i = 0; i< Keno_anzahlFelder; i++) {		if(this.kasten[i].length >= 2) {			n++		}	}	return n}/* draw Methoden */KenoState.prototype.draw = function (form) {	this.drawScheinEinsatz();	this.drawEinsatz();	this.drawAnzahlZiehungen();	this.drawPlus5()		for(var i = 0; i < Keno_anzahlFelder; i++) {		this.kasten[i].draw(i)		this.kasten[i].drawKenotyp(i)	}}KenoState.prototype.drawFeld  = function (which) {	var xes = this.kasten[which];		this.kasten[which].draw(which)		/*for(var i = 0; i < Keno_maxKreuze; i++) {		var layerName = "x" + which + "z" + i;		var x = xes[i];		if(x > 0) {						x = x - 1 // prepare for modulo arithmetic						var col = x % 7;			var row = Math.floor(x / 7);					var left   = Keno_feldLeft + which * Keno_feldWidth + col * Keno_kaestchenWidth;			var top    = Keno_feldTop  +                          row * Keno_kaestchenHeight;					NDS_showAndPositionLayer(layerName, left, top)		} else {			NDS_hideLayer(layerName)		}	}*/}KenoState.prototype.drawPlus5 = function () {	var ja = MM_findObj("plus5ja");	var nein = MM_findObj("plus5nein");	for(var i = 0; i < 5; i++) {		var image = MM_findObj("plus5" + (i + 1));		if (image) {			image.src = document.Keno_basePath+"d/pics/spielschein/" + this.spielscheinnummer.substr(i, 1) + ".gif";		}	}		if (ja) {		if (this.plus5_teilnahme) {			ja.src = document.Keno_basePath+"shared/13x15.gif"			nein.src = document.Keno_basePath+"shared/t.gif"		} else {			nein.src = document.Keno_basePath+"shared/13x15.gif"			ja.src = document.Keno_basePath+"shared/t.gif"		}	}}KenoState.prototype.drawEinsatz = function (form) {	var einsaetze = [100,200,500,1000];		for(var i in einsaetze) {		var einsatz = einsaetze[i];		var image   = MM_findObj("einsatz"+einsatz)   	    if(einsatz == this.einsatz) {			image.src = document.Keno_basePath+"shared/13x15.gif"    	} else {			image.src = document.Keno_basePath+"shared/t.gif"    	}	}}KenoState.prototype.drawAnzahlZiehungen = function () {	var anzahlen = [1,2,3,4,5,6];	for(var i in anzahlen) {		var anzahl = anzahlen[i];		var image = MM_findObj("ziehungen"+anzahl);		if (image) {			if (anzahl == this.anzahl_ziehungen) {			  image.src = document.Keno_basePath+"shared/13x15.gif"			} else {			  image.src = document.Keno_basePath+"shared/t.gif"			}        }	}}/*KenoState.prototype.drawScheinEinsatz = function () {	MM_findObj("einsatzLayer").innerHTML = this.scheinEinsatz();}*/KenoState.prototype.drawScheinEinsatz = function () {	var einsatz = this.scheinEinsatz() / 100; // cent -> euro	MM_findObj("scheinEinsatzLayer").innerHTML = NDS_numberToGermanString(einsatz)}