function checkEmail(mailaddr) {
	at2 = mailaddr.lastIndexOf("@");
	dot = mailaddr.lastIndexOf(".");

	if (at2 < 1 || dot < (at2+2) || (dot + 3) > mailaddr.length){
		return false;
	}
	return true;
}
function email2Check(theForm) {
	var x = checkEmail(theForm.email.value);
	if (!x){
		alert ("Please enter a valid email address");
	}
	return x;
}
function subscribeCheck(theForm) {
	ok = email2Check(theForm);
	if (!ok){
		return;
	}
	theForm.action.value="subscribe";
	theForm.submit();
}
function unsubscribeCheck(theForm) {
	ok = email2Check(theForm);
	if (!ok){
		return;
	}
	theForm.action.value="unsubscribe";
	theForm.submit();
}
function fixMenuForm(validate, searchWhat){
	if (document.findformmenubar.ourRef.value.length > 0){
		if (validate && document.findformmenubar.speedSearch.value.length > 0){
			alert("Please clear either the speed search box or the Evans ref box");
			document.findformmenubar.speedSearch.focus();
			return false;
		}
		document.findformmenubar.searchWhat.value=4;
		document.findformmenubar.searchFor.value=document.findformmenubar.ourRef.value;
	}else if (document.findformmenubar.speedSearch.value.length > 0){
		document.findformmenubar.searchWhat.value=searchWhat;
		document.findformmenubar.searchFor.value=document.findformmenubar.speedSearch.value;
	}
	return true;
}
function findItEx(){
	if (fixMenuForm(true, 7)){
		submitNewFind(document.findformmenubar);
	}
}
function findIt(){
	if (fixMenuForm(true, 1)){
		submitNewFind(document.findformmenubar);
	}
}
function findBike(){
	if (document.formbikefinder.sortDirection)
		document.formbikefinder.sortDirection.value=2;
	submitNewFind(document.formbikefinder);
}
function submitNewFind(theForm){
	if (theForm.page)
		theForm.page.value=1;
	theForm.submit();
}
function submitFind(theForm, page){
	if (page){
		theForm.page.value=page;
	}
	fixMenuForm(false, theForm.searchWhat.value);
	theForm.submit();
}
