function calcNow (book, qty) {
	if (book == "101") {
		sub = qty * 14.95; fmtPrice(sub); document.order.subOne.value = sub; calcSub(); checkEmail();
		} else if (book == "101m") {
		sub = qty * 6.95; fmtPrice(sub);  document.order.subOneM.value = sub; calcSub(); checkEmail();
		}
	if (book == "102") {
		sub = qty * 14.95; fmtPrice(sub); document.order.subTwo.value = sub; calcSub(); checkEmail();
		} else if (book == "102m") {
		sub = qty * 6.95; fmtPrice(sub); document.order.subTwoM.value = sub; calcSub(); checkEmail();
		}
	if (book == "103") {
		sub = qty * 14.95; fmtPrice(sub); document.order.subThree.value = sub; calcSub(); checkEmail();
		} else if (book == "103m") {
		sub = qty * 6.95; fmtPrice(sub); document.order.subThreeM.value = sub; calcSub(); checkEmail();
		}
	if (book == "104") {
		sub = qty * 14.95; fmtPrice(sub); document.order.subFour.value = sub; calcSub(); checkEmail();
		} else if (book == "104m") {
		sub = qty * 6.95; fmtPrice(sub); document.order.subFourM.value = sub; calcSub(); checkEmail();
		}
	if (book == "105") {
		sub = qty * 14.95; fmtPrice(sub); document.order.subFive.value = sub; calcSub(); checkEmail();
		} else if (book == "105m") {
		sub = qty * 6.95; fmtPrice(sub); document.order.subFiveM.value = sub; calcSub(); checkEmail();
		}
	if (book == "106") {
		sub = qty * 17.95; fmtPrice(sub); document.order.subSix.value = sub; calcSub(); checkEmail();
		}
	if (book == "107") {
		sub = qty * 19.95; fmtPrice(sub); document.order.subSeven.value = sub; calcSub(); checkEmail();
		}

	if (book == "108") {
		sub = qty * 10.95; fmtPrice(sub); document.getElementById('subEight').value = sub; calcSub(); checkEmail();
		}

	}

function calcSub()	{
	// CALC THE SUBTOTAL
	theSub = Number(document.order.subOne.value) +  Number(document.order.subOneM.value) +  Number(document.order.subTwo.value) +
			Number(document.order.subTwoM.value) +  Number(document.order.subThree.value) +  Number(document.order.subThreeM.value)
			+  Number(document.order.subFour.value) +  Number(document.order.subFourM.value) +  Number(document.order.subFive.value) + Number(document.order.subFiveM.value) +  Number(document.order.subSix.value) +  Number(document.order.subSeven.value) +  Number(document.order.subEight.value);

	document.order.subtotal.value = "";
	document.order.subtotal.value = theSub;
	var theType = "";

	// CALC THE DISCOUNT
	for (i=0; i<3; i++) {
		if (document.order.customer[i].checked)
			if (i == 0) {
				theDisc = false;
				} else if (i == 1) {
				theDisc = true;
				theType = "group";
				} else {
				theDisc = true;
				theType = "store";
				}
			}

	// CALCULATE TOTAL NUMBER OF BOOKS

	quan = new Array();

	quan[1] = Number(document.getElementById('q101').value);
	quan[2] = Number(document.getElementById('q101m').value);
	quan[3] = Number(document.getElementById('q102').value);
	quan[4] = Number(document.getElementById('q102m').value);
	quan[5] = Number(document.getElementById('q103').value);
	quan[6] = Number(document.getElementById('q103m').value);
	quan[7] = Number(document.getElementById('q104').value);
	quan[8] = Number(document.getElementById('q104m').value);
	quan[9] = Number(document.getElementById('q105').value);
	quan[10] = Number(document.getElementById('q105m').value);
	quan[11] = Number(document.getElementById('q106').value);
	quan[12] = Number(document.getElementById('q108').value);
	quan[13] = Number(document.getElementById('q108').value);

	totBooks = parseInt(0);

	for (i=1; i<quan.length; i++) {

		if (quan[i] == "") {
			quan[i] = 0;
			}

		totBooks += quan[i];
		totBooks = parseInt(totBooks);

		}


	// IF THIS IS A CHURCH OR GROUP, APPLY DISCOUNT ONE BASED ON QUANTITY
	if (theDisc == true && theType == "group") {

		if (totBooks < 21) {
			theDisc = theSub * .1;
			}

		if (totBooks > 20 && totBooks < 51) {
			theDisc = theSub * .15;
			}

		if (totBooks > 50) {
			theDisc = theSub * .2;
			}

		theDisc = fmtPrice(theDisc);
		document.order.discount.value = "";
		document.order.discount.value = theDisc;

		}


	// IF THIS IS A STORE, APPLY DISCOUNT TWO FOR STORES ONLY
	if (theDisc == true && theType == "store") {

		theDisc = theSub * .4;

		theDisc = fmtPrice(theDisc);
		document.order.discount.value = "";
		document.order.discount.value = theDisc;

		}




	// CALC THE SHIPPING
	workingSub = theSub;

	if (workingSub > .01 && workingSub <= 20) {
		theShip = 6.00;
		theShip = fmtPrice(theShip);
		} else if (workingSub > 20 && workingSub <= 50) {
		theShip = 8.00;
		theShip = fmtPrice(theShip);
		} else if (workingSub > 50 && workingSub <= 100) {
		theShip = 10.00;
		theShip = fmtPrice(theShip);
		} else {
		theShip = workingSub * .1;
		theShip = fmtPrice(theShip);
		}

	document.order.shipping.value = ""
	document.order.shipping.value = theShip

	// CALC THE TOTAL
	theTotal = Number(theSub) - Number(theDisc) + Number(theShip);
	theTotal = fmtPrice(theTotal);

	document.order.total.value = ""
	document.order.total.value = theTotal;
	}

// SUBROUTINE TO FIX DECIMAL POINTS
function fmtPrice(value) {
	result=+Math.floor(value)+".";
	var cents=100*(value-Math.floor(value))+0.5;
	result += Math.floor(cents/10);
	result += Math.floor(cents%10);
	sub = result;
	return sub;
	}

// CHECK ORGANIZATION FIELD
function checkOrg(type) {
	if (document.order.organization.value == "" && type == "school") {
		alert("You must enter the name of your organization.")
		document.order.organization.focus()
		}

	if (document.order.organization.value == "" && type == "store") {
		alert("You must enter the name of your bookstore.")
		document.order.organization.focus()
		}
	calcSub()
	}

//CHECK EMAIL
function checkEmail() {
	eAdd = document.order.email.value
	if (eAdd == "") {
		alert("Email is a required field")
		document.order.email.focus(); document.order.email.select();
		}
	}

