function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
		for(i=0; i < e.length ;i++){
			if(ok.indexOf(e.charAt(i))<0){ 
				return (false);
			}
		} 
		if (document.images) {
			re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
			re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
			if (!e.match(re) && e.match(re_two)) {
				return (-1);		
			} 
		}
	}
	
function check_form(theform) {
	if (theform.theirname.value=='') {
		alert('Please enter your name');
		theform.theirname.style.backgroundColor='yellow';
		theform.theirname.focus();
		return false;
	} else {
		if (theform.address1.value=='') {
			alert('Please enter the first line of your address');
			theform.address1.style.backgroundColor='yellow';
			theform.address1.focus();
			return false;
		} else {
			if (theform.city.value=='') {
				alert('Please enter your town or city');
				theform.city.style.backgroundColor='yellow';
				theform.city.focus();
				return false;
			} else {
				if (theform.address1.value=='') {
					alert('Please enter the first line of your address');
					theform.address1.style.backgroundColor='yellow';
					theform.address1.focus();
					return false;
				} else {
					if (theform.zip.value=='') {
						alert('Please enter your postcode');
						theform.zip.style.backgroundColor='yellow';
						theform.zip.focus();
						return false;
					} else {
						if(theform.email.value=='' || !check_email(theform.email.value)) {
							alert('Please enter a valid email address');
							theform.email.style.backgroundColor='yellow';
							theform.email.focus();
							return false;
						} else {
							if(!theform.oversixteen.checked) {
								alert('Sorry! You must be over sixteen years of age.');
								theform.oversixteen.style.backgroundColor='yellow';
								theform.oversixteen.focus();
								return false;
							} else {
								theform.doit.value='Please Wait...';
								theform.doit.disabled=true;
								return true;
							}
						}
					}
				}
			}
		}
	}
}