$().ready(function() {
	//FORM VALIDATION
	$("#rsvp").validate({
		errorLabelContainer: ".message",
		wrapper: "li",
		rules: {
			name: {
				required: "#name == 'abc'"
			},
			email: {
				required: true,
				email: true
			}
		},
		messages: {
			name: "Please enter your name",
			email: "Please enter a valid email address"
		}
	});
	
	//ANIMATION
	$("#btn-rsvp").click(function () {
		$("#thanks").fadeOut(300);
      	$("#intro").fadeOut(300, function () {
        	$("#rsvp-form").fadeIn(100);
      	});
      	return false;
    }); 

	$("#rsvp-cancel").click(function () {
      $("#rsvp-form").fadeOut(300, function () {
        $("#intro").fadeIn(100);
      });
      return false;
    });

	//CLEAR FORM FIELDS ON FOCUS
	$("#name, #email").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	
});