//
// Procedure Name:	calcMonthlyPayment
//
// Purpose:		Calculates the monthly payment as an integer and returns the "as low as" pricing
//			message including term.
//
//			example: as low as $55/mo., 24 months
//
// Parameters:
//	loan_amount	- amount of item to calculate monthly pricing on
//
// Return:
//	string	- monthly payment message
//
// Version:
//	08/01/2000			Created		
//	02/01/2001	KAJ		Modified initial range to 0 to 500. 
//
function calcMonthlyPayment(loan_amount)
{ 
	var expected_rate = 21.0;
	var term;
	
	if ((loan_amount >= 0) && (loan_amount <= 500))
		term = 12;
	else if ((loan_amount > 500) && (loan_amount <= 1000))
		term = 24;
	else
		term = 36;
		
	var monthly_amount;
	var payments_per_year = 12;

		if (loan_amount == 0.00 || expected_rate == 0.00 || term == 0) monthly_amount = 0.00;
		else
		{
			expected_rate = expected_rate/100.00;
			var C5 = expected_rate/payments_per_year;
			var temp =  ( (1-Math.pow(1+C5, - term))/C5 )*(1+C5);
			monthly_amount = loan_amount/temp;						
		}	
	monthly_amount = Math.round(monthly_amount);	
	document.write("or as low as $" + monthly_amount + "/mo., " + term + " months");	
}


//
// Procedure Name:	calcMonthlyPaymentSF
//
// Purpose:		Calculates the monthly payment as an integer and returns the "as low as" pricing
//			"short form" message without the term.
//
//			example: as low as $55/mo.
//
// Parameters:
//	loan_amount	- amount of item to calculate monthly pricing on
//
// Return:
//	string	- monthly payment "short form" message
//
// Version:
//	08/01/2000			Created		
//	02/01/2001	KAJ		Modified initial range to 0 to 500. 
//
function calcMonthlyPaymentSF(loan_amount)
{ 
	var expected_rate = 21.0;
	var term;
	
	if ((loan_amount >= 0) && (loan_amount <= 500))
		term = 12;
	else if ((loan_amount > 500) && (loan_amount <= 1000))
		term = 24;
	else
		term = 36;
		
	var monthly_amount;
	var payments_per_year = 12;

		if (loan_amount == 0.00 || expected_rate == 0.00 || term == 0) monthly_amount = 0.00;
		else
		{
			expected_rate = expected_rate/100.00;
			var C5 = expected_rate/payments_per_year;
			var temp =  ( (1-Math.pow(1+C5, - term))/C5 )*(1+C5);
			monthly_amount = loan_amount/temp;						
		}	
	monthly_amount = Math.round(monthly_amount);	
	document.write("or as low as $" + monthly_amount + "/mo.");	
}

//  MonthlyPayment
// returns monthly loan payment amount per month only.

function monthlyPayment(loan_amount)
{ 
	var expected_rate = 21.0;
	var term;
	
	if ((loan_amount >= 0) && (loan_amount <= 500))
		term = 12;
	else if ((loan_amount > 500) && (loan_amount <= 1000))
		term = 24;
	else
		term = 36;
		
	var monthly_amount;
	var payments_per_year = 12;

		if (loan_amount == 0.00 || expected_rate == 0.00 || term == 0) monthly_amount = 0.00;
		else
		{
			expected_rate = expected_rate/100.00;
			var C5 = expected_rate/payments_per_year;
			var temp =  ( (1-Math.pow(1+C5, - term))/C5 )*(1+C5);
			monthly_amount = loan_amount/temp;						
		}	
	monthly_amount = Math.round(monthly_amount);	
	document.write(monthly_amount + "/mo.");	
}

//
// Procedure Name:	apr_disclosure
//
// Purpose:		Returns the associated disclosure for the 'calcmonthlypayment' function without the term.
//
//			example: 21% APR.  Not all customers will qualify.  Includes shipping & handling and taxes.
//
// Parameters:
//	loan_amount	- amount of item to calculate monthly pricing on
//	shipFlag	- true/false is shipping included in the loan_amount value
//
// Return:
//	string	- APR disclosure message
//
// Version:
//	08/01/2000			Created		
//	02/01/2001	KAJ		Modified initial range to 0 to 500. 
//
function apr_disclosure(loan_amount,shipFlag)
{ 
	var expected_rate;
	if ((loan_amount >= 0) && (loan_amount <= 500))
		expected_rate = 28.09;
	else if ((loan_amount > 500) && (loan_amount <= 1000))
		expected_rate = 24.52;
	else if ((loan_amount > 1000) && (loan_amount <= 2125))
		expected_rate = 23.40;
	else if ((loan_amount > 2125) && (loan_amount <= 2400))
		expected_rate = 23.25;
	else if ((loan_amount > 2400) && (loan_amount <= 2725))
		expected_rate = 22.99;
	else if ((loan_amount > 2725) && (loan_amount <= 3200))
		expected_rate = 22.75;
	else if ((loan_amount > 3200) && (loan_amount <= 3825))
		expected_rate = 22.50;
	else if ((loan_amount > 3825) && (loan_amount <= 4775))
		expected_rate = 22.25;
	else if ((loan_amount > 4775) && (loan_amount <= 5000))
		expected_rate = 21.99;
	else
		expected_rate = 21.00;
		
	if (shipFlag)
		document.write(expected_rate + "% APR.  Not all customers will qualify.  Excludes shipping & handling and taxes.");	
	else
		document.write(expected_rate + "% APR.  Not all customers will qualify.  Includes shipping & handling and taxes.");	
}


//
// Procedure Name:	apr_disclosureSF
//
// Purpose:		Returns the associated disclosure for the 'calcmonthlypaymentSF' function 
//			including the term.
//
//			example: 21% APR.  24 months.  Not all customers will qualify.  
//				   Includes shipping & handling and taxes.
//
// Parameters:
//	loan_amount	- amount of item to calculate monthly pricing on
//	shipFlag	- true/false is shipping included in the loan_amount value
//
// Return:
//	string	- APR disclosure "short form" message
//
// Version:
//	08/01/2000			Created		
//	02/01/2001	KAJ		Modified initial range to 0 to 500. 
//
function apr_disclosureSF(loan_amount,shipFlag)
{ 
	var expected_rate;
	if ((loan_amount >= 0) && (loan_amount <= 500))
		expected_rate = 28.09;
	else if ((loan_amount > 500) && (loan_amount <= 1000))
		expected_rate = 24.52;
	else if ((loan_amount > 1000) && (loan_amount <= 2125))
		expected_rate = 23.40;
	else if ((loan_amount > 2125) && (loan_amount <= 2400))
		expected_rate = 23.25;
	else if ((loan_amount > 2400) && (loan_amount <= 2725))
		expected_rate = 22.99;
	else if ((loan_amount > 2725) && (loan_amount <= 3200))
		expected_rate = 22.75;
	else if ((loan_amount > 3200) && (loan_amount <= 3825))
		expected_rate = 22.50;
	else if ((loan_amount > 3825) && (loan_amount <= 4775))
		expected_rate = 22.25;
	else if ((loan_amount > 4775) && (loan_amount <= 5000))
		expected_rate = 21.99;
	else
		expected_rate = 21.00;
		
	if ((loan_amount >= 0) && (loan_amount <= 500))
		term = 12;
	else if ((loan_amount > 500) && (loan_amount <= 1000))
		term = 24;
	else
		term = 36;		
		
	if (shipFlag)
		document.write(expected_rate + "% APR.  "+term+" months.  Not all customers will qualify.  Excludes shipping & handling and taxes.");	
	else
		document.write(expected_rate + "% APR.  "+term+" months.  Not all customers will qualify.  Includes shipping & handling and taxes.");	
}


//
// Procedure Name:	future_disclosure
//
// Purpose:		Returns the future associated disclosure for the 'calcmonthlypayment' function without the term.
//
//			example: 21% APR.  Your credit quality may affect rate.  Not all customers will qualify.  
//				   Includes shipping & handling and taxes.
//
// Parameters:
//	loan amount	- amount of item to calculate monthly pricing on
//
// Return:
//	string	- future APR disclosure message
//
// Version:
//	08/01/2000			Created		
//	02/01/2001	KAJ		Modified initial range to 0 to 500. 
function future_disclosure(loan_amount)
{ 
	var expected_rate;
	if ((loan_amount >= 0) && (loan_amount <= 500))
		expected_rate = 28.09;
	else if ((loan_amount > 500) && (loan_amount <= 1000))
		expected_rate = 24.52;
	else if ((loan_amount > 1000) && (loan_amount <= 2125))
		expected_rate = 23.40;
	else if ((loan_amount > 2125) && (loan_amount <= 2400))
		expected_rate = 23.25;
	else if ((loan_amount > 2400) && (loan_amount <= 2725))
		expected_rate = 22.99;
	else if ((loan_amount > 2725) && (loan_amount <= 3200))
		expected_rate = 22.75;
	else if ((loan_amount > 3200) && (loan_amount <= 3825))
		expected_rate = 22.50;
	else if ((loan_amount > 3825) && (loan_amount <= 4775))
		expected_rate = 22.25;
	else if ((loan_amount > 4775) && (loan_amount <= 5000))
		expected_rate = 21.99;
	else
		expected_rate = 21.00;
		
	document.write(expected_rate + "% APR.  Your credit quality may affect rate.  Not all customers will qualify. ");
	document.write("Excludes shipping & handling and taxes.");
}


//
// Procedure Name:	loan_fee_disclosure
//
// Purpose:		Returns the loan fee disclosure message.
//
//			example:	The loan-processing fee is based on the total loan amount and will be charged to your
//					credit card upon shipment of the goods.
//
// Parameters:
//	none
//
// Return:
//	string	- Loan Fee disclosure message
//
// Version:
//	08/01/2000			Created		
//
function loan_fee_disclosure() {

	document.write("The loan-processing fee is based on the total loan amount and will be charged to your ");
	document.write("credit card upon shipment of the goods.");
}


//
// Procedure Name:	credit_report_disclosure
//
// Purpose:		Returns the credit report disclosure message.
//
// Parameters:
//	none
//
// Return:
//	string	- Credit report disclosure message
//
// Version:
//	08/01/2000			Created		
//
function credit_report_disclosure() {

	document.write("<P>iFINANCE, its agents, successors and assigns have made no representations or warranties, express or ");
	document.write("implied, regarding the value, condition or identification of the goods you will be purchasing with this ");
	document.write("loan; and you may be required to provide proof of identity and income in order to receive the loan proceeds.</P>");
	
	document.write("<P>You consent to receiving the following categories of information (“Communications”) in electronic format in ");
	document.write("connection with the iFINANCE Loan Program:  Loan Agreement (including Federal Truth in Lending and Electronic ");
	document.write("Funds Transfer Act Disclosures all other disclosures and notices required under applicable law; and any other ");
	document.write("communication relating to the iFINANCE Loan Program.  This consent applies to Communications from iFINANCE or ");
	document.write("any lender participating in the iFINANCE Loan Program.  Although we are not required to do so, we may provide ");
	document.write("any Communication in paper format in addition to, or instead of, in electronic format.</P>");
	
	document.write("<P>You confirm you have the following in order to access and retain electronic Communications:  ");
	document.write("(1) a SSL-Enabled web browser such as Netscape 4.0 or Microsoft Explorer 4.0 (or a later versions); ");
	document.write("(2) an e-mail account and e-mail software capable of receiving plain text formatted email; ");
	document.write("(3) a personal computer, operating system and telecommunications connections to the Internet capable of ");
	document.write("supporting the foregoing; and (4) sufficient electronic storage capacity on your hard drive or other data ");
	document.write("storage facility, or a printer that is capable of printing from your Internet browser and e-mail software.</P>");
	
	document.write("<P>You can withdraw your consent to electronic Communications, or update the information needed to contact you ");
	document.write("electronically, by sending an e-mail to	<A HREF=mailto:customerservice@ifinance.com>customerservice@ifinance.com</A>.  ");
	document.write("However, withdrawal of your consent ");
	document.write("will be effective only after a reasonable period of time to process your request.  Your ability to participate ");
	document.write("in the iFINANCE Loan Program may be terminated if you withdraw your consent.  After the effective date, we will ");
	document.write("send a paper copy of any future Communication that is required by applicable law to be given to you in writing.</P>");
	
	document.write("<P>All Communications, whether in paper or electronic format, will be considered to be in writing.  ");
	document.write("You will be considered to have received an electronic Communication when we transmit an e-mail to the address ");
	document.write("you have provided us or no later than three days after we post the Communication on our website.  ");
	document.write("Clicking on an “I agree” or similar button will indicate your intent to sign the relevant document or record ");
	document.write("and shall constitute your signature.  This consent is provided in connection with a transaction in or affecting ");
	document.write("interstate commerce that is subject to the federal Electronic Signatures in Global and National Commerce Act, "); 
	document.write("which will apply to the fullest extent possible to validate our ability to conduct business with you by ");
	document.write("electronic means.</P>")  

	document.write("<P>In addition, by clicking on the “I Accept” button below, you agree that everything you have stated in this ");
	document.write("application is correct and completed to the best of your knowledge.  You understand that this request for ");
	document.write("credit is being reviewed by iFINANCE and their associated lenders.  iFINANCE will assist in the origination ");
	document.write("and servicing of this loan if approved.  iFINANCE is authorized to check your credit and employment history.  ");
	document.write("Upon your request to iFINANCE, we will inform you whether or not a consumer report was requested, and if ");
	document.write("applicable, the name and address of the consumer reporting agency that furnished the report.  You have read ");
	document.write("and understood the application form and agree to provide any additional information, which may be legally required ");
	document.write("to determine credit worthiness.</P>");
	
}


//
// Procedure Name:	loan_approval_disclosure
//
// Purpose:		Message to be disclosed if customer is approved for loan.
//
// Parameters:
//	none
//
// Return:
//	string	- Loan Approval disclosure message
//
// Version:
//	08/01/2000			Created		
//
function loan_approval_disclosure() {

	document.write("Congratulations! iFINANCE is able to offer you the following payment plans.");
}


//
// Procedure Name:	agreement_bullets_disclosure
//
// Purpose:		Displays the required agreement disclosures to be viewed on the page when "signing"
//			the loan agreement electronically.
//
// Parameters:
//	none
//
// Return:
//	string	- Agreement Bullets disclosure message
//
// Version:
//	08/01/2000			Created		
//
function agreement_bullets_disclosure() {

	document.write("<LI> I agree to use electronic signatures.<BR>");
	document.write("<LI> I have read and understand this loan agreement.<BR>");
	document.write("<LI> I accept and agree to the terms in this loan agreement.<BR>");
	document.write("<LI> I acknowledge that I can either download or print the loan agreement.<BR>");

}


//
// Procedure Name:	format
//
// Purpose:		Format a number to two decimal places.
//
// Parameters:
//	number	- number to format to two decimal places
//
// Return:
//	string	- number formatted with 2 decimal places
//
// Version:
//	08/01/2000			Created		
//
function format( number, decplaces)
{
   var string = " " + Math.round(eval(number)*Math.pow(10, decplaces));
   
   while(string.length <= decplaces)
   {
      string = "0" + string;
   }
   
   var decpoint = string.length - decplaces;
   
   return string.substring(0, decpoint) + "." + string.substring(decpoint, string.length);
}	

