function Calculate(form) { var watt = 50; var kw = 0; var kwh = 0;
var halogenKwh = 12.50; var halogenFitting = 1.75; var halogenMonth = 17.50;
var ledKwh = 2; var ledFitting = 0.28; var ledMonth = 2.80;
var hours = 0; var fittings = 1; var costPerHour = 0; var costPerMonth = 0; var tenYrCost = 336.00; var ledCost = 336; var halogenCost = 2100.00; var otherSaving = 0; var savings = 0; var unitPrice = 14;
watt = form.watt.value; hours = form.hours.value; unitPrice = form.energy.value; fittings = form.fittings.value;
kw = watt / 1000; kwh = kw * hours; unitPrice = unitPrice / 100; costPerHour = kwh * unitPrice; costPerMonth = costPerHour * fittings; tenYrCost = costPerMonth * 120;
halogenKwh = 0.05 * hours; ledKwh = 0.008 * hours;
halogenFitting = halogenKwh * unitPrice; ledFitting = ledKwh * unitPrice;
halogenMonth = halogenFitting * fittings; ledMonth = ledFitting * fittings;
halogenCost = (halogenFitting * fittings) *120; ledCost = (ledFitting * fittings)* 120;
savings = halogenCost - tenYrCost; otherSaving = halogenCost - ledCost;
document.getElementById("halkwh").innerHTML=halogenKwh.toFixed(2); document.getElementById("ledkwh").innerHTML=ledKwh.toFixed(2);
document.getElementById("halfitting").innerHTML="£"+halogenFitting.formatMoney(2,'.',','); document.getElementById("ledfitting").innerHTML="£"+ledFitting.formatMoney(2,'.',',');
document.getElementById("halmonth").innerHTML="£"+halogenMonth.formatMoney(2,'.',','); document.getElementById("ledmonth").innerHTML="£"+ledMonth.formatMoney(2,'.',',');
document.getElementById("halogen").innerHTML="£"+halogenCost.formatMoney(2,'.',','); document.getElementById("LEDCost").innerHTML="£"+ledCost.formatMoney(2,'.',','); document.getElementById("otherSaving").innerHTML="£"+otherSaving.formatMoney(2,'.',',');
document.getElementById("kw").innerHTML=kw; document.getElementById("kwh").innerHTML=kwh.toFixed(2); document.getElementById("perFitting").innerHTML="£"+costPerHour.formatMoney(2,'.',','); document.getElementById("perMonth").innerHTML="£"+costPerMonth.formatMoney(2,'.',','); document.getElementById("TenYear").innerHTML="£"+tenYrCost.formatMoney(2,'.',',');
document.getElementById("cost").innerHTML="£"+savings.formatMoney(2,'.',',');
// Store in cookies the values }
Number.prototype.formatMoney = function(c, d, t){ var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "." : d, t = t == undefined ? "," : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(d{3})(?=d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); };