$(document).ready(function(){
	$(".required").each(function() {
		$(this).after("<span class='required-star'>*</span>");
	});
	
	$('#formContent').submit(function() {
		missingFields = 0;
	  $(".required").each(function() {
	  	if ($(this).val() == "") {
	  		missingFields = 1;
	  	} else {
	  		missingFields = 0;
	  	}
	  });

	  if (missingFields) {
	   	 alert("Sorry you are missing some of the required fields.\nPlease try again.");
	  } else {
	  	$(this).ajaxSubmit({
	  		success: function(i) {
	  			$("#formResponsetxt").html(i);
	  	   		$("#formContent").hide();
	  	   		$("#formResponse").show();
	  	   	}
	  	});
	  }
	   return false; // <-- important!
	});
	
	$('#try-form-again').livequery('click', function() {
		$("#formResponse").hide();
		$("#formContent").show();
	})
});
