/*******************************************************************
NI Calculator ..........

1) calculateSavings - woks out the savings based on the user inputs    
********************************************************************/ 
            
   function calculateSavings(controlRoot)
       {
                
                    var numOps = document.getElementById(controlRoot + 'uiOps').value;
                    var numDaysHoliday = document.getElementById(controlRoot + 'uiDays').value;
                    var holidayPayPerWeek = document.getElementById(controlRoot + 'uiPay').value;
                              
                    if (numOps == '' || numDaysHoliday == '' || holidayPayPerWeek == '' || parseInt(numOps) <= 0 || parseInt(numDaysHoliday) <= 0 || parseFloat(holidayPayPerWeek) <= 0)
                    {
                        alert ('Please enter positive values in all three input fields.');
                        return false;
                    }
                    
                    if (parseInt(numDaysHoliday) > 50)
                    {
                        alert ('Number of days holidays must be less than 51 days.');
                        return false;
                    }

                    if (parseInt(numDaysHoliday) < 28) {
                        alert('28 is the minimum statutory number of days holiday');
                        return false;
                    }
                    
                    /*var alcCost = 1.00;
                    var weeklyCostPerOp = 1.00 * 7;
                    var yearlyCosts = alcCost * numOps * 52;
                 
                    //Savings
                    var weeklySavings =  (holidayPayPerWeek  - 100) * 0.128 * numOps;
                    var weeklySavingsPerOp = (holidayPayPerWeek  - 100) * 0.128;
                    var weeksHoliday = numDaysHoliday / 5;
                    var yearlyNISavings = weeklySavings * weeksHoliday;
                    
                    document.getElementById(controlRoot + 'uiAnnualSavingsAmount').value = roundValue(yearlyNISavings);
                    document.getElementById(controlRoot + 'uiALCAmount').value = roundValue(yearlyCosts);
                    
                    document.getElementById(controlRoot + 'uiCostingSavingsDiv').style.className = "form_boxoutWhite";
                   
                    var message = '';
               
                    if (weeklySavingsPerOp >= weeklyCostPerOp)
                    {
                        var diff = roundValue(weeklySavingsPerOp - weeklyCostPerOp);
                        message = 'You can cover the costs of accident and life cover and still make a saving of £' + diff + 'form the National Insurance concession per operative per week.';
                    }
                    else
                    {
                        var diff = roundValue(weeklyCostPerOp - weeklySavingsPerOp);
                        message = 'With the National insurance concession, Template\'s accident and life cover will only cost you £' + diff + ' per operative per week.';
                     }
                    
                    //show the hidden parts of the costings div
                    document.getElementById(controlRoot + 'uiCostingSavingsLabel').style.display = 'block';
                    document.getElementById(controlRoot + 'uiALCLabel').style.visibilty = 'visible';
                    document.getElementById(controlRoot + 'uiALCAmount').style.visibilty = 'visible';
                    document.getElementById(controlRoot + 'uiCostingsSavingsMessage').value = message;
                    */
                   
                    return true;
              } 
              
 function seeCostingsSavings()
       {
               document.getElementById('uiBreakdown').style.display = "block";
       }

 

