// -----  Javascript files for Security 1st Federal Credit Union

//-------------------------------------------------------
function CALCULATE1() 

{

	var A=eval(document.LOAN.Amount.value);
	var B=eval(document.LOAN.APR.value)/100;
	var C=eval(document.LOAN.term.value);
	var D=(1+(B/12));
	var E=(A*(B/12)) / (1-Math.pow(D,C)) ;
	var result=Math.round(E*100)/100  

	document.LOAN.answer.value= "$"+ result;
	
	var PAID=((result*(-C))-A);
	var result2=Math.round(PAID*100)/100

	document.LOAN.intpaid.value= "$"+ result2 ;

	}


function CheckForm1()
{ 

	if(LOAN.Amount.value=="")
	{	
		alert("You Must Enter A Loan Amount");
		document.LOAN.focus();
	}

	if(LOAN.APR.value=="")
	{	
		alert("You Must Enter An Annual Percent Rate");
		document.LOAN.focus();
	}

	}

//-------------------------------------------------------

function CALCULATE2() 

{
	
	var A=eval(document.LOAN.Amount.value);
	var B=eval(document.LOAN.APR.value)/100;
	var C=eval(document.LOAN.term.value);
	var F=eval(document.LOAN.PMTS.value)*C;
	var G=eval(document.LOAN.PMTS.value);
	var D=(1+(B/G));
	var E=(A*(B/G)) / (1-Math.pow(D,F)) ;
	var result=Math.round(E*100)/100  

	document.LOAN.answer.value= "$"+ result;
	
	var PAID=((result*((-C)*G))-A);
	var result2=Math.round(PAID*100)/100

	document.LOAN.intpaid.value= "$"+ result2 ;

	}


function CheckForm2()
{ 

	if(LOAN.Amount.value=="")
	{	
		alert("You Must Enter A Mortgage Amount");
		document.LOAN.focus();
	}

	if(LOAN.APR.value=="")
	{	
		alert("You Must Enter An Interest Rate");
		document.LOAN.focus();
	}

	}
	
//-------------------------------------------------------

function CALCULATE3()

{
	var A=eval(document.SAV.PMT.value);
	var B=eval(document.SAV.RATE.value)/100;
	var C=eval(document.SAV.TIME.value);
	var FREQUENCY=eval(document.SAV.FRQ.value);
	var D=eval(B/12);
	var E=eval(D+1);
	var F=eval(C*FREQUENCY);
	var G=eval(Math.pow(E,F));
	var H=eval((A*(G-1)) / D);
	var result=Math.round(H*100)/100  
	
	document.SAV.answer.value= "$" +result;
}


function CheckForm3()
{ 

	if(SAV.PMT.value=="")
	{	
		alert("You Must Enter Your Monthly Deposit");
		document.SAV.focus();
	}

	if(SAV.RATE.value=="")
	{	
		alert("You Must Enter An Interest Rate");
		document.SAV.focus();
	}

	if(SAV.TIME.value=="")
	{	
		alert("You Must Enter The Amount Of Years You Will Be Saving");
		document.SAV.focus();
	}


	}

//-------------------------------------------------------

function CALCULATE4() 

{
	var A=eval(document.LOAN.Amount.value);
	var B=eval(document.LOAN.APR.value)/100;
	var C=eval(document.LOAN.term.value);
	var D=(B/12);
	var E=(D*A);
	var F=(C*12);
	var G=(1+D);
	var H=(Math.pow(G,F));
	var I=(H-1);
	var J=(E/I);

	var result=Math.round(J*100)/100  

	document.LOAN.answer.value= "$"+result;

	}
		 
function CheckForm4()
{ 
	if(LOAN.Amount.value=="")
	{	
		alert("You Must Enter A Goal Amount");
		document.LOAN.focus();
	}

	if(LOAN.APR.value=="")
	{	
		alert("You Must Enter An Interest Rate");
		document.LOAN.focus();
	}


	if(LOAN.term.value=="")
	{	
		alert("You Must Enter The Amount Of Time In Which You Would Like To Save Your Goal Amount");
		document.LOAN.focus();
	}	

	}

//-------------------------------------------------------

function poplink(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=250');");
}

//-------------------------------------------------------

function CheckLink(URL) {
    if (confirm(" You are linking to an alternate website not operated by Security First Credit Union. \r The credit union is not responsible for the content of the alternate web site. \r The credit union does not represent either the third party or the member if the two enter into a transaction. \r Privacy and security policies may differ from those practiced by the credit union."))
    {
        window.location = URL;
    }
}

//-------------------------------------------------------
