<!-- Copyright 2000 William Bontrager
//
//       Customer Friendly, Cart-less E-commerce Site
//
// NOTE: If you received this JavaScript source code from 
//       a friend or associate, you can pick up the latest 
//       version from http://willmaster.com/
//
// JavaScript functions and customization instructions.
//
// Customization instructions are in 9 steps.
//
// NOTE: When you customize a JavaScript line, make sure it 
//       ends with a semi-colon. I.E.: ;
//
// NOTE: It may be easier to make your order form before 
//       customizing this JavaScript code.
//



// STEP 1:
// The JavaScript functions need to know how many items you 
//   have for sale on your page. Change the number below to 
//   the number of items you have for sale:

NumberOfItemsForSale =13;


// 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);




// STEP 2
// The order form has hidden fields to relay identification 
//   to your credit card processing service.
// Enter the hidden field names here, between quotes.
// The first hidden field name follows [1] and so forth, up 
//   to the number of items you specified in step 1. The 
//   sequential numbers are in brackets.

HiddenFieldNameForItemID[1] = "desc_Astrology";
HiddenFieldNameForItemID[2] = "desc_Potpourri";
HiddenFieldNameForItemID[3] = "desc_Aleph_2160";
HiddenFieldNameForItemID[4] = "desc_Kabbalah_code";
HiddenFieldNameForItemID[5] = "desc_crop_circle";
HiddenFieldNameForItemID[6] = "desc_Alchemysteries";
HiddenFieldNameForItemID[7] = "desc_Jitterbug12";
HiddenFieldNameForItemID[8] = "desc_aromatherapy";
HiddenFieldNameForItemID[9] = "desc_Kit";
HiddenFieldNameForItemID[10] = "desc_stemenhance";
HiddenFieldNameForItemID[11] = "desc_TLMSDVD";
HiddenFieldNameForItemID[12] = "desc_Sonic_Merkavah";
HiddenFieldNameForItemID[13] = "desc_Dome_Retreat";
// STEP 3
// Each item you have for sale must also be identified by 
//   description when it is ordered. The identification 
//   can be with an item number, name, and/or narrative 
//   description. It is for you, so you can recognize it 
//   for what it is when you receive order confirmations 
//   from your credit card authorization service. (In 
//   step 2 you specified the hidden fields that will 
//   relay this identification to your credit card 
//   processing service.)
// Some credit card authorization services email your 
//   customer with confirmation, in which case these 
//   item descriptions should be clear enough for your 
//   customers to understand what was ordered.
// Descriptions are typed between quotes. Therefore, 
//   quotes within the ID must be preceeded with a back 
//   slash. I.E.:
//           "The tome, \"Happy Happy\" by I.M. Writer";
// The sequential numbers are in brackets. Type the item 
//   description in the same order as you typed the hidden 
//   field names in setp 2, so that DescriptionForItemID[1] 
//   is the description of the item in 
//   HiddenFieldNameForItemID[1], and so forth.

DescriptionForItemID[1] = "#Kalabah Astrology";
DescriptionForItemID[2] = "#Potpourri";
DescriptionForItemID[3] = "#A Zodiac Oracle (+cd)";
DescriptionForItemID[4] = "#Kabbalah_code";
DescriptionForItemID[5] = "#Crop Circle Oracle Cards";
DescriptionForItemID[6] = "#Alchemysteries Elixir";
DescriptionForItemID[7] = "#Jitterbug Aromatherapy Blend";
DescriptionForItemID[8] = "#Jitterbug Aromatherapy Kit";
DescriptionForItemID[9] = "#Alchemysteries Kit";
DescriptionForItemID[10] = "#Stem Enhance 1 bottle";
DescriptionForItemID[11] = "#Unicorn Messiah Merkavah Meditation";
DescriptionForItemID[12] = "#SonicMerkavah Journeys 2CDS";
DescriptionForItemID[13] = "#Crystal Dome Retreat";

// STEP 4
// Specify the cost of each item you have for sale.
// Type the item cost in the same order as you typed the 
//   the hidden field names in setp 2, so that ItemCost[1] 
//   is the cost of the item in HiddenFieldNameForItemID[1], 
//   and so forth.

ItemCost[1] = 256.00;
ItemCost[2] = 156.00;
ItemCost[3] = 111.00;
ItemCost[4] = 111.00;
ItemCost[5] = 78.00;
ItemCost[6] = 22.00;
ItemCost[7] = 36.00;
ItemCost[8] = 360.00;
ItemCost[9] = 222.00;
ItemCost[10] = 33.00;
ItemCost[11] = 77.00;
ItemCost[12] = 36.00;
ItemCost[13] = 360.00;

// STEP 5
// Specify the form field name where the customer will type 
//   the quantity being ordered. Field names should contain 
//   only letter, number, and underscore characters. I.E.:
//          <input type="text" name="num_tshirts" size="3">
// In the above example, the form field name is "num_tshirts".
// Type the field names in the same order as you typed the 
//   the hidden field names in setp 2.
// Form field names are typed between quotes.

ItemHowManyFieldName[1] = "num_Astrology";
ItemHowManyFieldName[2] = "num_Potpourri";
ItemHowManyFieldName[3] = "num_Aleph_2160";
ItemHowManyFieldName[4] = "num_Kabbalah_code";
ItemHowManyFieldName[5] = "num_crop_circle";
ItemHowManyFieldName[6] ="num_Alchemysteries";
ItemHowManyFieldName[7] ="num_Jitterbug12";
ItemHowManyFieldName[8] ="num_aromatherapy";
ItemHowManyFieldName[9] ="num_Kit";
ItemHowManyFieldName[10] ="num_stemenhance";
ItemHowManyFieldName[11] ="num_TLMSDVD";
ItemHowManyFieldName[12] ="num_Sonic_Merkavah";
ItemHowManyFieldName[13] ="num_Dome_Retreat";

// STEP 6
// Specify the form field name line subtotals, where the 
//   product total will be displayed after the customer 
//   types in how many they want. Field names should 
//   contain only letter, number, and underscore 
//   characters. I.E.:
//          <input type="text" name="sub_tshirts" size="3">
// In the above example, the form field name is "sub_tshirts".
// Type the field names in the same order as you typed the 
//   hidden field names in setp 2.
// Form field names are typed between quotes.

ItemSubTotalFieldName[1] = "sub_Astrology";
ItemSubTotalFieldName[2] = "sub_Potpourri";
ItemSubTotalFieldName[3] = "sub_Aleph_2160";
ItemSubTotalFieldName[4] = "sub_Kabbalah_code";
ItemSubTotalFieldName[5] = "sub_crop_circle";
ItemSubTotalFieldName[6] ="sub_Alchemysteries";
ItemSubTotalFieldName[7] ="sub_Jitterbug12";
ItemSubTotalFieldName[8] ="sub_aromatherapy";
ItemSubTotalFieldName[9] ="sub_Kit";
ItemSubTotalFieldName[10] ="sub_stemenhance";
ItemSubTotalFieldName[11] ="sub_TLMSDVD";
ItemSubTotalFieldName[12] ="sub_Sonic_Merkavah";
ItemSubTotalFieldName[13] ="sub_Dome_Retreat";

// STEP 7
// Here is where you specify your shipping charges. You 
//   can specify either by base price (could be flat rate) 
//   or a percentage of the product total or both. Both of 
//   the below two lines must have a value, which may be 
//   0 (zero). If both are larger than 0, then the program 
//   will calculate both into the shipping/handling charge.

BaseShippingCharge = 0.00;
ShippingChargeByPercentage = 10.00;




// STEP 8
// Here is where you specify your tax rate and whether or 
//   not you collect tax on shipping/handling charges. Both 
//   of the below two lines must have values -- the value 
//   on the second line is within quotes. The first value 
//   is the tax percentage you are collecting, which may be 
//   0 (zero). The second value is either "yes" or "no".

TaxRate = 10.0;
CollectTaxOnShipping = "no";




// STEP 9
// Type in the name of the field name that will hold the 
//   total amount to be charged to your customer's credit 
//   card. This is the same field name you used on the form. 
//   The field name is within quotes.

TotalAmountFieldName = "total_amount";





// No more customization is necessary.


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) / 7)) + 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();

//-->
