//

// config options

//



/////

/// Monthly Changes

/////



//Earnings Credit Rate (Will Change Monthly on 1st)

var D9 = 0.0025; 





/////

/// yearly Changes

/////



//Price per Business Accounts

var D14 = 20;



//Price per checks written per month

var D16 = 0.19;



//Price per deposits made per month 19 

var D18 = 0.55;



//Price per checks deposited per month

var D20 = 0.14; 



//Price per Lock Box Accounts

var D22 = 100;



//Price per Sweep Account to Investment

var D24 = 150;



//Price per Sweep Account to Loan

var DN1 = 200;



//Price per Sweep Account Investment and Loan

var DN2 = 250;



//Price per Receipt of ACH Credits

var D27 = 0.15;



//Price per Receipt of ACH Debits

var D29 = 0.15;



//Price per Online Internet Access

var D31 = 0;







// --- no changes below this line ---- //





// Constants

var test = 12;





// Globals

var D2 = 0;  

var D4 = 0;  

var D6 = 0;



var C14 = 0; 

var E14 = 0;



var C16 = 0; 

var E16 = 0;



var C18 = 0; 

var E18 = 0;



var C20 = 0; 

var E20 = 0;



var C22 = 0; 

var E22 = 0;



var C24 = 0; 

var E24 = 0;



var CN1 = 0;

var EN1 = 0;



var CN2 = 0;

var EN2 = 0;



var C27 = 0;

var E27 = 0;



var C29 = 0;

var E29 = 0;



var C31 = 0;

var E31 = 0;



var C33 = 0;

var E33 = 0; 



var D35 = 0; 

var E35 = 0; 



var E37 = 0;

var E39 = 0;

var E42 = 0;

var E44 = 0;

var E46 = 0;



//system constants

var DEBUG = 0;





// does the calculation for all values

function calculate()

{

   if (DEBUG) alert ("Calculate: start of function"); 



   ////

   // get values from form

   ////



   //Average collected balance

   D2 = document.wa.D2.value;



   //Price per Business Accounts

   C14 = document.wa.C14.value;



   //Price per checks written per month

   C16 = document.wa.C16.value;



   //Price per deposits made per month 

   C18 = document.wa.C18.value;



   //Price per checks deposited per month

   C20 = document.wa.C20.value;



   //Price per Lock Box Accounts

   C22 = document.wa.C22.value;



   //Price per Sweep Account of Investment

   C24 = document.wa.C24.value;



   //Price per Sweep Account of Loans

   CN1 = document.wa.CN1.value;



   //Price per Sweep Account of Investment and Loans

   CN2 = document.wa.CN2.value;



   //Price per Receipt of ACH Credits

   C27 = document.wa.C27.value;



   //Price per Receipt of ACH Debits

   C29 = document.wa.C29.value;



   //Price per Online Internet Access

   C29 = document.wa.C29.value;



   //Service Charges Paid per month at Current Bank

   E44 = document.wa.E44.value;

      

   ////

   // do the calculation and then set form value

   ////



   //Reserve Requirement		

   D4 = D2*0.1;   

   document.wa.D4.value = round (D4);



   //Net collected balance		

   D6 = D2-D4;

   document.wa.D6.value = round (D6);

   

   //Enter the Number of Business Accounts	

   E14 = D14*C14;

   document.wa.E14.value = round (E14);

   

   //The number of checks written per month

   E16 = D16*C16;

   document.wa.E16.value = round (E16);

   

   //The number of deposits made per month

   E18 = D18*C18;

   document.wa.E18.value = round (E18);

   

   //The number of checks deposited per month

   E20 = D20*C20;

   document.wa.E20.value = round (E20);

   	

   //The number of Lock Box Accounts

   E22 = D22*C22; 

   document.wa.E22.value = round (E22);

   

   //Sweep Account of Investment

   E24 = D24*C24;

   document.wa.E24.value = round (E24);



   //Sweep Account of Loans

   EN1 = DN1*CN1;

   document.wa.EN1.value = round (EN1);



   //Sweep Account of Investment and Loans

   EN2 = DN2*CN2;

   document.wa.EN2.value = round (EN2);



   //Receipt of ACH Credits

   E27 = D27*C27;

   document.wa.E27.value = round (E27);

				

   //Receipt of ACH Debits

   E29 = D29*C29;

   document.wa.E29.value = round (E29);

				

   //Online Internet Access

   E31 = D31*C31;

   document.wa.E31.value = round (E31);

   				

   //Total Cost of Services				

   E33 = E14+E16+E18+E20+E22+E24+EN1+EN2+E27+E29+E31;

   document.wa.E33.value = round (E33);

   				

   //FDIC Insurance (Federal Requirment)	

   E35 = D2*0.00011358;

   D35 = D2*0.00011358;

   document.wa.E35.value = round (E35);

   document.wa.D35.value = round (D35);

   

   //Computed based on Collected Balance

   //Total Bank Charges

   E37 = E33+E35;

   document.wa.E37.value = round (E37);



   //Amount of Earnings Credit

   if (((D6*D9)/365)*31 < E37)

   {

      E39 = ((D6*D9)/365)*31;

   }

   else

   {   

      E39 = E37;

   }

   document.wa.E39.value = round (E39);



   //Total Amount Service Charge Assessed to you at North Side Bank				

   if (E37 > E39)

   {

      E42 = E37-E39;

   }

   else

   {

      E42 = 0.00;

   }



   document.wa.E42.value = round (E42);



   //Your Monthly Savings by moving your accounts to North Side Bank				

   E46 = E44-E42;



   if (E46 > 0)

   {

      document.wa.E46.value = round (E46);

   }

   else

   {

      document.wa.E46.value = 0.00;

   }



   if (DEBUG) alert ("Calculate:"+

                      "D4 =  "+D4+

                      "\nD6 =  "+D6+

                      "\nD9 =  "+D9+

                      "\nE14 = "+E14+

                      "\nE16 = "+E16+

                      "\nE18 = "+E18+

                      "\nE20 = "+E20+

                      "\nE22 = "+E22+

                      "\nE24 = "+E24+     

                      "\nEN1 = "+EN1+  

                      "\nEN2 = "+EN2+                  

                      "\nE27 = "+E27+

                      "\nE29 = "+E29+

                      "\nE31 = "+E31+

                      "\nE33 = "+E33+

                      "\nE35 = "+E35+

                      "\nD35 = "+D35+

                      "\nE37 = "+E37+

                      "\nE39 = "+E39+

                      "\nE42 = "+E42+

                      "\nE46 = "+E46 );



}



//function round(number,X) {

// rounds number to X decimal places, defaults to 2

//    X = (!X ? 2 : X);

//    return Math.round(number*Math.pow(10,X))/Math.pow(10,X);

//}



function round(n) {

  var s = "" + Math.round(n * 100) / 100

  var i = s.indexOf('.')

  if (i < 0) return s + ".00"

  var t = s.substring(0, i + 1) + s.substring(i + 1, i + 3)

  if (i + 2 == s.length) t += "0"

  return t

}







