Type.registerNamespace("C2B_QuickBreakEvenPoint");C2B_QuickBreakEvenPoint.Init = function(controlIDs, filePath){
this.controlIDs = Sys.Serialization.JavaScriptSerializer.deserialize(controlIDs);this.pageMethodPath = filePath;C2B_QuickBreakEvenPoint.updatePrintButton();}
C2B_QuickBreakEvenPoint.ComputeBreakEvenPoint = function()
{
var txtLoanALoanAmount = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanALoanAmount);var txtLoanBLoanAmount = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanBLoanAmount);var comboLoanATerm = $get(C2B_QuickBreakEvenPoint.controlIDs.comboLoanATerm);var comboLoanBTerm = $get(C2B_QuickBreakEvenPoint.controlIDs.comboLoanBTerm);var txtLoanAInterestRate = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanAInterestRate);var txtLoanBInterestRate = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanBInterestRate);var txtLoanAPaymentAmount = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanAPaymentAmount);var txtLoanBPaymentAmount = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanBPaymentAmount);var txtLoanAPoints = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanAPoints);var txtLoanBPoints = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanBPoints);var txtResult = $get(C2B_QuickBreakEvenPoint.controlIDs.txtResult);var LoanALoanAmount = Empower.WebUI.Controls.GetProperty(txtLoanALoanAmount, 'value');var LoanBLoanAmount = Empower.WebUI.Controls.GetProperty(txtLoanBLoanAmount, 'value');var LoanANumberOfPayments = Empower.WebUI.Controls.GetProperty(comboLoanATerm, 'value');var LoanBNumberOfPayments = Empower.WebUI.Controls.GetProperty(comboLoanBTerm, 'value');var LoanAInterestRate = Empower.WebUI.Controls.GetProperty(txtLoanAInterestRate, 'value');var LoanBInterestRate = Empower.WebUI.Controls.GetProperty(txtLoanBInterestRate, 'value');var LoanAPaymentAmount = Empower.WebUI.Controls.GetProperty(txtLoanAPaymentAmount, 'value');var LoanBPaymentAmount = Empower.WebUI.Controls.GetProperty(txtLoanBPaymentAmount, 'value');var LoanAPoints = Empower.WebUI.Controls.GetProperty(txtLoanAPoints, 'value');var LoanBPoints = Empower.WebUI.Controls.GetProperty(txtLoanBPoints, 'value');var currentResults = Empower.WebUI.Controls.GetProperty(txtResult, 'value');PageMethods.set_path(this.pageMethodPath);PageMethods.ComputeBreakEvenPoint(LoanALoanAmount, LoanBLoanAmount, LoanANumberOfPayments, LoanBNumberOfPayments, 
LoanAInterestRate, LoanBInterestRate, LoanAPaymentAmount, LoanBPaymentAmount, LoanAPoints, LoanBPoints, currentResults,
C2B_QuickBreakEvenPoint.OnSucceeded, C2B_QuickBreakEvenPoint.OnFailed);}
C2B_QuickBreakEvenPoint.OnSucceeded = function(result, userContext, methodName)
{
var txtResult = $get(C2B_QuickBreakEvenPoint.controlIDs.txtResult);if(txtResult)
{
if(result.indexOf("\r\n") != -1)
{
var currentResults = Empower.WebUI.Controls.GetProperty(txtResult, 'value');if(currentResults != '')
{
currentResults += "*************************************************\n\n";}
currentResults += result;txtResult.value = currentResults;scrollToBottom(txtResult);scrollToBottom(txtResult);C2B_QuickBreakEvenPoint.updatePrintButton();}
else 
{
//MsgBoxShow(C2B_QuickBreakEvenPoint.controlIDs.msgError, 'Missing Field', result, '');
MissingFieldAlert(result);}
}
}
C2B_QuickBreakEvenPoint.updatePrintButton = function()
{
var txtResult = $get(C2B_QuickBreakEvenPoint.controlIDs.txtResult);var btnPrint = $get(C2B_QuickBreakEvenPoint.controlIDs.btnPrint);Empower.WebUI.Controls.SetProperty(btnPrint, 'disabled', true );if (Empower.WebUI.Controls.GetProperty(txtResult, 'value') != '')
{
Empower.WebUI.Controls.SetProperty(btnPrint, 'disabled', false );}
}
C2B_QuickBreakEvenPoint.OnFailed = function(error, userContext, methodName)
{
if(error != null) 
{
//MsgBoxShow(C2B_QuickBreakEvenPoint.controlIDs.msgError, 'Error', error, '');
ErrorAlert(error);}
}
C2B_QuickBreakEvenPoint.txtLoanALoanAmount_ValueChange = function()
{
var txtLoanALoanAmount = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanALoanAmount);var txtLoanBLoanAmount = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanBLoanAmount);var loanAamount = Empower.WebUI.Controls.GetProperty(txtLoanALoanAmount, 'value');Empower.WebUI.Controls.SetProperty(txtLoanBLoanAmount, 'value', loanAamount );}
C2B_QuickBreakEvenPoint.CalculateLoanAPaymentAmount = function()
{
var txtLoanAInterestRate = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanAInterestRate);var txtLoanALoanAmount = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanALoanAmount);var comboLoanATerm = $get(C2B_QuickBreakEvenPoint.controlIDs.comboLoanATerm);var txtLoanAPaymentAmount = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanAPaymentAmount);var InterestRate = Empower.WebUI.Controls.GetProperty(txtLoanAInterestRate, 'value');var LoanAmount = Empower.WebUI.Controls.GetProperty(txtLoanALoanAmount, 'value');var NumberOfPayments = Empower.WebUI.Controls.GetProperty(comboLoanATerm, 'value');if(LoanAmount > 0) 
{
Empower.WebUI.Controls.SetProperty(txtLoanAPaymentAmount, 'value', 
CommonJavaScriptFunctions.formatCurrency(C2B_QuickBreakEvenPoint.CalculateLoanPaymentAmount(InterestRate, LoanAmount, NumberOfPayments)) );}
}
C2B_QuickBreakEvenPoint.CalculateLoanBPaymentAmount = function()
{
var txtLoanBInterestRate = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanBInterestRate);var txtLoanBLoanAmount = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanBLoanAmount);var comboLoanBTerm = $get(C2B_QuickBreakEvenPoint.controlIDs.comboLoanBTerm);var txtLoanBPaymentAmount = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanBPaymentAmount);var InterestRate = Empower.WebUI.Controls.GetProperty(txtLoanBInterestRate, 'value');var LoanAmount = Empower.WebUI.Controls.GetProperty(txtLoanBLoanAmount, 'value');var NumberOfPayments = Empower.WebUI.Controls.GetProperty(comboLoanBTerm, 'value');if(LoanAmount > 0) 
{
Empower.WebUI.Controls.SetProperty(txtLoanBPaymentAmount, 'value', 
CommonJavaScriptFunctions.formatCurrency(C2B_QuickBreakEvenPoint.CalculateLoanPaymentAmount(InterestRate, LoanAmount, NumberOfPayments)) );}
}
C2B_QuickBreakEvenPoint.CalculateLoanPaymentAmount = function(interestRate, loanAmount, numberOfPayments)
{
if (interestRate > 0)
{
if (interestRate <= 100)
{
var errorMessage = "";var _interestRate = interestRate;if (loanAmount != null && numberOfPayments != null && numberOfPayments > 0)
{
var _loanAmount = loanAmount;var _numberOfPayments = numberOfPayments;var aniValue = C2B_QuickBreakEvenPoint.ANI(_numberOfPayments,(_interestRate / 1200));var payment = (_loanAmount / aniValue);var payment = CommonJavaScriptFunctions.RoundCurrency(_loanAmount / aniValue);return payment;}
}
} 
else 
{
return 0;}
}
C2B_QuickBreakEvenPoint.ClearControls = function()
{
var txtLoanAPoints = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanAPoints);var txtLoanBPoints = $get(C2B_QuickBreakEvenPoint.controlIDs.txtLoanBPoints);txtLoanAPoints.style.color = 'black';txtLoanBPoints.style.color = 'black';}
C2B_QuickBreakEvenPoint.ANI = function(term, interestRate)
{
return (1 - Math.pow((1 + interestRate),-term)) / interestRate;}
C2B_QuickBreakEvenPoint.Print = function()
{
var txtResult = $get(C2B_QuickBreakEvenPoint.controlIDs.txtResult);var printData = Empower.WebUI.Controls.GetProperty(txtResult, "value");ModalBlue.QuickCalcPrint(document.title, printData);}
