// Created by Mitch Fournier for BuyerZone.com - October 28, 2005

// A function for calculating the ROI for callcenter
//
function doCalc() {
	
	// Check that all inputs are entered (not yet implemented)
	//checkComplete();
	
	// ASSUMPTIONS
	CSR_HRS_PER_REP = 128;
	
	// INPUTS
	salary = document.forms.ROI.salary.value;
	mo_inquiries = document.forms.ROI.mo_inquiries.value;
	min_before = document.forms.ROI.min_before.value;
	min_after = document.forms.ROI.min_after.value;
	cost = document.forms.ROI.cost.value;
	
	// CALCULATE THE RAW DATA
	before_min = min_before;
	before_cover = mo_inquiries * (before_min/60);
	before_CSR = before_cover/CSR_HRS_PER_REP;
	before_cost = before_CSR * salary;
	
	after_min = min_after;
	after_cover = mo_inquiries * (after_min/60);
	after_CSR = after_cover/CSR_HRS_PER_REP;
	after_cost = after_CSR * salary;
	
	yr1_CSR_diff = before_CSR - after_CSR;
	yr1_CSR_save = before_cost - after_cost;
	yr1_cost = cost;
	yr1_savings = yr1_CSR_save - yr1_cost;
	yr1_ROI = yr1_savings/yr1_cost;
	
	// FILL THE FORM WITH FORMATTED DATA
	document.forms.ROI.before_min.value = before_min;
	document.forms.ROI.before_cover.value = Math.round(before_cover);
	document.forms.ROI.before_CSR.value = Math.round(before_CSR*10)/10;
	document.forms.ROI.before_cost.value = "$" + Math.round(before_cost);

	document.forms.ROI.after_min.value = after_min;
	document.forms.ROI.after_cover.value = Math.round(after_cover);
	document.forms.ROI.after_CSR.value = Math.round(after_CSR*10)/10;
	document.forms.ROI.after_cost.value = "$" + Math.round(after_cost);

	document.forms.ROI.yr1_CSR_diff.value = Math.round(yr1_CSR_diff);
	document.forms.ROI.yr1_CSR_save.value = "$" + Math.round(yr1_CSR_save);
	document.forms.ROI.yr1_cost.value = "$" + yr1_cost;
	document.forms.ROI.yr1_savings.value = "$" + Math.round(yr1_savings);
	document.forms.ROI.yr1_ROI.value = Math.round(yr1_ROI*100*10)/10 + "%";
	
	// SCROLL DOWN TO THE RESULTS
	location.hash = "results";

}

// A function for clearing the ROI form
//
function doClearinputs() {
	
	// CLEAR THE FORM
	document.forms.ROI.salary.value = "";
	document.forms.ROI.mo_inquiries.value = "";
	document.forms.ROI.min_before.value = "";
	document.forms.ROI.min_after.value = "";

	document.forms.ROI.cost.value = "";
}

// A function for clearing the ROI form
//
function doClear() {
	
	// CLEAR THE FORM
	document.forms.ROI.before_min.value = "";
	document.forms.ROI.before_cover.value = "";
	document.forms.ROI.before_CSR.value = "";
	document.forms.ROI.before_cost.value = "";

	document.forms.ROI.after_min.value = "";
	document.forms.ROI.after_cover.value = "";
	document.forms.ROI.after_CSR.value = "";
	document.forms.ROI.after_cost.value = "";

	document.forms.ROI.yr1_CSR_diff.value = "";
	document.forms.ROI.yr1_CSR_save.value = "";
	document.forms.ROI.yr1_cost.value = "";
	document.forms.ROI.yr1_savings.value = "";
	document.forms.ROI.yr1_ROI.value = "";
	

}

