function hov(loc,cls){
	if(loc.className)
		loc.className=cls;}

function goForm(theForm, target) {
  theForm.action = target;
  theForm.submit();
}

function GoUserForm(theForm, formId, formURL){
  theForm.action = formURL;
  theForm.FormId.value =formId;
  theForm.submit();
}

function replQuote(txtValue) {
  var result = '';
  var ch;
  for (var i=0; i < txtValue.length; ++i) {
    ch = txtValue.charAt(i);
    if (ch != '"' && ch != "'") {
      result = result + ch;
    }
  }
  return result;
}

function fixApos(txtValue) {
  var result = '';
  var ch;
  for (var i=0; i < txtValue.length; ++i) {
    ch = txtValue.charAt(i);
    if (ch == "'") {
      result = result + '\\' + ch;
    } else {
      result = result + ch;
    }
  }
  return result;
}

function spChar(txtValue) {
  var result = '';
  var ch;
  for (var i= --txtValue.length; i >= 0; --i) {
    ch = txtValue.charAt(i);
    if (ch == '\\') {
      result = '\\' + ch + result;
    }
  }
  txtValue = result;
  result = '';
  for (var i= --txtValue.length; i >= 0; --i) {
    ch = txtValue.charAt(i);
    if (ch == "'") {
      result = '\\' + ch + result;
    }
  }
  return result;
}

function validEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
   if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported)
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function validEmailAddresses(str) {
  var result = false;
  var s = str;
  var i = s.indexOf(';')
  if (i > -1)
  {
    while (i > -1) 
    {
      result = validEmail(s.substr(0, i));
      if (!result) {return false}
      else {
        s = s.substr(i+1, s.length - i+1);
        i = s.indexOf(';');
      }
    }
    return validEmail(s);
  } else { 
    return validEmail(s) 
  }
}

function SetLength(txtValue, newLength) {
  var result = txtValue;
  if (result.length > newLength) {
	 result = result.substring(0, newLength-1);
  }
  return result;
}

function emptyField(txtValue) {
  var ch
  if (txtValue.length == 0) return true;
  for (var i=0; i < txtValue.length; ++i) {
    ch = txtValue.charAt(i);
    if (ch != ' ' && ch != '\t') return false;
  }
  return true;
}

function isInteger(aNumber, minI, maxI) {
  aNumber = parseFloat(aNumber);
  if (isNaN(aNumber)) {
    return false;
  } else {
    if (Math.round(aNumber) == aNumber) {
      if ((aNumber >= minI) && (aNumber <= maxI)) {
        return true;
      } else {
       return false;
     }
    } else {
      return false;
    }
  }
}

function lTrim(txtValue) {
  var result = txtValue;
  var ch;
  if (result.length == 0) return result;
  while (result.charAt(0) == ' ') {
    result = result.substring(1, result.length);
    if (result.length == 0) return result;
  }
  return result;
}

function rTrim(txtValue) {
  var result = txtValue;
  var ch;
  if (result.length == 0) return result;
  while (result.charAt(result.length-1) == ' ') {
    result = result.substring(0, result.length-1);
    if (result.length == 0) return result;
  }
  return result;
}

function Trim(txtValue) {
  return rTrim(lTrim(txtValue));
}
