//alert("script");

$(document).ready(function(){  
$("form").submit(function(){  
  //alert("form");
// 'this' refers to the current submitted form  
var str = $(this).serialize();  

$.ajax({  
		type: "POST",  
		url: "mailme.php",  
		data: str,  
		success: function(msg){  
	
			$("#note").ajaxComplete(function(event, request, settings){  
	
					if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form  
					{  
						result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';  
						$("#rego").slideUp();
					}  
					else  
					{  
						result = msg;
						if(msg.search(/name/) != -1)
						{
							$("#name").addClass("error");
						} else {
							$("#name").removeClass("error");
						}
						
						if(msg.search(/organisation/) != -1)
						{
							$("#org").addClass("error");
						} else {
							$("#org").removeClass("error");
						}
						
						if(msg.search(/e-mail/) != -1)
						{
							$("#email").addClass("error");
						} else {
							$("#email").removeClass("error");
						}
						
						if(msg.search("an address") != -1)
						{
							$("#address").addClass("error");
						} else {
							$("#address").removeClass("error");
						}
					}  

					$(this).html(result);

			});  

		}  

});  

return false;

});  

});  
