function validate_contact() {

	// The home page has a contact form which must be completed correctly
	// This function returns 0 if there are any problems with this form

	error=false;

	//lert("Function validate_contact() ");

	// FIRST CLEAR ALL EXISTING ERROR MESSAGES

	$('div.form_error').html("");		

	// OLD STYLE ASSIGNMENTS FROM FORM ELEMENTS	
	//var name=document.contact_request.name.val;
	//var email=document.contact_request.email;
	//var country=document.contact_request.country;
	//var phone=document.contact_request.phone;
	//var skype=document.contact_request.skype;
	//var course=document.contact_request.course;
	//var additional_information=document.contact_request.additional_information;
	//var learning_method=document.contact_request.learning_method;

	var name = $("#name").val();
	var email = $("#email").val();
	var country = $("#country").val();
	var phone = $("#phone").val();

	var skype = $("#skype").val();
	var course = $("#course").val();
	var message = $("#message").val();
	var learning_method = $("#learning_method").val();

	if (name=="") {
		error_text=setword("read","Name",'');
		$('#name_error').html(error_text);		
		$("#name").focus();    
		error=true;
	}

	if (email=="") {
		error_text=setword("read","Email",'');
		$('#email_error').html(error_text);		
		$("#email").focus();    
		error=true;
	} else {
		if (echeck(email)==false){
			error_text=setword("read","Invalid email",'');
			$('#email_error').html(error_text);		
			$("#email").focus();    
			error=true;
		}
	}


	if (error==true) {
		alt_contact="Please send email to leonwool@fastmail.co.uk or skype leonwool, SMS 36-20-574-8150 ";
		error_text=setword("read",alt_contact,'');
		$('#form_error').html(error_text);
		return false;
	} else { 
		// Call the php function here to create a new row in the table

		if (live=='1') {

			//	JQUERY POST

			$('#form_error').append("Calling database update please wait ..");	
	
			// WAS  $.post("etlw/db_code/make_contact.php", $("#contact_request").serialize(),

			$(function(){
				$("#contact_request").submit(function(){
					$.('#form_error').load("etlw/db_code/make_contact.php", $("#contact_request").serialize(),
					function(data){
					}, "json");
				        return false;
				});
			});

			//$('#form_error').load("etlw/db_code/make_contact.php");

			// CHAT ROOM EXAMPLE
			//$("#load").load("new_message.php", { 'chat[]': [message] }).fadeIn(1000);
			// NOTE the data past into the POST  $messagetext = strip_tags($_POST['chat']['0']);

			$('#form_error').append("Thank you.");
			$("#form_container").fadeOut("slow");

			$("#form_container").html(done_it);


		} else {
			$('#form_error').html("You must be on the live web site to use this form");
		} 

		// Finally set the error as we have already loaded the contact.php
		return false;
	}

}

function reset_contact() {

	// Clear all flds and old error messages
	$('div.form_error').html("");		

}


function echeck(str) {

		//lert("Function echeck() ");

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)

		if (str.indexOf(at)==-1){
			return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
			return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			return false
		 }
		
		 if (str.indexOf(" ")!=-1){
			return false
		 }

		//lert("Function echeck() ");
		return true					

	}





