function isWhiteSpace(strValue)
{
  var whitespace = " \t\n\r";
  iLength = strValue.length;

  if(strValue == null || iLength == 0)
    return (true);

  for(var i = 0; i < iLength; i++)
    if(whitespace.indexOf(strValue.charAt(i)) == -1)
       return (false);

  return (true);
}

function isNumeric(strValue)
{
  iLength = strValue.length;

  for(x = 0; x < iLength; x++)
    if(isNaN(parseInt(strValue.charAt(x))))
      return (false);

  return (true);
}

function isEmail(strValue)
{
  if(isWhiteSpace(strValue)) return (false);

  // Check for invalid characters
  invalidChars = " ~\'^\`\"*+=\\|][(){}$&!#%/:,;";
  for(i=0; i<invalidChars.length; i++)
    if(strValue.indexOf(invalidChars.charAt(i),0) > -1)
      return (false);

  lengthOfstrValue = strValue.length;
  if((strValue.charAt(lengthOfstrValue - 1) == ".") || (strValue.charAt(lengthOfstrValue - 2) == ".")) return (false);

  Pos = strValue.indexOf("@");
  if(strValue.charAt(Pos + 1) == ".") return (false);

  while((Pos < lengthOfstrValue) && ( Pos != -1))
  {
    Pos = strValue.indexOf(".",Pos);
    if(strValue.charAt(Pos + 1) == ".") return (false);
    if(Pos != -1) Pos++;
  }

  // There must be one and only one @ symbol
  atPos = strValue.indexOf("@");
  if(atPos == -1) return (false);
  if(strValue.indexOf("@",atPos+1) != -1) return (false);

  // Also check for at least one period after the @ symbol
  periodPos = strValue.indexOf(".",atPos);
  if(periodPos == -1) return (false);
  if(periodPos+3 > strValue.length) return (false);

  return (true);
}

function isURL(strValue)
{
  if(isWhiteSpace(strValue)) return (false);

  // Check for invalid characters
  invalidChars = " ~\'^\`\"*+=\\|][(){}$&!@#%,;";
  for(i=0; i<invalidChars.length; i++)
    if(strValue.indexOf(invalidChars.charAt(i),0) > -1)
      return (false);

  // Make sure http:// is present (only once)
  atPos = strValue.indexOf("http://");
  if(atPos == -1) return (false);
  if(strValue.indexOf("http://",atPos+1) != -1) return (false);

  // Also check for at least one period after http://
  periodPos = strValue.indexOf(".",atPos);
  if(periodPos == -1) return (false);
  if(periodPos+3 > strValue.length) return (false);

  return (true);
}

function zipIsValid(strValue)
{
  iLength = strValue.length;
  if(isWhiteSpace(strValue))
  {
    return (false);
  }
  if(iLength != 5 && iLength != 9 && iLength != 10)
  {
    return (false);
  }

  if(iLength == 5 || iLength == 9)
  {
    if(!isNumeric(strValue))
    {
      return (false);
    }
  }
  else if(iLength == 10)
  {
    if(strValue.charAt(5) != "-" && strValue.charAt(5) != " ")
      return (false);
    for(x = 0; x < iLength; x++)
    {
      if(x != 5 && !isNumeric(strValue.charAt(x)))
        return (false);
    }
  }

  return (true);
}

function getSelectedOption(obj)
{
  for(var i = 0; i<obj.length; i++)
  {
    if(obj[i].checked)
    {
      return (obj[i].value);
    }
  }

  return (-1);
}

function isPhoneNumber(strValue)
{
  if(strValue.length != 12)
    return (false);
  else if(strValue.charAt(3) != '-' || strValue.charAt(7) != '-')
    return (false);
  else if(!isNumeric(strValue.substring(0,3)) || !isNumeric(strValue.substring(4,7)) || !isNumeric(strValue.substring(8,strValue.length)))
    return (false);
  else
    return (true);
}

function isDataOptionSelected(obj) //used in requestservice form in trade site
{
  if(obj.selectedIndex < 0)
    return (false);

  for(var i=0; i<obj.length; i++)
    if(obj.options[i].selected && obj.options[i].value != "")
      return (true);

  return (false);
}

function doAlertAndFocus(obj, message)
{
  alert(message);
  obj.focus();
  return (false);
}

function emailIsValid(strEmail, strConf)
{

	if(strEmail != strConf)
	{
		return (true);	
	}
	
}