    //replaces VBscript Ucase conversion subs: GV 9/2/03
function ConvertToUcase(fld)
{
  var regexp = /'/g
  var f = fld.value.toString()
  f = f.replace(regexp, "")
  f = f.toUpperCase()
  f = TrimString(f)
  fld.value = f
}

//simulates VB Trim function: GV 9/3/03    
function TrimString(sValue)
{
  if (!sValue)
  {
	  var sValue = "";
  }
  var endstring = sValue.length; 
  for (var i = 0; i < endstring; i++) {
    if (sValue.charAt(i) != " ") {      
      break;
    }
  var trimStart = i + 1;
  }
  sNewValue = sValue.substring(trimStart, endstring);
  return sNewValue;
}

//Trims field entries: GV 9/3/03 
function TrimFieldValue(fld)
{
 	if (fld)
 	{
 		var f = fld.value.toString()
  		f  = TrimString(f)
  		fld.value = f
	}
}

//displays desired text on status bar: GV 9/10/03
function SetWinText(strValue)
{ 
  window.status = strValue; 
}

  
  //enforces designated character limit in text boxes: GV 10/29/03
  function TruncateFieldValue(fld, count)
  {
    fld.value = TrimString(fld.value)
    var f = fld.value
    var flength = f.length
    if (flength > parseInt(count)) 
    {
      
      alert("Sorry, your Comments/Description field has been adjusted to " + count + " characters.")
      fld.value = f.substring(f, parseInt(count), flength)
    }
  }


//same as VBscript function
function FormatCurrency(amount)
{
  var centcounter = 0
  var currency = amount.toString()

  floatcurrency = parseFloat(currency)
  floatcurrency = Math.round(floatcurrency * 100)
  floatcurrency = floatcurrency / 100
  currency = floatcurrency.toString()
  
    if (currency.indexOf(".") == -1) 
  {
    currency += ".00"
  }
  else
  {
   var decimalplace = currency.indexOf(".")
   for (i = decimalplace; i <= currency.length; i++) 
   {
     centcounter += 1
   }
   if (centcounter < 4) 
   {
     currency += "0" 
   }
  }
  
  return "$" + currency
} 



//same as FormatCurrency but '$' is omitted. GV 10/28/03
function FormatCurrencyNoDollarSign(amount)
{
  var centcounter = 0
  var currency = TrimString(amount.toString())

  floatcurrency = parseFloat(currency)
  floatcurrency = Math.round(floatcurrency * 100)
  floatcurrency = floatcurrency / 100
  currency = floatcurrency.toString()
  
    if (currency.indexOf(".") == -1) 
  {
    currency += ".00"
  }
  else
  {
   var decimalplace = currency.indexOf(".")
   for (i = decimalplace; i <= currency.length; i++) 
   {
     centcounter += 1
   }
   if (centcounter < 4) 
   {
     currency += "0" 
   }
  }
  
  return currency
}

//formats text field value as currency. GV 10/28/03
function FormatFieldValueAsMoney(fld)
{
  var f = fld.value.toString()
  if (f != "") {
    if (isNaN(f)) 
    {
      f = "0"
    }
  }
  else
  {
    f = "0"
  }
  f = FormatCurrencyNoDollarSign(f)
  fld.value = f
} 

//changes 1 or 2 digit year date into a 4 digit year date AP 8-13-04
//to simulate EditDateOfClaim() 'sub' function
  function fourDigitYear(object)
    {
    var temp = object.value;
    var hold = 1;
    if (temp < 100)
        {
        if (temp.length == 1) hold = 10;
        if (temp < 50)//cut off for 2000 vs 1900 //Change as needed AP 8-13-04
            temp = 20 * hold  + temp;
        else
            temp = 19 * hold + temp;

        object.value = temp;

        if (object.value == 20)
            object.value = "";
        }
    }
	
  //SETS TEXT MESSAGE THAT APPEARS IN BROWSER STATUS BAR: GV 8/5/03-------------------------------------------------
  function SetStatusBarText(strText)
    {
      this.defaultStatus = "Enter a date-range, then click on Submit."
    }
	
// extracts all number chars from alphanumeric string. GV 1/21/08
function ExtractNums(sValue)
{
	var endstring = sValue.length; 
	var strNums = "";
	for (var i = 0; i < endstring; i++) 
	{
		if (!isNaN(sValue.charAt(i)))
		{
			strNums += sValue.charAt(i);
		}
	}
	return strNums;
}	

function ValidateEmail(emailStr) {
    var checkTLD = 1;
    var knownDomsPat = /^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/i;
    var emailPat = /^(.+)@(.+)$/;
    var specialChars = "\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
    var validChars = "\[^\\s" + specialChars + "\]";
    var quotedUser = "(\"[^\"]*\")";
    var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
    var atom = validChars + '+';
    var word = "(" + atom + "|" + quotedUser + ")";
    var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat = new RegExp("^" + atom + "(\\." + atom +")*$");
    var matchArray = emailStr.match(emailPat);
	var sEmail = "";
    if (matchArray == null) {
        return "Email address is in an incorrect format (check @ and .'s).";
    }
    var user = matchArray[1];
    var domain = matchArray[2];
    for (i=0; i<user.length; i++) {
        if (user.charCodeAt(i)>127) {
            return "Your email address contains invalid characters.";
        }
    }
    for (i=0; i<domain.length; i++) {
        if (domain.charCodeAt(i)>127) {
            return "Your email address domain name contains invalid characters.";
       }
    }
    if (user.match(userPat) == null) {
        sEmail = "Your email address does not seem to be valid.";
    }
    var IPArray = domain.match(ipDomainPat);
    if (IPArray != null) {
        for (var i=1; i<=4; i++) {
            if (IPArray[i] > 255) {
                return "Destination IP address is invalid!";
            }
        }
        return true;
    }
    var atomPat = new RegExp("^" + atom + "$");
    var domArr = domain.split(".");
    var len = domArr.length;
    for (i=0;i<len;i++) {
        if (domArr[i].search(atomPat)==-1) {
            return "The domain in your email address does not seem to be valid.";
       }
    }
    if (checkTLD && domArr[domArr.length-1].length != 2 && domArr[domArr.length-1].search(knownDomsPat) == -1) {
        return "Your email address must end in a known domain.";
    }
    if (len<2) {
       return "Your email address is missing a hostname!";
    }
    return "";
}