
// JavaScript Document

function total(form) {
	form.totalevexp.value = (form.totalEmp.value * 1) + (form.totalVeh.value * 1);
	form.totalevexp.value = rounding(form.totalevexp.value);
	
	document.getElementById("totalevexp").innerHTML = '<b><font color="white">$' + form.totalevexp.value + '</font></b>';

//	form.total.value = (form.totalEmp.value * 1) + (form.totalVeh.value * 1);
//	form.total.value = rounding(form.total.value);
//	document.getElementById("total").innerHTML = '<b><font color="white">$' + form.total.value + '</font></b>';
 
}

function calculate(form) {





	form.OTRate.value = form.hourlyRate.value * 1.5;
	form.OTRate.value = rounding(form.OTRate.value);
 
	form.wklyPay.value = ((form.hourlyRate.value * form.regHours.value) + (form.OTRate.value * form.OTHours.value)) * form.numDrivers.value;
	form.wklyPay.value = rounding(form.wklyPay.value);
 
 
	form.mthlyPay.value = (form.wklyPay.value * 52)/12;
	form.mthlyPay.value = rounding(form.mthlyPay.value);
 
 
	document.getElementById("mthlyPay2").innerHTML = '$' + form.mthlyPay.value;
 
	form.ssi.value = form.mthlyPay.value * .0765;
	form.ssi.value = rounding(form.ssi.value);
	document.getElementById("ssi").innerHTML = '$' + form.ssi.value;
 
	form.unemp.value = form.mthlyPay.value * .014;
	form.unemp.value = rounding(form.unemp.value);
	document.getElementById("unemp").innerHTML = '$' + form.unemp.value;
 
	form.comp.value = form.mthlyPay.value * .13;
	form.comp.value = rounding(form.comp.value);
	document.getElementById("comp").innerHTML = '$' + form.comp.value;
 
	form.misc.value = form.mthlyPay.value * .004;
	form.misc.value = rounding(form.misc.value);
	document.getElementById("misc").innerHTML = '$' + form.misc.value;
 
	form.vaca.value = (form.hourlyRate.value * form.regHours.value) /12
	form.vaca.value = rounding(form.vaca.value);
	document.getElementById("vaca").innerHTML = '$' + form.vaca.value;
 
	form.fringe.value = form.mthlyPay.value * .085;
	form.fringe.value = rounding(form.fringe.value);
	document.getElementById("fringe").innerHTML = '$' + form.fringe.value;
 
	form.totalEmp.value = (form.mthlyPay.value * 1) + (form.ssi.value * 1) + (form.unemp.value * 1) + (form.comp.value * 1) + (form.misc.value * 1) +
			(form.vaca.value * 1) + (form.fringe.value * 1);
	form.totalEmp.value = rounding(form.totalEmp.value);
	document.getElementById("totalEmp").innerHTML = '<b>$' + form.totalEmp.value + '</b>';
 //form.totalevexp.value = 'test';
 
// document.getElementById("totalevexp").innerHTML = 'test';
	total(form);
 
}
 
function rounding(num) {
 
	var rd = Math.round(num*100)/100;
	var res = rd.toFixed(2);
	if (res == "NaN") {
		res = "0.00";
	}
	return(res);
}
 
function calculatePrice(form) {
 
 
	var vt = new Array ('car', 'smpu', 'fspu', 'van', 'box', 'lbox');
	var cost = new Array ('14000', '15000', '18000', '24000', '28000', '36000');
	var mpg = new Array ('25', '20', '15', '15', '10', '8');
	for (i = 0; i < 6; i++) {
		if (form.type.value == vt[i]) {
			form.vehicleCost.value = cost[i];
			form.mpg.value = mpg[i];
		}
 
	}
//	calculateV(form);
}
 
function calculateV(form) {
 
	form.mthlyVehicle.value = (form.vehicleCost.value * .025) * form.numVehicles.value;
	form.mthlyVehicle.value = rounding(form.mthlyVehicle.value);
	document.getElementById("mthlyVehicle").innerHTML = '$' + form.mthlyVehicle.value;
 
	form.license.value = (form.vehicleCost.value * .0003) * form.numVehicles.value;;
	form.license.value = rounding(form.license.value);
	document.getElementById("license").innerHTML = '$' + form.license.value;
 
	form.gas.value = (((form.miles.value)/form.mpg.value) * form.gasPrice.value * 5 * 52)/12 * form.numVehicles.value;;
	form.gas.value = rounding(form.gas.value);
	document.getElementById("gas").innerHTML = '$' + form.gas.value;
 
	form.insurance.value = (form.vehicleCost.value * .0108) * form.numVehicles.value;;
	form.insurance.value = rounding(form.insurance.value);
	document.getElementById("insurance").innerHTML = '$' + form.insurance.value;
 
 
	form.maint.value = (form.vehicleCost.value * .0070) * form.numVehicles.value;;
	form.maint.value = rounding(form.maint.value);
	document.getElementById("maint").innerHTML = '$' + form.maint.value;
 
 
	form.extMaint.value = (form.vehicleCost.value * .0010) * form.numVehicles.value;;
	form.extMaint.value = rounding(form.extMaint.value);
	document.getElementById("extMaint").innerHTML = '$' + form.extMaint.value;
 
	form.totalVeh.value = (form.mthlyVehicle.value * 1) + (form.license.value * 1) +
		(form.gas.value * 1) + (form.insurance.value * 1) + (form.maint.value * 1) +
		(form.extMaint.value * 1);
	form.totalVeh.value = rounding(form.totalVeh.value);
	document.getElementById("totalVeh").innerHTML = '<b>$' + form.totalVeh.value + '</b>';
 
	total(form);
 
 
 
}
