////////////////////////////////////////////////////////////////////////
//                                                                    //
//               Feel free to use and modify this script,             //
//               however this notice must remain intact.              //
//                                                                    //
//     This script was developed by NorthWest Payroll Services        // 
//     for use on their website at http://www.nwbservices.co.uk       //
//                                                                    //
//     Using this script or a variation of it without this notice     //
//           may result in criminal action being taken for            //
//                     violation of copyright                         //
//                                                                    //
//  NorthWest Payroll Services are the UK's No1 Payroll Bureau for    //
//        an all inclusive cost effective payroll service             //
//                                                                    //
////////////////////////////////////////////////////////////////////////


/* Pension contribution calculator.*/


function calcPension() {

 frm=getObject("pensioncalc");
 var rates=new Array(0,0.175,0.2,0.25,0.3,0.35,0.4);
 var min=3600,basicRateTax=0.22;
 //var max=99000; // 03-04
 //var max=102000; // 04-05
 var max=105600; // 05-06
 var divNames="23";

 if (frm.ageGroup.selectedIndex==0) {error(1,divNames); frm.ageGroup.focus(); return;}
 allow=rates[frm.ageGroup.selectedIndex];
 salary=stripJunk(frm.grspay.value.toLowerCase(),' ,Np');
 if (salary<=0 || isNaN(salary) || salary.length==0) {error(2,divNames); frm.grspay.value=""; frm.grspay.focus(); return;}
 if (salary>max) {salary=max;}
 frm.grspay.value="N"+DecimalPlaces(salary,2);
 otherPension=stripJunk(frm.others.value.toLowerCase(),' ,Np');
 if (otherPension<0 || isNaN(otherPension)) {frm.others.value=""; otherPension=0;} else frm.others.value="N"+DecimalPlaces(otherPension,2);
 displayIt('','dstat','body');
 cont=salary*allow;
 if (cont<min) {cont=min;}
 cont=cont-otherPension;
 bc=getObject("botCalc");
 bc.focus();
 if (cont<=0) {
  displayIt("Zero",'d3','SHL');
  displayIt("Zero",'d2','SHL');
 } else { 
  displayIt("N"+DecimalPlaces(cont,2),'d3','SHL');
  displayIt("N"+DecimalPlaces(cont*(1-basicRateTax),2),'d2','SHL');
 }
}

/* End Pension contribution calculator */