function settrue(fieldname) {
	document.getElementById(fieldname).setAttribute("value", 1);
}

function setfalse(fieldname) {
	document.getElementById(fieldname).setAttribute("value", 0);
}

function cleartext(fieldname) {
	document.getElementById(fieldname).value = "";
}

function regExpCheck(text) {
	var myRegExp = /^[^ a-z0-9._-]/i;
	return !(myRegExp.test(text)); 
}

function regExpEmailCheck(text) {
	var myRegExp = /^[a-z0-9._-]{1,30}@[a-z0-9._-]{1,30}.[com|edu|gov|net|org]$/i;
	return (myRegExp.test(text));
}

function regExpUNIDCheck(text) {
	var myRegExp = /^u?[0-9]{0,8}$/i;
	return (myRegExp.test(text));
}

function verify() {
	var themessage = "You are required to complete the following fields:\n";
	
	if (document.form.event_name.value == "") {
		themessage = themessage + "\tName of event\n";
	}
	if (document.form.event_date.value == "") {
		themessage = themessage + "\tDate\n";
	}
	if (document.form.event_time.value == "") {
		themessage = themessage + "\tTime\n";
	}
	if (document.form.event_location.value == "") {
		themessage = themessage + "\tLocation\n";
	}
	if (document.form.assistance_needed.value == "") {
		themessage = themessage + "\tAssistance needed\n";
	}
	if (document.form.contact_name.value == "") {
		themessage = themessage + "\tContact's name\n";
	}
	if (document.form.contact_email.value == "") {
		themessage = themessage + "\tE-mail address\n";
	}
	if (document.form.contact_phone.value == "") {
		themessage = themessage + "\tPhone number\n";
	}
			
	//make sure there are no errors from empty required fields
	if (themessage == "You are required to complete the following fields:\n") {
		
		//if no errors have been found so far, check for valid data in the fields
		themessage = "The following fields contain invalid data:\n";
		if (regExpCheck(document.form.event_name.value) == false) {
			themessage = themessage + "\tName of event\n";
		}
		if (regExpCheck(document.form.event_date.value) == false) {
			themessage = themessage + "\tDate\n";
		}
		if (regExpCheck(document.form.event_time.value) == false) {
			themessage = themessage + "\tTime\n";
		}
		if (regExpCheck(document.form.event_location.value) == false) {
			themessage = themessage + "\tLocation\n";
		}
		if (regExpCheck(document.form.assistance_needed.value) == false) {
			themessage = themessage + "\tAssistance needed\n";
		}
		if (regExpCheck(document.form.other_comments.value) == false) {
			themessage = themessage + "\tOther comments\n";
		}
		if (regExpCheck(document.form.contact_name.value) == false) {
			themessage = themessage + "\tContact's name\n";
		}
		if (regExpEmailCheck(document.form.contact_email.value) == false) {
			themessage = themessage + "\tE-mail address\n";
		}
		if (regExpCheck(document.form.contact_phone.value) == false) {
			themessage = themessage + "\tPhone number\n";
		}
		
		if (themessage == "The following fields contain invalid data:\n") {
			document.form.submit();	
		}	else {
			alert(themessage);
			return false;
		}
	}
	else {			
		alert(themessage);
		return false;
	}
}