$(document).ready(function(){
	
		
	//
	// Contact form
	//
	
	$("#contact-form:not(.busy)").submit( function() {
		
		// Clear the feedback section
		$("#contact-form .feedback").hide().html('');
		
		// 'Wait' message
		$("#contact-submit").val('Sending...').attr('disabled', true);
				
		// Submit the request
		$.post('/src/ajax/abs.ajax.php', $("#contact-form").serialize(), function(r) {
			
			if( r.status == 'success' ) {
				// Submitted successfully; disable form and provide feedback
				$("#contact-submit").remove();
				$("#contact-form .text-field").attr('disabled', true);
				$("#contact-form .feedback").html('<p class="form-success">' + r.message + '</p>').fadeIn();			
			} else {
				// An error occurred; allow user to retry
				$("#contact-form .feedback").html('<p class="form-error">' + r.message + '</p>').fadeIn();
				$("#contact-submit").attr('disabled', false).val('Try Again');

			}
			
		}, 'json');
		
		return false;
		
		
	});
	
	// Hide form error on click
	$("#contact-form .form-error").live('click', function() {
		$("#contact-form .feedback").fadeOut( function() { $(this).hide().html(''); } );
	});
	
});
