/************************************************

   calculator1.js - Specific calculator1 routines
  
   Copyright 2003 Better-Mortgages.co.uk Ltd
   All rights reserved.
  
 ************************************************/

helpText = "Please enter all details required on the left hand form, including a property value (even if only an estimate). When you press the 'Calculate' button, the results will appear in the right hand box.\n\nWhen you choose an interest rate, remember that while there may be some mortgages offering lower rates than the Bank of England Base Rate, these rates tend to be short term offers, where the rate reverts to the lenders base rate in the first year or two. You also need to be aware that there are costs associated with the arrangement of any mortgage which will be over and above your monthly payments.";

alertLTV = "You are asking to borrow more than 100% of the property value. Very few mortgages of 100% loan to value (LTV) or greater are currently available. If you are looking to arrange a first mortgage or remortgage, the typical LTV is 95% or less.\n\nFor a Buy to Let mortgage you may not find a lender willing to lend more than 75%.\n\nThe more deposit you can offer, the lower will be your LTV, and the more likely you will be able to find a mortgage at favourable terms. You should also remember that when you buy or sell a property there will be other related costs and fees, and you need to take these into account in your overall calculations.\n\nIf you need a loan of 100% LTV please give us a call as we may still be able to help by structuring a group of loans to provide an equivalent 100% LTV facility, providing you can afford it.";
// alertLTV = "You are asking to borrow more than 100% of the property value. While mortgages of greater than 100% are available, they are rare. If you are looking to arrange a first mortgage or remortgage, the typical Loan to Value (LTV) is 85% - 90%. For a Buy to Let mortgage you will be unlikely to find a lender willing to lend more than 85%. The more deposit you can offer, the lower will be your LTV, and the more likely you will be able to find a mortgage at favourable terms. You should also remember that when you buy or sell a property there will be other related costs and fees, and you need to take these into account in your overall calculations.";

function calcMortgage(form){
  var rateStrng = form.rateU.selectedIndex + "." + form.rateT.selectedIndex + form.rateH.selectedIndex;
  var theRate = eval((rateStrng/100)/12);
  var theTerm = eval(form.term.options[form.term.selectedIndex].value*12);
  var thePropertyValue = form.property_value.value;
  var theMortgage = eval(form.amount.value);
  var theLTV = Math.round(theMortgage / thePropertyValue*100);
  var repayId = form.repay_method.selectedIndex;
  var repayMethod = repayText[repayId];
  if (theLTV > 100) alert(alertLTV);
  if (repayId == 0) var thePayment = "" + paymentInt(theMortgage, theRate);
  else if (repayId == 1) var thePayment = "" + paymentCrm(theMortgage, theRate, theTerm);
  var theResult = repayMethod + "Mortgage = £" + insertCommas("" + theMortgage) + "\n";
  theResult += "Interest Rate = " + rateStrng + "%\n";
  theResult += "Monthly repayment = £" + insertCommas(thePayment);
  form.results.value = theResult;
  return false;
}