function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail address")
		    return false
		 }

 		 return true					
	}
		function radio_button_checker()
		{
		// set var radio_choice to false
		var radio_choice = false;
		
		// Loop from zero to the one minus the number of radio button selections
		for (i=0;i<document.enquiryform.Radio_Location.length;i++) {
			if (document.enquiryform.Radio_Location[i].checked) {
				alert("Thank you for your enquiry")
				radioLocationID = document.enquiryform.Radio_Location.checked;
				return true;
			}	
		}//end for	
			if (!radio_choice)
			{
			// If there were no selections made display an alert box 
			alert("Please select a location.")
			return (false);
			}
			return (true);
		}


	
function ValidateForm(){

query=self.location.search;
var nameID=document.enquiryform.Name
var emailID=document.enquiryform.Email
var postcodeID=document.enquiryform.Postcode
var radioLocationID=document.enquiryform.Radio_Location
var msg="Please Enter: \n\n"


if(nameID.value==""||nameID.value==null){
	msg=msg+"Name\n"
	nameID.focus()
	if(postcodeID.value==""||postcodeID.value==null){
		msg=msg+"Postcode\n"
		if ((emailID.value==null)||(emailID.value=="")){
			msg=msg+"Email address"
			alert(msg)
			emailID.focus()
			return false
		}
		if (echeck(emailID.value)==false){
			msg=msg+"Email address"
			alert(msg)
			emailID.value=""
			emailID.focus()
			return false
		}
		alert(msg)
		return false
	}//end post neg
	if(postcodeID.value!=""||postcodeID.value!=null){
		if((emailID.value==null)||(emailID.value=="")){
			msg=msg+"Email address"
			alert(msg)
			emailID.focus()
			return false
		}//end if email false
		if (echeck(emailID.value)==false){
			msg=msg+"Email address"
			alert(msg)
			emailID.value=""
			emailID.focus()
			return false
		}
		alert(msg)
		return false
	}//end post pos
	
}//end if name neg
if(nameID.value!=""||nameID.value==null){
//	alert("name here")
	if(postcodeID.value==""||postcodeID.value==null){
		msg=msg+"Postcode\n"
		if ((emailID.value==null)||(emailID.value=="")){
			msg=msg+"Email address"
			alert(msg)
			emailID.focus()
			return false
		}
		if (echeck(emailID.value)==false){
			msg=msg+"Email address"
			alert(msg)
			emailID.value=""
			emailID.focus()
			return false
		}
		alert(msg)
		return false
	}//end post neg
	if(postcodeID.value!=""||postcodeID.value!=null){
		if((emailID.value==null)||(emailID.value=="")){
			msg=msg+"Email address"
			alert(msg)
			emailID.focus()
			return false
		}//end if email false
		if (echeck(emailID.value)==false){
			msg=msg+"Email address"
			alert(msg)
			emailID.value=""
			emailID.focus()
			return false
		}
		if(query != ""){
		alert("Thank you for your enquiry!")
		return true;

		}
		else{
		return radio_button_checker();
		}
	}//end post pos
}//end if name pos
}//end function


