// -----  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("The linked site is not owned or controlled by the credit union. \r \r The credit union is not responsible for the availability, content, or security of the linked site. \r \r The credit union is not responsible for any claims related to any goods or services obtained from the linked site. \r \r The linked site's privacy policies may differ from those of the credit union and the credit union is not responsible for compliance with those policies."))
    {
        window.location = URL;
    }
}

//-------------------------------------------------------

