//  Copyright ©2009 Paul Barrett - www.pbarrett.co.uk
//-----------------------------------------------------------------------------
//  Filename                : pb.contact.js
//-----------------------------------------------------------------------------
//  Project                 : Website Development
//  Version                 : 1.00
//  Author                  : Paul Barrett
//  Date Created            : 14 July 2009
//-----------------------------------------------------------------------------
//  Description:
//  Provides ajax functionality for the contact section of the website.
//
//  Requires the following libraries/plugins:
//    jquery-1.3.2.min.js
//  
//  
//  Revisions:
//  14 July 2009 - No revisions yet.
//-----------------------------------------------------------------------------

$(document).ready(function () {
							
	$("form").submit(function(){

		var str = $("form").serialize();
			
		$.ajax({
			type: "POST",
			url: "contact.php",
			data: str,
			success: fMsgResult
		});
	
		return false;
	});
	
	
	//-----------------------------------------------------------------------------
	//  FUNCTIONS
	//-----------------------------------------------------------------------------
	function fMsgResult(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"><p>Your message has been sent. Thank you!</p></div>';
				$("#fields").hide();
			}
			else
			{
				result = msg;
			}
			
			$(this).html(result);
		
		});	
	}
	
});