var policyamt, premium, inputamt,enteramt;

function reset()
{ 
   document.Calculator.enteramt.value = "";
   document.Calculator.outputamt.value = " ";
   outputamt = " ";
   calcPrem(2);
}
        
function calcPrem(a)
{
   if (document.Calculator.enteramt.value == "") inputamt = 0
   else
      inputamt = parseFloat(document.Calculator.enteramt.value);
      if ((inputamt < 100001) || (inputamt == " "))
      {
        alert('See chart below for rates under $100,000');
        document.Calculator.enteramt.value = "";
        document.Calculator.outputamt.value = " ";
      }
      else 
      {
        if ((inputamt>= 100001)&&(inputamt <= 1000000))premium=First(inputamt);
        if ((inputamt>= 1000001)&&(inputamt <= 5000000))premium=Second(inputamt);
        if ((inputamt>= 5000001)&&(inputamt <= 15000000))premium=Third(inputamt);
        if ((inputamt>= 15000001)&&(inputamt <= 25000000))premium=Fourth(inputamt);
        if (inputamt>= 25000000)premium=Fifth(inputamt);
        premium = Math.round(premium);
	document.Calculator.enteramt.value = " $    " + inputamt;
        document.Calculator.outputamt.value = " $    " + premium;
      }
}

function First(insedamt)
{
   var cost = 0;
               
   cost = insedamt - 100000;
   cost = cost * .005340;
   cost = cost + 843;
  return cost;
}

function Second(insedamt)
{
   var cost = 0;
               
   cost = insedamt - 1000000;
   cost = cost * .00439;
   cost = cost + 5649;
  return cost;
}

function Third(insedamt)
{
   var cost = 0;
                
   cost = insedamt - 5000000;
   cost = cost * .00362;
   cost = cost + 23209;
  return cost;
}

function Fourth(insedamt)
{
   var cost = 0;
                
   cost = insedamt - 15000000;
   cost = cost * .00257;
   cost = cost + 59409;
  return cost;
}

function Fifth(insedamt)
{
   var cost = 0;
                
   cost = insedamt - 25000000;
   cost = cost * .00154;
   cost = cost + 85109;
  return cost;
}

