<!-- 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);
var VendsPerWeek = ignoreCommas(document.vending.VendsPerWeek.value);

if(VendsPerDay != '' && VendsPerWeek != ''){
alert('Please enter one or the other, not both');	
return false;
}
	
DailyTotal = Currency(Num800Machines * VendsPerDay * AverageVend);
WeeklyTotal = Currency(Num800Machines * VendsPerDay * AverageVend * 7);
MonthlyTotal = Currency(Num800Machines * VendsPerDay * AverageVend * 30);
YearlyTotal = Currency(Num800Machines * VendsPerDay * AverageVend * 365);

DailyTotal2 = Currency(Num800Machines * VendsPerWeek * AverageVend / 7);
WeeklyTotal2 = Currency(Num800Machines * VendsPerWeek * AverageVend);
MonthlyTotal2 = Currency(Num800Machines * VendsPerWeek * AverageVend * 4);
YearlyTotal2 = Currency(Num800Machines * VendsPerWeek * AverageVend * 52);


//alert(DailyTotal2 + WeeklyTotal2 + MonthlyTotal2 + YearlyTotal2);

/*DailyTotal = Currency(Num800Machines * VendsPerWeek * AverageVend);
WeeklyTotal = Currency(Num800Machines * VendsPerWeek * AverageVend * 7);
MonthlyTotal = Currency(Num800Machines * VendsPerWeek * AverageVend * 30);
YearlyTotal = Currency(Num800Machines * VendsPerWeek * 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;
}


//alert(VendsPerDay);

if(VendsPerDay == ''){
form.DailyTotal.value = '$ ' + DailyTotal2;
form.WeeklyTotal.value = '$ ' + WeeklyTotal2;
form.MonthlyTotal.value = '$ ' + MonthlyTotal2;
form.YearlyTotal.value = "$ " + YearlyTotal2; // display total amount
}	else	{
	
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 -->
