var mortgage = {
init:function(){
$("#calculate").bind({
"click":function(){
mortgage.displayBasic();
}
});
},
dataArr:[],
displayBasic:function(){
if(mortgage.formCheck())
{
var monthlyPayment = removeLeadZero(document.calculator.monthlyPayment.value, false, false);
var repaymentPeriod = removeLeadZero(document.calculator.repaymentPeriod.value, false, false);
var interestRate = document.calculator.interestRate.value;
var monthlyInterest = interestRate / 12.00 / 100.00;
var var1 = raiseP(( 1 + monthlyInterest), repaymentPeriod);
var result = (monthlyPayment / monthlyInterest * (1-1/ var1 )*100.00 )/100.00;
$("#monthlyPaymentResult").html(commaSplit( round(monthlyPayment, 2) ));
$("#repaymentPeriodResult").html(commaSplit( repaymentPeriod ));
$("#interestRateResult").html(commaSplit( interestRate ));
result = "" + result;
dec = result.indexOf(".");
if (dec > 0)
{
dollars = result.substring(0,dec);
cents = result.substring(dec+1,dec+3);
cents = (cents.length < 2) ? cents + "0" : cents;
result = dollars + "." + cents;
} else {
result = dollars + ".00" ;
}
$("#PrincipleLoanAmountResult").html(commaSplit(result) );
}
},
calInstallment:function(a, r, n) {
return ( (r * a * Math.pow(1 + r, n)) / ( Math.pow(1 + r, n) - 1) )
},
calInstallmentNum:function(a, r, instal) {
return Math.log10(instal / (instal - (r * a))) / Math.log10(1 + r);
},
calAccInterest:function(a, r, instal, instalnum) {
return (instal * (instalnum -1)) + ( Math.pow((1 + r), instalnum) * (a - (instal / r)) ) + ( (1 + r) * instal / r ) - a;
},
genTable:function(arr){
var tempTable = "";
tempTable += "
";
tempTable += "";
tempTable += '| '+mortgageDisplayText.Term[lang]+' | ';
tempTable += ''+mortgageDisplayText.Instalment[lang]+" | ";
tempTable += ''+mortgageDisplayText.InterestPayment[lang]+" | ";
tempTable += ''+mortgageDisplayText.PrincipalRepayment[lang]+" | ";
tempTable += ''+mortgageDisplayText.OutstandingBalance[lang]+" | ";
tempTable += "
";
for(i=0;i";
tempTable += ""+(i+1)+" | ";
for(j=0;jHK$ "+arr[i][j]+"";
tempTable += "";
}
tempTable += "
";
return tempTable;
},
formCheck:function(){
var check = true;
var errorText = "";
var paramArray = new Array();
var strErrMsg = "";
if (document.calculator.monthlyPayment.value) {
paramArray[paramArray.length] = new Array("monthlyPayment", mortgageDisplayText.InvalidRepaymentAmountRange[lang], "MA");
} else {
strErrMsg += mortgageDisplayText.InputMonthlyRepaymentAmount[lang]+"\n";
}
if (document.calculator.repaymentPeriod.value) {
paramArray[paramArray.length] = new Array("repaymentPeriod", mortgageDisplayText.InvalidRepaymentPeriod[lang], "MA");
} else {
strErrMsg += mortgageDisplayText.InputRepaymentPeriod[lang]+"\n";
}
if (document.calculator.interestRate.value) {
paramArray[paramArray.length] = new Array("interestRate", mortgageDisplayText.InvalidInterestRate[lang], "MN");
} else {
strErrMsg += mortgageDisplayText.InputInterestRate[lang]+"\n";
}
strErrMsg += TextValidateNoTemplate(document.calculator,paramArray);
if(strErrMsg == '')
{
var repayCheck = document.calculator.repaymentPeriod.value;
var monthlyPayment = removeLeadZero(document.calculator.monthlyPayment.value, false, false);
var repaymentPeriod = removeLeadZero(document.calculator.repaymentPeriod.value, false, false);
var interestRate = document.calculator.interestRate.value;
if (interestRate > 100 || interestRate <= 0)
{
strErrMsg += mortgageDisplayText.InvalidInterestRateRange[lang]+"\n";
check = false;
}
if (parseInt(repayCheck, 10) == 'NaN' || parseInt(repayCheck, 10) <= 0 || parseInt(repayCheck, 10) > 999) {
strErrMsg += mortgageDisplayText.InvalidRepaymentPeriodRange[lang]+"\n";
check = false;
}
}
if(strErrMsg != '')
{
alert( strErrMsg );
check = false;
}
return check;
}
}
var mortgageDisplayText = {
index:function(){
if(lang=="tc")
$("#header").html('');
else if(lang=="sc")
$("#header").html('');
else
$("#header").html('');
$(".MonthlyPaymentAmount").text(mortgageDisplayText.MonthlyRepaymentAmount[lang]);
$(".RateOfInterest").text(mortgageDisplayText.RateOfInterest[lang]);
$(".RepaymentPeriod").text(mortgageDisplayText.RepaymentPeriod[lang]);
$("#RateEnquiry").html(''+mortgageDisplayText.RateEnquiry[lang]+'')
$("#calculate").val(mortgageDisplayText.Calculate[lang]);
$("#clear").val(mortgageDisplayText.Clear[lang]);
$(".CalculationResult").text(mortgageDisplayText.CalculationResult[lang]);
$("#YourInput").text(mortgageDisplayText.YourInput[lang]);
$("#PrincipleLoanAmount").text(mortgageDisplayText.PrincipleLoanAmount[lang]);
if(lang=="en")
$("#MakeAppointment").html(''+mortgageDisplayText.MakeAppointment[lang]+'')
else
$("#MakeAppointment").html(''+mortgageDisplayText.MakeAppointment[lang]+'')
$("#InstantPropertyValuation").html(''+mortgageDisplayText.InstantPropertyValuation[lang]+'')
$("#CloseBtn").html(''+mortgageDisplayText.CloseBtn[lang]+'')
$("#note1").text(mortgageDisplayText.note1[lang]);
$("#note2").text(mortgageDisplayText.note2[lang]);
},
detail:function(){
$("#PrincipleLoanAmount").text(mortgageDisplayText.PrincipleLoanAmount[lang]);
$("#RateOfInterest").text(mortgageDisplayText.RateOfInterest[lang]);
$("#RepaymentPeriod").text(mortgageDisplayText.RepaymentPeriod[lang]);
$("#calculate").val(mortgageDisplayText.Calculate[lang]);
$("#clear").val(mortgageDisplayText.Clear[lang]);
$("#note3").text(mortgageDisplayText.note3[lang]);
},
RateEnquiry:{
"en":"Rate Enquiry",
"tc":"查詢利率",
"sc":"查询利率"
},
RateEnquiryLink:{
"en":"https://www.cncbinternational.com/rate-table/init_rate_en.html",
"tc":"https://www.cncbinternational.com/rate-table/init_rate_tc.html",
"sc":"https://www.cncbinternational.com/rate-table/init_rate_sc.html"
},
RateEnquiryLink_HKCBF:{
"en":"#",
"tc":"#",
"sc":"#"
},
Calculate:{
"en":"Calculate",
"tc":"計算",
"sc":"计算"
},
Clear:{
"en":"Clear",
"tc":"重新輸入",
"sc":"重新输入"
},
CalculationResult:{
"en":"Calculation Result",
"tc":"計算結果",
"sc":"计算结果"
},
YourInput:{
"en":"Your Input",
"tc":"你的資料",
"sc":"你的资料"
},
MonthlyRepaymentAmount:{
"en":"Monthly Repayment Amount (HKD)",
"tc":"每月供款額 (港幣)",
"sc":"每月供款额 (港币)"
},
PrincipleLoanAmount:{
"en":"Principal Loan Amount (HKD)",
"tc":"貸款額 (港幣)",
"sc":"贷款额 (港币)"
},
RateOfInterest:{
"en":"Expected Annual Interest Rate (%) ",
"tc":"預期貸款年利率 (%)",
"sc":"预期贷款年利率 (%)"
},
Year:{
"en":"Year",
"tc":"",
"sc":""
},
RepaymentPeriod:{
"en":"Repayment Period (Months)",
"tc":"還款期 (月)",
"sc":"还款期 (月)"
},
Term:{
"en":"No. of Installment",
"tc":"期數",
"sc":"期数"
},
MonthlyPaymentMethod:{
"en":"Monthly Payment Method",
"tc":"每月供款方法",
"sc":"每月供款方法"
},
BiWeeklyPaymentMethod:{
"en":"Bi Weekly Payment Method",
"tc":"每兩星期供款方法",
"sc":"每两星期供款方法"
},
InstallmentAmount:{
"en":"Installment Amount (HKD)",
"tc":"供款金額 (港幣)",
"sc":"供款金额 (港币)"
},
ActualNumberOfInstallments:{
"en":"Actual number of installments",
"tc":"實際供款期數",
"sc":"实际供款期数"
},
EffectiveRepaymentPeriodMonths:{
"en":"Effective Repayment Period (months)",
"tc":"實際供款年期 (月)",
"sc":"实际供款年期 (月)"
},
EffectiveRepaymentPeriodYears:{
"en":"Effective Repayment Period (years)",
"tc":"實際供款年期 (年)",
"sc":"实际供款年期 (年)"
},
TotalInterestPaid:{
"en":"Total Interest Paid (HKD)",
"tc":"總利息支出 (港幣)",
"sc":"总利息支出 (港币)"
},
OpeningBalance:{
"en":"Opening Balance
(HKD)",
"tc":"",
"sc":""
},
Instalment:{
"en":"Repayment Amount",
"tc":"供款金額",
"sc":"供款金额"
},
InterestPayment:{
"en":"Interest",
"tc":"利息",
"sc":"利息"
},
PrincipalRepayment:{
"en":"Principal",
"tc":"本金",
"sc":"本金"
},
OutstandingBalance:{
"en":"Outstanding Balance",
"tc":"本金餘額",
"sc":"本金余额"
},
RepaymentSchedule:{
"en":"Repayment Schedule",
"tc":"還款表",
"sc":"还款表"
},
MakeAppointment:{
"en":"Make Appointment with Mortgage Specialist",
"tc":"預約按揭顧問",
"sc":"预约按揭顾问"
},
MakeAppointmentLink:{
"en":"https://www.cncbinternational.com/cms/onlineapp/mortgageapptform/en/index.html",
"tc":"https://www.cncbinternational.com/cms/onlineapp/mortgageapptform/tc/index.html",
"sc":"https://www.cncbinternational.com/cms/onlineapp/mortgageapptform/sc/index.html"
},
MakeAppointmentLink_HKCBF:{
"en":"#",
"tc":"#",
"sc":"#"
},
InstantPropertyValuation:{
"en":"Instant Property Valuation",
"tc":"即時物業估價",
"sc":"即时物业估价"
},
InstantPropertyValuationLink:{
"en":"https://www.cncbinternational.com",
"tc":"https://www.cncbinternational.com",
"sc":"https://www.cncbinternational.com"
},
CloseBtn:{
"en":"Close",
"tc":"關閉",
"sc":"关闭"
},
CloseBtnLink:{
"en":"winclose.html",
"tc":"winclose.html",
"sc":"winclose.html"
},
note1:{
"en":"*The above information is for reference only.",
"tc":"* 以上資料只供參考",
"sc":"* 以上资料只供参考。"
},
note2:{
"en":"Should you have any enquiries, please call our Customer Service Hotline 2287 6788 for assistance.",
"tc":"如有任何疑問,請致電本行客戶服務熱線 2287 6788 查詢。",
"sc":"如有任何疑问,请致电本行客户服务热线 2287 6788 查询。"
},
note2_HKCBF:{
"en":"Should you have any enquiries, please call our Customer Service Hotline 3603 3760 for assistance.",
"tc":"如有任何疑問,請致電本行客戶服務熱線 3603 3760 查詢。",
"sc":"如有任何疑问,请致电本行客户服务热线 3603 3760 查询。"
},
note3:{
"en":"Note: The calculation is based on the information provided by customer and the calculator result is for reference only",
"tc":"註: 以上的計算結果是根據客戶提供之資料計算及只供參考",
"sc":"注: 以上的计算结果是根据客户提供之资料计算及只供参考"
},
InputMonthlyRepaymentAmount:{
"en":"Please input the Monthly Repayment Amount",
"tc":"請輸入每月供款額",
"sc":"请输入每月供款额"
},
InputLoanAmount:{
"en":"Please input the Loan Amount.",
"tc":"請輸入貸款額。",
"sc":"请输入贷款额。"
},
InputRepaymentPeriod:{
"en":"Please input the Repayment Period.",
"tc":"請輸入還款期。",
"sc":"请输入还款期。"
},
InputInterestRate:{
"en":"Please input the Interest Rate.",
"tc":"請輸入年利率。",
"sc":"请输入年利率。"
},
InvalidLoanAmount:{
"en":"The amount you inputted is invalid. Please re-enter.",
"tc":"你所輸入的貸款額不正確,請重新輸入。",
"sc":"你所输入的贷款额不正确,请重新输入。"
},
InvalidRepaymentPeriod:{
"en":"The period you inputted is invalid. Please re-enter.",
"tc":"你所輸入的還款期不正確,請重新輸入。",
"sc":"你所输入的还款期不正确,请重新输入。"
},
InvalidInterestRate:{
"en":"The rate you inputted is invalid. Please re-enter.",
"tc":"你所輸入的年利率不正確,請重新輸入。",
"sc":"你所输入的年利率不正确,请重新输入。"
},
InvalidRepaymentAmountRange:{
"en":"Monthly Repayment Amount must be between 1 to 999,999,999.",
"tc":"每月供款额須在1至999,999,999內。",
"sc":"每月供款额须在1至999,999,999内。"
},
InvalidRepaymentPeriodRange:{
"en":"Repayment Period must be between 1 to 999.",
"tc":"還款期數值須在1至999內。",
"sc":"还款期数值须在1至999内。"
},
InvalidInterestRateRange:{
"en":"Interest Rate must be between 0.01 to 99.99% .",
"tc":"年利率數值須在0.01至99.99%內。",
"sc":"年利率数值须在0.01至99.99%内。"
}
}