/*
	Website scripts
	(c) BDesigned Studios
*/





function openWindow(address,winurl,winwidth,winheight) {
	var new_window = window.open(address,winurl,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=' + winwidth + ',height=' + winheight);
}

function popup_centre(popupwidth,popupheight) {
	/* When calling this function supply the width and height of the popup */
	var horizontal = ((screen.availWidth / 2) - (popupwidth / 2));
	var vertical = ((screen.availHeight / 2) - (popupheight / 2));
	window.moveTo(horizontal,vertical);
}

function validateReservation() {
	var errormessage = 'Please ensure that you have completed the following:\n';
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if(
	   (document.booking_form.forename.value != '') &&
	   (document.booking_form.surname.value != '') &&
	   (filter.test(document.booking_form.emailaddress.value)) &&
	   (document.booking_form.dateofres.value != '') &&
	   (document.booking_form.timeofres.value != '') &&
	   (document.booking_form.noofpeople.value != '')
	  ) {
			document.booking_form.submit();
	} else {
		if(document.booking_form.forename.value == '') {
			errormessage += "  > Your first name\n";
		}
		if(document.booking_form.surname.value == '') {
			errormessage += "  > Your last name\n";
		}
		if(document.booking_form.emailaddress.value == '') {
			errormessage += "  > Email address\n";
		} else {
			if((filter.test(document.booking_form.emailaddress.value)) == false) {
				errormessage += "  > You must enter a valid email address\n";
			}
		}
		if(document.booking_form.dateofres.value == '') {
			errormessage += "  > A reservation date\n";
		}
		if(document.booking_form.timeofres.value == '') {
			errormessage += "  > A time of reservation\n";
		}
		if(document.booking_form.noofpeople.value == '') {
			errormessage += "  > Number of people\n";
		}
		alert(errormessage);
	}
}
