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 ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

jQuery(function() {
  jQuery('.error').hide();
  jQuery('input.text-input').css({backgroundColor:"#FFFFFF"}); //it runs without this
  jQuery('input.text-input').focus(function(){				  //it runs without this
    jQuery(this).css({backgroundColor:"#ffffff"});             //it runs without this
  });													  //it runs without this
  jQuery('input.text-input').blur(function(){				  //it runs without this
    jQuery(this).css({backgroundColor:"#FFFFFF"});			  //it runs without this
  });													  //it runs without this

  jQuery(".submit").click(function() {
		// validate and process form
		// first hide any error messages
    jQuery('.error').hide();

		

		var title = jQuery("input#company").val();
		if (title == ""){
			jQuery("label#title_error").show();
			jQuery("input#company").focus();
			return false;
    	}
					
var name = jQuery("input#Name").val();
		if (name == ""){
			jQuery("label#name_error").show();
			jQuery("input#Name").focus();
			return false;
    	}
					
		var email = jQuery("input#Email").val();
		if (email == ""){
			jQuery("label#email_error").show();
			jQuery("input#Email").focus();
			return false;
    	}
		
		
		

var emailID=document.form3.Email
if (echeck(emailID.value)==false){
emailID.value=""
//emailID.focus()

jQuery("label#invalid_email_error").show();
jQuery("input#Email").focus();

return false
}		
		
		var phone = jQuery("input#Phone").val();
		var ext = jQuery("input#Ext").val();
		var organization = jQuery("input#Organization").val();
		if (organization == ""){
			jQuery("label#organization_error").show();
			jQuery("input#Organization").focus();
			return false;
    	}
		var country = jQuery("input#Country").val();
		if (country == ""){
			jQuery("label#country_error").show();
			jQuery("input#Country").focus();
			return false;
    	}
		var enquiry = jQuery("textarea#Enquiry").val();
		if (enquiry == ""){
			jQuery("label#enquiry_error").show();
			jQuery("textarea#Enquiry").focus();
			return false;
    	}


		var dataString = '&email=' + email + '&name=' + name + '&title=' + title + '&phone=' + phone + '&ext=' + ext + '&organization=' + organization + '&country=' + country + '&enquiry=' + enquiry;
		//alert (dataString);return false;
		
		jQuery.ajax({
      type: "POST",
      url: "email_process.php",
      data: dataString,
      success: function(){
        jQuery('#contact_form').html("<div id='message'></div>");
        jQuery('#message').html("<div align='center' height='100px'>Your email has been sent.<br /></div>")
			.append("<div align='center'><font color='#333333' size='2px' weight='bolder'>We will be in touch soon.</font></div>")
			.hide()
			.fadeIn(1800, function(){
				jQuery('#message').append("");
			});
		}
		});
    return false;
	});
});
runOnLoad(function(){
  jQuery("input#name").select().focus();
});
