// extend the current rules with new groovy ones
	
// this one requires the text "blue", we define a default message, too
	$.validator.addMethod("blue", function(value) {
		return value == "blue";
	}, 'Please enter "blue"!');
	

$().ready(function() {
		var validator = $("#ContactForm").bind("invalid-form.validate", function() {
			$("#drawer").html("Your form contains " + validator.numberOfInvalids() + " errors. Errors are bordered in <samp style=\"color:red\"><strong>red</strong></samp>.");
		}).validate({
			
			errorContainer: $("#drawer"),
		
			//Setup our validation rules
			 rules: {
				name: {
				   required: true,
				   minlength: 1
				 },
				email: {
					required: true,
					email: true
				},
				color: "blue",
				message: {
					required: true,
					maxlength: 3000
				}
			},	
			
			//Execute this Function if Form is invalid
			 invalidHandler: function(form, validator) {		    
				
				//alert("Error");
				
				//Fancy drawer function from jquery.tools
				$("#drawer").slideDown(function()  {		
					// colored flash effect
					$("#drawer").css("backgroundColor", "#fff");
					setTimeout(function() { $("#drawer").css("backgroundColor", "#B3CDEF"); }, 1000);
				});
				
			 },
			 
			 submitHandler: function(form) {			
				//on SUCCESFUL submit, slide that SHIZ up!
				$("#drawer").slideUp();	
				form.submit();//VERY IMPORTANT!
			 }
		
	});
		
});