function BeforeSubmit() {
	var  checkcount=0;
	if(document.searchform.user.checked){
		checkcount=checkcount + 1;
	}
	if(document.searchform.album.checked){
		checkcount=checkcount + 1;
	}
	if(document.searchform.event.checked){
		checkcount=checkcount + 1;
	}
	if(checkcount == 0){
		alert("Please select what to search for (events, albums. photographers)");
		return false;
	}
	if(document.searchform.searchtext.value.length < 3){
		alert("You need to enter a search text with at least 3 characters!");
		return false;
	}
	if(document.searchform.searchtext.value.indexOf('"') > -1) {
		alert('The " (double quote) character is not allowed in a search');
		return false;
	}
}		

function BeforeFindSubmit() {

	if(trim(document.findphotos.photoname.value) == ""){
		alert("Please enter the name of a photo to search for");
		document.findphotos.photoname.value = trim(document.findphotos.photoname.value);
		return false;
	}
	if(document.findphotos.photoname.value.indexOf('"') > -1) {
		alert('The " (double quote) character is not allowed in a search');
		return false;
	}
}		

function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}
