$(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();
	})
	
	//Donate Form
	$('.setdonate').click(function() {
		amount = $(this).attr('rel');
		$('.setdonate').each(function() {
			$(this).removeClass('active');
			$(this).addClass('inactive');
		});
		$(this).addClass('active');
		$("#donateAmount").val(amount);
	});
	
});
