<!--
/* <![CDATA[ */

function FormsValidation(theForm,theDetails)
{
if(theDetails.indexOf("Firstname")!=-1)
{
   // FistName
  if (theForm.Firstname.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.Firstname.focus();
    return (false);
  }

  if (theForm.Firstname.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"First Name\" field.");
    theForm.Firstname.focus();
    return (false);
  }

  if (theForm.Firstname.value.length > 25)
  {
    alert("Please enter at most 25 characters in the \"First Name\" field.");
    theForm.Firstname.focus();
    return (false);
  }
}

if(theDetails.indexOf("Surname")!=-1)
{
// Surname
  if (theForm.Surname.value == "")
  {
    alert("Please enter a value for the \"Surname\" field.");
    theForm.Surname.focus();
    return (false);
  }

  if (theForm.Surname.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Surname\" field.");
    theForm.Surname.focus();
    return (false);
  }

  if (theForm.Surname.value.length > 25)
  {
    alert("Please enter at most 25 characters in the \"Surname\" field.");
    theForm.Surname.focus();
    return (false);
  }
}

if(theDetails.indexOf("Email")!=-1)
{ 
//Email
  if (theForm.Email.value == "")
  {
    alert("Please enter a value for the \"Email Address\" field.");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.Email.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"Email Address\" field.");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.Email.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Email Address\" field.");
    theForm.Email.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-@._";
  var checkStr = theForm.Email.value;
  var allValid = 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;
    }
  }
  
  var i = 1;
  var sLength = checkStr.length;
  
  // look for @
  while ((i < sLength) && (checkStr.charAt(i) != "@"))
  { i++;}
  diff=sLength-i;
  if(diff<1)
  {
     alert("You have not used an \"@\" symbol in your email address.Please use one.")
     theForm.Email.focus();
     return (false);
  }
  
  // look for .
  i = 1;
  while ((i < sLength) && (checkStr.charAt(i) != "."))
  { i++;}
  diff=sLength-i;
  if(diff<1)
  {
     alert("You have not used an \".\" symbol in your email address.Please use one.")
     theForm.Email.focus();
     return (false);
  }
  
  if (!allValid)
  {
    alert("Please enter only letter, digit and \"@._\" characters in the \"Email Address\" field.");
    theForm.Email.focus();
    return (false);
  }

  if(theForm.EmailConfirm)
  { 
	//Email Confirm
	if (theForm.Email.value != "" && theForm.EmailConfirm.value == "")
	{
		alert("Please confirm your \"Email Address\".");
		theForm.EmailConfirm.focus();
		return (false);
	}
	
	if (theForm.Email.value != theForm.EmailConfirm.value)
	{
		alert("Your email addresses do not match. Please check your email addresses.");
		theForm.EmailConfirm.focus();
		return (false);
	}
  }
}

if(theDetails.indexOf("DOB")!=-1)
{ 
  //Date of Birth
	  if (theForm.DOBDay.value == "" || theForm.DOBMonth.value == "" || theForm.DOBYear.value == "")
	  {
	    alert("Please enter your date of birth.");
	    theForm.DOBDay.focus();
	    return (false);
	  }
	
	  if (!isDay(theForm.DOBDay.value))
	  {
	    alert("Please enter the day correctly.");
	    theForm.DOBDay.focus();
	    return (false);
	  }
	  
	  if (!isMonth(theForm.DOBMonth.value))
	  {
	    alert("Please enter the month correctly.");
	    theForm.DOBMonth.focus();
	    return (false);
	  }
	  
	  if (!isYear(theForm.DOBYear.value))
	  {
	    alert("Please enter the year correctly. The year should consist of 4 digits.");
	    theForm.DOBYear.focus();
	    return (false);
	  }
	  
	  //Check the Day is correct based on the month
	  var day = parseFloat(theForm.DOBDay.value);
	  var month = parseFloat(theForm.DOBMonth.value);
	  var year = parseFloat(theForm.DOBYear.value);
	  if(month == 2 && ((isLeapYear(year) && day > 29) || (!isLeapYear(year) && day > 28)))
	  {
	  	alert("Please enter a correct date for the month.");
	    	theForm.DOBDay.focus();
	    	return (false);	
	  }
	  else if((month == 4 || month==6 || month==9 || month == 11) && day > 30)
	  {
	  	alert("Please enter a correct date for the month.");
	    	theForm.DOBDay.focus();
	    	return (false);	
	  }
	  
	  //Check the Year is not in the future
	  var curYear = new Date().getFullYear();
	  if(year > curYear || year < (curYear - 150))
	  {
	  	alert("Please enter a valid year.");
	    	theForm.DOBYear.focus();
	    	return (false);
	  }
	  
	  //Check not greater than current date
	  var curDate = new Date();
	  var birthDate = new Date(year, month-1, day);
	  if(birthDate >= curDate)
	  {
	  	alert("Please enter a date that is less than the current date.");
	    	theForm.DOBDay.focus();
	    	return (false);
	  }
}

if(theDetails.indexOf("AddressStreet")!=-1)
{ 
// Street Address
  if (theForm.AddressStreet.value == "")
  {
    alert("Please enter a value for the \"Street Address\" field.");
    theForm.AddressStreet.focus();
    return (false);
  }

  if (theForm.AddressStreet.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Street Address\" field.");
    theForm.AddressStreet.focus();
    return (false);
  }

  if (theForm.AddressStreet.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Street Address\" field.");
    theForm.AddressStreet.focus();
    return (false);
  }
}

if(theDetails.indexOf("AddressCity")!=-1)
{ 
// City
  if (theForm.AddressCity.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.AddressCity.focus();
    return (false);
  }

  if (theForm.AddressCity.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"City\" field.");
    theForm.AddressCity.focus();
    return (false);
  }

  if (theForm.AddressCity.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"City\" field.");
    theForm.AddressCity.focus();
    return (false);
  }
}

if(theDetails.indexOf("AddressState")!=-1)
{ 
// State
  if (theForm.AddressState.value == "")
  {
    alert("Please enter a value for the \"State\" field.");
    theForm.AddressState.focus();
    return (false);
  }

  if (theForm.AddressState.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"State\" field.");
    theForm.State.focus();
    return (false);
  }

  if (theForm.AddressState.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"State\" field.");
    theForm.AddressState.focus();
    return (false);
  }  
}

if(theDetails.indexOf("AddressCountry")!=-1)
{ 
// Country

  if (theForm.AddressCountry.selectedIndex < 0)
  {
    alert("Please select one of the \"Country\" options.");
    theForm.AddressCountry.focus();
    return (false);
  }

  if (theForm.AddressCountry.selectedIndex == 0)
  {
    alert("The first \"Country\" option is not a valid selection.  Please choose one of the other options.");
    theForm.AddressCountry.focus();
    return (false);
  }
}

if(theDetails.indexOf("AddressPostCode")!=-1)
{ 
// Postcode
  if (theForm.AddressPostCode.value == "")
  {
    alert("Please enter a value for the \"Postcode\" field.");
    theForm.AddressPostCode.focus();
    return (false);
  }

  if (theForm.AddressPostCode.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Postcode\" field.");
    theForm.AddressPostCode.focus();
    return (false);
  }

  if (theForm.AddressPostCode.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Postcode\" field.");
    theForm.Postcode.focus();
    return (false);
  }  
}

if(theDetails.indexOf("PhoneHome")!=-1)
{  
// Telephone
  if (theForm.PhoneHome.value == "")
  {
    alert("Please enter a value for the \"Telephone\" field.");
    theForm.PhoneHome.focus();
    return (false);
  }

  if (theForm.PhoneHome.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Telephone\" field.");
    theForm.PhoneHome.focus();
    return (false);
  }

  if (theForm.PhoneHome.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Telephone\" field.");
    theForm.PhoneHome.focus();
    return (false);
  }
}

if(theForm.PhoneHome && !RF_CheckGenericPhoneNumber(theForm.PhoneHome.value))
{
	alert("Please enter at valid phone number.");
	theForm.PhoneHome.focus();
	return (false);
}

if(theDetails.indexOf("PhoneMobile")!=-1)
{  
// Mobile Phone
  if (theForm.PhoneMobile.value == "")
  {
    alert("Please enter a value for the \"Mobile Phone\" field.");
    theForm.PhoneMobile.focus();
    return (false);
  }

  if (theForm.PhoneMobile.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Mobile Phone\" field.");
    theForm.PhoneMobile.focus();
    return (false);
  }

  if (theForm.PhoneMobile.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Mobile Phone\" field.");
    theForm.PhoneMobile.focus();
    return (false);
  }
}

if(theForm.PhoneMobile && !RF_CheckGenericPhoneNumber(theForm.PhoneMobile.value))
{
	alert("Please enter at valid phone number.");
	theForm.PhoneMobile.focus();
	return (false);
}

if(theDetails.indexOf("AgeBracket")!=-1)
{ 
// AgeBracket

  if (theForm.AgeBracket.selectedIndex < 0)
  {
    alert("Please select one of the \"Age Bracket\" options.");
    theForm.AgeBracket.focus();
    return (false);
  }

  if (theForm.AgeBracket.selectedIndex == 0)
  {
    alert("The first \"Age Bracket\" option is not a valid selection.  Please choose one of the other options.");
    theForm.AgeBracket.focus();
    return (false);
  }
}

if(theDetails.indexOf("MemberCategory")!=-1)
{ 
// AgeBracket

  if (theForm.MemberCategory.selectedIndex < 0)
  {
    alert("Please select an Area of Interest.");
    theForm.MemberCategory.focus();
    return (false);
  }

  if (theForm.MemberCategory.selectedIndex == 0)
  {
    alert("Please select an Area of Interest.");
    theForm.MemberCategory.focus();
    return (false);
  }
}

if(theForm.btnSubmit)
     theForm.btnSubmit.disabled = true;
     
  return (true);
}
/* ]]> */
//-->