<!--//

	//------------------------------------------------------------
	// Function Name: IsValidEmail
	// Parameters   : 
	// Author       : 
	// Date         : 
	// Purpose      : 
	//------------------------------------------------------------
	function IsValidEmail(str) {
 		if (str.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
			return true;
		else
			return false;
	}


	//------------------------------------------------------------
	// Function Name: y2k
	// Parameters   : 
	// Author       : Matthew Wall
	// Date         : 24-02-2004
	// Purpose      : 
	//------------------------------------------------------------
	function y2k(number) { return (number < 1000) ? number + 1900 : number; }


	//------------------------------------------------------------
	// Function Name: isDate
	// Parameters   : 
	// Author       : Matthew Wall
	// Date         : 24-02-2004
	// Purpose      : 
	//------------------------------------------------------------
	function isDate(day,month,year) {
		// checks if date passed is valid
		// will accept dates in following format:
		// isDate(dd,mm,ccyy), or
		// isDate(dd,mm) - which defaults to the current year, or
		// isDate(dd) - which defaults to the current month and year.
		// Note, if passed the month must be between 1 and 12, and the
		// year in ccyy format.
	
	    var today = new Date();
	    year = ((!year) ? y2k(today.getYear()):year);
	    month = ((!month) ? today.getMonth():month-1);
	    if (!day) return false
	    var test = new Date(year,month,day);
	    if ( (y2k(test.getYear()) == year) && (month == test.getMonth()) && (day == test.getDate()) )
	        return true;
	    else
	        return false;
		}



	//------------------------------------------------------------
	// Function Name: IsNumeric
	// Parameters   : sText
	// Author       : Matthew Wall
	// Date         : 06/07/2004
	// Purpose      : 
	// From         : http://www.codetoad.com/javascript/isnumeric.asp
	//------------------------------------------------------------	
	function IsNumeric(sText){
		var ValidChars = "0123456789.";
		var IsNumber=true;
		var Char;
		
		for (i = 0; i < sText.length && IsNumber == true; i++) { 
			Char = sText.charAt(i); 
			if (ValidChars.indexOf(Char) == -1) {
				IsNumber = false;
			}
		}
		return IsNumber;
	}


	//------------------------------------------------------------
	// Function Name: radioButtonChecker
	// Parameters   : form element
	// Author       : Matthew Wall
	// Date         : 06/07/2004
	// Purpose      : 
	// From         : http://javascript.about.com/library/blradio4.htm
	//------------------------------------------------------------	
	function radioButtonChecker(btn) {
		var cnt = -1;
		for (var i=btn.length-1; i > -1; i--) {
   		if (btn[i].checked) {cnt = i; i = -1;}
   	}
		if (cnt > -1) return btn[cnt].value;
		else return null;
	}



	//------------------------------------------------------------
	// Function Name: validateSelectControl
	// Parameters   : form element
	// Author       : Matthew Wall
	// Date         : 06/07/2004
	// Purpose      : 
	// From         : https://lists.latech.edu/pipermail/javascript/2004-September/008543.html
	//------------------------------------------------------------	
	function validateSelectControl (objSelect) {
    var iNumSelected = 0;

    for (var iCount=0; objSelect.options[iCount]; iCount++) {
			if (objSelect.options[iCount].selected == true) {
				iNumSelected ++;
			}
    }
		
    if (iNumSelected == 0) {
        return false;
    }
    return true;
}

	
	/*==============================================================================
	
	Application:   Utility Function
	Author:        John Gardner
	Version:       V1.0
	Date:          23rd May 2005
	Description:   Used to check the validity of a UK National Insurance Number
	  
	Parameters:    toCheck - National insurance number to be checked. 
	
	This function checks the validty of the supplied number. 
	
	If the number is found to be in a valid format, the function returns a value of 
	true, otherwise a value of false.
	
	See http://www.govtalk.gov.uk/gdsc/html/frames/NationalInsuranceNumber-2-1-Release.htm
	for a formal specification.
	  
	Example call:
	  
	  if (checkNINO (myNINO) {
	    alert ("National Insurance Number has a valid format")
	  } 
	  else {alert ("National Insurance Number has invalid format")};
	                    
	------------------------------------------------------------------------------*/
	function checkNINO (toCheck) {
	
	  var valid = false;
	  var exp = /^[A-CEGHJ-NOPR-TW-Z]{1}[A-CEGHJ-NPR-TW-Z]{1}[0-9]{6}[ABCD\s]{1}/
	  if (toCheck.match(exp)) {
	    valid = true;
	  }
	  exp = /(^GB)|(^BG)|(^NK)|(^KN)|(^TN)|(^NT)|(^ZZ).+/
	  if (toCheck.match(exp)) {
	    valid = false;
	  }
	  
	  // Return with the error status
	  return valid;
	}
	  
//-->