function RB_ViewEvent (id) {
	var thisform=document.forms[0];
	thisform.dbAction.value=id;
	if (id.substring(0,2)=='sd') {
		// sort by date event
	} else if (id.substring(0,2)=='so') {
		// sort by office event
	} else if (id.substring(0,2)=='cc') {
		//alert('Changing course selection: id ='+thisform.title.value);
		thisform.dbAction.value=id+thisform.title.value;
		thisform.action=thisform.thisScript.value;
		//alert(thisform.dbAction.value);
	}
	thisform.submit();
}

function validateForm() {
	flag=0
	var thisform=document.f1;
	if (thisform.firstName.value == "") {
		alert("Please provide a first name");
		flag++;
	}
	if (thisform.lastName.value == "") {
		alert("Please provide a last name");
		flag++;
	}
	// validate email address
	if (thisform.email.value == "") {
		alert("Please provide an email address");
		flag++;
	}
	else
	{
		var user = /^\w+/;
		var dom = /\w+(\.\w{2,})+$/g;
		user = thisform.email.value.match(user);
		company = thisform.email.value.match(dom);
		if (thisform.email.value.indexOf('@') == -1 || user == null || company == null) {
			alert("Please provide a valid email address");
			flag++;
		}
	}
	// validate company data
	if (thisform.company.value == "") {
		alert("Please provide your organisation's name. If the registration is personal, please write personal");
		flag++;
	}
	//validate address
	if (thisform.postaladdress.value == "") {
		alert("Please provide an address");
		flag++;
	}
	//check privacy statement checked
	if (thisform.privacy.checked == false) {
		alert("Please confirm you have read the Privacy statement by ticking the box");
		flag++;
	}

/*	commented out 2007-10-08 (gareth Bevan) -- contact method not needed

if (thisform.contactVia[0].checked) {
		
	} 
	if (thisform.contactVia[1].checked) {
		// validate address data
		if (thisform.address.value == "") {
			alert("Please provide an address");
			flag++;
		}
		if (thisform.townCity.value == "") {
			alert("Please provide a town or city");
			flag++;
		}
		if (thisform.county.value == "") {
			alert("Please provide a county");
			flag++;
		}
		if (thisform.country.value == "") {
			alert("Please provide a country");
			flag++;
		}
		if (thisform.postCode.value == "") {
			alert("Please provide a post code");
			flag++;
		}
	} 
	if (thisform.contactVia[2].checked) {
		// validate phone number
		if (thisform.telNumber.value == "") {
			alert("Please provide a telephone number");
			flag++;
			}
	}
*/
	if (flag==0){
		return true;
	} else {
		(flag==1)?xx="item":xx="items";
		(flag==1)?yy="is":yy="are";
		alert("We are sorry, but there "+yy+" "+flag+" "+xx+" which you must fill in before the form can be sent.");
		return false;
	}
}

function validateContactForm() {
	flag=0
	var thisform=document.enquiryform;
	
	//validate name
	if (thisform.contactname.value == "") {
		alert("Please provide your name");
		flag++;
	}
	else
	{
		if(thisform.contactname.value.length>100) {
			alert("Your name must be less than 100 characters long");
			flag++;
		}
	}
	// validate email address
	if (thisform.email.value == "") {
		alert("Please provide an email address");
		flag++;
	} else {
		var user = /^\w+/;
		var dom = /\w+(\.\w{2,})+$/g;
		user = thisform.email.value.match(user);
		company = thisform.email.value.match(dom);
		if (thisform.email.value.indexOf('@') == -1 || user == null || company == null) {
			alert("Please provide a valid email address");
			flag++;
		}	
	}

	// validate telephone
	if(thisform.telNumber.value.length>20) {
		alert("Your telehpne number must be less than 20 characters long");
		flag++;
	}
	
	// validate enquiry
	if (thisform.TBEnquiry.value == "") {
		alert("Please provide a brief description of your enquiry");
		flag++;
	} else {
		if(thisform.TBEnquiry.value.length>500) {
			alert("Your enquiry must be less than 500 characters long");
			flag++;
		}
	}	

	
	if (flag==0){
		return true;
	} else {
		(flag==1)?xx="item":xx="items";
		(flag==1)?yy="is":yy="are";
		alert("We are sorry, but there "+yy+" "+flag+" "+xx+" which you must fill in before the form can be sent.");
		return false;
	}
}
