function checkform ( form )
{
if (form.total_amount.value == "0.00") 			{alert( unescape("Bitte w&auml;hlen Sie ein Heft aus.") );		form.total_amount.focus();				return false ; }
return true ;
}

// Anzahl der aktuellen zu bestellenden Hefte ! 

NumberOfItemsForSale = 8;

// Do not change the next eleven lines.
function MakeStringArray(n) {
	n++;
	this.length = n;
	for (var i = 1; i<=n; i++) { this[i] = new String(); }
	return this;
}

HiddenFieldNameForItemID = new MakeStringArray(NumberOfItemsForSale);
DescriptionForItemID = new MakeStringArray(NumberOfItemsForSale);
ItemCost = new MakeStringArray(NumberOfItemsForSale);
ItemHowManyFieldName = new MakeStringArray(NumberOfItemsForSale);
ItemSubTotalFieldName = new MakeStringArray(NumberOfItemsForSale);





HiddenFieldNameForItemID[1] = "desc_heft27";
HiddenFieldNameForItemID[2] = "desc_heft28";
HiddenFieldNameForItemID[3] = "desc_heft29";
HiddenFieldNameForItemID[4] = "desc_heft30";
HiddenFieldNameForItemID[5] = "desc_heft32";
HiddenFieldNameForItemID[6] = "desc_heft33";
HiddenFieldNameForItemID[7] = "desc_heft34";
HiddenFieldNameForItemID[8] = "desc_heft35";


DescriptionForItemID[1] = "Heft 27";
DescriptionForItemID[2] = "Heft 28";
DescriptionForItemID[3] = "Heft 29";
DescriptionForItemID[4] = "Heft 30";
DescriptionForItemID[5] = "Heft 32";
DescriptionForItemID[6] = "Heft 33";
DescriptionForItemID[7] = "Heft 34";
DescriptionForItemID[8] = "Heft 35";


ItemCost[1] = 7.65;
ItemCost[2] = 7.65;
ItemCost[3] = 7.65;
ItemCost[4] = 7.65;
ItemCost[5] = 7.65;
ItemCost[6] = 7.65;
ItemCost[7] = 7.65;
ItemCost[8] = 7.65;


ItemHowManyFieldName[1] = "num_heft27";
ItemHowManyFieldName[2] = "num_heft28";
ItemHowManyFieldName[3] = "num_heft29";
ItemHowManyFieldName[4] = "num_heft30";
ItemHowManyFieldName[5] = "num_heft32";
ItemHowManyFieldName[6] = "num_heft33";
ItemHowManyFieldName[7] = "num_heft34";
ItemHowManyFieldName[8] = "num_heft35";


ItemSubTotalFieldName[1] = "sub_heft27";
ItemSubTotalFieldName[2] = "sub_heft28";
ItemSubTotalFieldName[3] = "sub_heft29";
ItemSubTotalFieldName[4] = "sub_heft30";
ItemSubTotalFieldName[5] = "sub_heft32";
ItemSubTotalFieldName[6] = "sub_heft33";
ItemSubTotalFieldName[7] = "sub_heft34";
ItemSubTotalFieldName[8] = "sub_heft35";



BaseShippingCharge = 0;
ShippingChargeByPercentage = 0;






TaxRate = 0;
CollectTaxOnShipping = "no";





TotalAmountFieldName = "total_amount";








function Image(url,w,h,tl,bgcolor,textcolor) {
// url of image, width of image, height of image, title text, background color, text color -- 
//    the first three must have values, the last three may be null.

	var title = '<br><b>' + tl + '</b>';
	var hh = String(parseInt(h,10)+67);
	if(tl.length <1) title = '';
	else hh = String(parseInt(hh) + parseInt((tl.length / (parseInt(w) / 8)) + 1) * 18);
	var bbc = ' bgcolor="' + bgcolor + '"';
	if(bgcolor.length <1) bbc = '';
	var ttc = ' text="' + textcolor + '"';
	if(textcolor.length <1) ttc = '';
	var Properties = 'height=' + hh + ',width=' + String(parseInt(w,10)+25);
	var pPicture = window.open('','',Properties);
	pPicture.document.writeln('<html><head><title>' + tl + '<\/title>');
	pPicture.document.writeln('<script language="JavaScript">');
	pPicture.document.writeln('<!-- ');
	pPicture.document.writeln('function CloseMe() {');
	pPicture.document.writeln('self.close();');
	pPicture.document.writeln('}');
	pPicture.document.writeln('\/\/ -->');
	pPicture.document.writeln('<\/script>');
	pPicture.document.write('<\/head><body ' + bbc + ttc + '" onBlur="CloseMe()"><center>');
	pPicture.document.write('<IMG SRC="' + url + '" width="' + w + '" height="' + h + '" border="0">');
	pPicture.document.write(title);
	pPicture.document.write('<p><form><input type="button" onClick="window.close()" value="Close Window"><\/form>');
	pPicture.document.writeln('<\/center><\/body><\/html>');
}

function Description(url,w,h) {
// url of web page, width of popup, height of popup -- 
//    all must have values.
	var attributes = 'resizable=yes,scrollbars=yes,' + 
	'width=' + w + ',height=' + h;
	window.open(url,"DescPopup",attributes);
}

function GenerateInvoiceNumber() {
	var d = new Date();
	return d.getTime();
}

function moneytize(n) {
	n = (n * 100) + .005;
	var s = n + 'z';
	n = parseInt(s);
	n /= 100;
	s = new String(n);
	var l = s.length;
	if(s.indexOf('.') == -1) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	if(s.indexOf('.') == (s.length - 1)) { s += '00'; }
	return s;
}

function initialize() {
	var counter = 1;
	var ii = 0;
	for(counter = 1; counter <= NumberOfItemsForSale; counter++) {
		var tss = '';
		var s = 'document.wmp_cart.' + ItemHowManyFieldName[counter] + '.value';
		var ti = 0;
		var ts = 'parseInt(' + s + ')';
		ti = eval(ts);
		if(isNaN(ti) || (ti < .01)) {
			ts = s + '="0"';
			ti = eval(ts);
			ti = 0;
			tss = 'document.wmp_cart.' + HiddenFieldNameForItemID[counter] + '.value = ""';
		}
		else {
			tss = 'document.wmp_cart.' + HiddenFieldNameForItemID[counter] + '.value = DescriptionForItemID[' + counter + ']';
		}
		tss = eval(tss);
		ts = 'ti = ' + ti + ' * parseFloat(' + ItemCost[counter] + ')';
		ti = eval(ts);
		tss = moneytize(ti);
		ii += parseFloat(tss);
		ts = new String(tss);
		if(ts.substring(0,1) == '.') { tss = '0' + tss; }
		ts = 'document.wmp_cart.' + ItemSubTotalFieldName[counter] + '.value = tss';
		ts = eval(ts);
	}
	document.wmp_cart.subtotal.value = "0.00";
	document.wmp_cart.shipping.value = "0.00";
	document.wmp_cart.tax.value = "0.00";
	ts = 'document.wmp_cart.' + TotalAmountFieldName + '.value = "0.00"';
	ts = eval(ts);
	return ii;
}

function calc() {
	var T = initialize();
	if(T < 0.01) { return 0; }
	T = moneytize(T);
	document.wmp_cart.subtotal.value = T;
	var ti = (ShippingChargeByPercentage / 100) * parseFloat(T);
	ti += BaseShippingCharge;
	document.wmp_cart.shipping.value = moneytize(ti);
	if(document.wmp_cart.charge_tax.checked) {
		var tax_s = new String(CollectTaxOnShipping);
		if((tax_s.substring(0,1) == 'y') || (tax_s.substring(0,1) == 'Y')) {
			document.wmp_cart.tax.value = ((TaxRate / 100) * (T + parseFloat(document.wmp_cart.shipping.value))) + .005;
		}
		else { document.wmp_cart.tax.value = ((TaxRate / 100) * T) + .005; }
	}
	document.wmp_cart.tax.value = moneytize(document.wmp_cart.tax.value);
	ti = parseFloat(T) + parseFloat(document.wmp_cart.shipping.value) + parseFloat(document.wmp_cart.tax.value);
	ti = moneytize(ti);
	s = 'document.wmp_cart.' + TotalAmountFieldName + '.value = "' + ti + '"';
	ti = eval(s);
	return ti;
}

InvoiceNumber = GenerateInvoiceNumber();
