	output='text';
	allowed=true;
	allowsend=false;
	current=0;
	session=false;
	timer=true;
	fastbet=false;
	bet=0;
	logedin=false;
	ctimer=null;
	bets=new Array();
	select=new Array();
	active=null;
	course=null;
	confirmInProgress=false;
	controlsActive=false;
	
	submit_wettschein_image=new Image();
	submit_wettschein_image.src="images/" + txtPfad + "/submit_wettschein_erstellen.jpg";
	submit_wettschein_active_image=new Image();
	submit_wettschein_active_image.src="images/" + txtPfad + "/submit_wettschein_erstellen_active.jpg";
	
	
	
	

	function wettschein_countdown(redirect)
	{
		var contents;
		var tv_contents;
		
		if (timer)
		{
			minimum=-1;
			selected=-1;
			closing=false;
			
			for (i=0;i<races.length;i++)
			{
				if (((minimum==-1) || (selected==-1) || (races[i][7]<minimum)) && (races[i][7]>=15))
				{
					minimum=races[i][7];
					selected=i;
				}
			}
			
			if (selected!=-1)
			{
				tv_contents="";
				contents="<SPACER TYPE=BLOCK HEIGHT=18>";
				
				for (i=0;i<races.length;i++)
				{
					if (races[i][7]==0)
					{
						timer=false;
						if (ctimer!=null) clearTimeout(ctimer);
						refresh("index");
					}
					
					if (races[i][7]<15)
					{
						bet=0;
						
						if ((races[i][0]==current) && (allowsend))
						{
							cells_reset();
							generate_victory_bet(current);
							generate_intake_bet(current);
						}
						
						tv_contents=races[i][11]+": " + txtRennenWirdGestartet;
						contents="<FONT COLOR=\"#990000\">" + races[i][11]+": " + txtWettannahmeClosed + "</FONT>";
						closing=true;
					}
					
					if ((i==selected) && (!closing))
					{
						contents=races[i][11]+": " + txtClosedIn + ": "+(races[i][7]-15)+" s";
						allowed=true;
					}
					
					if (races[i][7]>0)
					{
						races[i][7]=races[i][7]-1;
						
						if (i==selected)
						{
							switch (browser)
							{
								case 1:
										tv_countdown.innerHTML=tv_contents;
										countdown_layer.innerHTML=contents;
								break;
								
								case 2:
										document.getElementById("tv_countdown").innerHTML=tv_contents;
										document.getElementById("countdown_layer").innerHTML=contents;
								break;
								
								default: browser_error(); break;
							}
						}
					}
				}
			}
			else
			{
				refresh("index");
			}
			
			if (session)
			{
				minimum=-1;
				selected=-1;
				contents="";
				
				for (i=0;i<races.length;i++)
				{
					for (j=0;j<stored.length;j++)
					{
						if (stored[j][0]==races[i][0])
						{
							if (races[i][7]<15)
							{
								timer=false;
								if (ctimer!=null) clearTimeout(ctimer);
								eval('destroy_bet('+races[i][0]+',\''+redirect+'\');');
							}
							else
							{
								if (((minimum==-1) || (selected==-1) || (races[i][7]<minimum)) && (races[i][7]>=14))
								{
									if (races[i][7]<75) contents="<B>" + txtTKValidUntil + ": "+(races[i][7]-14)+" sec.</B>";
									else contents="<B>" + txtTKValidUntil + ": "+(Math.round((races[i][7]-14)/60))+" min.</B>";

									minimum=races[i][7];
									selected=i;
								}
							}
						}
					}
				}
				
				if (timer)
				{
					switch (browser)
					{
						case 1: bettime.innerHTML=contents; break;
						case 2: document.getElementById("bettime").innerHTML=contents; break;
						default: browser_error(); break;
					}
				}
			}
			
			ctimer=setTimeout("wettschein_countdown('"+redirect+"')",1000);
		}
	}
	
	
	function generate_race_options(race)
	{
		if (races.length>0)
		{
			for (i=0;i<=races.length;i++)
			{
				if (i==races.length) { race=races[0][0]; break; }
				if (races[i][0]==race) { break; }
			}
		}

		for (i=0;i<races.length;i++)
		{
			if (races[i][0]==race)
			{
				contents='<TABLE><TR><TD WIDTH=20>';
				
				if (i>0) contents+='<A HREF="#" onClick="change_race('+races[(i-1)][0]+');"><IMG SRC="images/wetten_previous.gif" WIDTH=20 HEIGHT=17 HSPACE=3 BORDER=0 ALT=""></A>';
				
				contents+='</TD>';
				
				contents+='<TD width=112 align=center><INPUT NAME="selector" TYPE="hidden" VALUE="'+races[i][0]+'">';
				contents+='<FONT CLASS="nv" COLOR="#FFFFFF"><B>' + txtRennen + ' '+races[i][11]+'</B></FONT></TD>';
				
				contents+='<TD WIDTH=36>';
				
				if ((i+1)<races.length) contents+='<A HREF="#" onClick="change_race('+races[(i+1)][0]+');"><IMG SRC="images/wetten_next.gif" WIDTH=20 HEIGHT=17 HSPACE=3 BORDER=0 ALT=""></A>';
				
				contents+='</TD></TR></TABLE>';
			}
		}

		current=race;
		
		switch (browser)
		{
			case 1: race_options.innerHTML=contents; break;
			case 2: document.getElementById("race_options").innerHTML=contents; break;
			default: browser_error(); break;
		}
		
	}
	
	function is_stored(race,col,row)
	{
		if (races[race][9])
		{
			for (x=0;x<races[race][10].length;x++)
			{
				if (String(races[race][10][x])==String(String(col)+String(row))) return true;
			}
		}
		
		return false;
	}
	
	function generate_victory_bet(race)
	{
		contents='';
		
		if (races.length>0)
		{
			contents+='<TABLE BORDER=0 WIDTH=54 CELLSPACING=0 CELLPADDING=0>';
			
			for (i=0;i<=races.length;i++)
			{
				if (i==races.length) { race=0; break; }
				if (races[i][0]==race) { race=i; break; }
			}

      maxQuote = 0;
			for (i=1;i<=6;i++) {
				if (Number(races[race][i]) >= maxQuote) {
				  maxQuote = Number(races[race][i]);
				}
			}
			
			for (i=1;i<=6;i++)
			{
				contents+='<TR>';
				contents+='<TD WIDTH=53 HEIGHT=32 ALIGN="center">';

/*
				if (is_stored(race,i,0)) contents+='<DIV ID="cell_'+races[race][0]+'_'+i+'0" STYLE="width:53;height:31;" class="oddInBetslip"><TABLE BORDER=0 WIDTH=53 HEIGHT=31 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN="center"><FONT CLASS="nv"><FONT COLOR="#000000"><B>'+races[race][i]+'</B></FONT></FONT></TD></TR></TABLE></DIV>';
				else contents+='<DIV ID="cell_'+races[race][0]+'_'+i+'0" STYLE="width:53;height:31;"><TABLE BORDER=0 WIDTH=53 HEIGHT=31 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN="center"><FONT CLASS="nv"><A ID="href_'+races[race][0]+'_'+i+'0" HREF="#" onMouseOver="cell_focus(this,'+races[race][0]+','+i+',0);" onMouseOut="cell_unfocus(this,'+races[race][0]+','+i+',0);" onClick="cell_set(this,'+races[race][0]+','+i+',0,\'#F4E5E5\',\'index\'); return false;" CLASS="lnv"><FONT COLOR="#000000"><B>'+races[race][i]+'</B></FONT></A></FONT></TD></TR></TABLE></DIV>';
*/
				if (is_stored(race,i,0)) {
				  contents+='<DIV ID="cell_'+races[race][0]+'_'+i+'0" STYLE="width:53;height:31;" class="oddInBetslip"><TABLE BORDER=0 WIDTH=53 HEIGHT=31 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN="center"><FONT CLASS="nv">';
				  if (races[race][i] == maxQuote) {
				    contents+='<FONT COLOR="#FF0000">';
				  } else {
				    contents+='<FONT COLOR="#000000">';
				  }
				  contents+='<B>'+races[race][i]+'</B></FONT></FONT></TD></TR></TABLE></DIV>';
				}	else {
				  contents+='<DIV ID="cell_'+races[race][0]+'_'+i+'0" STYLE="width:53;height:31;"><TABLE BORDER=0 WIDTH=53 HEIGHT=31 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN="center"><FONT CLASS="nv"><A ID="href_'+races[race][0]+'_'+i+'0" HREF="#" onMouseOver="cell_focus(this,'+races[race][0]+','+i+',0);" onMouseOut="cell_unfocus(this,'+races[race][0]+','+i+',0);" onClick="cell_set(this,'+races[race][0]+','+i+',0,\'#F4E5E5\',\'index\'); return false;" CLASS="lnv">';
				  if (races[race][i] == maxQuote) {
				    contents+='<FONT COLOR="#FF0000">';
				  } else {
				    contents+='<FONT COLOR="#000000">';
				  }
				  contents+='<B>'+races[race][i]+'</B></FONT></A></FONT></TD></TR></TABLE></DIV>';
				}
				
				contents+='</TD>';
				contents+='</TR>';
			}
			contents+='</TABLE>';
		}
		
		switch (browser)
		{
			case 1: victory_bet.innerHTML=contents; break;
			case 2: document.getElementById("victory_bet").innerHTML=contents; break;
			default: browser_error(); break;
		}
	}
	
	function generate_intake_bet(race)
	{
		contents='';
		
		if (races.length>0)
		{
			contents+='<TABLE BORDER=0 WIDTH=324 CELLSPACING=0 CELLPADDING=0>';
			
			for (i=0;i<=races.length;i++)
			{
				if (i==races.length) { race=0; break; }
				if (races[i][0]==race) { race=i; break; }
			}
			
			
      maxQuote = 0;
			for (j=1;j<=6;j++) {
				for (i=1;i<=6;i++) {
				  if (j!=i) {
  				  if (Number(races[race][(j*10)+i]) >= maxQuote) {
  				    maxQuote = Number(races[race][(j*10)+i]);
  				  }
				  }
				}
			}

			
			for (j=1;j<=6;j++)
			{
				contents+='<TR>';
				
				for (i=1;i<=6;i++)
				{
					contents+='<TD WIDTH=53 HEIGHT=32 ALIGN="center">';
					
					if (j!=i)
					{

/*
						if (is_stored(race,j,i)) contents+='<DIV ID="cell_'+races[race][0]+'_'+j+i+'" STYLE="width:53;height:31;" class="oddInBetslip"><TABLE BORDER=0 WIDTH=53 HEIGHT=31 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN="center"><FONT CLASS="nv"><FONT COLOR="#000000"><B>'+races[race][(j*10)+i]+'</B></FONT></FONT></TD></TR></TABLE></DIV>';
						else contents+='<DIV ID="cell_'+races[race][0]+'_'+j+i+'" STYLE="width:53;height:31;"><TABLE BORDER=0 WIDTH=53 HEIGHT=31 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN="center"><FONT CLASS="nv"><A ID="href_'+races[race][0]+'_'+j+i+'" HREF="#" TITLE="#'+j+' vor #'+i+': ' + txtQuote + '='+races[race][(j*10)+i]+'" onMouseOver="cell_focus(this,'+races[race][0]+','+j+','+i+');" onMouseOut="cell_unfocus(this,'+races[race][0]+','+j+','+i+');" onClick="cell_set(this,'+races[race][0]+','+j+','+i+',\'#F4E5E5\',\'index\'); return false;" CLASS="lnv"><FONT COLOR="#000000"><B>'+races[race][(j*10)+i]+'</B></FONT></A></FONT></TD></TR></TABLE></DIV>';
*/
						if (is_stored(race,j,i)) {
						  contents+='<DIV ID="cell_'+races[race][0]+'_'+j+i+'" STYLE="width:53;height:31;" class="oddInBetslip"><TABLE BORDER=0 WIDTH=53 HEIGHT=31 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN="center"><FONT CLASS="nv">';
    				  if (races[race][(j*10)+i] == maxQuote) {
  						  contents+='<FONT COLOR="#FF0000">';
  						} else {
  						  contents+='<FONT COLOR="#000000">';
  						}
						  contents+='<B>'+races[race][(j*10)+i]+'</B></FONT></FONT></TD></TR></TABLE></DIV>';
						}	else {
						   contents+='<DIV ID="cell_'+races[race][0]+'_'+j+i+'" STYLE="width:53;height:31;"><TABLE BORDER=0 WIDTH=53 HEIGHT=31 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN="center"><FONT CLASS="nv"><A ID="href_'+races[race][0]+'_'+j+i+'" HREF="#" TITLE="#'+j+' vor #'+i+': ' + txtQuote + '='+races[race][(j*10)+i]+'" onMouseOver="cell_focus(this,'+races[race][0]+','+j+','+i+');" onMouseOut="cell_unfocus(this,'+races[race][0]+','+j+','+i+');" onClick="cell_set(this,'+races[race][0]+','+j+','+i+',\'#F4E5E5\',\'index\'); return false;" CLASS="lnv">';
    				  if (races[race][(j*10)+i] == maxQuote) {
  						  contents+='<FONT COLOR="#FF0000">';
  						} else {
  						  contents+='<FONT COLOR="#000000">';
  						}
						   contents+='<B>'+races[race][(j*10)+i]+'</B></FONT></A></FONT></TD></TR></TABLE></DIV>';
						}


					}
					else contents+='<FONT COLOR="#000000">---</FONT>';
					
					contents+='</TD>';
				}
				
				contents+='</TR>';
			}
				
			contents+='</TABLE>';
		}
		
		switch (browser)
		{
			case 1: intake_bet.innerHTML=contents; break;
			case 2: document.getElementById("intake_bet").innerHTML=contents; break;
			default: browser_error(); break;
		}
	}
	
	function cell_focus(id,race,first,second)
	{
		if ((bets!=null) && (bets[race]!=null) && (bets[race][first]!=null) && (bets[race][first][second]!=null))
		{
			id.style.textDecoration="underline";
		}
	}
	
	function cell_unfocus(id,race,first,second)
	{
		if ((bets!=null) && (bets[race]!=null) && (bets[race][first]!=null) && (bets[race][first][second]!=null))
		{
			if (bets[race][first][second]==0) id.style.textDecoration="none";
		}
	}
	
	function cell_set(id,race,first,second,bgcolor,redirect)
	{
		var selected=-1;
		
		for (i=0;i<races.length;i++)
		{
			if (races[i][0]==current)
			{
				selected=i;
				break;
			}
		}
		
		if ((bets!=null) && (bets[race]!=null) && (bets[race][first]!=null) && (bets[race][first][second]!=null))
		{
			if (bets[race][first][second]==0)
			{
				if (races[selected][7]>=15)
				{
					bets[race][first][second]=1;
					cell_focus(id,race,first,second);
					
					switch (browser)
					{
						case 1: eval('cell_'+race+'_'+first+second+'.className="oddSelected"'); break;
						case 2: eval('document.getElementById("cell_'+race+'_'+first+second+'").className="oddSelected"'); break;
						default: browser_error(); break;
					}
		
					if (!allowsend)
					{
						allowsend=true;
						switch (browser)
						{
							case 1: document.images.wettschein_erstellen.src=submit_wettschein_active_image.src; break;
							case 2: document.images.wettschein_erstellen.src="images/" + txtPfad + "/submit_wettschein_erstellen_active.jpg"; break;
							default: browser_error(); break;
						}
					}
				}
			}
			else
			{
				submit_wettschein_disable=true;
				bets[race][first][second]=0;
				cell_unfocus(id,race,first,second);
	
				switch (browser)
				{
					case 1: eval('cell_'+race+'_'+first+second+'.style.backgroundColor="transparent";'); break;
					case 2: eval('document.getElementById("cell_'+race+'_'+first+second+'").style.backgroundColor="transparent";'); break;
					default: browser_error(); break;
				}
				
				for (k=0;k<races.length;k++)
				{
					for (j=1;j<=6;j++)
					{
						for (i=0;i<=6;i++)
						{
							if (bets[races[k][0]][j][i]==1)
							{
								submit_wettschein_disable=false;
								break;
							}
						}
					}
				}
				
				if ((submit_wettschein_disable) && (allowsend))
				{
					allowsend=false;
					switch (browser)
					{
						case 1: document.images.wettschein_erstellen.src=submit_wettschein_image.src; break;
						case 2: document.images.wettschein_erstellen.src="images/" + txtPfad + "/submit_wettschein_erstellen.jpg"; break;
						default: browser_error(); break;
					}
				}
			}
		}
	}
	
	function cells_reset()
	{
		var selected=false;
		
		bets=new Array();
		for (k=0;k<races.length;k++)
		{
			bets[races[k][0]]=new Array();
			for (j=1;j<=6;j++)
			{
				bets[races[k][0]][j]=new Array();
				for (i=0;i<=6;i++)
				{
					bets[races[k][0]][j][i]=0;
					if ((select!=null) && (select[races[k][0]]!=null) && (select[races[k][0]][(((j*10)+i))]!=null))
					{
						if (select[races[k][0]][(((j*10)+i))]==1)
						{
							if ((races[k][0]!=current) || (races[k][7]>=15))
							{
								bets[races[k][0]][j][i]=1;
								
//								if (null!=eval('href_'+races[k][0]+'_'+j+i))
//								{
//									id=eval('href_'+races[k][0]+'_'+j+i);
//									id.style.textDecoration="underline";
									
    								switch (browser)
    								{
    									case 1: if (eval('document.all.cell_'+races[k][0]+'_'+j+i)) eval('cell_'+races[k][0]+'_'+j+i+'.className="oddSelected"'); break;
    									case 2: if (eval('document.getElementById("cell_'+races[k][0]+'_'+j+i+'")')) eval('document.getElementById("cell_'+races[k][0]+'_'+j+i+'").className="oddSelected"'); break;
    									default: browser_error(); break;
    								}
//								}
								
								selected=true;
							}
						}
					}
				}
			}
		}
		
		if (!selected)
		{
			allowsend=false;
			switch (browser)
			{
				case 1: document.images.wettschein_erstellen.src=submit_wettschein_image.src; break;
				case 2: document.images.wettschein_erstellen.src="images/" + txtPfad + "/submit_wettschein_erstellen.jpg"; break;
				default: browser_error(); break;
			}
		}
		else
		{
			allowsend=true;
			switch (browser)
			{
				case 1: document.images.wettschein_erstellen.src=submit_wettschein_active_image.src; break;
				case 2: document.images.wettschein_erstellen.src="images/" + txtPfad + "/submit_wettschein_erstellen_active.jpg"; break;
				default: browser_error(); break;
			}
		}
	}
	
	function change_race(index)
	{
		select=null;
		cells_reset();
		generate_victory_bet(index);
		generate_intake_bet(index);
		generate_race_options(index);
		current=index;
	}
	
	function save_bets(redirect)
	{
		redirect='wettschein_exec.jsp?action=store&output='+output+'&back='+redirect+'&race='+current;		
		
		if (bets!=null)
		{
			for (k=0;k<races.length;k++)
			{
				for (j=1;j<=6;j++)
				{
					for (i=0;i<=6;i++)
					{
						if (bets[races[k][0]][j][i]!=0)
						{
    						redirect+='&bet='+races[k][0]+'_'+((j*10)+i)+'E'+document.wettschein.deposit.value;
						}
					}
				}
			}
		}
		
		redirect=redirect+generate_deposit();
		
		location.href=redirect;
	}
	
	function generate_stored_bets(redirect)
	{
		if (session)
		{
			contents='<FORM NAME="wettschein_confirm" ACTION="wettschein_exec.jsp" METHOD="post">';
			contents+='<TABLE WIDTH=248 BORDER=0 CELLSPACING=0 CELLPADDING=0>';
			contents+='<TR><TD WIDTH=248 HEIGHT=30><a href="javascript:toggleControlsActive()"><IMG SRC="images/' + txtPfad + '/wettschein_label.gif" WIDTH=248 HEIGHT=30 BORDER=0 ALT=""></a></TD></TR>';
			contents+='<TR><TD WIDTH=248 HEIGHT=23><IMG SRC="images/' + txtPfad + '/wettschein_menu.gif" WIDTH=248 HEIGHT=23 BORDER=0 ALT=""></TD></TR>';
			contents+='<TR>';
			contents+='<TD WIDTH=248 VALIGN="top" BACKGROUND="images/wettschein_data_bg.gif">';
			contents+='<TABLE WIDTH=242 BORDER=0 CELLSPACING=0 CELLPADDING=0>';
			
			counter=0;
			combination=true;
			combination_count=0;
			combination_error=0;
			combinations=new Array();
			
			for (i=0;i<stored.length;i++)
			{
				contents+='<TR>';
				contents+='<TD WIDTH=37 ALIGN="center"><FONT CLASS="sv">'+stored[i][5]+'</FONT><INPUT NAME="race['+i+']" TYPE="hidden" VALUE="'+stored[i][0]+'"></TD>';
				contents+='<TD WIDTH=45 ALIGN="center"><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2><TR>';
				contents+='<TD><IMG SRC="images/number_'+String(stored[i][1]).substring(0,1)+'_s.gif" WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>';
				
				if (String(stored[i][1]).substring(1,2)!="0") contents+='<TD><IMG SRC="images/number_'+String(stored[i][1]).substring(1,2)+'_s.gif" WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>';
				
				contents+='<INPUT NAME="bet['+i+']" TYPE="hidden" VALUE="'+stored[i][1]+'"></TD></TR></TABLE></TD>';
				contents+='<TD WIDTH=41 ALIGN="center"><FONT CLASS="sv">'+stored[i][2]+'</FONT></TD>';
				contents+='<TD WIDTH=58 HEIGHT=25 ALIGN="center"><INPUT TABINDEX=10'+i+' NAME="deposit['+i+']" TYPE="text" MAXLENGTH=6 SIZE=4 VALUE="'+deposit[i]+'" onChange="update_deposit_win('+i+');" onFocus="this.select(); show_controls('+i+',this);" STYLE="font-family:Verdana,Arial,Helvetica; font-size:10px;"></TD>';
				contents+='<TD WIDTH=44 ALIGN="center"><FONT CLASS="sv"><DIV ID="possible_win_'+i+'">0 €</DIV></FONT></TD>';
				contents+='<TD WIDTH=17 ALIGN="center"><A HREF="#" onClick="delete_bet('+stored[i][0]+stored[i][1]+',\''+redirect+'\'); return false;"><IMG SRC="images/submit_delete.gif" BORDER=0 ALT=""></A></TD>';
				contents+='</TR>';
				
				
				for (j=0;j<combinations.length;j++)
				{
					if (stored[i][0]==combinations[j]) { combination_error=stored[i][5]; combination=false; }
				}
				
				combinations[counter]=stored[i][0];
				combination_count++;
				counter++;
			}
			
			contents+='</TABLE></TD></TR>';
				
			if (counter>1)
			{
				contents+='<TR><TD WIDTH=248 HEIGHT=9><IMG SRC="images/wettschein_separator_1.gif" WIDTH=248 HEIGHT=9 BORDER=0 ALT=""></TD></TR>';
				contents+='<TR><TD WIDTH=248 VALIGN="top" BACKGROUND="images/wettschein_einzellwetten_bg.gif"><TABLE WIDTH=242 BORDER=0 CELLSPACING=0 CELLPADDING=0><TR>';
				contents+='<TD WIDTH=123 HEIGHT=25><FONT CLASS="sv"><B>&nbsp;'+stored.length+' ' + txtEinzelwetten + ' ' + txtZuJe + ':</B></FONT></TD>';
				contents+='<TD WIDTH=58 HEIGHT=25 ALIGN="center"><INPUT TABINDEX=10'+stored.length+' NAME="duplicate" TYPE="text" MAXLENGTH=6 SIZE=4 VALUE="'+duplideposit+'" onChange="update_duplicate_win();" onFocus="this.select(); show_controls(\'duplicate\',this);" STYLE="font-family:Verdana,Arial,Helvetica; font-size:10px;"></TD>';
				contents+='<TD WIDTH=44 HEIGHT=25 ALIGN="center"><SPACER TYPE=BLOCK WIDTH=44></TD>';
				contents+='<TD WIDTH=17 HEIGHT=25 ALIGN="center"><SPACER TYPE=BLOCK WIDTH=17></TD>';
				contents+='</TR></TABLE></TD></TR>';
				
				contents+='<TR><TD WIDTH=248 HEIGHT=1><IMG SRC="images/wettschein_separator_line.gif" WIDTH=248 HEIGHT=1 BORDER=0 ALT=""></TD></TR>';
			}
			
			if ((combination) && (counter>1))
			{
				contents+='<TR><TD WIDTH=248 VALIGN="top" BACKGROUND="images/wettschein_einzellwetten_bg.gif"><TABLE WIDTH=242 BORDER=0 CELLSPACING=0 CELLPADDING=0><TR>';
				contents+='<TD WIDTH=123 HEIGHT=25><TABLE WIDTH=123 CELLSPACING=0 CELLPADDING=0><TR><TD><FONT CLASS="sv"><B>&nbsp;' + txtKombi +':</B></FONT></TD><TD ALIGN="right"><FONT CLASS="sv">'+(Math.round(combination_course*100)/100)+'</FONT></TD></TR></TABLE></TD>';
				contents+='<TD WIDTH=58 HEIGHT=25 ALIGN="center"><INPUT TABINDEX=10'+(stored.length+1)+' NAME="combination" TYPE="text" MAXLENGTH=6 SIZE=4 VALUE="'+combideposit+'" onChange="update_combination_win('+(Math.round(combination_course*100)/100)+')" onFocus="this.select(); show_controls(\'combination\',this,'+(Math.round(combination_course*100)/100)+');" STYLE="font-family:Verdana,Arial,Helvetica; font-size:10px;"></TD>';
				contents+='<TD WIDTH=44 HEIGHT=25 ALIGN="center"><FONT CLASS="sv"><DIV ID="possible_win_combination">0 €</DIV></FONT></TD>';
				contents+='<TD WIDTH=17 HEIGHT=25 ALIGN="center"><SPACER TYPE=BLOCK WIDTH=17></TD>';
				contents+='</TR></TABLE></TD></TR>';
			}
			else if (!combination)
			{
				contents+='<TR><TD WIDTH=248 VALIGN="top" BACKGROUND="images/wettschein_einzellwetten_bg.gif"><TABLE WIDTH=242 BORDER=0 CELLSPACING=0 CELLPADDING=0><TR>';
				contents+='<TD WIDTH=248 HEIGHT=28 ALIGN="center"><FONT CLASS="sv" COLOR="#AA0000">' + txtKombiNotPossible + '<BR><FONT COLOR="#000000">' + txtRennen + ' '+combination_error+' ' + txtMehrfach +  '</FONT></FONT></TD>';
				contents+='</TR></TABLE></TD></TR>';
			}
			
			contents+='<TR><TD WIDTH=248 HEIGHT=5><IMG SRC="images/wettschein_data_bottom.gif" WIDTH=248 HEIGHT=5 BORDER=0 ALT=""></TD></TR>';
			contents+='<TR><TD WIDTH=248 HEIGHT=24><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD WIDTH=124 ALIGN="center" VALIGN="top"><A HREF="#" onClick="reset_bets(\''+redirect+'\'); return false;"><IMG SRC="images/' + txtPfad + '/submit_reset.gif" BORDER=0 ALT=""></A></TD><TD WIDTH=124 VALIGN="top"><A HREF="#" onClick="return confirm_bets();"><IMG SRC="images/' + txtPfad + '/submit_wetten_senden.gif" BORDER=0 ALT=""></A><INPUT NAME="action" TYPE="hidden" VALUE="confirm"></TD></TR></TABLE></TD></TR>';
			contents+='<TR><TD ALIGN="center"><FONT CLASS="sv"><DIV ID="bettime"></DIV></FONT></TD></TR>';
			contents+='</TABLE></FORM>';
			
			switch (browser)
			{
				case 1: stored_bets.innerHTML=contents; break;
				case 2: document.getElementById("stored_bets").innerHTML=contents; break;
				default: browser_error(); break;
			}
			
			for (i=0;i<stored.length;i++)
			{
				update_deposit_win(i);
			}
			
			if ((combination) && (counter>1))
			{
				update_combination_win((Math.round(combination_course*100)/100));
			}
		}
	}
	
	function confirm_bets()
	{
		if (!logedin)
		{
			alert(txtNotLoggedIn);
			return false;
		}
		
		if (!confirmInProgress) {		

    		var number=0;
    		var deposit=0;
    		var counter=0;
    		
    		for (i=0;i<stored.length;i++)
    		{
    			if (Number(document.wettschein_confirm["deposit["+i+"]"].value)==document.wettschein_confirm["deposit["+i+"]"].value)
    			{
    				if (Number(document.wettschein_confirm["deposit["+i+"]"].value)>0)
    				{
    					counter++;
    					deposit+=Number(document.wettschein_confirm["deposit["+i+"]"].value);
    				}
    			}
    		}
    		
    		if (stored.length>1)
    		{
    			if (document.wettschein_confirm["duplicate"]!=null)
    			{
    				if (Number(document.wettschein_confirm["duplicate"].value)==document.wettschein_confirm["duplicate"].value)
    				{
    					if (Number(document.wettschein_confirm["duplicate"].value)>0)
    					{
    						counter+=stored.length;
    						deposit+=stored.length*Number(document.wettschein_confirm["duplicate"].value);
    					}
    				}
    			}
    			
    			if (document.wettschein_confirm["combination"]!=null)
    			{
    				if (Number(document.wettschein_confirm["combination"].value)==document.wettschein_confirm["combination"].value)
    				{
    					if (Number(document.wettschein_confirm["combination"].value)>0)
    					{
    						counter++;
    						deposit+=Number(document.wettschein_confirm["combination"].value);
    					}
    				}
    			}
    		}
    		
    		if ((counter==0) || (deposit==0))
    		{
    			alert(txtKeineEinsaetze);
    			return false;
    		}
    		
    		deposit=Number(Math.round(deposit*100)/100);
    		
    
    		if (confirm(txtFolgendeWetten + "\n\n" + txtAnzahlWetten + ": " + counter + "\n" + txtGesamtEinsatz + ": " + deposit + " " +  txtWg)) {
        		confirmInProgress=true;
        		location.href='wettschein_exec.jsp?action=confirm' + generate_deposit();
    		}
    	}
    	return false;
		
	}
	
	function delete_bet(id,redirect)
	{
   		location.href='wettschein_exec.jsp?action=delete&output='+output+'&race='+current+'&back='+redirect+'&id='+id+generate_deposit();
		
	}
	
	function destroy_bet(id,redirect)
	{
	    if (!confirmInProgress) {
    		location.href='wettschein_exec.jsp?action=destroy&output='+output+'&race='+current+'&back='+redirect+'&id='+id+generate_deposit()+generate_selected();
    	}
	}
	
	function reset_bets(redirect)
	{
		location.href='wettschein_exec.jsp?action=reset&output='+output+'&race='+current+'&back='+redirect+generate_deposit();
	}
	
	function refresh(redirect)
	{
	    if (!confirmInProgress) {
    		redirect=redirect+".jsp?output="+output+"&race="+current;
    		redirect=redirect+generate_deposit();
    		redirect=redirect+generate_selected();
    		location.href=redirect;
    	}
	}
	
	function generate_selected()
	{
		var getdata="";

		if (bets!=null)
		{
			for (k=0;k<races.length;k++)
			{
				for (j=1;j<=6;j++)
				{
					for (i=0;i<=6;i++)
					{
                        if (bets[races[k][0]] != null && (bets[races[k][0]][j][i]!=null) && (bets[races[k][0]][j][i]!=0)) getdata+="&select="+races[k][0]+"_"+((j*10)+i)+"E"+bets[races[k][0]][j][i];
					}
				}
			}
		}

		return getdata;
	}
	
	function generate_deposit()
	{
		var getdata="";
		
		if (session)
		{
			for (i=0;i<stored.length;i++)
			{
			    // 0 setzen, falls feld leer ist
			    if (document.wettschein_confirm["deposit["+i+"]"].value == "") document.wettschein_confirm["deposit["+i+"]"].value = "0";
			    
				if (Number(document.wettschein_confirm["deposit["+i+"]"].value)==document.wettschein_confirm["deposit["+i+"]"].value)
				{
						getdata=getdata+"&deposit="+stored[i][4]+"_"+document.wettschein_confirm["deposit["+i+"]"].value;
    			}
			}
			
			if (document.wettschein_confirm["combination"]!=null)
			{
			    // 0 setzen, falls feld leer ist
			    if (document.wettschein_confirm["combination"].value == "") document.wettschein_confirm["combination"].value = "0";
				if (Number(document.wettschein_confirm["combination"].value)==document.wettschein_confirm["combination"].value)
				{
						getdata=getdata+"&combideposit="+document.wettschein_confirm["combination"].value;
    			}
			}
			
			if (document.wettschein_confirm["duplicate"]!=null)
			{
			    // 0 setzen, falls feld leer ist
			    if (document.wettschein_confirm["duplicate"].value == "") document.wettschein_confirm["duplicate"].value = "0";
				if (Number(document.wettschein_confirm["duplicate"].value)==document.wettschein_confirm["duplicate"].value)
				{
						getdata=getdata+"&duplideposit="+document.wettschein_confirm["duplicate"].value;
    			}
			}
		}
		
		return getdata;
	}
	
	function update_deposit_win(id)
	{
		var contents;
		
		contents="";
		
		if (document.wettschein_confirm["deposit["+id+"]"].value!=null)
		{
		    document.wettschein_confirm["deposit["+id+"]"].value = trim(document.wettschein_confirm["deposit["+id+"]"].value);
			if (Number(document.wettschein_confirm["deposit["+id+"]"].value)==document.wettschein_confirm["deposit["+id+"]"].value && !isNaN(Number(document.wettschein_confirm["deposit["+id+"]"].value)) && Number(document.wettschein_confirm["deposit["+id+"]"].value)>=0)
			{
				if (Number(document.wettschein_confirm["deposit["+id+"]"].value)>0)
				{
					contents=String(Math.round(Number(document.wettschein_confirm["deposit["+id+"]"].value) * Number(stored[id][2]) * 100)/100);
				}
				else { contents="0"; }
			} else {
			    alert(txtKeineZahl);
			    document.wettschein_confirm["deposit["+id+"]"].value = "";
			}
			
			
		}
		
		switch (browser)
		{
			case 1: eval('possible_win_'+id+'.innerHTML=contents;'); break;
			case 2: eval('document.getElementById("possible_win_'+id+'").innerHTML=contents;'); break;
			default: browser_error(); break;
		}
	}

	
	function update_duplicate_win()
	{
	
		if (document.wettschein_confirm["duplicate"].value!=null)
		{
		    document.wettschein_confirm["duplicate"].value = trim(document.wettschein_confirm["duplicate"].value);
			if (Number(document.wettschein_confirm["duplicate"].value)==document.wettschein_confirm["duplicate"].value && !isNaN(Number(document.wettschein_confirm["duplicate"].value)) && Number(document.wettschein_confirm["duplicate"].value) >= 0)
			{
			    // nothing to do
			} else {
			    alert(txtKeineZahl);
			    document.wettschein_confirm["duplicate"].value = "";
			}
		}
	}

	
	function update_combination_win(rate)
	{
		var contents;
		
		contents="";
		
		if (document.wettschein_confirm["combination"].value!=null)
		{
		    document.wettschein_confirm["combination"].value = trim(document.wettschein_confirm["combination"].value);
			if (Number(document.wettschein_confirm["combination"].value)==document.wettschein_confirm["combination"].value && !isNaN(Number(document.wettschein_confirm["combination"].value)) && Number(document.wettschein_confirm["combination"].value)>=0)
			{
				if (Number(document.wettschein_confirm["combination"].value)>0)
				{
					contents=String(Math.round(Number(document.wettschein_confirm["combination"].value) * rate * 100)/100);
				}
				else { contents="0"; }
			} else {
			    alert(txtKeineZahl);
			    document.wettschein_confirm["combination"].value = "";
			}
			
			switch (browser)
			{
				case 1: eval('possible_win_combination.innerHTML=contents;'); break;
				case 2: eval('document.getElementById("possible_win_combination").innerHTML=contents;'); break;
				default: browser_error(); break;
			}
		}
	}
	
	

	function show_controls(idN,elementN,combi)
	{
		if (session)
		{
		    if (controlsActive) {
    			if (browser=1)
    			{
    				var toppos=0;
    				var leftpos=0;
    				var backup=elementN;
    
    				while (elementN!=null && !elementN.cbe) { 
    				    toppos+=elementN.offsetTop; 
    				    elementN=elementN.offsetParent; 
    				}
    				
    				elementN=backup;
    				
    				while (elementN!=null) { leftpos+=elementN.offsetLeft; elementN=elementN.offsetParent; }
    				
    				if ((active!=null) && (idN!=active)) hide_controls();
    				
    				control_input.style.left=leftpos-5;
    				control_input.style.top=toppos-8;
    				control_controler.style.left=leftpos+46;
    				control_controler.style.top=toppos-39;
    				
    				control_input.style.visibility='visible';
    				control_controler.style.visibility='visible';
    				active=idN;
    				course=combi;
    			}
    		}
		}
	}
	
	function hide_controls(from)
	{
		if (session)
		{
			if (browser=1)
			{
				var hide=true;
				
				if (from!=null)
				{
					for (i=0;i<stored.length;i++)
					{
						if ((from.indexOf("controler")!=-1) || (from==("deposit["+i+"]")) || (from==("duplicate")) || (from==("combination"))) hide=false;
					}
				}
				
				if ((hide) && (active!=null))
				{
					control_input.style.visibility='hidden';
					control_controler.style.visibility='hidden';
					active=null;
				}
			}
		}
	}
	
	function increase_value(value)
	{
		if (session)
		{
			if (browser=1)
			{
				if (active=="duplicate")
				{
					if (Number(eval("document.wettschein_confirm['duplicate'].value"))!=eval("document.wettschein_confirm['duplicate'].value")) eval("document.wettschein_confirm['duplicate'].value=0;");
					eval("document.wettschein_confirm['duplicate'].value=Number(Number(document.wettschein_confirm['duplicate'].value) + "+value+");");
					eval("document.wettschein_confirm['duplicate'].select()");
				}
				
				if (active=="combination")
				{
					if (Number(eval("document.wettschein_confirm['combination'].value"))!=eval("document.wettschein_confirm['combination'].value")) eval("document.wettschein_confirm['combination'].value=0;");
					eval("document.wettschein_confirm['combination'].value=Number(Number(document.wettschein_confirm['combination'].value) + "+value+");");
					update_combination_win(course);
					eval("document.wettschein_confirm['combination'].select()");
				}
				
				if (active==Number(active))
				{
					if (Number(eval("document.wettschein_confirm['deposit["+active+"]'].value"))!=eval("document.wettschein_confirm['deposit["+active+"]'].value")) eval("document.wettschein_confirm['deposit["+active+"]'].value=0;");
					eval("document.wettschein_confirm['deposit["+active+"]'].value=Number(Number(document.wettschein_confirm['deposit["+active+"]'].value) + "+value+");");
					update_deposit_win(active);
					eval("document.wettschein_confirm['deposit["+active+"]'].select()");
				}
			}
		}
	}
	
	function reset_value(value)
	{
		if (session)
		{
			if (browser=1)
			{
				if (active=="duplicate")
				{
					eval("document.wettschein_confirm['duplicate'].value=0;");
					eval("document.wettschein_confirm['duplicate'].select()");
				}
				
				if (active=="combination")
				{
					eval("document.wettschein_confirm['combination'].value=0;");
					update_combination_win(course);
					eval("document.wettschein_confirm['combination'].select()");
				}
				
				if (active==Number(active))
				{
					eval("document.wettschein_confirm['deposit["+active+"]'].value=0;");
					update_deposit_win(active);
					eval("document.wettschein_confirm['deposit["+active+"]'].select()");
				}
			}
		}
	}
	
    function trim(s) {
        while (s.substring(0,1) == ' ' || s.substring(0,1) == '+' || s.substring(0,1) == '-') {
            s = s.substring(1,s.length);
        }
        while (s.substring(s.length-1,s.length) == ' ') {
            s = s.substring(0,s.length-1);
        }
        return s;
    }
	
	
	function focusInput() {
		if (session)
		{
			if (browser=1)
			{
				if (active=="duplicate")
				{
					eval("document.wettschein_confirm['duplicate'].select()");
				}
				
				if (active=="combination")
				{
					eval("document.wettschein_confirm['combination'].select()");
				}
				
				if (active==Number(active))
				{
					eval("document.wettschein_confirm['deposit["+active+"]'].select()");
				}
			}
		}
	}


    function toggleControlsActive() {
        controlsActive = !controlsActive;
    }