 
// Registration Form Validation
//-------------------------------------------------------------------------  
function checkForm(theForm)
{

  if (theForm.person.value == "")
  {
    alert("Please enter your Name.");
    theForm.person.focus();
    return (false);
  }  
  
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÉäåéöúûü¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷ÿŸ⁄€‹›ﬁﬂ‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ¯˘˙˚¸˝˛ˇ \t\r\n\f";
  var checkStr = theForm.person.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 letters for your Name.");
    theForm.person.focus();
    return (false);
  } 

  if (theForm.custom2.selectedIndex <= 0)
  {
    alert("Please select one of the \"Event\" options.");
    theForm.custom2.focus();
    return (false);
  }
  
    if (theForm.custom5.selectedIndex <= 0)
  {
    alert("Please select one of the \"Sex\" options.");
    theForm.custom5.focus();
    return (false);
  }

  if (theForm.custom3.selectedIndex <= 0)
  {
    alert("Please select one of the \"Age Division\" options.");
    theForm.custom3.focus();
    return (false);
  }
  
    if (checkDate(theForm))
  {    
    theForm.custom6.value = theForm.month.value + '/' + theForm.day.value + '/' + theForm.year.value;    
  } else { return false; }


  if (theForm.disclaimer.checked != true)
  {
    alert("Before adding this participant please indicate that you have read \nand agree to the 'Disclaimer' by clicking the appropriate checkbox.");
    theForm.disclaimer.focus();
    return (false);
  }
  
  theForm.custom1.value = "Name: " + theForm.person.value;  
  theForm.custom6.value = "Birth Date: " + theForm.custom6.value;
  
  return true;
}

function setPrice() {
	if(document.form1.custom3.selectedIndex == 1 || document.form1.custom3.selectedIndex == 2) {
		document.form1.fee.value = "$12";
		document.form1.price.value = 12;
	} else {
		document.form1.fee.value = "$25";
		document.form1.price.value = 25;
	}
}

//-------------------------------------------------------------------------  
// Open Disclaimer Popup
win = new Object;
function openDisclaimer() {
		win = window.open('disclaimer.html', 'winD','width=850,height=650,top=50,left=50,scrollbars=0,status');
	win.focus();
} 


//-------------------------------------------------------------------------  
// date validation
function checkDate(theForm)
{

  if (theForm.month.value == "")
  {
    alert("Please enter a value for the \"month\" field.");
    theForm.month.focus();
    return (false);
  }

  if (theForm.month.value.length < 1)
  {
    alert("Please enter at least 2 characters in the \"month\" field.");
    theForm.month.focus();
    return (false);
  }

  if (theForm.month.value.length > 2)
  {
    alert("Please enter at most 2 characters in the \"month\" field.");
    theForm.month.focus();
    return (false);
  }

  var checkOK = "0123456789-,";
  var checkStr = theForm.month.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  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 (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"month\" field.");
    theForm.month.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal <= "12"))
  {
    alert("Please enter a value less than or equal to \"12\" in the \"month\" field.");
    theForm.month.focus();
    return (false);
  }
  
//------------------------------------------------------------------------- 
  if (theForm.day.value == "")
  {
    alert("Please enter a value for the \"day\" field.");
    theForm.day.focus();
    return (false);
  }
  if (theForm.day.value.length < 1)
  {
    alert("Please enter at least 2 characters in the \"day\" field.");
    theForm.day.focus();
    return (false);
  }

  if (theForm.day.value.length > 2)
  {
    alert("Please enter at most 2 characters in the \"day\" field.");
    theForm.day.focus();
    return (false);
  }
  
  var checkOK = "0123456789-,";
  var checkStr = theForm.day.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  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 (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"day\" field.");
    theForm.day.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal <= "31"))
  {
    alert("Please enter a value less than or equal to \"31\" in the \"day\" field.");
    theForm.day.focus();
    return (false);
  }

  if (theForm.year.value == "")
  {
    alert("Please enter a value for the \"year\" field.");
    theForm.year.focus();
    return (false);
  }

  if (theForm.year.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"year\" field.");
    theForm.year.focus();
    return (false);
  }

  if (theForm.year.value.length > 4)
  {
    alert("Please enter at most 4 characters in the \"year\" field.");
    theForm.year.focus();
    return (false);
  }

  var chkVal = theForm.year.value;
  var prsVal = chkVal;
  if (chkVal != "" && !(prsVal > "1900" && prsVal < "2010"))
  {
    alert("Please enter a value greater than \"1900\" and less than \"2010\" in the \"year\" field.");
    theForm.year.focus();
    return (false);
  }
  return (true);
}
//-------------------------------------------------------------------------         
