 function email(str) {
	    var error = ""
  var at="@";
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){  
		document.getElementById("email").style.backgroundColor = '#aebed0';	
		
		   error = "Invalid E-mail\n";
		   return error;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){  
		document.getElementById("email").style.backgroundColor = '#aebed0';	
	
		   error = "Invalid E-mail\n";
		   return error;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		document.getElementById("email").style.backgroundColor = '#aebed0';	
	
		       error = "Invalid E-mail\n";
		   return error;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		document.getElementById("email").style.backgroundColor = '#aebed0';	

		     error = "Invalid E-mail\n";
		   return error;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){	 
		document.getElementById("email").style.backgroundColor = '#aebed0';	

		      error = "Invalid E-mail\n";
		   return error;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){	
		document.getElementById("email").style.backgroundColor = '#aebed0';	

		   error = "Invalid E-mail\n";
		   return error;
		 }
		
		 if (str.indexOf(" ")!=-1){
		     error = "Invalid E-mail\n";
		document.getElementById("email").style.backgroundColor = '#aebed0';	

		   return error;
		 }

		   return error; 
}


	

function validate_form() {

var reason = "";


	reason += email(document.enquiry.email.value);
  	reason += validatefname();
  	reason += validatelname();	
  	reason += validateaddress();
  	reason += validatetelephone();
  	reason += validatemobile();		
  	reason += validatedatetime();
	reason += validateeventdescription();
	reason += validateguests();
    reason += validatevenueaddress();
	reason += validatevenuetelephone();
	reason += validateliaisonpersonmobile();
	reason += validatebandsize();
	reason += validatebandsetuptime();
	reason += validatedressingroom();
	reason += validatebandmeals();
	reason += validatedresscode();
	reason += validatestarttime();
	reason += validateendtime();
	reason += validatepowerpoint();
	reason += validateoutsideshelter();
	reason += validateequipoffload();
	reason += validatevehicleparking();
	reason += validatehuman();

	
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    return false;
  }
else
{
   document.enquiry.submit();
   }
}
function validatefname() {

var error = "";
 
    if (document.enquiry.fname.value == "") 
	{	
		document.getElementById("fname").style.backgroundColor = '#aebed0';
        error = "Please specify your first name.\n";
    } 
    return error;  
	
}

function validatelname() {
    var error = "";
 
    if (document.enquiry.lname.value == "") 
	{	
		document.getElementById("lname").style.backgroundColor = '#aebed0';
        error = "Please specify your last name.\n";
    } 
    return error;  
	
}

function validateaddress() {
    var error = "";
 
    if (document.enquiry.address.value == "") 
	{	
		document.getElementById("address").style.backgroundColor = '#aebed0';
        error = "Please specify your full address.\n";
    } 
    return error;  
}
	 

function validatetelephone() {
    var error = "";
 
    if (document.enquiry.telephone.value == "") 
	{	
		document.getElementById("telephone").style.backgroundColor = '#aebed0';
        error = "Please specify your contact telephone number.\n";
    } 
    return error;  
	
}
function validatemobile() {
    var error = "";
 
    if (document.enquiry.mobile.value == "") 
	{	
		document.getElementById("mobile").style.backgroundColor = '#aebed0';
        error = "Please specify your mobile number.\n";
    } 
    return error;  
	
}
function validatedatetime() {
    var error = "";
 
    if (document.enquiry.datetime.value == "") 
	{	
		document.getElementById("datetime").style.backgroundColor = '#aebed0';
        error = "Please specify the date and time of your event.\n";
    } 
    return error;  
	
}
function validateeventdescription() {
    var error = "";
 
    if (document.enquiry.eventdescription.value == "") 
	{	
		document.getElementById("eventdescription").style.backgroundColor = '#aebed0';
        error = "Please give details of the proposed event.\n";
    } 
    return error;  
	
}

function validateguests() {
    var error = "";
 
    if (document.enquiry.guests.value == "") 
	{	
		document.getElementById("guests").style.backgroundColor = '#aebed0';
        error = "Please specify the approximate number of guests.\n";
    } 
    return error;  
	
}

function validatevenueaddress() {
    var error = "";
 
    if (document.enquiry.venueaddress.value == "") 
	{	
		document.getElementById("venueaddress").style.backgroundColor = '#aebed0';
        error = "Please specify the venue address.\n";
    } 
    return error;  
	
}

function validatevenuetelephone() {
    var error = "";
 
    if (document.enquiry.venuetelephone.value == "") 
	{	
		document.getElementById("venuetelephone").style.backgroundColor = '#aebed0';
        error = "Please specify the venue telephone number.\n";
    } 
    return error;  
	
}

function validateliaisonpersonmobile() {
    var error = "";
 
    if (document.enquiry.liaisonpersonmobile.value == "") 
	{	
		document.getElementById("liaisonpersonmobile").style.backgroundColor = '#aebed0';
        error = "Please specify the liaison person's mobile number.\n";
    } 
    return error;  
	
}

function validatebandsize() {
    var error = "";
 
    if (document.enquiry.bandsize.value == "Please Select") 
	{	
		document.getElementById("bandsize").style.backgroundColor = '#aebed0';
        error = "Please specify the size of the band required.\n";
    } 
    return error;  
	
}

function validatebandsetuptime() {
    var error = "";
 
    if (document.enquiry.bandsetuptime.value == "") 
	{	
		document.getElementById("bandsetuptime").style.backgroundColor = '#aebed0';
        error = "Please specify the required time of setup.\n";
    } 
    return error;  
	
}

function validatedressingroom() {
    var error = "";
 
    if (document.enquiry.dressingroom.value == "Please Select") 
	{	
		document.getElementById("dressingroom").style.backgroundColor = '#aebed0';
        error = "Please specify whether or not there is a dressing room available.\n";
    } 
    return error;  
	
}

function validatebandmeals() {
    var error = "";
 
    if (document.enquiry.bandmeals.value == "") 
	{	
		document.getElementById("bandmeals").style.backgroundColor = '#aebed0';
        error = "Please specify whether or not there will be band meals.\n";
    } 
    return error;  
	
}

function validatedresscode() {
    var error = "";
 
    if (document.enquiry.dresscode.value == "Please Select") 
	{	
		document.getElementById("dresscode").style.backgroundColor = '#aebed0';
        error = "Please specify what the band dress code will be.\n";
    } 
    return error;  
	
}

function validatestarttime() {
    var error = "";
 
    if (document.enquiry.starttime.value == "") 
	{	
		document.getElementById("starttime").style.backgroundColor = '#aebed0';
        error = "Please specify the event start time.\n";
    } 
    return error;  
	
}

function validateendtime() {
    var error = "";
 
    if (document.enquiry.endtime.value == "") 
	{	
		document.getElementById("endtime").style.backgroundColor = '#aebed0';
        error = "Please specify the event end time.\n";
    } 
    return error;  
	
}

function validatepowerpoint() {
    var error = "";
 
    if (document.enquiry.powerpoint.value == "Please Select") 
	{	
		document.getElementById("powerpoint").style.backgroundColor = '#aebed0';
        error = "Please specify if a powerpoint can be accessed.\n";
    } 
    return error;  
	
}

function validateoutsideshelter() {
    var error = "";
 
    if (document.enquiry.outsideshelter.value == "Please Select") 
	{	
		document.getElementById("outsideshelter").style.backgroundColor = '#aebed0';
        error = "Please specify if band shelter will be provided.\n";
    } 
    return error;  
	
}

function validateequipoffload() {
    var error = "";
 
    if (document.enquiry.equipoffload.value == "") 
	{	
		document.getElementById("equipoffload").style.backgroundColor = '#aebed0';
        error = "Please specify if there will be an area for the band to offload.\n";
    } 
    return error;  
	
}

function validatevehicleparking() {
    var error = "";
 
    if (document.enquiry.vehicleparking.value == "") 
	{	
		document.getElementById("vehicleparking").style.backgroundColor = '#aebed0';
        error = "Please specify whether vehicle parking will be provided.\n";
    } 
    return error;  
	
}

function validatehuman() {
    var error = "";
 
    if (document.enquiry.human.value !== "5") 
	{	
		document.getElementById("human").style.backgroundColor = '#aebed0';
        error = "Please answer the question - what is 2+3?.\n";
    } 
    return error;  
	
}
