(function($) {
	function successfulSubmission(data) {
		if (data.success) {
			var originalRightColumn = jQuery('#GIBGuideForm_SignUpForm').parent();

			var columnHolder = originalRightColumn.parent();

			var newRightColumn = jQuery('<div></div>').addClass('rightColumn').css('display', 'none');

			columnHolder.append(newRightColumn);
			
			originalRightColumn.fadeOut(function() {
				newRightColumn.html(data.content).fadeIn();
			});
		}
	}

	function beforeSubmit(data) {
		var originalRightColumn = jQuery('#GIBGuideForm_SignUpForm').parent();

		originalRightColumn.fadeOut(function() {
			originalRightColumn.html('You have successfully signed up for the GIB newsletter.').fadeIn();
		});
	}

	$('#OverlayContentHolder #GIBGuideForm_SignUpForm').livequery(function() {
		$(this).ajaxForm({
			dataType: 'json',
			success: successfulSubmission,
			beforeSubmit: beforeSubmit
		});
	});
})(jQuery);


