<!-- Begin
var Num800Machines;
var DaysToEmpty;
var AverageVend;

function Currency(value) {
var temp = "" + (Math.round( value * 100));
return temp.slice(0,-2) + "." + temp.slice(-2);
}

function HowMany(form) {
var DailyTotal;
var WeeklyTotal;
var MonthlyTotal;
var YearlyTotal;
var NumEmpties;
var Begin;
var End;

var Num800Machines = ignoreCommas(document.vending.Num800Machines.value);
var AverageVend = ignoreCommas(document.vending.AverageVend.value);
var VendsPerDay = ignoreCommas(document.vending.VendsPerDay.value);

DailyTotal = Currency(Num800Machines * VendsPerDay * AverageVend);

WeeklyTotal = Currency(Num800Machines * VendsPerDay * AverageVend * 7);

MonthlyTotal = Currency(Num800Machines * VendsPerDay * AverageVend * 30);

YearlyTotal = Currency(Num800Machines * VendsPerDay * AverageVend * 365);




/* Insert comma */
if (DailyTotal.length > 6) {
Begin = DailyTotal.substring(0,DailyTotal.length-6);
End = DailyTotal.substring(DailyTotal.length-6,DailyTotal);
DailyTotal = Begin + "," + End;
}

if (WeeklyTotal.length > 6) {
Begin = WeeklyTotal.substring(0,WeeklyTotal.length-6);
End = WeeklyTotal.substring(WeeklyTotal.length-6,WeeklyTotal);
WeeklyTotal = Begin + "," + End;
}

if (MonthlyTotal.length > 6) {
Begin = MonthlyTotal.substring(0,MonthlyTotal.length-6);
End = MonthlyTotal.substring(MonthlyTotal.length-6,MonthlyTotal);
MonthlyTotal = Begin + "," + End;
}

if (YearlyTotal.length > 6) {
Begin = YearlyTotal.substring(0,YearlyTotal.length-6);
End = YearlyTotal.substring(YearlyTotal.length-6,YearlyTotal);
YearlyTotal = Begin + "," + End;
}

form.DailyTotal.value = '$ ' + DailyTotal;
form.WeeklyTotal.value = '$ ' + WeeklyTotal;
form.MonthlyTotal.value = '$ ' + MonthlyTotal;
form.YearlyTotal.value = "$ " + YearlyTotal; // display total amount

}


function ignoreCommas(string) {
	var temp = "";
	string = '' + string;
	splitstring = string.split(",");
	for(i = 0; i < splitstring.length; i++)
		temp += splitstring[i];
	return temp;
}

function ClearForm(form){
form.Num800Machines.value = "";
form.AverageVend.value = "";
form.DaysToEmpty.value = "";
form.DailyTotal.value = "";
form.WeeklyTotal.value = "";
form.MonthlyTotal.value = "";
form.YearlyTotal.value = "";
}
// End -->
