// keep track of what they're currently usingvar additionalRadio = false;var currentCartItem = 0;var totalBooklets = 0;function formatDollars(aNumber) {	if (aNumber > 0) {		aNumber = aNumber.toString();		aNumber = aNumber.substring(0,aNumber.length - 2) + '.' + aNumber.substr(aNumber.length - 2);		return aNumber;	} else {		return '0.00';	}}function normalizeQuantities() {	if (! (document.orderForm.gleo_quant.value >= 0)) {		document.orderForm.gleo_quant.value = 0;	}		if (! (document.orderForm.image_quant.value >= 0)) {		document.orderForm.image_quant.value = 0;	}		if (! (document.orderForm.dnapi_quant.value >= 0)) {		document.orderForm.dnapi_quant.value = 0;	}		if (! (document.orderForm.agc_quant.value >= 0)) {		document.orderForm.agc_quant.value = 0;	}		if (! (document.orderForm.additional.value >= 0)) {		document.orderForm.additional.value = 0;	}}	function calculateTotals() {	var subtotal = 0;	var shipping = 0;	var total = 0;	var additional;		normalizeQuantities();		// figure out the additional contribution	additional = Math.round(Number(document.orderForm.additional.value) * 100);		document.orderForm.additional_opt[0].checked = false;	document.orderForm.additional_opt[1].checked = false;	document.orderForm.additional_opt[2].checked = false;	if (document.orderForm.additional_opt[0].value * 100 == additional)		document.orderForm.additional_opt[0].checked = true;	else if (document.orderForm.additional_opt[1].value * 100 == additional)		document.orderForm.additional_opt[1].checked = true;	else if (additional > 0)		document.orderForm.additional_opt[2].checked = true;		// things are measured as integers (cents) to prevent javascript rounding errors		// god loves each one / made in god's image	if ((Number(document.orderForm.gleo_quant.value) + Number(document.orderForm.image_quant.value) + Number(document.orderForm.dnapi_quant.value) + Number(document.orderForm.agc_quant.value)) < 10) {		document.orderForm.gleo_cost.value = document.orderForm.gleo_quant.value * 700;		document.orderForm.image_cost.value = document.orderForm.image_quant.value * 700;		document.orderForm.dnapi_cost.value = document.orderForm.dnapi_quant.value * 700;		document.orderForm.agc_cost.value = document.orderForm.agc_quant.value * 700;	} else {		document.orderForm.gleo_cost.value = document.orderForm.gleo_quant.value * 500;		document.orderForm.image_cost.value = document.orderForm.image_quant.value * 500;		document.orderForm.dnapi_cost.value = document.orderForm.dnapi_quant.value * 500;		document.orderForm.agc_cost.value = document.orderForm.agc_quant.value * 500;	}	subtotal += document.orderForm.gleo_cost.value * 1;	subtotal += document.orderForm.image_cost.value * 1;	subtotal += document.orderForm.dnapi_cost.value * 1;	subtotal += document.orderForm.agc_cost.value * 1;		// calculate shipping	totalBooklets = Number(document.orderForm.gleo_quant.value) + Number(document.orderForm.image_quant.value) + Number(document.orderForm.dnapi_quant.value) + Number(document.orderForm.agc_quant.value);	if (totalBooklets > 0)		shipping = 600;	if (totalBooklets > 1)		shipping += 150 * (totalBooklets - 1);	if (shipping > 1500)		shipping = 1500;	total = subtotal + shipping + additional;	// calculated fields	document.orderForm.subtotal.value = formatDollars(subtotal);	document.orderForm.shipping.value = formatDollars(shipping);	document.orderForm.total.value = formatDollars(total);	document.orderForm.additional.value = formatDollars(additional);	document.orderForm.additional_cost.value = formatDollars(additional);		// cost holders	document.orderForm.gleo_cost.value = document.orderForm.gleo_sub.value = formatDollars(document.orderForm.gleo_cost.value);	document.orderForm.image_cost.value = document.orderForm.image_sub.value = formatDollars(document.orderForm.image_cost.value);	document.orderForm.dnapi_cost.value = document.orderForm.dnapi_sub.value = formatDollars(document.orderForm.dnapi_cost.value);	document.orderForm.agc_cost.value = document.orderForm.agc_sub.value = formatDollars(document.orderForm.agc_cost.value);}function validate() {	var email_p = /^(.+\@.+\..+)$/;	var ccNum_p = /^[0-9]{16}$/;		calculateTotals();	if (document.orderForm.total.value == '0.00') {		alert('Please order at least one booklet or make a contribution.');		document.orderForm.image_quant.focus();		return false;	}		if ((totalBooklets >= 6) && (totalBooklets < 10)) {		if (! confirm('We noticed you\'ve ordered ' + totalBooklets + ' booklets - if you increase your order to 10, you\'ll save money and have extra to share.\r\rPress "OK" to continue with your order as is, or "Cancel" to edit your choices.')) {			return false;		}	}		return true;}function addCartItem(name, price, quantity) {	currentCartItem++;	document.paypalForm['item_name_' + currentCartItem].value = name;	document.paypalForm['amount_' + currentCartItem].value = formatDollars((price * 100) / quantity);	document.paypalForm['quantity_' + currentCartItem].value = quantity;	document.paypalForm['shipping_' + currentCartItem].value = 0;}function addCartItemFromPrefix(prefix) {	if (Number(document.orderForm[prefix + '_quant'].value) > 0) {		addCartItem(document.orderForm[prefix + '_name'].value, document.orderForm[prefix + '_sub'].value, document.orderForm[prefix + '_quant'].value);	}}function resetPayPalPayment() {	for (var i = 1; i <= 6; i++) {		document.paypalForm['item_name_' + i].value = '';		document.paypalForm['amount_' + i].value = '';		document.paypalForm['quantity_' + i].value = '';	}	currentCartItem = 0;}function doPayPalPayment() {	resetPayPalPayment();	addCartItemFromPrefix('gleo');		addCartItemFromPrefix('image');		addCartItemFromPrefix('dnapi');		addCartItemFromPrefix('agc');			if (Number(document.orderForm.additional.value) > 0) {		addCartItem('Contribution', document.orderForm.additional.value, 1);		}		document.paypalForm.shipping_1.value = Number(document.orderForm.shipping.value);		return true;}