function ValidateNumber (varNumberType, formObj , sMessage, varRangeFrom, varRangeTo)
{
    var formObjValue = formObj.value;
	var varReturn = false;

	if (formObjValue !="") 
	{
		if (varNumberType =="Integer")
		{
			if (isNaN(formObjValue)) 
			{
					alert("Please enter a number into the " + sMessage + " field");
					formObj.select();
			}
			else
			{		
				if (varRangeTo == "")
				{
					
					if (formObjValue < varRangeFrom)
				    {
						alert("Please enter a number into the " + sMessage + " field greater than " + varRangeFrom );
						formObj.select();
					}
					else
					{
					  varReturn = true;
					}
				}
				else
				{
					if ((formObjValue < varRangeFrom) || (formObjValue > varRangeTo))
				    {
						alert("Please enter a number into the " + sMessage + " field ranging from " + varRangeFrom + " to " + varRangeTo);
						formObj.select();
					}
					else
					{
					  varReturn = true;
					}
				}
			}
	
		return varReturn;
	    }
	}
}

function ValidateList (formObj , sMessage)
{
    var formObjValue = formObj.value;
	var varReturn = false;

	if (formObjValue == "<SELECT>")
	{
		alert("Please select a value from the " + sMessage + " List");
		if (formObj.disabled== false)
		{
			formObj.focus();
		}
	}
	else
	{
	  varReturn = true;
	}
	return varReturn;
}


function ValidateDate (formObj , sMessage)
{
	var varErrorCount=0;
    var formObjValue = formObj.value;
	var varHour;
	var varTimeSep;
	var varMinute;
	var varDay;
	var varMonth;
	var varYear;
	var varReturn = false;
	//	 sMessage is redundant at the moment - to be used in the future if we need a specific message
	if (formObjValue !="") 
	{
		varDay = formObjValue.substring(0, 2);

		if (isNaN(varDay))varErrorCount = 1;
		sep1 = formObjValue.substring(2, 3);
		varMonth = formObjValue.substring(3, 5);
		if (isNaN(varMonth))varErrorCount = 1;
		sep2 = formObjValue.substring(5, 6);
		varYear =  formObjValue.substring(6, formObjValue.length);
		if (isNaN(varYear))varErrorCount = 1;
		if (varYear.length == 4 )
			varYear = varYear;
		else
		{
			if (varYear.length == 2 )
			{
			  if (Number(varYear) <= 30) 
				varYear = Number(varYear) + 2000;
			  else 
				varYear = Number(varYear) +  1900;                
			}
			else
			  varErrorCount = 1;
		}
		
		//basic error checking
		if (varDay<1 || varDay>31) varErrorCount = 1;
		if ((sep1 != '/') && (sep1 != '-'))  varErrorCount = 1;
		if (varMonth<1 || varMonth>12) varErrorCount = 1;
		if ((sep1 != '/') && (sep1 != '-')) varErrorCount = 1;
		if (varYear<0 || varYear>2050) varErrorCount = 1;

		//advanced error checking
		// varMonths with 30 varDays
		if (varMonth==4 || varMonth==6 || varMonth==9 || varMonth==11)
			if (varDay==31) varErrorCount=1;

		// february, leap varYear
		if (varMonth == 2)
		{
			g = parseInt(varYear/4);
			if (isNaN(g)) 
				varErrorCount=1;
			if (varDay > 29) varErrorCount=1;
			if (varDay == 29 && ((varYear/4)!=parseInt(varYear/4))) varErrorCount=1;
		}

		if (varErrorCount > 0)
		{
			alert('Please correct the date to be a valid date in the format of "dd/mm/yy" or "dd/mm/yyyy" ');
			formObj.select();
		}
		else
		{
			formObj.value = varDay + "/" + varMonth + "/" + varYear;
			varReturn = true;
		}
		return varReturn;
	}

}

function ValidateTime (varValidationType, formObj)
{
	var varErrorCount=0;
    var formObjValue = formObj.value;
	var varHour;
	var varTimeSep;
	var varMinute;
	var varDay;
	var varMonth;
	var varYear;
	var x;
	var varReturn = false;

	if (formObjValue !="") 
	{
		if (varValidationType == "24Time")
		{
			if (formObjValue.length != 5)
			{
				varErrorCount++;
			}
			else
			{
				varHour = formObjValue.substring(0, 2);
				varTimeSep = formObjValue.substring(2, 3);
				varMinute = formObjValue.substring(3, 6);

				if (isNaN(varMinute))
				{
					varErrorCount++;
				}
				else if ((varMinute > 60) || (varMinute <= 0))
						varErrorCount++;

				if ((varTimeSep != ":") && (varTimeSep != ".")) varErrorCount++;

				if (isNaN(varHour))
					varErrorCount++;
				else if ((varHour > 24) || (varHour <= 0))
					varErrorCount++;
			}

			if (varErrorCount > 0)
			{
				alert("Please enter a valid time in the following format HH:MM (24hr)");
				formObj.select();
				varReturn = false;
			}
			else
			{
				formObj.value = 	varHour + ":" + varMinute;
				varReturn = true;
			}
			return varReturn;
		}
	}
}


function CheckBoxValidation(chkbox2)
{
    if (chkbox2.checked == true)
        chkbox2.checked = false;
}

function OpenPopup(PopupType)
{
	var vPopup = window.open(PopupType, 'newwin', 'scrollbars=yes,status=Yes,width=700,height=400');
	vPopup.opener = self;
    vPopup.focus();

}

function DateCheck(from, to,msgString)
{
	if (Date.parse(from.value) <= Date.parse(to.value)) 
	{
		return true;
	}
	else 
	{
		alert(msgString);
		return false;
	}
}


/*
	Title				- Form1_ValidateRegistor(theForm)
	Language			- javaScript
	Purpose				- Validate form Registor
	Querystring Inputs	-
	Form Inputs			-
	Business Objects	-
	Session Objects		-
	Usage				-
	Programmer Name		- Modified by Tang
	Date				- 07/2007


*/
function Form1_ValidateRegistor(theForm)
{

	var alertsay = ""; // define for long lines
	// alertsay is not necessary for your code,
	// but I need to break my lines in multiple lines
	// so the code won't extend off the edge of the page

	// check to see if the field is blank
	if (theForm.Alias.value == "")
	{
		alert("You must enter an Name.");
		theForm.Alias.focus();
		return (false);
	}

	// require at least 3 characters be entered
	if (theForm.Alias.value.length < 3)
	{
		alert("Please enter at least 3 characters in the \"Name\" field.");
		theForm.Alias.focus();
		return (false);
	}

	// allow ONLY alphanumeric keys, no symbols or punctuation
	// this can be altered for any "checkOK" string you desire
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'$ ";
	var checkStr = theForm.Alias.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;
			}
		}
		
		if (!allValid)
		{
			alert("Please enter only letter and numeric characters in the \"Name\" field.");
			theForm.Alias.focus();
			return (false);
		}


		// check if email field is blank
		if (theForm.Email.value == "")
		{
			alert("Please enter a value for the \"Email\" field.");
			theForm.Email.focus();
			return (false);
		}

	// test if valid email address, must have @ and .

		var checkEmail = "@.";
		var checkStr = theForm.Email.value;
		var EmailValid = false;
		var EmailAt = false;
		var EmailPeriod = false;
	
		for (i = 0;  i < checkStr.length;  i++)
		{
			ch = checkStr.charAt(i);
			
			for (j = 0;  j < checkEmail.length;  j++)
			{
				if (ch == checkEmail.charAt(j) && ch == "@")
					EmailAt = true;
				if (ch == checkEmail.charAt(j) && ch == ".")
					EmailPeriod = true;
				if (EmailAt && EmailPeriod)
					break;
				if (j == checkEmail.length)
					break;
			}
				// if both the @ and . were in the string
			if (EmailAt && EmailPeriod)
			{
				EmailValid = true
				break;
			}
		}
		if (!EmailValid)
		{
			alert("The \"email\" field must contain an \"@\" and a \".\".");
			theForm.Email.focus();
			return (false);
		}


		// because this is a sample page, don't allow to exit to the post action
		// comes in handy when you are testing the form validations and don't
		// wish to exit the page
		alertsay = "Thank You for your registration with RISA. "
		alertsay = alertsay + "You will Receive future RISA News Letters."
		alert(alertsay);
		return (true);

		/*<form action="javascript.asp?ID=<%=siteID%>"
		method="POST" onsubmit="return Form1_Validator(this)" name="Form1">
		Your Name:
		<input type="text" size="15" maxlength="15" name="Alias"><br>
		3 checks:
		Not blank, at least 3 characters, only alphanumeric characters allowed.<p>

		Comment: (Please enter 150 characters maximum.)<br>
		<textarea name="comment" rows="4" cols="50" wrap="virtual">
		</textarea><br>

		Email:
		<input type="text" size="60" name="Email" value><br>
		2 checks: Can't be blank. A valid email address must contain an "@"
		and a "." in the address.<p>

		<input type="submit" name="Submit" value="Submit">
		<input type="reset" name="Reset" value="Reset"><p>
		</form>
		*/
		// replace the above with return(true); if you have a valid form to submit to

}


/*
	Title				- Form1_ValidateRegisterTrainers(theForm)
	Language			- javaScript
	Purpose				- Validate form Register Trainers
	Querystring Inputs	-
	Form Inputs			-
	Business Objects	-
	Session Objects		-
	Usage				-
	Programmer Name		- Modified by Tang
	Date				- 07/2007


*/

function FrontPage_Form1_ValidateRegisterTrainers(theForm)
{

  // AccountNo
	/* if (theForm.AccountNo.value == "")
	  {
		alert("Please enter a value for the \"Account Number\" field.");
		theForm.AccountNo.focus();
		return (false);
	  }
	  
	  if (theForm.AccountNo.value.length > 14)
	  {
		alert("Please enter at most 14 characters in the \"Account Number\" field.");
		theForm.AccountNo.focus();
		return (false);
	  }
	  
	  var checkOK = "0123456789-.";
	  var checkStr = theForm.AccountNo.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 += ".";
		  decPoints++;
		}
		else
		  allNum += ch;
	  }
	  if (!allValid)
	  {
		alert("Please enter only digit characters in the \"Account Number\" field.");
		theForm.AccountNo.focus();
		return (false);
	  }
	
	  if (decPoints > 1 || !validGroups)
	  {
		alert("Please enter a valid number in the \"AccountNo\" field.");
		theForm.AccountNo.focus();
		return (false);
	  }
	  */
	  
	  
	  // Code
	  var checkOK = "0123456789-.,";
	  var checkStr = theForm.Code.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 += ".";
		  decPoints++;
		}
		else if (ch == "," && decPoints != 0)
		{
		  validGroups = false;
		  break;
		}
		else if (ch != ",")
		  allNum += ch;
	  }
	  if (!allValid)
	  {
		alert("Please enter only digit characters in the \"Code\" field.");
		theForm.Code.focus();
		return (false);
	  }
	
	  if (decPoints > 1 || !validGroups)
	  {
		alert("Please enter a valid number in the \"Code\" field.");
		theForm.Code.focus();
		return (false);
	  }
	  
	  // Surname
	  if (theForm.Surname.value == "")
	  {
		alert("Please enter a value for the \"Surname\" field.");
		theForm.Surname.focus();
		return (false);
	  }
	
	  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&#402;&#352;&#338;&#381;&#353;&#339;&#382;&#376;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'";
	  var checkStr = theForm.Surname.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;
		}
	  }
	  
	  alert ("surname == "+ checkStr);
	  alert ("allValid == "+ allValid);
	  
	  if (!allValid)
	  {
		alert("Please enter only letter and \"'\" characters in the \"Surname\" field.");
		theForm.Surname.focus();
		return (false);
	  }

	  
	  // GivenNames
	  if (theForm.GivenNames.value == "")
	  {
		alert("Please enter a value for the \"GivenNames\" field.");
		theForm.GivenNames.focus();
		return (false);
	  }
	
	  if (theForm.GivenNames.value.length > 50)
	  {
		alert("Please enter at most 50 characters in the \"GivenNames\" field.");
		theForm.GivenNames.focus();
		return (false);
	  }
	
	  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&#402;&#352;&#338;&#381;&#353;&#339;&#382;&#376;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ";
	  var checkStr = theForm.GivenNames.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 \"GivenNames\" field.");
		theForm.GivenNames.focus();
		return (false);
	  }


	  // CBODate
	  if (theForm.CBODate.selectedIndex < 0)
	  {
		alert("Please select one of the \"CBODate\" options.");
		theForm.CBODate.focus();
		return (false);
	  }
	
	  if (theForm.CBODate.selectedIndex == 0)
	  {
		alert("The first \"CBODate\" option is not a valid selection.  Please choose one of the other options.");
		theForm.CBODate.focus();
		return (false);
	  }
	
	  // CBOMonth
	  if (theForm.CBOMonth.selectedIndex < 0)
	  {
		alert("Please select one of the \"CBOMonth\" options.");
		theForm.CBOMonth.focus();
		return (false);
	  }
	
	  if (theForm.CBOMonth.selectedIndex == 0)
	  {
		alert("The first \"CBOMonth\" option is not a valid selection.  Please choose one of the other options.");
		theForm.CBOMonth.focus();
		return (false);
	  }
	  
	  // Year
	  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 digits in the \"Year\" field.");
		theForm.Year.focus();
		return (false);
	  }
	
	  if (theForm.Year.value.length > 4)
	  {
		alert("Please enter at most 4 digits in the \"Year\" field.");
		theForm.Year.focus();
		return (false);
	  }
	  
	  
	  // Sex
	  if (theForm.Sex.selectedIndex < 0)
	  {
		alert("Please select one of the \"Sex\" options.");
		theForm.Sex.focus();
		return (false);
	  }
	
	  if (theForm.Sex.selectedIndex == 0)
	  {
		alert("The first \"Sex\" option is not a valid selection.  Please choose one of the other options.");
		theForm.Sex.focus();
		return (false);
	  }
	  
	  // Unit
	  if (theForm.Unit.value == "")
	  {
		alert("Please enter a value for the \"Street\" field.");
		theForm.Unit.focus();
		return (false);
	  }
	
	  if (theForm.Unit.value.length > 9)
	  {
		alert("Please enter at most 9 characters in the \"Street\" field.");
		theForm.Unit.focus();
		return (false);
	  }
	
	  var checkOK = "0123456789-/ \t\r\n\f";
	  var checkStr = theForm.Unit.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 \"Street\" field.");
		theForm.Unit.focus();
		return (false);
	  }
	
	  // StreetName	
	  if (theForm.StreetName.value == "")
	  {
		alert("Please enter a value for the \"StreetName\" field.");
		theForm.StreetName.focus();
		return (false);
	  }
	
	  if (theForm.StreetName.value.length > 150)
	  {
		alert("Please enter at most 150 characters in the \"StreetName\" field.");
		theForm.StreetName.focus();
		return (false);
	  }
	
	  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&#402;&#352;&#338;&#381;&#353;&#339;&#382;&#376;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'\" \t\r\n\f";
	  var checkStr = theForm.StreetName.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, whitespace and \"'\"\" characters in the \"StreetName\" field.");
		theForm.StreetName.focus();
		return (false);
	  }
	
	
	  // Suburb
	  if (theForm.Suburb.value == "")
	  {
		alert("Please enter a value for the \"Suburb\" field.");
		theForm.Suburb.focus();
		return (false);
	  }
	
	  if (theForm.Suburb.value.length > 50)
	  {
		alert("Please enter at most 50 characters in the \"Suburb\" field.");
		theForm.Suburb.focus();
		return (false);
	  }
	
	  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&#402;&#352;&#338;&#381;&#353;&#339;&#382;&#376;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ\"'";
	  var checkStr = theForm.Suburb.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 and \"\"'\" characters in the \"Suburb\" field.");
		theForm.Suburb.focus();
		return (false);
	  }
	  
	  // State
	  if (theForm.State.selectedIndex < 0)
	  {
		alert("Please select one of the \"State\" options.");
		theForm.State.focus();
		return (false);
	  }
	
	  if (theForm.State.selectedIndex == 0)
	  {
		alert("The first \"State\" option is not a valid selection.  Please choose one of the other options.");
		theForm.State.focus();
		return (false);
	  }
	
	  // PostCode
	  if (theForm.PostCode.value == "")
	  {
		alert("Please enter a value for the \"PostCode\" field.");
		theForm.PostCode.focus();
		return (false);
	  }
	
	  if (theForm.PostCode.value.length < 4)
	  {
		alert("Please enter at least 4 characters in the \"PostCode\" field.");
		theForm.PostCode.focus();
		return (false);
	  }
	
	  if (theForm.PostCode.value.length > 4)
	  {
		alert("Please enter at most 4 characters in the \"PostCode\" field.");
		theForm.PostCode.focus();
		return (false);
	  }
	
	  var checkOK = "0123456789-.,";
	  var checkStr = theForm.PostCode.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 += ".";
		  decPoints++;
		}
		else if (ch == "," && decPoints != 0)
		{
		  validGroups = false;
		  break;
		}
		else if (ch != ",")
		  allNum += ch;
	  }
	  if (!allValid)
	  {
		alert("Please enter only digit characters in the \"PostCode\" field.");
		theForm.PostCode.focus();
		return (false);
	  }
	
	  if (decPoints > 1 || !validGroups)
	  {
		alert("Please enter a valid number in the \"PostCode\" field.");
		theForm.PostCode.focus();
		return (false);
	  }
	  
	  // AreaCode
	  if (theForm.AreaCode.value == "")
	  {
		alert("Please enter a value for the \"AreaCode\" field.");
		theForm.AreaCode.focus();
		return (false);
	  }
	
	  if (theForm.AreaCode.value.length < 2)
	  {
		alert("Please enter at least 2 characters in the \"AreaCode\" field.");
		theForm.AreaCode.focus();
		return (false);
	  }
	
	  if (theForm.AreaCode.value.length > 2)
	  {
		alert("Please enter at most 2 characters in the \"AreaCode\" field.");
		theForm.AreaCode.focus();
		return (false);
	  }
	
	  var checkOK = "0123456789-.,";
	  var checkStr = theForm.AreaCode.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 += ".";
		  decPoints++;
		}
		else if (ch == "," && decPoints != 0)
		{
		  validGroups = false;
		  break;
		}
		else if (ch != ",")
		  allNum += ch;
	  }
	  if (!allValid)
	  {
		alert("Please enter only digit characters in the \"AreaCode\" field.");
		theForm.AreaCode.focus();
		return (false);
	  }
	
	  if (decPoints > 1 || !validGroups)
	  {
		alert("Please enter a valid number in the \"AreaCode\" field.");
		theForm.AreaCode.focus();
		return (false);
	  }
	  
	  // PhoneNumber
	  if (theForm.PhoneNumber.value == "")
	  {
		alert("Please enter a value for the \"PhoneNumber\" field.");
		theForm.PhoneNumber.focus();
		return (false);
	  }
	
	  if (theForm.PhoneNumber.value.length < 6)
	  {
		alert("Please enter at least 6 characters in the \"PhoneNumber\" field.");
		theForm.PhoneNumber.focus();
		return (false);
	  }
	
	  if (theForm.PhoneNumber.value.length > 9)
	  {
		alert("Please enter at most 9 characters in the \"PhoneNumber\" field.");
		theForm.PhoneNumber.focus();
		return (false);
	  }
	
	  var checkOK = "0123456789-.,";
	  var checkStr = theForm.PhoneNumber.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 += ".";
		  decPoints++;
		}
		else if (ch == "," && decPoints != 0)
		{
		  validGroups = false;
		  break;
		}
		else if (ch != ",")
		  allNum += ch;
	  }
	  if (!allValid)
	  {
		alert("Please enter only digit characters in the \"PhoneNumber\" field.");
		theForm.PhoneNumber.focus();
		return (false);
	  }
	
	  if (decPoints > 1 || !validGroups)
	  {
		alert("Please enter a valid number in the \"PhoneNumber\" field.");
		theForm.PhoneNumber.focus();
		return (false);
	  }
	  
	  // Mobile
	  if (theForm.Mobile.value == "")
	  {
		alert("Please enter a value for the \"Mobile\" field.");
		theForm.Mobile.focus();
		return (false);
	  }
	
	  if (theForm.Mobile.value.length < 9)
	  {
		alert("Please enter at least 9 characters in the \"Mobile\" field.");
		theForm.Mobile.focus();
		return (false);
	  }
	
	  if (theForm.Mobile.value.length > 11)
	  {
		alert("Please enter at most 11 characters in the \"Mobile\" field.");
		theForm.Mobile.focus();
		return (false);
	  }
	
	  var checkOK = "0123456789-.,";
	  var checkStr = theForm.Mobile.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 += ".";
		  decPoints++;
		}
		else if (ch == "," && decPoints != 0)
		{
		  validGroups = false;
		  break;
		}
		else if (ch != ",")
		  allNum += ch;
	  }
	  if (!allValid)
	  {
		alert("Please enter only digit characters in the \"Mobile\" field.");
		theForm.Mobile.focus();
		return (false);
	  }
	
	  if (decPoints > 1 || !validGroups)
	  {
		alert("Please enter a valid number in the \"Mobile\" field.");
		theForm.Mobile.focus();
		return (false);
	  }
	  
	  // Email
	  if (theForm.Email.value == "")
	  {
		alert("Please enter a value for the \"Email\" field.");
		theForm.Email.focus();
		return (false);
	  }
	
	  if (theForm.Email.value.length > 100)
	  {
		alert("Please enter at most 100 characters in the \"Email\" field.");
		theForm.Email.focus();
		return (false);
	  }
	
	  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&#402;&#352;&#338;&#381;&#353;&#339;&#382;&#376;ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-@.\"' \t\r\n\f";
	  var checkStr = theForm.Email.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, digit, whitespace and \"@.\"'\" characters in the \"Email\" field.");
		theForm.Email.focus();
		return (false);
	  }
	  
	  // PersonnelID
	  var checkOK = "0123456789-.,";
	  var checkStr = theForm.PersonnelID.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 += ".";
		  decPoints++;
		}
		else if (ch == "," && decPoints != 0)
		{
		  validGroups = false;
		  break;
		}
		else if (ch != ",")
		  allNum += ch;
	  }
	  if (!allValid)
	  {
		alert("Please enter only digit characters in the \"PersonnelID\" field.");
		theForm.PersonnelID.focus();
		return (false);
	  }
	
	  if (decPoints > 1 || !validGroups)
	  {
		alert("Please enter a valid number in the \"PersonnelID\" field.");
		theForm.PersonnelID.focus();
		return (false);
  	  }
	  
 
  
	var alertsay = "";
	
	alertsay = "Thankyou for registering online for StableAssist. Your details have been forwarded to RISA.  "
	alertsay = alertsay + "An email will be sent to you with details of a Username and Password within 24 hours or next working business day. "
	alert(alertsay);

  return (true);

}