$(document).ready(function(){  
$("form").submit(function(){  
  
// 'this' refers to the current submitted form  
var str = $(this).serialize();  
  
   $.ajax({  
   type: "POST",  
   url: "mailing_list.php",  
   data: str,  
   success: function(msg){  
  
$("#error_mailing_list").ajaxComplete(function(event, request, settings){  
											   
											  $("#error_mailing_list").fadeIn("medium");
  
if(msg == '<div class="sending"></div>') // Message Sent? Show the 'Thank You' message and hide the form  
{  
result = '<p class="result_success"><strong>Thank you!</strong> Your details have been submitted.</p>';  
$("#mailing_form").hide();  
}  
else  
{  
result = msg;  
$(".mailing_textbox").css({'background' : '#f7d4c2'});
}  
  
$(this).html(result);  
  
});  
  
}  
  
 });  
  
return false;  
  
});  
  
});