// form validation and ajax submitter.
jQuery(function() {
		// Remove textfield contents 
		$("input.clearBox").each(function() {
			$(this).data('default', $(this).val())
				.focus(function() {
					// If the value of the field is the original value, set it to nothing
					if ($(this).val() == $(this).data('default') || '') {
						$(this).val('');
					}
				})
				.blur(function() {
					var default_val = $(this).data('default');
					// If the value of the empty, set it to the original value :)
					if ($(this).val() == '') {
						$(this).val($(this).data('default'));
					}
				});
		});

		// show a simple loading indicator when submitting the form
		$("#loader").hide();
		$(document).ajaxStart(function() {
			$("#loader").fadeIn();
		}).ajaxStop(function() {
			$("#loader").fadeOut();
		}).ajaxError(function(a, b, e) {
			throw e;
		});
		
		
		//Validate Then Submit The Form
		var v = $("#subscribe").validate({
			submitHandler: function(form) {
				$("#submitbutton").slideUp();
				$(form).ajaxSubmit({
					success: function(responseText, statusText, xhr, $form) {
						$("#progress").html(responseText);
						$("#progress").fadeIn();
					}
				});
			} 
		});
	});
