
	var tot_units = 0;
	var tot_cost = 0;
	
function orderformcalc(theform) {
				var f = document.creat;
	if (f.NumbCopies.value != "" ){
		if(isNaN(f.NumbCopies.value) == true || f.NumbCopies.value == 0){
				alert ("Please enter a valid number of Manuals");
				f.NumbCopies.focus();
				f.NumbCopies.value ="1";
				f.NumbCopies.select();
				orderformcalc();
				return false;
		}else{
				var priceq =0;
				tot_units = f.NumbCopies.value;
				priceq += (tot_units * 19.95);
				f.qtydisct.value = "$" + formatPrice(priceq);
				f.subt.value = "$" + formatPrice(priceq);
			//Calculate Discount
				discount = getDiscountPrice(tot_units);	
				discountcost = (priceq - discount * tot_units);		
				f.qtymanuals.value = "- $" + formatPrice(discountcost) 
				f.manual.value = "$" + discount;
				f.mansubt.value = "$" + formatPrice(priceq-discountcost);
			//Manual Subtotal
				mansubt = priceq-discountcost;
						
			//Calculate State Taxes For Maryland
				var t_tax= 0;
			/*if (SetSate() == 'MD'){
				var tax = 0;
				tax += mansubt * .00;		
				t_tax += tax; 
				f.salestax.value = "$" + formatPrice(t_tax);
			}else{
				f.salestax.value = "$0.00";
			}*/
			//Calculate Shipping and Handling
				var shipping=0;
			if (tot_units <=20){
				shipping += 3.75 + ((tot_units-1)*(3.30));
				f.shipping.value ="$" + formatPrice(shipping);
			}else if(tot_units <= 51 ){
				shipping += 3.75 + ((tot_units-1)*(1.70));
				f.shipping.value ="$" + formatPrice(shipping);
			}else if (tot_units <= 100000){
				shipping += 3.75 + ((tot_units-1)*(2.00));
				f.shipping.value ="$" + formatPrice(shipping);
			}else{
				shipping += 3.75;
				f.shipping.value ="$" + formatPrice(shipping);
			}
			//REPORTS ORDER TOTAL
				f.subtotal.value = "$" + formatPrice(mansubt+t_tax+shipping);
				f.amount.value = formatPrice(mansubt+t_tax+shipping);
				f.undefined_quantity.value=tot_units;
		}

	}	


}
function formatPrice(value) {
var result= Math.floor(value) + ".";
var cents = 100 * (value-Math.floor(value)) + 0.5;
result += Math.floor(cents / 10);
result += Math.floor(cents % 10);
return result;
}
var max_units = 50; // quantities in excess of max_units all have the same unit price
function getDiscountPrice(units) {
// Note: It is important to work your way down from max to min amounts!
if (units >= max_units) return 13.95; 
if (units >= 25 && units <=50) return 16.95;
if (units >= 1 && units <=24) return 19.95;
if (units <= 0) return 0;
}
function SetSate(sts){
	sts= document.creat.state;
	if (sts.value != "" ){
		var state = sts.value;
		return state;
	}else{
		alert ("Please enter a Shipping State");
		sts.focus();
		sts.select();
		return false;
	}
}

