/**
 * Connect any events related to loans here
 */
$(document).ready( function()
	{
		/**
		 * This is only needed on the loan 'apply now' page so do a simple
		 * check to see if the form exists
		 */
		if( $('#form_applynow').size() > 0 )
		{
			Cupid.Project.Loan.restrictLoanTerm( {
				form: 'form#form_applynow',
				loanAmt: 'input#fLoanAmount',
				selectOption: 'select#iTermMonth option[value="18"]',
				triggerAmt: 2000
			});
		}

		/**
		 * We only need this for the loan calculator, so check to see if we
		 * can find the form before running the code.
		 */
		if( $( 'form[name="frmcalc"]' ).size() > 0 )
		{
			$( 'form[name="frmcalc"]' ).submit( function() {
				Cupid.Project.Loan.calculateRepayments();
				_gaq.push(['_trackEvent', 'Calculator', 'Submitted']);
				return false;
			});

			Cupid.Project.Loan.restrictLoanTerm( {
				form: 'form[name="frmcalc"]',
				loanAmt: 'input#vLoanAmo',
				selectOption: 'select#vPeriod option[value="1.5"]',
				triggerAmt: 2000
			} );
		}
	}
);

