function alertAndFocus(element, alertText) {
	alert(alertText);
	element.focus();	
}
function isEmpty(element, defaultValue, errorAlert) { 
	//alert(element.value);
	if ( (element.value == "" ) || (element.value == defaultValue ) ){ 
		alertAndFocus(element,errorAlert); 
		return true;  
	} else {
		return false;  
	}
}
function clearInput(defaultText, elementName) {	
	element = document.getElementById(elementName);			
	//alert(element.value)
	if (element.value == defaultText) {
		element.value= "";
	}	
}


function validateform()
{
	    if 
		( isEmpty(document.getElementById("frmForename"), "First Name", "Please enter first name.") )
	        {
	        return false;
	        }
	    if 
		( isEmpty(document.getElementById("frmSurname"), "Surname", "Please enter surname.") )
	        {
	        return false;
	        }
	    if (document.Booking.frmAddress1.value.length < 1)
	        {
	        alert("Please enter your Address")
	        document.Booking.frmAddress1.focus()
	        return false;
	        }
		if (document.Booking.frmAddress3.value.length < 1)
	        {
	        alert("Please enter your Town")
	        document.Booking.frmAddress3.focus()
	        return false;
	        }

	    if (document.Booking.frmCounty.value.length < 1)
	        {
	        alert("Please enter your County")
	        document.Booking.frmCounty.focus()
	        return false;
	        }

	    if (document.Booking.frmPostcode.value.length < 1)
	        {
	        alert("Please enter your Postcode")
	        document.Booking.frmPostcode.focus()
	        return false;
	        }

	    if (document.Booking.frmPhoneHome.value.length < 1)
	        {
	        alert("Please enter Your Phone Number")
	        document.Booking.frmPhoneHome.focus()
	        return false;
	        }
			
		if (document.Booking.frmEmail.value.length < 1)
	        {
	        alert("Please enter your email address")
	        document.Booking.frmEmail.focus()
	        return false;
	     	}
			if (document.Booking.frmEmail.value.length > 0)
	        {
				if (document.Booking.frmEmail.value.indexOf("@",0) == - 1 || document.Booking.frmEmail.value.indexOf(".",0) == - 1)
				{
				alert("Please enter a valid Email Address")
				document.Booking.frmEmail.focus()
				return false;
				}
			}

	    if (document.Booking.frmBoatType.value.length < 1)
	        {
	        alert("Please enter the Boat Type")
	        document.Booking.frmBoatType.focus()
	        return false;
	        }

	    if (document.Booking.frmBoatMake.value.length < 1)
	        {
	        alert("Please enter the make of the boat")
	        document.Booking.frmBoatMake.focus()
	        return false;
	        }

	    if (document.Booking.frmBoatLength.value.length < 1)
	        {
	        alert("Please enter the Boat Length")
	        document.Booking.frmBoatLength.focus()
	        return false;
	        }
	
			
	return true;
}
