function validate(thisForm){

	//eval("var thisForm = document." + thisForm);

	//pass an instance of our form
	var noOfElements=thisForm.elements.length;

	var strEmptyTextBox="" , strConfirm="";
	var intEmptyCount=0;
	var anyEmpty=false;
	var intFocusWhere=0;
	var noOfOptions;
	var blFocusNeeded=false;

	for (var i=0; i < noOfElements; i++){
	
	//checks to see if any input field is left blank, skip if theres a select list or buttons
	//checks only for fields with * in name field, this will only work is we place the * at the
	//last position of the form element name, e.g. firstname*, email*, occupation* et.

		if ((thisForm.elements[i].type=="text" ||
			thisForm.elements[i].type == "password" || 
			thisForm.elements[i].type == "textarea") &&
			(thisForm.elements[i].name.indexOf("*") > -1)){

			var asteriskPosition = thisForm.elements[i].name.indexOf("*");
			//show to the user the form element name without the asterisk
			var noAsteriskName = thisForm.elements[i].name.substring(0, asteriskPosition);

			if ((thisForm.elements[i].value==null) ||  (thisForm.elements[i].value=="")){
			
				if (!blFocusNeeded) {
					intFocusWhere=i; blFocusNeeded=true
				}
			
				if (thisForm.elements[i].type != "submit" || 
					thisForm.elements[i].type != "select-one" ||
					thisForm.elements[i].type != "reset" ||
					thisForm.elements[i].type != "button"){
			
					strEmptyTextBox += noAsteriskName + "\n";
					intEmptyCount += 1; 
					anyEmpty=true;
				}
			}
		}
	}
		

	if (anyEmpty){
		
		if (noOfElements == intEmptyCount){
			return false
		}
		else {
			strAlert= "The " + intEmptyCount + " required field(s) are empty : \n" 
			 + "----------------------------\n\n" 
			 + strEmptyTextBox + "\n"
			 + "----------------------------\n\n" 
			 + "Please enter the required data.\n\n" 
			 
			alert(strAlert);
			thisForm.elements[intFocusWhere].focus();

			return false;
		}
	} 
	
	else{
		//remove the asterisks in the form name before submission
		for (var i=0; i < noOfElements; i++){
			var aster=thisForm.elements[i].name.indexOf("*");

			if( aster > -1){
				thisForm.elements[i].name = thisForm.elements[i].name.substring(0, aster);
			}
		//alert(thisForm.elements[i].name + " " + i);
		}
		return true;
	}

}
function validEmail(form){
	if (form.emailadd.value.match(emailFilter) == null)
	{
		form.emailadd.focus();
		form.emailadd.select();
		alert("Invalid email address.");
		return false;
	}
}