//------------------------------------------------------------------------
// FIELD VALIDATION CODE
//------------------------------------------------------------------------
// CREATED: July 2007 by JES
// PURPOSE: Validation Methods
//------------------------------------------------------------------------

//------------------------------------------------------------------------
// BASIC VALIDATION
//  - Simply add "required" to the name of a field and it will be checked
//  - Created by: wsabstract.com | http://www.wsabstract.com */
//------------------------------------------------------------------------
function checkrequired(which) {
  var pass=true;
  for (i=0;i<which.length;i++) {
    var tempobj=which.elements[i];
    if (tempobj.name.substring(0,8)=="required") {
      if (((tempobj.type=="text"||tempobj.type=="textarea")&&
          tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
          tempobj.selectedIndex==0)) {
        pass=false;
        break;
      }
    }
  }
  if (!pass) {
    shortFieldName=tempobj.name.substring(8,30).toUpperCase();
    shortFieldName=shortFieldName.replace(/_/g," " );
    alert(shortFieldName+" field is required.");
    return false;
  } else {
  return true;
  }
}

//------------------------------------------------------------------------
// REMOVE EXCESS WHITESPACE (STRIP)
//  - Created by: Pat Cahill
//------------------------------------------------------------------------
function remove_XS_whitespace(item)
{
  var tmp = "";
  var item_length = item.value.length;
  var item_length_minus_1 = item.value.length - 1;
  for (index = 0; index < item_length; index++)
  {
    if (item.value.charAt(index) != ' ')
    {
      tmp += item.value.charAt(index);
    }
    else
    {
      if (tmp.length > 0)
      {
        if (item.value.charAt(index+1) != ' ' && index != item_length_minus_1)
        {
          tmp += item.value.charAt(index);
        }
      }
    }
  }
  item.value = tmp;
}