﻿function LocalLoad()
{
	
	document.getElementById("imgCalc").src = "../images/header/subnav/calc_over.jpg";
}

function calcroi(form)
{
  if ((document.form.pieces.value == "") ||
      (document.form.progcost.value == "") ||
	  (document.form.resprate.value == "") ||
	  (document.form.convrate.value == "") ||
	  (document.form.avespend.value == "") ) {
     alert ("All input fields must have a value");
	 } else {
	 numberofpieces = document.form.pieces.value;
	 programcost = document.form.progcost.value;
     responserate = document.form.resprate.value;
	 conversion = document.form.convrate.value;
	 averagespent = document.form.avespend.value;
	 } 

	costofpieces = programcost/numberofpieces;
	costpieceround = (parseInt(costofpieces*100))/100;
	responds = numberofpieces * (responserate/100);
	respsround = Math.round(responds);
	responsecost = programcost/respsround;
	respcostround = (parseInt(responsecost*100))/100;
	buyersnumber = (respsround * (conversion/100));
	buyround = Math.round(buyersnumber);
	totalrevenue = averagespent * buyround;
	totrevround = (parseInt(totalrevenue*100))/100;
	costofbuyer = programcost/buyround;
	costbuyround = (parseInt(costofbuyer))/100;
	returnoninvestment = ((totrevround - programcost)/programcost)*100;
	roiround = (parseInt(returnoninvestment*100))/100;
	document.form.piececost.value = costpieceround;
	document.form.responders.value = respsround;
	document.form.respcost.value = respcostround;
	document.form.buyers.value = buyround;
	document.form.totrev.value = totrevround;
	document.form.costbuyer.value = costbuyround;
	document.form.roi.value = roiround;
}

function reset(form)
{
	document.form.pieces.value = "";
	document.form.piececost.value = "";
	document.form.resprate.value = "";
	document.form.convrate.value = "";
	document.form.avespend.value = "";
	document.form.progcost.value = "";
	document.form.responders.value = "";
	document.form.respcost.value = "";
	document.form.buyers.value = "";
	document.form.totrev.value = "";
	document.form.costbuyer.value = "";
	document.form.roi.value = "";

}

//function ContactMe(strUnderOver)
//{
//	window.location = "ProfitTestContact.aspx?clickedon=" + strUnderOver + "&total=" + document.getElementById("spnTotal").innerHTML;
//}