// JavaScript Document
function submitForm()
{
	if (trimStr(document.jubilee_registration.firstname.value).length <= 0)
	{
		alert("Please enter the First Name");
		document.jubilee_registration.firstname.focus();
		return false;
	}
	
	if (trimStr(document.jubilee_registration.lastname.value).length <= 0)
	{
		alert("Please enter the Last Name");
		document.jubilee_registration.lastname.focus();
		return false;
	}
	
	if (trimStr(document.jubilee_registration.address1.value).length <= 0)
	{
		alert("Please enter the first line of address");
		document.jubilee_registration.address1.focus();
		return false;
	}
	
	if (trimStr(document.jubilee_registration.postcode.value).length <= 0)
	{
		alert("Please enter the Postcode");
		document.jubilee_registration.postcode.focus();
		return false;
	}
	
	if ((trimStr(document.jubilee_registration.phone.value).length <= 0) &&
				 (trimStr(document.jubilee_registration.mobile.value).length <= 0) &&
				 (trimStr(document.jubilee_registration.howdidyou.value).length <= 0))
	{
		alert("Please enter either a phone/mobile number or an email address");
		document.jubilee_registration.phone.focus();
		return false;
	}
	
	if (trimStr(document.jubilee_registration.email2.value).length <= 0)
	{
		alert("Please enter how you heard about jubilee \n If it is through a someone enter the name of the person");
		document.jubilee_registration.email2.focus();
		return false;
	}	
	
	
	if (trimStr(document.jubilee_registration.select.value) == "Select")
	{
		alert("Please select a title");
		document.jubilee_registration.select.focus();
		return false;
	}	
	
	return true;
	
}


function trimStr(str) 
{
  while (str.substring(0,1) == ' ') 
  {
	str = str.substring(1,str.length);
  }

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