// JavaScript Document
//by Douglas Munro 5/9/2009
function checkform()
{
	var valid = 1
	var namesub = ''
	var telsub = ''
	var emailsub = ''
	var enquirysub = ''
	var mes5 = ''
	var mes6 = ''
	var mes7= ''
	var mes8= ''
	var mes9 = ''
	if (document.form.name.value == '')
	{
		var namesub = '** No name entered'
		valid = 0
	}
	if (!document.form.tel.value)
	{
		var telsub = '** No telephone number entered'
		valid = 0
	}
	//this part validates the email address, check blank, @ and dot(uses indexOf(char,start) if -1 does not exist
	//uses else statement
	if (document.form.formREPLY.value == '')
	{
		var emailsub = '** Email field empty'
		valid = 0
	}
		else
		if ( document.form.formREPLY.value.indexOf("@",0)<0)
		{
			var emailsub = '** Email field missing @'
			valid = 0
		} 
		else
			if ( document.form.formREPLY.value.indexOf(".",0)<0)
			{
				var emailsub = '** Email missing dot'
				valid = 0
			}
	if (document.form.enquiry.value == '')
	{
		var enquirysub = '** Message is empty'
		valid = 0
	}
	//check a series of radio buttons to find if one is checked
	if (valid == 0)
	{
		// something else is wrong
		alert('The following fields were not entered:\n\n' + namesub+ '\n' +telsub+ '\n' + emailsub + '\n' + enquirysub )
		return false;
	}
		return true;
	// If the script gets this far through all of your fields
	// without problems, it's ok and you can submit the form
}

