function validLogin() {
 var err = false;
 if(document.login.email.length == 0 || document.login.email.value == ''){
    alert('You must supply a valid email address. Please try again');
    document.login.email.focus();
    err = true;
 }
 if(document.login.password.length <= 5 || document.login.password.value == ''){
    alert('You must supply a valid password. Please try again.');
    document.login.password.focus();
    err = true;
 }
 if (err == false) document.login.submit();
}

function clearText(fieldName) {
 if (fieldName.defaultValue == fieldName.value){
  fieldName.value = '';
  fieldName.style.color = '#000000';
  }
}

function validateText(fieldName) {
 if (fieldName.value == ''){
  fieldName.value = fieldName.defaultValue;
  fieldName.style.color = '#909090';
 } else {
  fieldName.style.color = '#006600';
 }
}

function validate() {
var err = false;
if (document.application.company_name.length == 0 || document.application.company_name.value == document.application.company_name.defaultValue){
    err = true;
    document.application.company_name.style.color = '#FF0000';
}
if (document.application.contact_person.length == 0 || document.application.contact_person.value == document.application.contact_person.defaultValue){
    err = true;
    document.application.contact_person.style.color = '#FF0000';
}
if (document.application.booth_reps.length == 0 || document.application.booth_reps.value == document.application.booth_reps.defaultValue){
    err = true;
    document.application.booth_reps.style.color = '#FF0000';
}
if (document.application.address.length == 0 || document.application.address.value == document.application.address.defaultValue){
    err = true;
    document.application.address.style.color = '#FF0000';
}
if (document.application.city.length == 0 || document.application.city.value == document.application.city.defaultValue){
    err = true;
    document.application.city.style.color = '#FF0000';
}
if (document.application.state.length == 0 || document.application.state.value == document.application.state.defaultValue){
    err = true;
    document.application.state.style.color = '#FF0000';
}
if (document.application.zip.length == 0 || document.application.zip.value == document.application.zip.defaultValue){
    err = true;
    document.application.zip.style.color = '#FF0000';
}
if (document.application.phone.length == 0 || document.application.phone.value == document.application.phone.defaultValue){
    err = true;
    document.application.phone.style.color = '#FF0000';
}
if (document.application.email.length == 0 || document.application.email.value == document.application.email.defaultValue){
    err = true;
    document.application.email.style.color = '#FF0000';
}
if (!IsNumeric(document.application.exhibitor_space_1.value) && document.application.exhibitor_space_1.value != ''){
    err = true;
    document.application.exhibitor_space_1.style.color = '#FF0000';
}
if (!IsNumeric(document.application.exhibitor_space_2.value) && document.application.exhibitor_space_2.value != ''){
    err = true;
    document.application.exhibitor_space_2.style.color = '#FF0000';
}
if (!IsNumeric(document.application.exhibitor_space_3.value) && document.application.exhibitor_space_3.value != ''){
    err = true;
    document.application.exhibitor_space_3.style.color = '#FF0000';
}
if (!IsNumeric(document.application.exhibitor_space_4.value) && document.application.exhibitor_space_4.value != ''){
    err = true;
    document.application.exhibitor_space_4.style.color = '#FF0000';
}
if (err == true){
    alert("You must fill in all of the application contact fields. Missing or incorrect fields have been highlighted in red. Please fix the errors and try again.");
}else{
    document.application.submit();
}
}

function IsNumeric(strString)
   //  check for valid numeric strings    
{
   var strValidChars = "123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}