// JavaScript Document
var hoursofday,daysofmonth,bulbsinsign,wattsofbulb,costperkilo,costperled,engerynow;
var ledwatts,led,price,refitcost,ledengerycost,savings,year2save,year1save,month1save,month2save;
var refit,tco,month1,year1,month2,year2,roi,roipayback;
function doMath() {
  if ((document.LEDvBulb.name.value == "") ||
 	  (document.LEDvBulb.hours.value == "") ||
      (document.LEDvBulb.days.value == "") ||
	  (document.LEDvBulb.bulbs.value == "") ||
	  (document.LEDvBulb.watts.value == "") ||
	  (document.LEDvBulb.kilo.value == "") ||
	  (document.LEDvBulb.part.value == "") ||
	  (document.LEDvBulb.led.value == "") ||
	  (document.LEDvBulb.price.value == "") ) {
     alert ("All input fields must have a value");
	 } else {
	 hoursofday = document.LEDvBulb.hours.value;
	 daysofmonth = document.LEDvBulb.days.value;
     bulbsinsign = document.LEDvBulb.bulbs.value;
	 wattsofbulb = document.LEDvBulb.watts.value;
	 costperkilo = document.LEDvBulb.kilo.value;
	 ledpart = document.LEDvBulb.part.value;
	 ledwatts = document.LEDvBulb.led.value;
	 costperled = document.LEDvBulb.price.value;
	 }
engerynow = hoursofday * daysofmonth * bulbsinsign * wattsofbulb * costperkilo / 1000;
ledengerycost = hoursofday * daysofmonth * bulbsinsign * ledwatts * costperkilo / 1000;
document.LEDvBulb.engerynow.value=custRound(engerynow,2)
document.LEDvBulb.ledengerycost.value=custRound(ledengerycost,2)
savings = engerynow - ledengerycost;
document.LEDvBulb.savings.value=custRound(savings,2)
Refitcost = bulbsinsign * costperled;
document.LEDvBulb.refit.value=custRound(Refitcost,2)
tco = bulbsinsign * costperled / 12 + ledengerycost;
document.LEDvBulb.tco.value=custRound(tco,2)
month1save = engerynow - tco;
document.LEDvBulb.month1.value=custRound(month1save,2)
year1save = month1save * 12;
document.LEDvBulb.year1.value=custRound(year1save,2)
month2save = engerynow - ledengerycost;
document.LEDvBulb.month2.value=custRound(month2save,2)
year2save = month2save * 12;
document.LEDvBulb.year2.value=custRound(year2save,2)
roipayback = Refitcost / month2save;
document.LEDvBulb.roi.value=custRound(roipayback,2)
}
function custRound(x,places) {
return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places)
}
function resetField(field) {
		field.focus()
		field.select()
		field.value=field.defaultValue
		//field.value="0"
		}
// End -->
