$(document).ready(function(){

$.fn.clearForm = function() {
  return this.each(function() {
 var type = this.type, tag = this.tagName.toLowerCase();
 if (tag == 'form')
   return $(':input',this).clearForm();
 if (type == 'text' || type == 'password' || tag == 'textarea')
   switch (this.id){
		case 'name':
		this.value = 'Your name';
		break;
		case 'email':
		this.value = 'Your email';
		break;
		case 'message':
		this.value = 'Your message';
		break;
		default : this.value = 'Your message';
		}
		   
 else if (type == 'checkbox' || type == 'radio')
   this.checked = false;
 else if (tag == 'select')
   this.selectedIndex = 0;
  });
};

$("#contact").submit(function(){

var str = $(this).serialize();

   $.ajax({
   type: "POST",
   url: "contact/contact.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_success>Thank you for your message. We will reply very soon.</div>';
$("#fields").show();
$('#contact').clearForm();
}
else
{
result = msg;
}

$(this).html(result);

});

}

 });

return false;

});

// ------- Submit Second Form -------

$("#feedback").submit(function() {

var str = $(this).serialize();

   $.ajax({
   type: "POST",
   url: "feedback.php",
   data: str,
   success: function(msg){
    
$("#note-two").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><div>poo</div>';
$("#fields-two").show();
}
else
{
result = msg;
}

$(this).html(result);

});

}

 });

return false;

});

});
