//                  Aust   Cana   Euro   Japan   Mexi   GrBr  USA    Braz   SAfr   India
//                  ----   ----   ----   -----   ----   ----  ----   ----   ----   ----
gCConv = new Array( 1.75,  1.52,  1.03,  121.90, 9.87,  0.67,  1.00,  2.77,  10.30,  49.00, -1 );
gCName = new Array( "AUD", "CAD", "EUR", "JPY", "MXP", "GBP", "USD", "BRL", "ZAR", "INR",  "???" );


function FixValue(rawValue, iRightOfDecimal ){

   	var iCents = 100*(rawValue-Math.floor(rawValue))+0.5;
   	newValue   = Math.floor(rawValue);
	
	if( iRightOfDecimal == 0 ) {
		return newValue;
	}
	newValue = newValue + ".";

	newValue += Math.floor(iCents/10);
	if( iRightOfDecimal == 1 ) {
		return newValue;
	}

	newValue += Math.floor(iCents%10);
   	return newValue;
}


function calcROI( iSeats, iTimePeriod, iIndex, iRightOfDecimal ){
	var i;
	var iLicense;
	var iROIMax;

	iROIMax= 0;
	if     (iSeats > 0     	 && iSeats <= 2500   ){	p=3;	}
	else if(iSeats > 2500    && iSeats <= 5000   ){	p=2.50;	}
	else if(iSeats > 5000    && iSeats <= 10000  ){	p=2;	}
	else if(iSeats > 10000   && iSeats <= 100000 ){	p=1.50;	}

	iLicense = iSeats * p * 12;
	iROIMax= gCConv[iIndex] * (iLicense/iTimePeriod);
	iROIMax= FixValue (iROIMax, iRightOfDecimal);
	return iROIMax;
}

var		gROIMax;
var		w2;
function spamCalculator(f){
	var iIndex;
	var iSpamPerDay  		= f.scSpamPerDay.options[f.scSpamPerDay.selectedIndex].text;
	var iSpamSeconds		= f.scSpamSeconds.options[f.scSpamSeconds.selectedIndex].text;
	var iEMailEmployees		= f.scEmailEmployees.value;
	var iWorkDay	      	= f.scWorkdays.value;
	var iSalary				= f.scSalary.value;

	
	iIndex = 6;
	var iCost = (iEMailEmployees * iSpamPerDay * iWorkDay) * (iSalary * (iSpamSeconds/3600));		

	f.scYSpamCostCompany.value  = " $" + FixValue(iCost,2);
	f.scYSpamCostEmployee.value = " $" + FixValue((iCost/iEMailEmployees), 2);
	
	f.scDSpamCostCompany.value  = " $" + FixValue((iCost/iWorkDay),2);
	f.scDSpamCostEmployee.value = " $" + FixValue(((iCost/iEMailEmployees)/iWorkDay),2);
	
	var szPeriod;
	var i = FixValue( (iEMailEmployees * (iSpamSeconds/3600) * (iSpamPerDay*365) ), 2 );
	
	
	if( i <= 250 ) {
		szPeriod = "Hours";
	}
	else {
		i = FixValue( (i/24), 2 );
		szPeriod = "Days";
	}
		
	f.YCProductivity.value = " " + i + " " + szPeriod;	
	f.YEProductivity.value = " " + FixValue( ((iSpamSeconds/3600) * (iSpamPerDay*365)), 2 ) + " Hours";
		
	gROIMax = calcROI(iEMailEmployees, (iCost/iWorkDay), iIndex, 0 );
	
	if( gROIMax < 1 ) {
		f.szROICompany.value = "Solace Suite(TM) Email Spam Filtering and Continuity Service pays for itself in less than 1 day";
	}
	else {
		f.szROICompany.value = "Solace Suite(TM) Email Spam Filtering and Continuity Service pays for itself in " + gROIMax + " days or less";
	}

   MM_showHideLayers('results','','show');
}
//-->

<!--
function Validator (theForm)
{

  if (theForm.scEmailEmployees.value == "")
  {
    alert("Please enter a value for the \"Employees with Email\" field.");
    theForm.scEmailEmployees.focus();
    return (false);
  }

  if (theForm.scEmailEmployees.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Employees with Email\" field.");
    theForm.scEmailEmployees.focus();
    return (false);
  }

  if (theForm.scEmailEmployees.value.length > 5)
  {
    alert("Please enter at most 5 characters in the \"Employees with Email\" field.");
    theForm.scEmailEmployees.focus();
    return (false);
  }

  var checkOK = "0123456789-,";
  var checkStr = theForm.scEmailEmployees.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Employees with Email\" field.");
    theForm.scEmailEmployees.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "1" && prsVal <= "99999"))
  {
    alert("Please enter a value greater than or equal to \"1\" and less than or equal to \"99999\" in the \"Employees with Email\" field.");
    theForm.scEmailEmployees.focus();
    return (false);
  }

  if (theForm.scWorkdays.value == "")
  {
    alert("Please enter a value for the \"Work days\" field.");
    theForm.scWorkdays.focus();
    return (false);
  }

  if (theForm.scWorkdays.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Work days\" field.");
    theForm.scWorkdays.focus();
    return (false);
  }

  if (theForm.scWorkdays.value.length > 3)
  {
    alert("Please enter at most 3 characters in the \"Work days\" field.");
    theForm.scWorkdays.focus();
    return (false);
  }

  var checkOK = "0123456789-,";
  var checkStr = theForm.scWorkdays.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Work days\" field.");
    theForm.scWorkdays.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "1" && prsVal <= "366"))
  {
    alert("Please enter a value greater than or equal to \"1\" and less than or equal to \"366\" in the \"Work days\" field.");
    theForm.scWorkdays.focus();
    return (false);
  }

  if (theForm.scSalary.value == "")
  {
    alert("Please enter a value for the \"Hourly Salary\" field.");
    theForm.scSalary.focus();
    return (false);
  }

  if (theForm.scSalary.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Hourly Salary\" field.");
    theForm.scSalary.focus();
    return (false);
  }

  if (theForm.scSalary.value.length > 5)
  {
    alert("Please enter at most 5 characters in the \"Hourly Salary\" field.");
    theForm.scSalary.focus();
    return (false);
  }

  var checkOK = "0123456789-,";
  var checkStr = theForm.scSalary.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Hourly Salary\" field.");
    theForm.scSalary.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= "1" && prsVal <= "99999"))
  {
    alert("Please enter a value greater than or equal to \"1\" and less than or equal to \"99999\" in the \"Hourly Salary\" field.");
    theForm.scSalary.focus();
    return (false);
  }
  return (true);
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
