<!--
var totalLayer 
function findTotalLayer() {
	if (document.getElementById) {
		totalLayer = document.getElementById('total');
	} else if (document.all) {
		totalLayer = document.all.total;
	}
}

function calculateTotal(price) {


  price = calculatePremium(price);
  
  var priceStr = "<table cellpadding=0 cellspacing=0 border=0 width=100><tr><td class=content align=right>" + price + "</td></tr></table>"
	
	if (document.layers) {
			document.total.document.total1.document.writeln(priceStr);
			document.total.document.total1.document.close();

	} else {
		if (totalLayer) {
			totalLayer.innerHTML=priceStr
		}
	}
}

function calculatePremium(price) {

  if(isNumber(price)==true) {
    price = (parseFloat(price)*0.04)

    if(price<75) {
      if (price<=0) {
        price = 0;
      } else {
        price=75;
      }
    }
    price = price * 1.08;
        
    price = dollarFormat(price);

  } else {
    price="0"
  }

  price = "$" + price;
  
  return price;
}

function calculatePremiumUntaxed(price) {

  if(isNumber(price)==true) {
    price = (parseFloat(price)*0.04)

    if(price<75) {
      if (price<=0) {
        price = 0;
      } else {
        price=75;
      }
    }
    price = dollarFormat(price);

  } else {
    price="0"
  }

  price = price;
  
  return price;
}

function calculateSalesTax(price) {
  if(isNumber(price)==true) {

    if(price<75) {
      if (price<=0) {
        price = 0;
      } else {
        price=75;
      }
    }
    price = price * .08;
        
    price = dollarFormat(price);

  } else {
    price="0"
  }

  price = "$" + price;
  
  return price;
}

function calculateSeasonTotal(price) {
    document.forms[0].premiumUntaxed.value= "$" + dollarFormat(calculatePremiumUntaxed(price));
    document.forms[0].salesTax.value=calculateSalesTax(calculatePremiumUntaxed(price));
    document.forms[0].totalDue.value=calculatePremium(price);
}

function dollarFormat(price) {
    //alert(isNaN(price)==true)
    if (isNumber(price)==true && isNaN(price)==false) {
      price = (Math.floor((price * 100)+.5))/100    
      
      var decPos = price.toString().indexOf(".");    
      var dec
      if (decPos!=-1) {
        dec = price.toString().substring(decPos);
        
        if (dec.length==1) {
          price = price + "00";
        } else if (dec.length==2) {
          price = price + "0"
        }
  
      } else { price=price+".00"; }
    } else {
        price=0;
    }
    
    return price

}

function isNumber(numVal) {

  var oneDecimal = false;
  var numStr = numVal.toString();
  
  for (var i=0;i<numStr.length;i++) {
    var oneChar = numStr.charAt(i);
    if (i==0 && oneChar=="-") {
      continue;
    }
  
    if (oneChar=="." && !oneDecimal) {
      oneDecimal=true;
      return false;
    }
    
    if(oneChar<"0" || oneChar>"9") {
      return false;
    }
    
    return true;
  }

}
// -->
