window.top.knr=1;

function nope()
{
	alert('Dieser Artikel ist zur Zeit nicht lieferbar.\nDer dort angegebene Preis ist der letzgültige Preis für dieses Produkt\nund somit nur ein Richtpreis!');
}

function yep()
{
	alert('Dieser Artikel ist zur Zeit lieferbar.');
}

function doitnow()
{
	if (document.bestform.agb.checked)
	{
		document.bestform.action="/cgi-bin/rcs/energie/rcs_best.cgi";
		document.bestform.submit();
	}
	else
	{
		alert("Es ist leider unerlässlich, daß Sie unsere AGBs akzeptieren.");
	}
}

function myround(zahl,stellen)
{
	shifter=Math.pow(10,stellen)
	dummy=String(Math.round(zahl*shifter)/shifter);
	if (dummy.search(/.+\.../)==-1)
	{
		if (dummy.indexOf(".")==-1)
		{
			dummy=dummy+".";
		}
		while ( (dummy.indexOf(".")) >= (dummy.length-stellen) )
		{
			dummy=dummy+"0";
		}
	}
	return dummy;
}

function buildcust()
{
	document.writeln('									<TABLE BORDER="0" CELLPADDING="2" CELLSPACING="0">');
	document.writeln('										<TR>');
	document.writeln('											<TD>Kundennummer</TD>');
	document.writeln('											<TD>'+window.top.kunde[0]+'<input type=hidden name="kunde_knr" value="'+window.top.kunde[0]+'"></TD>');
	document.writeln('										</TR>');
	document.writeln('										<TR>');
	document.writeln('											<TD>Name</TD>');
	document.writeln('											<TD>'+window.top.kunde[7]+' '+window.top.kunde[1]);
	document.writeln('												<input type=hidden name="kunde_anrede" value="'+window.top.kunde[7]+'">');
	document.writeln('												<input type=hidden name="kunde_name" value="'+window.top.kunde[1]+'"></TD>');
	document.writeln('										</TR>');
	document.writeln('										<TR>');
	document.writeln('											<TD>Straße</TD>');
	document.writeln('											<TD>'+window.top.kunde[2]+'<input type=hidden name="kunde_str" value="'+window.top.kunde[2]+'"></TD>');
	document.writeln('										</TR>');
	document.writeln('										<TR>');
	document.writeln('											<TD>Ort</TD>');
	document.writeln('											<TD>'+window.top.kunde[8]+' '+window.top.kunde[3]+'<input type=hidden name="kunde_ort" value="'+window.top.kunde[8]+' '+window.top.kunde[3]+'"></TD>');
	document.writeln('										</TR>');
	if (window.top.kunde[4]!="")
	{
		document.writeln('										<TR>');
		document.writeln('											<TD>Ansprechpartner</TD>');
		document.writeln('											<TD>'+window.top.kunde[9]+' '+window.top.kunde[4]);
		document.writeln('												<input type=hidden name="kunde_aansprech" value="'+window.top.kunde[9]+'">');
		document.writeln('												<input type=hidden name="kunde_ansprech" value="'+window.top.kunde[4]+'"></TD>');
		document.writeln('										</TR>');
	}
	document.writeln('										<TR>');
	document.writeln('											<TD>Telefon</TD>');
	document.writeln('											<TD>'+window.top.kunde[5]+'<input type=hidden name="kunde_tel" value="'+window.top.kunde[5]+'"></TD>');
	document.writeln('										</TR>');
	document.writeln('										<TR>');
	document.writeln('											<TD>eMail</TD>');
	document.writeln('											<TD>'+window.top.kunde[6]+'<input type=hidden name="kunde_email" value="'+window.top.kunde[6]+'"></TD>');
	document.writeln('										</TR>');
	document.writeln('									</TABLE>');
}

function buildlastwk()
{
	artcount=1;
	document.writeln('									<table width=650 cellspacing=0 cellpadding=2 border=0>');
	document.writeln('										<tr>');
	document.writeln('											<td valign=top colspan=2><p>Menge</p></td>');
	document.writeln('											<td valign=top><p>Artikel</p></td>');
	document.writeln('											<td valign=top><p>Beschreibung</p></td>');
	document.writeln('											<td valign=top><p class=center>Einzel<br>EUR</p></td>');
	document.writeln('											<td valign=top><p class=center>Einzel<br>ATS</p></td>');
	document.writeln('											<td valign=top><p class=center>Gesamt<br>EUR</p></td>');
	document.writeln('											<td valign=top><p class=center>Gesamt<br>ATS</p></td>');
	document.writeln('										</tr>');
	for (h=1;h<window.top.artikel.length;h++)
	{
		for (u=1;u<window.top.artikel[h].length;u++)
		{
			a=1;
			while (a<window.top.artikel[h][u].length)
			{
				_menge=window.top.artikel[h][u][a+5];
				if (_menge>0)
				{
					nlstring="";
					document.writeln('										<tr>');
					if (window.top.artikel[h][u][a+0]=="N")
					{
						nlstring="* ";
						document.writeln('														<td><a class=small href="javascript:nope();"><img src="x.gif" border=0></a></td>');
					}
					else
					{
						document.writeln('														<td><a class=small href="javascript:yep();"><img src="hakerl.gif" border=0></a></td>');
					}
					document.writeln('											<td width=40><p class=smallleft>'+window.top.artikel[h][u][a+5]+' Stk</td>');
					document.writeln('											<td width=130><p class=smallleft>'+window.top.artikel[h][u][a+1]+'</p></td>');
					document.writeln('											<td width=280><p class=smallleft>'+window.top.artikel[h][u][a+2]+'</p></td>');
					document.writeln('											<td width=50><nobr><p class=smallright>'+myround(window.top.artikel[h][u][a+3],2)+'</nobr></p></td>');
					document.writeln('											<td width=50><nobr><p class=smallright>'+myround(window.top.artikel[h][u][a+4],2)+'</nobr></p></td>');
					document.writeln('											<td width=50><nobr><p class=smallright>'+myround(window.top.artikel[h][u][a+3]*window.top.artikel[h][u][a+5],2)+'</nobr></p></td>');
					document.writeln('											<td width=50><nobr><p class=smallright>'+myround(window.top.artikel[h][u][a+4]*window.top.artikel[h][u][a+5],2)+'</nobr></p>');
					dummystr=window.top.artikel[h][u][a+5]+'Stk '+nlstring+window.top.artikel[h][u][a+1]+' ('+window.top.artikel[h][u][a+2]+')';
					document.writeln('											<input type=hidden name="art_'+artcount+'_1" value="'+dummystr+'">');
					dummystr='zu EUR '+myround(window.top.artikel[h][u][a+3],2)+' (ATS '+myround(window.top.artikel[h][u][a+4],2)+')';
					document.writeln('											<input type=hidden name="art_'+artcount+'_2" value="'+dummystr+'">');
					dummystr='=> GESAMT EUR '+myround(window.top.artikel[h][u][a+3]*window.top.artikel[h][u][a+5],2)+' (ATS ';
					dummystr=dummystr+myround(window.top.artikel[h][u][a+4]*window.top.artikel[h][u][a+5],2)+')';
					document.writeln('											<input type=hidden name="art_'+artcount+'_3" value="'+dummystr+'"></td>');
//					alert(document.bestform["art_"+artcount+"_1"].value);
//					alert(document.bestform["art_"+artcount+"_2"].value);
//					alert(document.bestform["art_"+artcount+"_3"].value);
					document.writeln('										</tr>');
					artcount++;
				}
				a=a+7;
			}
		}
	}
	document.writeln('									</table>');
	document.writeln('									<table width=650 cellspacing=0 cellpadding=2 border=0>');
	document.writeln('										<tr>');
	document.writeln('											<td><img src="/rcs/energie/_fill.gif" height=3 width=650 vspace=2><input type=hidden name="art_nums" value="'+eval(artcount-1)+'"></td>');
	document.writeln('										</tr>');
	document.writeln('									</table>');
	document.writeln('									<table width=650 cellspacing=0 cellpadding=2 border=0>');
	document.writeln('										<tr>');
	document.writeln('											<td width=550><p><b>Gesamt</b></p></td>');
	document.writeln('											<td width=50><p class=smallright><b>'+myround(window.top.gsumme,2)+'</b></p></td>');
	document.writeln('											<td width=50><p class=smallright><b>'+myround(window.top.gsummee,2)+'</b></p>');
	dummystr='GESAMTSUMME: EUR '+myround(window.top.gsumme,2)+' (ATS '+myround(window.top.gsummee,2)+')';
	document.writeln('											<input type=hidden name="gsumme" value="'+dummystr+'"></td>');
	document.writeln('										</tr>');
	document.writeln('									</table>');
}