//var $q=jQuery.noConflict();
	$(document).ready(function(){	
		$("#commentForm").validate({		
			//set the rules for the field names
			rules: {
				name: {
					required: true,
					minlength: 2
				},
				email: {
					required: true,
					email: true
				},				
				url: {
					url:true
				},				
				comment: {
					required: true,
					minlength: 5
				}
			},			
			//set messages to appear inline
			messages: {
				name: {
					required:"Enter your Name",
					minlength:"Enter atleast 2 characters"
				},
				email: {
					required:"An email is required",
					email:"Enter a valid e-mail"
				},
				comment: {
					required:"A comment is required",
					minlength:"Enter atleast 5 characters"
				}
			},			
			//Submit the Form  
			submitHandler: function() {			
			//Post the form values via ajax post 
				$.post("send_email.php", $("#commentForm").serialize()+'&ajax=1', function(result){				
					//recieve acknowledgment from send_email.php
					if(result == 'sent')
					{					
						$('#commentForm').remove();		//hide comment form
						$('#mail_success').fadeIn(500);	//Show mail success div
					}					
					else 
					{					
						$('#commentForm').remove();		//hide comment form
						$('#mail_fail').fadeIn(500);		//Show mail failure div
					}				
				});			
			}		
		});
	});

