function getRisk()
{
	document.frmCalc.resultDay.value=round_decimals((document.frmCalc.numEmps.value*document.frmCalc.numEmails.value)/500,0);
	document.frmCalc.resultMo.value=round_decimals((document.frmCalc.numEmps.value*document.frmCalc.numEmails.value)/500*30,0);
	document.frmCalc.resultYear.value=round_decimals((document.frmCalc.numEmps.value*document.frmCalc.numEmails.value)/500*365,0);
	return true;
}



function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}

function pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString()
    
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")

    // Is there a decimal point?
    if (decimal_location == -1) {
        
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0
        
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }
    
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
    
    if (pad_total > 0) {
        
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) 
            value_string += "0"
        }
    return value_string
}



function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) ||
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}


function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

var whitespace = " \t\n\r";
function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}


function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function




function isEmail (s)
{   
		if (s.indexOf(" ")!=-1) return false;

		if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
   
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}


var dtCh= "/";
var minYear=1980;
var maxYear=2050;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}


function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
  var arrdays = new Array()
	for (var i = 1; i <= n; i++) {
		arrdays[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {arrdays[i] = 30}
		if (i==2) {arrdays[i] = 29}
   }
   return arrdays
}


function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		return false //"validDate"
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return false //"validDate"
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return false //"validDate"
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		return false
	}
  if (!inthePast(dtStr)){
    return false //"inPast"
  }
return true
}

function inthePast(dtStr) {
  var now = new Date();
  var today = new Date(now.getFullYear(),now.getMonth(),now.getDate());
  var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
  var date = new Date(strYear, strMonth-1, strDay)

  //var date = new Date(dateString.substring(6,10),
  //                    dateString.substring(0,2)-1,
  //                    dateString.substring(3,5));
  
  //if (today >= date)
    //return true;
  //else
    //return false;
    
  return true;  
}






function MM_validateForm() { //v4.0
  var i,i2,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  var count = 0;
  
  for (i=0; i<(args.length-2); i+=3) 
	{	
 		test=args[i+2]; val=MM_findObj(args[i]);strFriendlyName = args[i+1];
 		
		//alert('test:' + test)
		//alert('val:' + val)
		//alert('strFriendlyName:' + strFriendlyName)
 		
		if (args[i]=='00N30000000jp4F')
		{
			var formObj = document['frmContact']['00N30000000jp4F'];
			for (i2=0;i2<formObj.length; i2++)
		  	{
		  		//alert(formObj[i].checked)
		  		if(formObj[i2].checked)
		  		count++;
		  	}
			var formObj = document['frmContact']['00N30000000jp4I'];
			if (formObj.checked)
			{
				count++;
			}
	  	
		 	if (count==0)
		 	{
		 		errors += '- '+strFriendlyName+' is required.\n';
		 	}
		}
		
		

		if (val) 
		{ 
			nm=val.name; if ((val=val.value)!="") 
		{
		
		if (test.indexOf('isDate')!=-1) 
		{
      if (!isDate(val)) errors+='- '+strFriendlyName+' must contain a valid date.\n';
		}
		else if (test.indexOf('isEmail')!=-1)
		{
      if (isEmail(val)==false) errors+='- '+strFriendlyName+' must contain an e-mail address.\n';
			
    }
		else if (test!='R') 
		{
      if (isNaN(val)) errors+='- '+strFriendlyName+' must contain a number.\n';
      if (test.indexOf('inRange') != -1) 
			{ 
				p=test.indexOf(':');
      	min=test.substring(8,p); max=test.substring(p+1);
      	if (val-0<min || max<val-0) errors+='- '+strFriendlyName+' must contain a number between '+min+' and '+max+'.\n';
    	}
		}
		}
		else if (test.charAt(0) == 'R') 
		{
			errors += '- '+strFriendlyName+' is required.\n'; 
		}
		}
  } 
	if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
}

function rand(number) {
        return Math.ceil(rnd()*number);
}

function PopUp(url,h,w,sb,rs,st,tb,mb,ti) 
{
  lft = (screen.availWidth -w)/2;
  t = (screen.availHeight -h)/2;
  p = "scrollbars=" + sb + ",resizable=" + rs + ",status=" + st + ",toolbar=" + tb + ",menubar=" + mb + ",titlebar=" + ti + ",top=" + t + ",left=" +lft + ",width=" + w + ",height=" + h;
  window.open(url, rand(101)-1, p);
}

function PopDetail(url,h,w,sb,rs,st,tb,mb,ti) 
{
  lft = (screen.availWidth -w)/2;
  t = ((screen.availHeight -h)/2)+229;
  p = "scrollbars=" + sb + ",resizable=" + rs + ",status=" + st + ",toolbar=" + tb + ",menubar=" + mb + ",titlebar=" + ti + ",top=" + t + ",left=" +lft + ",width=" + w + ",height=" + h;
  window.open(url, "detail", p);
}






