$(document).ready(function(){
	d = new Date();
	month = d.getMonth();
	monthOffset = (month < 12 ? 1 : -12);
	month = month + monthOffset;
	months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
	$(".month").val(months[month]);

	var forms = $('form').each(
		function(index) {
			id = $(this).attr('id');

			$(this).submit(function() {
				var student_name = $(this).children(".fencer_name").val();
				if ("" == student_name) {
					alert("Please enter the name of the student");
					return false;
				}
				class_month = $(this).children(".month").val();
				class_name = $(this).children(".class_name").val();
				
				recurring = $(this).children(':checkbox:checked').length;
				if (recurring) {
					value = $(this).children(".recurring_id").val();
					$(this).children(".invoice").val(student_name + " recurring " + class_name + " " + d.getTime());
				} else {
					value = $(this).children(".single_id").val();
					$(this).children(".invoice").val(student_name + " " + class_month + " " + class_name + " " + d.getTime());
				}
				$(this).children(".button_id").val(value);
			});
		});
});

