//This function validates the data from the form
function validate_form()
{
    valid = true;  //Variable valid set to true, allowing data to be sent to php file

	//If firstname field is empty alert is displayed and valid is set to false stopping data being sent
    if (document.contact_form.txtfName.value =="")   
    {
        alert ( "Please fill in your first name." );
        valid = false;
    }
	
	//If firstname field and email field are empty, alert is displayed and valid is set to false stopping data being sent
	if (!document.contact_form.txtfName.value =="" && document.contact_form.txtEmail.value =="")
    {
        alert ( "Please fill in your email address." );
        valid = false;
    }
	//If firstname, email and comment fields are empty, alert is displayed and valid is set to false stopping data being sent
	if (!document.contact_form.txtfName.value =="" && !document.contact_form.txtEmail.value =="" && document.contact_form.txtComment2.value =="")
    {
        alert ( "Please enter a comment" );
        valid = false;
    }
    return valid; //Status of var valid is returned
}


