/* Der Keno Kasten ist 1 basiert */var Keno_feldTop   = 168;var Keno_feldLeft  = 265;var Keno_feldWidth = 75;var Keno_kaestchenWidth  = 9;var Keno_kaestchenHeight = 11;var Keno_typLeft            = 267;var Keno_typTop             = 295;var Keno_typWidth           = 77;var Keno_typKaestchenWidth  = 12;var Keno_typKaestchenHeight = 13;//267px; top: 295px;var Keno_typDefault         = 0;var Keno_anzahlFelder = 5;var Keno_maxKreuze    = 10;function KenoKasten() {	this.length = 0;	this.should_typ = 0;}KenoKasten.prototype.quicktipp = function () {		var array = [];	array[69] = false;		var hits = 0		var kasten = [];		while(hits < this.should_typ) {		var number = NDS_getRandomArrayIndex(array);		if(!array[number]) {			array[number]  = true			kasten[hits++] = number + 1; // Basis 1		}	}		this.kasten = kasten	this.length = kasten.length}KenoKasten.prototype.addX = function (n) {	this.should_typ = 0;	if(this.length == 10) {		//alert("Maximaler Kenotyp 10")	} else {			for(var i in this.kasten) {			var x = this.kasten[i];			if(x == n) {				return;			}		}			this.kasten[this.length++] = n;	}}KenoKasten.prototype.isComplete = function () {	var typ = this.kenotyp();		if(typ == 0) {		return false;	}		if(typ == this.should_typ) {		return true;	}	return false}KenoKasten.prototype.delNthX = function (n) {		this.should_typ = 0;		var newKasten = [];		var j = 0;		for(var i = 0; i < this.length; i++) {		if(i != n) {			newKasten[j++] = this.kasten[i]		}	}			this.length--;		this.newKasten(newKasten)}KenoKasten.prototype.deleteAfter = function (n) {			var newKasten = [];		var j = 0;		for(var i = 0; i < this.length; i++) {		if(i < n) {			newKasten[j++] = this.kasten[i]		} else {			this.length--;		}	}			this.newKasten(newKasten)}KenoKasten.prototype.actualLength = function () {	return this.kasten.length}KenoKasten.prototype.kenotyp = function () {	var typ = this.kasten.length	if(typ < 2) {		return 0	}	if(typ > 10) {		alert("fehler: zu hoher keno typ")	}	return typ}KenoKasten.prototype.copyKasten = function (kasten) {			var newKasten = [];	for(var i in kasten) {		newKasten[i] = kasten[i]	}	this.newKasten(newKasten)}KenoKasten.prototype.newKasten = function (kasten) {		this.kasten = kasten		this.length = kasten.length < 2 ? 0 : this.kasten.length // minimum length = 2}KenoKasten.prototype.load = function (value) {			var kasten = NDS_split(",", value);		//alert(kasten[0])		if(kasten[0] == null || kasten[0] == "") kasten = []		this.newKasten(kasten)}KenoKasten.prototype.save = function () {		return NDS_join(",", this.kasten)}KenoKasten.prototype.draw = function (which) {	var xes = this.kasten;		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 korr = Math.floor(which / 3);					var left   = Keno_feldLeft + which * Keno_feldWidth + col * Keno_kaestchenWidth - korr;			var top    = Keno_feldTop  +                          row * Keno_kaestchenHeight;					NDS_showAndPositionLayer(layerName, left, top)		} else {			NDS_hideLayer(layerName)		}	}}var Keno_subFeldLeft        = 268;var Keno_subFeldTop         = 168;var Keno_subKaestchenWidth  = 19;var Keno_subKaestchenHeight = 21;KenoKasten.prototype.drawClose = function () {	var xes = this.kasten;		for(var i = 0; i < Keno_maxKreuze; i++) {		var layerName = "subX" + 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_subFeldLeft + col * Keno_subKaestchenWidth;			var top    = Keno_subFeldTop  + row * Keno_subKaestchenHeight;					NDS_showAndPositionLayer(layerName, left, top)		} else {			NDS_hideLayer(layerName)		}	}		this.drawKenotypClose();}KenoKasten.prototype.drawKenotyp  = function (which) {	var layerName = "kenoTypLayer"+which	var kenotyp = this.kenotyp();	if(kenotyp > 0) {		kenotyp = kenotyp - 2 //modulo		var col = kenotyp % 5;		var row = Math.floor(kenotyp / 5);		var korr = Math.floor(which / 3);		var x = Keno_typLeft + which * (Keno_typWidth - 2) + col * Keno_typKaestchenWidth - korr;		var y = Keno_typTop  +                       + row * Keno_typKaestchenHeight;					//alert(x)					NDS_showAndPositionLayer(layerName, x, y)	} else {		NDS_hideLayer(layerName)	}}KenoKasten.prototype.drawKenotypClose = function (form) {		var kenotyp = this.kenotyp() || Keno_typDefault;		if(this.should_typ > 0) {		kenotyp = this.should_typ	}		this.should_typ = kenotyp		for(var i = 2; i <= 10; i++) {		var image   = MM_findObj("subKenotyp"+i)		if(i == kenotyp) {			image.src = document.Keno_basePath+"/shared/13x15.gif"		} else {			image.src = document.Keno_basePath+"/shared/t.gif"		}	}		var quoten   = "";	var anzahlen = "";	var wahrscheinlichkeiten = '';	var gp = document.Keno_gewinnplaene[kenotyp];	for(var i in gp) {	    var zeile  = gp[i];	    if(!zeile) {alert(kenotyp)}		var anzahl = zeile[0];		var quote  = zeile[document.Keno_state.getEinsatzIndex()];		var wahrscheinlichkeit = zeile[zeile.length-1]				//quoten   = quoten   + quote  + ' <img src="'+document.Keno_basePath+'/pics/Keno/gp_euro.gif" width="8" height="8" class="subGewinnplan"> <br>'		quoten   = quoten   + quote  + ' EUR <br>'		anzahlen = anzahlen + anzahl + ' <br>'		wahrscheinlichkeiten = wahrscheinlichkeiten + wahrscheinlichkeit + '<br>'	}		NDS_fillLayer("subGewinnplanAnzahlLayer", anzahlen, "subGewinnplan");	NDS_fillLayer("subGewinnplanQuoteLayer", quoten, "subGewinnplan");	NDS_fillLayer("subWahrscheinlichkeitLayer", wahrscheinlichkeiten, "subWahrscheinlichkeit");		Keno_tippHelp()}