	$().ready(function() {
	
		$("label").inFieldLabels();
/*
$("#submit_button").click(function() {
 		$("#commentForm").submit();
		}); 	

	$(".textinput").focus(function() {
		$(this).prev().hide();
	})
	.blur(function() {
		if($(this).val() == "") {
			$(this).prev().show();
		}
	});
*/

	$('#commentForm').validate({	
		onkeyup: false,
		rules: {
			firstname: "required",
			surname: "required",
			postcode: "required",
			email: { required: true, email: true}
		},
		messages: {
			firstname: "",
			surname:"",
			email: "",
			postcode: ""
		},
		invalidHandler: function(form, validator) {
                    var errors = validator.numberOfInvalids();
                      if (errors) {
                        var message = errors == 1
                              ? 'You missed 1 field. It has been highlighted'
                              : 'You missed ' + errors + ' fields. They have been highlighted';
                          alert(message);
                    } 
              },
		submitHandler: function() {
			$.post("/register.php", $("#commentForm").serialize(), function(data) {
				$("#registerarea").html(data);
				
			});
		}              
   	});

		
	});	

