// Alle JavaScripte der OPENSTORE eCommerce Loesung sind
// urheberrechtlich geschuetzt. Jede weitergehende, kommerzielle
// oder nicht kommerzielle Modifizierung/Vervielfaeltigung
// ist nur mit schriftlicher Zustimmung von LEITBILD Media
// gestattet. Alle Rechte vorbehalten.
// OPENSTORE 3.0, © 1999 LEITBILD Media

var Buydeliveryvar = 0, specialwert = 0, specialdel = 0

function doSpecial(wert) {
	if (dospecialdelivery == 1) {
	if (wert == 0) specialdel = 0
	if (wert == 1) specialdel = Buyspecialdelivery
	specialwert = wert
	parent.main.location.href = "../cart/order.htm"
	}
		}

function selSpecial(specialwert) {
	parent.main.document.buyform.special.options.options[specialwert].selected  =  true;
		}

function makeTablebuy(cartArray) {
	var	bfont = "<Font Face='"+BuyFont+"' Size='"+BuyFontSize+"'>";
	var	pos, singleqty = 0;
	var	avail1 = "", avail2 = "", avail3 = "";
	var itm, extension, makeTotal = 0, itmsquant = 0;
	var placer = ""+imgleer+" WIDTH='3' HEIGHT='3' BORDER='0'>";
	var placer2 = ""+imgleer+" WIDTH=";
	var innerwith = (BuyWidth - 85) - 2*BuyPriceWidth
	var tab = "<TABLE BORDER=0 cellpadding='"+BuyCellpadding+"' cellspacing=0"
		if (BuyTableColorYes == 1) tab += " bgcolor='"+BuyTableColor+"'"
		tab += " width='"+BuyWidth+"'>"

		tab += "<tr"
		if (BuyTableHeadColorYes == 1) tab += " bgcolor='"+BuyTableHeadColor+"'"
	 	tab += "><td>"+imgleer+" WIDTH=6 HEIGHT=3></td><td valign=bottom colspan=2><font face='"+BuyFont+"' size=1> "+BuyItemNaming+"</font></TD><TD ALIGN=CENTER valign=bottom>"+bfont+""+BuyQtyNaming+"</font></TD><TD ALIGN=right valign=bottom>"+bfont+""+BuyPriceNaming+"</font></TD><TD ALIGN=right valign=bottom>"+bfont+""+BuyItemTotalNaming+"</font></TD><td>"+placer+"</td></TR>"

	for (var i = 0; i < cartArray.length; i++) {
		availeinzel = avail2txt
		pos = i + 1

		itm = itmSplit(cartArray[i])

		itmsquant += parseFloat(itm[3])

availval = itm[5].substring(itm[5].length - 1, itm[5].length)
		
if (availval == '1' && avail1 != "") avail1 += "+"+pos
if (availval == '2' && avail2 != "") avail2 += "+"+pos
if (availval == '3' && avail3 != "") avail3 += "+"+pos
if (availval == '' && avail2 != "") avail2 += "+"+pos

if (availval == '1' && avail1 == "") avail1 += BuyPositiontxt + pos
if (availval == '2' && avail2 == "") avail2 += BuyPositiontxt + pos
if (availval == '3' && avail3 == "") avail3 += BuyPositiontxt + pos
if (availval == '' && avail2 == "") avail2 += BuyPositiontxt + pos

		extension = format((itm[3] * itm[1]),2)
		makeTotal += parseFloat(extension)

		tab += "<TR><TD valign=top><Font Face='"+BuyFont+"' Size='"+BuyFontSize+"' color="+PositionColor+">"

	if (showPosition == 1) tab += ""+pos+"."

		tab += "<br></font></TD><TD valign=top colspan=2><Font Face='"+BuyFont+"' Size='"+BuyFontSize+"' color='"+BuyItemFontColor+"'><b>"+itm[0]+"</b></TD><TD align=center>"+bfont+"<b>"+itm[3]+"</b></TD><TD align=right>"+bfont+""+itm[1]+"</TD><TD align=right>"

		tab += ""+hiddenfield+"'itm"+pos+"' VALUE='"+itm[0]+"'>"
	if (itm[6] != 0) tab += ""+hiddenfield+"'itmsize"+pos+"' VALUE='"+itm[6]+"'>"
	if (itm[8] != 0) tab += ""+hiddenfield+"'itmplus"+pos+"' VALUE='"+itm[8]+"'>"
		tab += ""+hiddenfield+"'itmnumber"+pos+"' VALUE='"+itm[4]+"'>"
		tab += ""+hiddenfield+"'quant"+pos+"' VALUE='"+itm[3]+"'>"
		tab += ""+hiddenfield+"'price"+pos+"' VALUE='"+itm[1]+"'>"
		tab += ""+hiddenfield+"'total"+pos+"' VALUE='"+extension+"'>"

		tab += ""+bfont+""+extension+"</TD><TD>"+placer+"</TD></TR>"

		var colval1 = 2, colval2 = 3

if (itm[7] != "") colval1 = 1, colval2 = 4;

		tab += "<TR><td colspan=1>"+placer+"</TD><TD align=left colspan=4><table BORDER=0 CELLPADDING=0 CELLSPACING=0><tr><td width=1% valign=top>"
		
		itm[7] = itm[7].replace(/xxx/, "width="+BuyItemImgWidth+"")

if (itm[7] != "" && showBuyItemImg == 1) tab += ""+itm[7]+""

		tab += "<br></td><td>"+placer+"</TD>"
		
		tab += "<td valign=top>"+bfont+""+itm[2]+""

 		if (itm[6] != 0 || showBuyItemNumber == 1) tab += " <nobr>("
		if (showBuyItemNumber == 1) tab += ""+itm[4]+""
 		if (itm[8] != 0 && showBuyItemNumber == 1) tab += ", "
		if (itm[8] != 0) tab += ""+parent.menu.PlusTxt+""+itm[8]+""
 		if (itm[6] != 0 && showBuyItemNumber == 1) tab += ", "
		if (itm[6] != 0) tab += ""+parent.menu.SizeTxt+""+itm[6]+""
 		if (itm[6] != 0 || showBuyItemNumber == 1) tab += ")</nobr>"

		tab += "</td></tr></table></TD><td colspan=2>"+placer+"</TD>"
		
	if (BuyItemDivision == 1) tab += "<tr><td>"+placer+"</td><td colspan=5 align=center><IMG SRC='../images/leer_s.gif' WIDTH='100\%' HEIGHT='"+parent.logo.BuyItemsDivisionHeight+"' BORDER='0'></TD><td>"+placer+"</td></TR>\n"
	}

		delivery = 0
		delivercost = 0

		if (makeTotal > 1 && makeTotal < Buy2delivery2 && doBuydelivery2 == 1) delivercost = Buydelivery2
		else if (makeTotal >= Buy2delivery2 && makeTotal < Buyfreedelivery && doBuydelivery2 == 1) delivercost = Buydelivery
		else if (makeTotal > 1 && makeTotal < Buyfreedelivery && doBuydelivery2 == 0) delivercost = Buydelivery
		else if (makeTotal >= Buyfreedelivery) delivercost = 0

			if (BuydeliveryperITEM == 1) delivery = delivercost * itmsquant + specialdel
			if (BuydeliveryperITEM == 0) delivery = delivercost + specialdel
		
	tab += "<TR><td colspan=2>"+placer+"</TD><TD COLSPAN=3>"+bfont+""+Buytotaltxt+"</font></TD><td align=right>"+bfont+""+format(makeTotal, 2)+"</font></td><td>"+placer+"</td></TR><TR><td colspan=2>"+placer+"</TD><TD COLSPAN=3>"+bfont+""+Buydeliverytxt+"</font></TD><td align=right>"+bfont+""+format(delivery, 2)+"</font></td><td>"+placer+"</td></TR>"

		totalplusdelivery = makeTotal + delivery

	tab += "<TR><td>"+placer+"</TD><TD COLSPAN=4>"+bfont+"<b>"+Buytotalplusdeliverytxt+" "+currency+"</b> "

	if (BuyshowtxtBRUTTO == 1 && ItemsNettoPrice != 1) tab += ""+BuytxtBRUTTO+""
	if (BuyshowtxtNETTO == 1 && ItemsNettoPrice == 1) tab += ""+BuytxtNETTO+""

	tab += "</font>"

	tab += ""+hiddenfield+"'grandTotal' SIZE=8 VALUE='"+format(makeTotal, 2)+"'>"
	tab += ""+hiddenfield+"'delivery' VALUE='"+format(delivery, 2)+"'>"
	tab += ""+hiddenfield+"'totalplusdelivery' VALUE='"+format(totalplusdelivery, 2)+"'>"
	tab += ""+hiddenfield+"'itmCount' VALUE='"+i+"'>"

	tab += "</TD><td align=right>"+bfont+"<u>"+format(totalplusdelivery, 2)+"</u></font></td><td>"+placer+"</td></TR>"

		totalEURO = 0
		totalEURO = totalplusdelivery * EUROrate
		
	if (BuyshowEURO == 1) { tab += "<TR><td>"+placer+"</TD><TD COLSPAN=4>"+bfont+"<b>"+BuyEUROtotaltxt+"</b> "

	if (BuyshowtxtBRUTTO == 1 && ItemsNettoPrice != 1) tab += ""+BuytxtBRUTTO+""
	if (BuyshowtxtNETTO == 1 && ItemsNettoPrice == 1) tab += ""+BuytxtNETTO+""

	tab += "</font></TD><td align=right>"+bfont+"<u>"+format(totalEURO, 2)+"</u></font></td></td><td>"+placer+"</td></TR>"
			}

		TAX = 0
	if (ItemsNettoPrice == 1) TAX = totalplusdelivery * (1 + BuyTAXpercent/100)
	else TAX = totalplusdelivery - totalplusdelivery / (1 + BuyTAXpercent/100)

	if (BuyshowTAX == 1) {
	tab += "<TR><td colspan=2>"+placer+"</TD><TD COLSPAN=3>"
	
	tab += ""+hiddenfield+"'Tax' VALUE='"+format(TAX, 2)+"'>"
	
	tab += ""+bfont+""+BuyTAXpercent+""+BuyTaxtxt+""+currency+"</font></TD><td align=right>"+bfont+""+format(TAX, 2)+"</font></td><td>"+placer+"</td></TR>"
			}

	if (showPositiontxt == 1) {
	tab += "<tr><td>"+placer+"</td><td colspan=5><font face="+BuyFont+" size='1' color="+PositionColor+">"
	if (avail1 != "") tab += ""+avail1 + avail1txt
	if (avail2 != "") tab += ""+avail2 + avail2txt
	if (avail3 != "") tab += ""+avail3 + avail3txt
	tab += "</font>"+placer+"</td><td>"+placer+"</td></TR>"
			}

	tab += "<tr"
	if (BuyTableHeadColorYes == 1) tab += " bgcolor='"+BuyTableFootColor+"'"
	tab += "><td>"+placer2+"'6' HEIGHT='3'></td><td>"+placer2+"'6' HEIGHT='3'></TD><td>"+placer2+""+innerwith+" HEIGHT='3'></TD><TD>"+placer2+"'38' HEIGHT='3' BORDER='0'></TD><TD>"+placer2+""+BuyPriceWidth+" HEIGHT='3'></TD><TD>"+placer2+""+BuyPriceWidth+" HEIGHT='3'></TD><td>"+placer2+"'6' HEIGHT='3'></td></TR>"
	tab += "</TABLE>"
	return tab
}

function clearwhenorder() {
	if (orderclear == 1) {
		document.cart.cartData.value = ""
		showCart()
			}
		}


