I have written a function that does a few calculations based on numbers entered into several fields. I have most of it working, but a few things just don't ever fire and perhaps someone can see what's errored in my code.

Background: User inputs the vendor list price, quantity, a discount (if one is offered), a discount the company receives from vendor (STB discount) and lastly, payment method. If a credit card type is selected for payment method, a fee amount would come into the calculations.

What I can't seem to get to work right is the calculation and addition of the credit card fee to the rest of the calculations. See code below, and thanks.

Oh, the function fires with the onChange of one of the discount fields....

function calc_discount(){
  	price = document.mainform.vendorlistprice.value;
	price = price.replace(/[^\d\.]/g,"");
	quantity = document.mainform.quantity.value;
	discnt = document.mainform.discount.value;
	discnt = discnt.replace(/[^\d\.]/g,"");
	newprice = price*quantity
	reducedprice = newprice*(discnt/100);
	saleprice = (newprice-reducedprice).toFixed(2);
	saleprice = saleprice.replace(/[^\d\.]/g,"");
	document.mainform.sale_price.value = (newprice-reducedprice).toFixed(2);
	// Start calc of customer savings
	document.mainform.customersavings.value = (price-saleprice).toFixed(2);
	// Start Secondary reduction calculation
	discnt = document.mainform.stb_discount.value;
	discnt = discnt.replace(/[^\d\.]/g,"");
	reducedprice = price*(discnt/100);
	cogs = (price-reducedprice).toFixed(2);
  	document.mainform.cogs.value = cogs;
	// Start calc of Profit
	document.mainform.profit.value = (saleprice-cogs).toFixed(2);
	// Start calc for cc fee
	var paymentmethod = document.getElementById("paymentmethod").selectedIndex;
  	if (paymentmethod.length>0){
	var type  = paymentmethod;
	switch (type)
	case 6:
	var perct = .0325;
	case 7:
	var perct = .003;
	case 8:
	var perct = .03;
	var perct = 0;
	creditfee = (cogs*perct).toFixed(2);  
	document.mainform.creditfee.value = creditfee;
	document.mainform.profit.value = (saleprice-cogs-creditfee).toFixed(2);
  function docalcs() {
 var discount = document.mainform.discount.value
 if (discount.length>0) {