var PurchasePrice = 0;
var OwnersPolicyPremium = 0;
var ClosingFee = 0;
var TotalCosts = 0;

function InitForm(){
	document.seller.PurchasePrice.focus();
}

function calcSellersPolicy() {
  if(document.seller.TotalCosts.value != 0) {  
    alert("Please clear the form before the next calculation.");
    document.seller.PurchasePrice.focus();
    return false; 
  }
  
  if(document.seller.PurchasePrice.value == 0) {  
    alert("Please enter the purchase price.");
    document.seller.PurchasePrice.focus();
    return false; 
  }
  
  PurchasePrice = parseFloat(document.seller.PurchasePrice.value);
  ClosingFee    = parseFloat(document.seller.ClosingFee.value);

  if (PurchasePrice > 100000) { 
    OwnersPolicyPremium = ((((PurchasePrice - 100000)/1000)  * 5) + 575);
  } else {
    OwnersPolicyPremium = ((PurchasePrice/1000) * 5.75) ;
  }

  if (OwnersPolicyPremium < 300) { 
    OwnersPolicyPremium = 300; 
  }

  TotalCosts          = OwnersPolicyPremium + ClosingFee;
  TotalCosts          = roundOff(TotalCosts);
  OwnersPolicyPremium = roundOff(OwnersPolicyPremium);

  document.seller.PurchasePrice.value       = currency(document.seller.PurchasePrice.value);
  document.seller.ClosingFee.value          = currency(document.seller.ClosingFee.value);
  document.seller.OwnersPolicyPremium.value = currency(OwnersPolicyPremium);
  document.seller.TotalCosts.value          = currency(TotalCosts);
}