var PurchasePrice = 0;
var TitleSearch = 85;
var ClosingFee = 0;
var TitleInsurance = 0;
var TotalCosts = 0;
var TitleInsurance2 = 25;
var LoanClosingFee = 395;
var Endorsement81 = 50;
var EndorsementForm9 = 0;
var TotalEndorsements = 0;
var TotalPremium = 0;


function InitForm(){
	document.seller.PurchasePrice.focus();
}


function calcSellersPolicy() {
  if(document.seller.TotalPremium.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);
  TitleSearch       =  parseFloat(document.seller.TitleSearch.value);
  TotalEndorsements =  0;
  Endorsement81     =  parseFloat(document.seller.Endorsement81.value);
  EndorsementForm9  =  parseFloat(document.seller.EndorsementForm9.value);
  LoanClosingFee    =  parseFloat(document.seller.LoanClosingFee.value);



  if (PurchasePrice > 100000) { 

    TitleInsurance = ((((PurchasePrice - 100000)/1000)  * 5) + 575);

  } else {

    TitleInsurance = ((PurchasePrice/1000) * 5.75) ;
  }



  if (TitleInsurance < 100) { 

    TitleInsurance = 100; 

  }

	PurchasePrice = parseFloat(document.seller.PurchasePrice.value);

  if (PurchasePrice > 50000) { 

    ClosingFee = 160;
  } 
	else {

    ClosingFee = 260 ;

  }
  
  if (document.seller.balloon.checked == true) { 
    TotalEndorsements = TotalEndorsements + 50; 
  }
  
  if (document.seller.adjustable.checked == true) { 
    TotalEndorsements = TotalEndorsements + 50; 
  }
  
  if (document.seller.condo.checked == true) { 
    TotalEndorsements = TotalEndorsements + 50; 
  }
  
  if (document.seller.master.checked == true) { 
    TotalEndorsements = TotalEndorsements + 50; 
  }

//  EndorsementForm9  = parseFloat(((ownersPolicy) * .1) + 25);
  EndorsementForm9  = parseFloat(((TitleInsurance) * .1) + 25);
  TotalEndorsements = TotalEndorsements + EndorsementForm9 + Endorsement81;
  TotalPremium      = LoanClosingFee + TitleInsurance2 + TotalEndorsements;
  EndorsementForm9  = roundOff(EndorsementForm9);


  TotalCosts          =  TitleSearch + ClosingFee + TitleInsurance;
  TotalCosts          = roundOff(TotalCosts);
  TitleInsurance      = roundOff(TitleInsurance);



  document.seller.PurchasePrice.value       = currency(document.seller.PurchasePrice.value);
  document.seller.TitleSearch.value         = currency(TitleSearch);	
  document.seller.ClosingFee.value          = currency(ClosingFee);
  document.seller.TitleInsurance.value      = currency(TitleInsurance);
  document.seller.TotalCosts.value          = currency(TotalCosts);  
  document.seller.TitleInsurance2.value     = currency(TitleInsurance2);
  document.seller.Endorsement81.value       = currency(Endorsement81);
  document.seller.EndorsementForm9.value    = currency(EndorsementForm9);
  document.seller.TotalEndorsements.value   = currency(TotalEndorsements);
  document.seller.LoanClosingFee.value      = currency(LoanClosingFee);
  document.seller.TotalPremium.value        = currency(TotalPremium);
  

}


