monthly_savings = 0
function Calculate()
{
theForm=document.GoLive_Form1;
//manual values
num_minutes = parseFloat(theForm.TotalFaxes.value) * parseFloat(theForm.AvgMinutesPerFax.value);
theForm.ManualMinutes.value = num_minutes;
num_minutes_per_year = num_minutes * 250;
hours_per_year = num_minutes_per_year / 60;
theForm.temp.value = hours_per_year;
theForm.HoursPerYear.value = RoundUp(theForm.temp.value);
wages_per_year = parseFloat(theForm.HoursPerYear.value) * parseFloat(theForm.AvgWage.value);
theForm.temp.value = wages_per_year;
theForm.ManualLaborCostPerYear.value = RoundUp(theForm.temp.value);
//4-Sight Fax values
theForm.FourSightMinutes.value = parseInt(theForm.TotalFaxes.value);
foursight_minutes_per_year = parseInt(theForm.FourSightMinutes.value) * 250;
foursight_hours_per_year = foursight_minutes_per_year / 60;
theForm.temp.value = foursight_hours_per_year;
theForm.ManualHoursPerYear.value = RoundUp(theForm.temp.value);
manual_labor_cost_per_year = parseFloat(theForm.ManualHoursPerYear.value) * parseFloat(theForm.AvgWage.value);
theForm.temp.value = manual_labor_cost_per_year;
theForm.FourSightLaborCostPerYear.value = RoundUp(theForm.temp.value);
//Savings Calculation
Savings = parseFloat(theForm.ManualLaborCostPerYear.value) - parseFloat(theForm.FourSightLaborCostPerYear.value);
theForm.temp.value = Savings;
theForm.AnnualCostSavings.value = RoundUp(theForm.temp.value);
//Select a sample cost based on pages per day
pages_per_day = parseInt(theForm.TotalFaxes.value) * parseInt(theForm.Pages.value);
if (pages_per_day <= 1500)
   {
   document.payback_form.Cost.value = "3800";
   }
   else if (pages_per_day > 1500 && pages_per_day <= 8000)
   {
   document.payback_form.Cost.value = "10000";
   }
   else document.payback_form.Cost.value = "19000";
//Payback Calculation
monthly_savings = parseFloat(theForm.AnnualCostSavings.value) / 12;
theForm.temp.value = monthly_savings;
monthly_savings = RoundUp(theForm.temp.value);
document.payback_form.SaveMonth.value = monthly_savings;
//clear the payback form
document.payback_form.PayMonth.value = "";
}

function RoundUp(inValue)
{
	//this will round inValue to 2 decimal places
	
	var decimal = ".";
	var pos;
	var newValue;
	var temp1;
	var temp2;
	var temp3;
	var round;
	pos = inValue.indexOf(decimal);
//if no decimal, don't round
   if (pos <= -1)
   {
        newValue = inValue
        return newValue;
   }
   else
//otherwise, go ahead and round
	newValue = inValue.substring(0, 1);
	
	for (var i = 1; i <= pos; i++)
		newValue += inValue.substring(i, i+1);	
	
	temp1 = inValue.substring(i, i+1);	
	temp2 = inValue.substring(++i, i+1);
	temp3 = inValue.substring(++i, i+1);
	
	if (parseInt(temp3) >= 5)
	{
		round = parseInt(temp2);
		round++;
		newValue += temp1;
		newValue += round;		 
	}
	else
	{
		newValue += temp1;
		newValue += temp2;
	}	
	return newValue;

}   

function Payback()
{
PayMonth = 0;
theForm = document.payback_form;
     if (monthly_savings == false)
     {
     alert("Please fill in the Calculator fields first.");
     return;
     }
theForm.SaveMonth.value = monthly_savings;
pay_month = parseFloat(theForm.Cost.value) / monthly_savings;
theForm.temp.value = pay_month;
theForm.PayMonth.value = RoundUp(theForm.temp.value);
}

function validate(inValue, whereTo)
{
//this checks for and removes any characters not in the valid list
var newValue = "";
var firstDigit = true;
valid="01234567890.";

if (inValue != "")
{
for (var i = 0; i < inValue.length; i++)
{
   var checkMe=(inValue.substring(i,i+1))
   if (valid.indexOf(checkMe) >= 0)
   {
      if (firstDigit)
      {
         newValue = checkMe;
         firstDigit = false;
      }
      else
//build new value with valid chars only
         newValue += checkMe;
   }
}
}
//replace with valid value
whereTo.value = newValue;
}

function doReset() {
	payback_form.PayMonth.value="";
	payback_form.SaveMonth.value="";
	payback_form.Cost.value="";
}

//-->