function validate() {
	var number = document.getElementById("number").value;
	var pay = document.getElementById("pay").value;
	var work = document.getElementById("worked").value;
	//var saving = document.getElementById("saving").value;
	var saving = 2;
	
	var weeklysave = 0;
	
    submitOK = "true";
   
	if (submitOK == "false") {
		return false;
	}  
        
    var myCost = new savingInfo(number, pay, saving, work);
    mdiv = document.getElementById("results");
    
    var inner
    var line = "<div style=\"border-bottom:1px solid #C4C4C4; margin-top:5px; margin-bottom:10px;\"></div>";

    inner = "<h2>Overpayment</h2>";
    inner += line;
    inner += "<p>If employees know their attendance is being monitored, overall attendance will generally improve. Studies by the APA, Robert Half as well as other professional entities have determined that employees will be overpaid from 1 to 8% of their wage due to inaccuracies in tracking time actually worked. Employees can be overpaid by up to 30 minutes per day due to lateness, early leaving, long lunch breaks etc.<br/><br/>TimeCentre will eliminate or reduce this overpayment. Salaried employees will be more careful about the time they are at work thus creating a savings as they will be working longer for the same fixed cost. If we assume a conservative 1% reduction in the payment of wages for un-worked time, then the following savings will be realized each week.</p>";
    inner += "<table border=\"0\" style=\"font-weight:bold; margin-bottom:12px\">";
    inner += "<tr><td width=\"250\">Number of employees :</td><td>" + number + "</td></tr>";
    inner += "<tr><td>Total hours per week :</td><td>" + number * work + "</td></tr>";
    inner += "<tr><td>Total weekly pay :</td><td>" + "$" + number * work * pay + "</td></tr>";
    inner += "<tr><td>Increase in hours per week gained :</td><td>" + number * work / 100 + "</td></tr>";
    inner += "<tr><td>Saving per week :</td><td>" + "$" + (number * work / 100) * pay + "</td></tr>";
    inner += "</table>";

    inner += "<h2>Human Error</h2>";
    inner += line;
    inner += "<p>With a non-computerized system, there is a potential for human error at each stage of the payroll calculation process. Studies indicate companies using a manual system are likely to be experiencing an error rate of between 1 and 5%. If we assume that we can reduce the error rate by a very conservative 0.5%, then the following savings will be realized each week.</p>";
    inner += "<table border=\"0\" style=\"font-weight:bold; margin-bottom:12px\">";
    inner += "<tr><td width=\"250\">Number of employees  			: " + number + "</td></tr>";
    inner += "<tr><td>Total hours per week :</td><td>" + number * work + "</td></tr>";
    inner += "<tr><td>Total weekly pay :</td><td>" + "$" + number * work * pay + "</td></tr>";
    inner += "<tr><td>Rate of human error per week :</td><td>" + "0.5%</p>";
    inner += "<tr><td>Saving per week :</td><td>" + "$" + (number * work / 100) * pay * 0.5 + "</td></tr>";
    inner += "</table>";

    inner += "<h2>Administration Costs</h2>";
    inner += line;
    inner += "<p>Studies have determined that on average, managers will take up to 7 minutes to manually calculate and edit each employee’s hours at work, and an additional 2 minutes to manually enter data from each time sheet into a payroll application. TimeCentre eliminates this work. If we assume our system will eliminate a conservative 5 minutes per time sheet for the calculation and data entry process, then the following savings will be realized each week.</p>";
    inner += "<table border=\"0\" style=\"font-weight:bold; margin-bottom:12px\">";
    inner += "<tr><td width=\"250\">Number of employees :</td><td>" + number + "</td></tr>";
    inner += "<tr><td>Calculation and entry time (hours) :</td><td>" + roundNumber((number * 5 / 60), 2) + "</td></tr>";
    inner += "<tr><td>Saving per week :</td><td>" + "$" + roundNumber(((number * 5 / 60) * pay), 2) + "</td></tr>";
    inner += "</table>";

    inner += "<h2>Your Return on Investment</h2>";
    inner += line;
	weeklysave = ((number*work/100)*pay)+((number*work/100)*pay*0.5)+(roundNumber(((number*5/60)*pay),2));
	inner += "<p>Based on these figures, installing TimeCentre will save you $" + weeklysave + " each week.</p>";
	inner += "<p>The figures suggest that the total annual savings you will realize by implementing TimeCentre within your organization is:</p>";
	inner += "<p class=\"Normal\" style=\"font-weight:bold;\">$" + roundNumber((weeklysave * 52), 2) + " per year</p>";
	inner += "<br/><br/>"

	mdiv.innerHTML = inner;

	return false;

}


function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

function savingInfo(myNumber, myPay, mySaving) {
		this.myNumber = myNumber;
		this.myPay = myPay;
		this.mySaving = mySaving;
		this.mySavingInfo = mySavingInfo;

}

function mySavingInfo(number, pay, saving) {
	return Math.round(number*pay*saving*235/60);
}


function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}
