	/*
	 *                              VALIDATION FUNCTIONS
	 *                             Written By: Yanlin Liu
	 *                             For the Mater Hospital
	 *							   Last Update : 04/03/2006
	 *					Free to use provided above comment inserted		
	 */

	function validForm(controlObject,controlId)
	{		
		switch(controlId)
		{	
			case "emailBaby":   
				if (isEmptyField(controlObject.clientName,"Your Name"))
					return false;			
				if (invalidEmail(controlObject.clientEmail,"Your Email",true))
					return false;	
				if (isEmptyField(controlObject.babyName,"Baby's Name"))
					return false;
				if (exceedTextLength(controlObject.clientComment,"Your Memorial Message",50))
					return false;
				if (controlObject.clientAgree[0].value == 1){
					alert("Please tick check box.");
					return false;
				}							
			break;	  
			case "add":
				if (invalidEmail(controlObject.email,"Your Email",true))
					return false;	
				if (controlObject.subscribe.checked==false){
					alert("Please tick the check box to confirm your subscription.");
					return false;
				}
			break;

			case "remove":
				if (invalidEmail(controlObject.email,"Your Email",true))
					return false;	
				if (controlObject.unsubscribe.checked==false){
					alert("Please tick the check box to confirm your unsubscription.");
					return false;
				}
			
			break;
			default:
			break;		
		}	
	}	
	
	function CheckDateFormat(formField,fieldLabel)	{		
		var field 	= new String(fieldLabel);
		var strDate = new String(formField.value);		
		var strDateArray;
		var validDate;				
		strDateArray = strDate.split("/");		
		if (strDateArray.length == 3 ){
			validDate = CheckDateValue(strDateArray[0],strDateArray[1],strDateArray[2])			
			if (!validDate){
				alert("Please enter '" + field +"' in DD/MM/YYYY format.");
				formField.select();
				return true;		
			}
			else{
				return true;
			}
		}
		else{
			alert("Please enter '" + field +"' in DD/MM/YYYY format.");
			formField.select();
			return true;		
		}
		
	}
	
	function CheckDateValue(day,month,year){
		var toDay 	= parseInt(day,10);
		var toMonth = parseInt(month,10);
		var toYear	= parseInt(year,10);
		
		//alert(toDay);
		//alert(toMonth);
		//alert(toYear);
		
		if (toYear  < 1900 || toYear > 2100)
			return false;
		if (toMonth < 1 || toMonth > 12 )
			return false;
		if (toDay < 1 || toDay > 31)
			return false;	
		return true;
	}

	function isNullRadioButton(formField,buttonNumber)
	{
		if(formField[buttonNumber].checked)
			return true;
		else
			return false;
	}		

	function isNullCheckBox(fieldName,fieldText,fieldNo){
		var emptyCheckBox = true;
			for(i=1;i<fieldNo+1;i++)
				{			
					if(document.getElementById(fieldName+i).checked)
						emptyCheckBox = false;	
				}
				if(emptyCheckBox)
				alert("Please tick checkbox for '"+fieldText+"'");
		return emptyCheckBox;
	}

	function isNullDropDown(formField,fieldLabel) {
		var value = new String(formField.value);
		var field = new String(fieldLabel);
		if (formField.value == "N/A") {
			alert("Please select '" + field + "'.");
			formField.focus();
			return true;
		}
			return false;
	}

	function isNullDropDown2(formField,fieldLabel,defaultValue) {
		var value			= new String(formField.value);
		var defaultValue	= new String(defaultValue);
		var field			= new String(fieldLabel);
		if (formField.value == defaultValue) {
			alert("Please select '" + field + "'.");
			formField.focus();
			return true;
		}
			return false;
	}
		
	function isEmptyField(formField,fieldLabel) {
		//convert the input value into a string
		var value = new String(formField.value);
		//convert the name of the element into a string for alert
		var field = new String(fieldLabel);
		
			//if the length of the input is not greater than 0
			if (!value.length > 0) {
				alert("Please enter '" + field + "'.");
				formField.select();
				return true;
			} //end if
			
			return false;
	}	

	function CheckInteger(formField,fieldLabel,required) {
		//convert the input value into a string
		var value = new String(formField.value);
		//extract the integer from the string
		checkvalue = parseInt(value); 
		//convert the name of the element into a string for alert
		var field = new String(fieldLabel);
		
		//if required
		if (required) {
			if (isEmptyField(formField,fieldLabel))
				return true;
		} else {
			if (CheckNotNullNoError(formField,fieldLabel)) {
				formField.value = 0;
				return false;
			} 
		}
		if (checkvalue != value && value.length != 0) {
			alert("Please enter digits only for '"  +field+ "'");
			formField.select();
			return true;
		} //end if
		return false;
	}


	function CheckDecimal(formField,fieldLabel,required,decimals) {
		//convert the input value into a string
		var value = new String(formField.value);
		//extract the integer from the string
		checkvalue=parseFloat(value); 
		//convert the name of the element into a string for alert
		var field = new String(fieldLabel);
		
		//if required
		if (required) {
			//check if null
			if (CheckNotNull(formField,fieldLabel)) {
				return true;
			}
		} 

		//if the checkvalue which will only be numbers does not equal the value
		if (checkvalue != value && value.length != 0) {
			alert("Please enter decimal number for '"  +field+ "'");
			formField.select();
			return true;
		} //end if
		//formField.value = (Math.round(checkvalue*decimals*10))/(decimals*10);
		return false;
	}

	
	function CheckNotNullNoError(formField,fieldLabel) {
		//convert the input value into a string
		var value = new String(formField.value);
		//convert the name of the element into a string for alert
		var field = new String(fieldLabel);
		
		//if the length of the input is not greater than 0
		if (!value.length > 0) {
			return true;
		} //end if
		return false;
	}
	
	 
	function CheckDateNotBeforeNow(formField,fieldLabel) {
		//convert the name of the element into a string for alert
		var field = new String(fieldLabel);
		//make value equal to the input value
		var value = new String(formField.value);
		//Todays Date
		var now = new Date();
		
		//Pull current date apart into its various parts
		var currDay = now.getDate();
		var currMonth = now.getMonth();
		var currYear = now.getFullYear();
		
		//pull the date apart into it respective values
		//and make them valid ints
		var inDay = value.substr(0,2);
		inDay = parseInt(inDay);
		var inMonth = value.substr(3,2);
		inMonth = parseInt(inMonth);
		if (value.length == 8) {
			var inYear = value.substr(6,2);
			inYear = parseInt(inYear);
			//Because year is only 2 digit make it 4
			var year = new String(currYear);
			year = year.substr(0,2);
			year = parseInt(year);
			if (inYear < 50) {
				inYear = year*100 + inYear;
			} else {
				inYear = (year-1)*100 + inYear;
			}
		} else {
			var inYear = value.substr(6,4);
			inYear = parseInt(inYear);
		}
		
		//Check if date is before or after todays date by doing three comparsions
		if (inYear > currYear) {
			alert("The date in the " + field + " must be before todays date");
			formField.focus();
			return true;
		} else {
			return false;
		}
		if (inMonth > currMonth) {
			alert("The date in the " + field + " must be before todays date");
			formFeld.focus();
			return true;
		} else {
			return false;
		}
		if (inDay > currDay) {
			alert("The date in the " + field + " must be before todays date");
			formField.focus();
			return true;
		} else {
			return false;
		}
	}


	function CheckString(formField,fieldLabel,stringType,miniLength,required) {
		//convert the input value into a string
		var value = new String(formField.value);
		//stores all the valid values in a string
		switch(stringType){		
			case "password":			
			var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
			break;							
			case "name":		
			var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- "
			break; 			
		}			
		//a variable stores if the string is valid or not
		var ok = "yes";
		//a temporary variable to the loop
		var temp;
		//convert the name of the element into a string for alert
		var field = new String(fieldLabel);
		
		//if required
		if (required) {
			//check if null
			if (CheckNotNull(formField,fieldLabel)) {
				return true;
			} 
		} else {
			//check if null
			if (CheckNotNullNoError(formField,fieldLabel)) {
				return false;
			} 
		}
		
		if (formField.value.length < miniLength)	{
			alert('"'+fieldLabel + '" can not be less than ' + miniLength + ' letters or digits');
			formField.select();
			return true;
		}
		//for loop going through checking if each value in the string is in 
		//is in the variable valid
		for (var i=0; i<value.length; i++) {
			temp = "" + value.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "no";
		} //end for

		//if ok is equal to null
		if (ok == "no") {
			alert("Invalid input for " + field + ",Try Again");
			formField.select();
			return true;
   		} //end if
		return false;
	}	

	function CheckDate(formField,fieldLabel,required) {
		var field 		= new String(fieldLabel);
		var dateLength 	= new String(formField);
		var value 		= new String(formField.value);
		var valid 		= "1234567890/-"
		var ok 			= "yes";
		var strDateArray;
		strDateArray = value.split("/");

		if (!required&&value.length==0)
		{
			return false;		
		}
		else // if required or 
		{
			if (value.length!=0 || required)
				{	
					// check 
					if (isEmptyField(formField,fieldLabel))
						 return true;
					 
					if (value.length > 10 || value.length < 8 )
					{
						alert("Please enter '" + field +"' in DD/MM/YYYY format.");
						formField.select();
						return true;
					}
			
					for (var i=0; i<value.length; i++)
					{
						temp = "" + value.substring(i, i+1);
						if (valid.indexOf(temp) == "-1") ok = "no";
					} //end for
					
					if (strDateArray.length != 3 ){
						alert("Please enter '" + field +"' in DD/MM/YYYY format.");
						formField.select();
						return true;		
					}
					
					if (!chkdate(formField,fieldLabel))
					{
						alert("Please enter '" + field +"' in DD/MM/YYYY format.");
						formField.select();
						return true;
						//else if the the chkdate returns true
					} 
					else
					{
						return false;
					}//end if
				}
				else
				{
					return true;
				} // end of second if
		} // end of first if
	}// end of function

	//----------------------------------------------------------------------------
	
	
	
	/* ---------------------------------------------------------------------------
	 * FUNCTION NAME: chkdate
	 * ---------------------------------------------------------------------------
	 * FUNCTION DESCRIPTION: This function does the checking of the date for 
	 * checkdate. Uses a helper method to check if the year is a leap year or not
	 * ---------------------------------------------------------------------------
	 * PARAMETERS: Formvalue -> Value of the field being checked
	 * ---------------------------------------------------------------------------
	 */
	
	function chkdate(formField,fieldLabel) {
		//declares all the variables used in this function
		var strDate;
		var strDateArray;
		var strDay;
		var strMonth;
		var strYear;
		var intday;
		var intMonth;
		var intYear;
		var booFound = false;
		var intElementNr;
		var err = 0;

		//an array which store all the value seperators 
		//Used if all seperators are valid
		//var strSeparatorArray = new Array("/",".","-");
		var strSeparatorArray = new Array("/");

		var strDate = new String(formField.value);

		//for loop which breaks the date into three parts, day, month and year
		for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
			//if the 
			if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
				strDateArray = strDate.split(strSeparatorArray[intElementNr]);
				if (strDateArray.length != 3) {
					err = 1;
					return false;
				} else {
					strDay 		= strDateArray[0];
					strMonth 	= strDateArray[1];
					strYear 	= strDateArray[2];
				}
			booFound = true;
   			}
		}

		if (booFound == false) {
			if (strDate.length>5) {
				strDay = strDate.substr(0, 2);
				strMonth = strDate.substr(2, 2);
				strYear = strDate.substr(4);
   			}
		}

		if (strYear.length == 2) {
			strYear = '20' + strYear;
		}

		intday = parseInt(strDay, 10);

		if (isNaN(intday)) {
			err = 2;
			return false;
		}

		intMonth = parseInt(strMonth, 10);

		if (isNaN(intMonth)) {
			if (isNaN(intMonth)) {
				err = 3;
				return false;
   			}
		}

		intYear = parseInt(strYear, 10);
		
		if (isNaN(intYear)) {
			err = 4;
			return false;
		}

		if (intMonth>12 || intMonth<1) {
			err = 5;
			return false;
		}
		
		if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
			err = 6;
			return false;
		}

		if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
			err = 7;
			return false;
		}

		if (intMonth == 2) {
			if (intday < 1) {
				err = 8;
				return false;
			}
			if (LeapYear(intYear) == true) {
				if (intday > 29) {
					err = 9;
					return false;
				}
			} else {
				if (intday > 28) {
					err = 10;
					return false;
				}
			}
		}
		
		return true;
	}

	//----------------------------------------------------------------------------
	
	/* ---------------------------------------------------------------------------
	 * FUNCTION NAME: LeapYear
	 * ---------------------------------------------------------------------------
	 * FUNCTION DESCRIPTION: This function is a helper method for chkdate, it 
	 * determines whether the year in the date being checked is a leap year
	 * ---------------------------------------------------------------------------
	 * PARAMETERS: intYear -> The year being checked
	 * ---------------------------------------------------------------------------
	 */

	function LeapYear(intYear) {
		if (intYear % 100 == 0) {
			if (intYear % 400 == 0) { return true; }
		} else {
			if ((intYear % 4) == 0) { return true; }
		}
		return false;
	}

	//----------------------------------------------------------------------------

	/* ---------------------------------------------------------------------------
	 * FUNCTION NAME: doDateCheck
	 * ---------------------------------------------------------------------------
	 * FUNCTION DESCRIPTION: This function checks whether the first date is before
	 * the second date.
	 * ---------------------------------------------------------------------------
	 * PARAMETERS: formField1 -> The the reference name of the first field being 
	 *                           checked
	 *             formLabel1 -> A string representing the first field
	 *	       formField2 -> The the reference name of the second field being 
	 *                           checked
	 *             formLabel2 -> A string representing the second field
	 * ---------------------------------------------------------------------------
	 */

	function doDateCheck(formField1,formField2,fieldLabel1,fieldLabel2) {
		//Create String objects of all the fields
		var fieldvalue1 = new String(formField1.value); 
		var fieldvalue2 = new String(formField2.value); 
		var field1 = new String(fieldLabel1);
		var field2 = new String(fieldLabel2);

		//break apart the date to be compared
		tempDate1 = new String(fieldvalue1);
		date1length = fieldvalue1.length;
		pos = tempDate1.indexOf("/");
		day1 = tempDate1.substring(0,pos);
		if (day1.length == 1) {
			day1 = "0" + day1;
		}
		tempDate1 = tempDate1.substr(pos+1,date1length-pos-1)

		pos = tempDate1.indexOf("/");
		month1 = tempDate1.substring(0,pos);
		if (month1.length == 1) {
			month1 = "0" + month1;
		}
		tempDate1 = tempDate1.substr(pos+1,date1length-pos-1);
		year1 = tempDate1;
		
		tempDate2 = new String(fieldvalue2);
		date2length = fieldvalue2.length;
		pos = tempDate2.indexOf("/");
		day2 = tempDate2.substring(0,pos);
		if (day2.length == 1) {
			day2 = "0" + day2;
		}
		tempDate2 = tempDate2.substr(pos+1,date2length-pos-1)
		pos = tempDate2.indexOf("/");
		month2 = tempDate2.substring(0,pos);
		if (month2.length == 1) {
			month2 = "0" + month2;
		}
		tempDate2 = tempDate2.substr(pos+1,date2length-pos-1);
		year2 = tempDate2;


		//date1 must be before date2
		if (year1 > year2) {
			result = true;
		} else if (year1 == year2) {
			if (month1 > month2) {
				result = true;
			} else if (month1 == month2) {
				if (day1 > day2) {
					result = true;
				} else if (day1 == day2) {
					result = false;
				} else {
					result = false;
				}
			} else {
				result = false;
			}
		} else {
			result = false;
		}
		
		//determine assault
		if (result) {
			alert(field2 + " must occur after the " + field1);
			return true;
		} else {
			return false;
		}	
	}
	
	//----------------------------------------------------------------------------

	/* ---------------------------------------------------------------------------
	 * FUNCTION NAME: validEmail
	 * ---------------------------------------------------------------------------
	 * FUNCTION DESCRIPTION: This function checks whether the email address being
	 * passed to it is a valid one. Returns true if it is NOT a valid email.
	 * ---------------------------------------------------------------------------
	 * PARAMETERS: formField -> The the reference name of the field being checked
	 *             formLabel -> A string representing the field
	 *             required -> A boolean value representing if the formField can 
	 *                         equal NULL
	 * ---------------------------------------------------------------------------
	 */
function invalidEmail(formField,fieldLabel,required) {
		var result = false;
		
		//if required and it is null
		if (required && isEmptyField(formField,fieldLabel))
			result = true;
		//end if

		//if it is a valid email 
		if(!result){
			if (formField.value.length < 3)
			{
				alert("Please enter email in correct format: yourname@yourdomain.com");
				formField.select();
				result = true;
			}
		}

		if(!result){
			if (!isEmailAddr(formField.value)) {
				alert("Please enter email in correct format: yourname@yourdomain.com");
				formField.select();
				result = true;
			}
		}
   
  		return result;
	}

	//----------------------------------------------------------------------------

	/* ---------------------------------------------------------------------------
	 * FUNCTION NAME: isEmailAddr
	 * ---------------------------------------------------------------------------
	 * FUNCTION DESCRIPTION: This function is a helper function for validEmail it 
	 * simply checks if the email has a "@" and "." in it in the right order.
	 * ---------------------------------------------------------------------------
	 * PARAMETERS: email -> Value of the email being checked
	 * ---------------------------------------------------------------------------
	 */

	function isEmailAddr(email) {
  		var result = false;
  		var theStr = new String(email);
  		var index = theStr.indexOf("@");

  		if (index > 0) {
   			var pindex = theStr.indexOf(".",index);
   			if ((pindex > index+1) && (theStr.length > pindex+1))
				result = true;
 		}
  		return result;
	}


	//----------------------------------------------------------------------------

	/* ---------------------------------------------------------------------------
	 * FUNCTION NAME: checkTime
	 * ---------------------------------------------------------------------------
	 * FUNCTION DESCRIPTION: This function checks whether the given value is a 
	 * value time eg. HH:MM (in 24hr time) or HH:MM:SS AM/PM (in 12hr time) 
	 * ---------------------------------------------------------------------------
	 * PARAMETERS: formField -> The the reference name of the field being checked
	 *             formLabel -> A string representing the field
	 *             required -> A boolean value representing if the formField can 
	 *                         equal NULL
	 * ---------------------------------------------------------------------------
	 */

	function checkTime(formField,fieldLabel,required) {
		//convert the input value into a string
		var value = new String(formField.value);
		//find the length of the date
		var length = value.length;
		//find the index of the first colon
		var ColIndex = value.indexOf(":");

		//if required
		if (required) {
			//check if null
			if (CheckNotNull(formField,fieldLabel)) {
				return true;
			} 
		} else {
			//check if null
			if (CheckNotNullNoError(formField,fieldLabel)) {
				formField.value = "00:00";
				return false;
			} 
		}

		if (length > 5) {
			if (length > 11 || ColIndex < 0) {
				alert("The " + fieldLabel +" is invalid. \n Please use the format HH:MM (in 24hr time) or HH:MM:SS AM/PM (in 12hr time).");
				formField.select();
				return true;
			} else {
				hr = value.substring(0,ColIndex);
				temp = value.substring(ColIndex+1,length);
				Col2Index = temp.indexOf(":");
				min = temp.substring(0,Col2Index);
				SpaceIndex = temp.indexOf(" ");
				sec = temp.substring(Col2Index+1,SpaceIndex);
				period = temp.substr(SpaceIndex+1,2);
				if (Col2Index < 0 || SpaceIndex < 0) {
					alert("The " + fieldLabel +" is invalid. \n Please use the format HH:MM (in 24hr time) or HH:MM:SS AM/PM (in 12hr time).");
					formField.select();
					return true;
				} else {
					if (hr > 12 || hr < 0) {
						alert("The " + fieldLabel +" is invalid. \n Please use the format HH:MM (in 24hr time) or HH:MM:SS AM/PM (in 12hr time).");
						formField.select();
						return true;
					}
					if (min > 59 || min < 0) {
						alert("The " + fieldLabel +" is invalid. \n Please use the format HH:MM (in 24hr time) or HH:MM:SS AM/PM (in 12hr time).");
						formField.select();
						return true;
					}
					if (sec > 59 || sec < 0) {
						alert("The " + fieldLabel +" is invalid. \n Please use the format HH:MM (in 24hr time) or HH:MM:SS AM/PM (in 12hr time).");
						formField.select();
						return true;
					}
					if (period != "PM" && period != "AM") {
						alert("The " + fieldLabel +" is invalid. \n Please use the format HH:MM (in 24hr time) or HH:MM:SS AM/PM (in 12hr time).");
						formField.select();
						return true;
					}
				}
			}
		} else {
			if (ColIndex > 0) {
				hr = value.substring(0,ColIndex);
				min = value.substring(ColIndex+1,length);
				if (hr > 23 || hr < 0) {
					alert("The " + fieldLabel +" is invalid. \n Please use the format HH:MM (in 24hr time) or HH:MM:SS AMPM (in 12hr time).");
					formField.select();
					return true;
				}
				if (min > 59 || min < 0) {
					alert("The " + fieldLabel +" is invalid. \n Please use the format HH:MM (in 24hr time) or HH:MM:SS AMPM (in 12hr time).");
					formField.select();
					return true;
				}
				return false;
			} else {
				alert("The " + fieldLabel +" is invalid. \n Please use the format HH:MM (in 24hr time) or HH:MM:SS AMPM (in 12hr time).");
				formField.select();
				return true;
			}
		}
		return false;
	}
		
	
	function CheckDateRange(formField,fieldText,range1,range2){		
		var currDay  = new Date();		
		var passDay  = new Date(formField.value);     
		
		var passYear 	= parseInt(passDay.getFullYear());
		var currentYear = parseInt(currDay.getFullYear());
		var yearDiff    = currentYear - passYear;
		if (yearDiff > range1 && yearDiff < range2 ){
			return true;
		}
		else{
			alert("The '"+fieldText+"' field must be between '"+range1+"' and '"+range2+"'");			
			formField.select();
			return false;
		}
	}
	
	function CheckYearRange(formField,fieldText,range1,range2){		
		var passDay  	= new Date(formField.value);     		
		var passYear 	= parseInt(passDay.getFullYear());
		if (passYear >= range1 && passYear <= range2 ){
			return true;
		}
		else{
			alert("The '"+fieldText+"' must be between '"+range1+"' and '"+range2+"'");			
			formField.select();
			return false;
		}
	}
	
	function CheckIntergerRange(formField,fieldLabel,range1,range2){		
		//convert the input value into a string
		var value = new String(formField.value);
		//convert the name of the element into a string for alert
		var field = new String(fieldLabel);		
		value	  = parseInt(value);
		if (value >= range1 && value <= range2 ){
			return true;
		}
		else{
			alert("The '"+fieldLabel+"' must be between '"+range1+"' and '"+range2+"'");			
			formField.select();
			return false;
		}
	}
	
	
	function isDecimal(formField,fieldLabel) {
		//convert the input value into a string
  		var theStr = new String(formField.value);
  		//search for .
  		var index = theStr.indexOf(".");
  		
		if (index != 1 && theStr != "") {
  			alert(fieldLabel + " must be in decimal (N.N)! ");
  			formField.select();
			return false;
 		}
		else {
	  		return true;
		}
		

	}
	
	function checkPassword(formField,fieldLabel)
	{
		var result = true;
		if (formField.value == "")
		{
			alert('Please enter a value for the "' + fieldLabel +'" field.');
			formField.focus();
			result = false;
		}
		else if (formField.value.length < 4)
		{
			alert('Field "' + fieldLabel + '" can not be less than 4 letters or digits');
			formField.focus();
			result = false;
		}
		if (result){
			if(!chkvalidPass(formField,fieldLabel))
			{
				result = false;
			}
		}
		return result;
	}
	
	function chkvalidPass(formField,fieldLabel)
	{
		var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
		var checkStr = formField.value;
		var allValid = true;
		for (var i = 0;  i < checkStr.length;  i++)
		{
			ch = checkStr.charAt(i);
			for (var j = 0;  j <checkOK.length;  j++)
			{
				if (ch == checkOK.charAt(j))
			    break;
			}
			if (j == checkOK.length)
			{
				allValid = false;
				break;
			}
		}
		if (!allValid)
		{
			alert('Enter letters and digits only');
			formField.focus();
			return false;
		}
		else {
			return true;
		}
	}
	
	function exceedTextLength(formField,fieldLabel,textLength) {
		var value = new String(formField.value);
		var field = new String(fieldLabel);

		if (value.length < 1)
		{
			alert("Please enter '"+field+"'")
			formField.select();
			return true;
		}

		if (value.length > textLength ) {
			alert("Please enter maximum of "+textLength+" characters in '"  +field+ "'");
			formField.select();
			return true;
		}		
		return false;		
	}

	function isNullSingleCheckBox(fieldName,fieldText,fieldValue){
		if (formField.value !=fieldValue)
		{
			alert("Please tick checkbox for '"  +fieldText+ "'");
			formField.select();
			return true;
		}
		return false;
	}