<!--

// Check to see if field is empty
function emptyField(textObj)
{
if (textObj.value.length == 0) return true;
for (var i=0; i<textObj.value.length; ++i) {
var ch = textObj.value.charAt(i);
if (ch != ' ' && ch != '\t') return false;
}

return true;

}

function moneyFormat(textObj) {
   var newValue = textObj.value
   var decAmount = ""
   var dolAmount = ""
   var decFlag = false
   var aChar = ""

   // ignore all but digits and decimal points.
   for(i=0; i < newValue.length; i++) {
      aChar = newValue.substring(i,i+1)
      if(aChar >= "0" && aChar <= "9") {
         if(decFlag) {
            decAmount = "" + decAmount + aChar
         }
         else {
            dolAmount = "" + dolAmount + aChar
         }
      }
      if(aChar == ".") {
         if(decFlag) {
            dolAmount = ""
            break
         }
         decFlag=true
      }
   }

   // Ensure that at least a zero appears for the dollar amount.
   if(dolAmount == "") {
      dolAmount = "0"
   }
   // Strip leading zeros.
   if(dolAmount.length > 1) {
      while(dolAmount.length > 1 && dolAmount.substring(0,1) == "0") {
         dolAmount = dolAmount.substring(1,dolAmount.length)
      }
   }

   // Round the decimal amount.
   if(decAmount.length > 2) {
      if(decAmount.substring(2,3) > "4") {
         decAmount = parseInt(decAmount.substring(0,2)) + 1
         if(decAmount < 10) {
            decAmount = "0" + decAmount
         }
         else {
            decAmount = "" + decAmount
         }
      }
      else {
         decAmount = decAmount.substring(0,2)
      }
      if (decAmount == 100) {
         decAmount = "00"
         dolAmount = parseInt(dolAmount) + 1
      }
   }

   // Pad right side of decAmount
   if(decAmount.length == 1) {
      decAmount = decAmount + "0"
   }
   if(decAmount.length == 0) {
      decAmount = decAmount + "00"
   }

   // Check for negative values and reset textObj
   if(newValue.substring(0,1) != '-' || (dolAmount == "0" && decAmount == "00")) {
      textObj.value = dolAmount + "." + decAmount
   }
   else{
      textObj.value = '-' + dolAmount + "." + decAmount
   }
}

function calculate(formObj) {
	if (formObj.maResident.checked) {
		tax = 0.05
		} else { tax = 0
	}


	// Start Totaling for Products
	var Total1 = parseInt(formObj.quantity1.value) * (25.00);
	formObj.price1.value = Math.round(Total1*100)/100;
	moneyFormat(document.form1.price1);
	
	var Total2 = parseInt(formObj.quantity2.value) * (99.00);
	formObj.price2.value = Math.round(Total2*100)/100;
	moneyFormat(document.form1.price2);
	
	var Total3 = parseInt(formObj.quantity3.value) * (110.00);
	formObj.price3.value = Math.round(Total3*100)/100;
	moneyFormat(document.form1.price3);
	
	//Total all items	
	var Subtotal = Number(Total1 + Total2 + Total3);
	formObj.sub_total.value = Math.round(Subtotal*100)/100;
	moneyFormat(document.form1.sub_total);
	
	var salestax = (Subtotal) * tax;
	formObj.display_taxes.value = Math.round(salestax*100)/100;
	moneyFormat(document.form1.display_taxes);
	
	var shipping = 15.00;
	formObj.display_shipping.value = Math.round(shipping*100)/100;
	moneyFormat(document.form1.display_shipping);
	
	var Total = Subtotal + salestax + shipping;
	formObj.chargetotal.value = Math.round(Total*100)/100;
	moneyFormat(document.form1.chargetotal);

	if (form1.quantity1.value > 0) {
		form1.item1.value = 'Getting Started with HIPAA Security';
		} else { form1.item1.value = '' }
		
	if (form1.quantity2.value > 0) {
		form1.item2.value = 'HIPAA Security Risk Assessment Documents';
		} else { form1.item2.value = '' }

	if (form1.quantity3.value > 0) {
		form1.item3.value = 'Both Offerings';
		} else { form1.item3.value = '' }

}


// end hide -->