function CheckString(theField) {
  var aName = theField.value.split(/\s+/g); // split the sentence into an array of words
  if (aName != "")
  theField.value = SetName(aName); // join it back together
}

// Called by function CheckString
function SetName(aName) {
  var patternName = /(\w)(.*)/; // a letter, and then one, none or more letters
  for (i = 0 ; i < aName.length ; i ++ ) {
    var partsName = aName[i].match(patternName); // just a temp variable to store the fragments in.
    var firstLetterName = partsName[1].toUpperCase();
    var restOfWordName = partsName[2].toLowerCase();
    aName[i] = firstLetterName + restOfWordName; // re-assign it back to the array and move on
  }
  return aName.join(' '); // join it back together
}


function CheckForm(theForm)
{

  if (theForm.CompanyName.value == "")
  {
    alert("Please enter a value for the \"Company Name\" field.");
    theForm.CompanyName.focus();
    return (false);
  }

  if (theForm.CompanyName.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"Company Name\" field.");
    theForm.CompanyName.focus();
    return (false);
  }

  if (theForm.TelephoneNumber.value == "")
  {
    alert("Please enter a value for the \"Telephone Number\" field.");
    theForm.TelephoneNumber.focus();
    return (false);
  }

  if (theForm.TelephoneNumber.value.length < 10)
  {
    alert("Please enter at least 10 characters in the \"TelephoneNumber\" field.");
    theForm.TelephoneNumber.focus();
    return (false);
  }

  if (theForm.Password.value == "")
  {
    alert("Please enter a value for the \"Password\" field.");
    theForm.Password.focus();
    return (false);
  }

  var checkOK = "0123456789-()- \t\r\n\f";
  var checkStr = theForm.TelephoneNumber.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit, whitespace and \"()-\" characters in the \"TelephoneNumber\" field.");
    theForm.TelephoneNumber.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ";
  var checkStr = theForm.Password.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter characters in the \"Password\" field.");
    theForm.Password.focus();
    return (false);
  }

  var chkVal = theForm.Password.value;
  var prsVal = chkVal;
  if (chkVal != "" && !(prsVal == "greatmusic"))
  {
    alert("Please enter the correct value in the \"Password\" field.");
    theForm.Password.focus();
    return (false);
  }
  return (true);
}