$("#contact-wrapper").hide();$("#btnAddComment").click(function(){var isValid=true;var message="";var email=$("#userEmail").val();var name=$("#userName").val();if(email==""){isValid=false;message="* Email is missing";}
if(name==""){isValid=false;message+="<br>* Name is missing";}
if(!isValidEmailAddress(email)){isValid=false;message+="<br>* Email is invalid";}
if($("#comment").val()==""){isValid=false;message+="<br>* Comment is missing";}
if(isValid){var data="userEmail="+$("#userEmail").val()+"&userName="+$("#userName").val()+"&comment="+$("#comment").val();data=data+"&blogId="+$("#hidBlogId").val()+"&userIP="+$("#hidIPAddress").val()+"&challenge="+$("#recaptcha_challenge_field").val()+"&response="+$("#recaptcha_response_field").val();$.ajax({type:"POST",url:"/Comment/AddComment",data:data,success:function(data){if(data=="true"){$('#contact-wrapper').html("<p>Thanks for your comment.</p>");DisplayComments();}
else{$('#result').html("<p>Please fill in the two words below correctly.</p>");}},error:function(){$('#result').html("<p>There was an error posting your comment.</p>");}});}
else{$('#result').html("<p>"+message+"</p>");}});$('#comment').keyup(function(){var len=this.value.length;if(len>=300){this.value=this.value.substring(0,300);}
$('#charLeft').text(300-len);});$("#toggle").click(function(){$("#contact-wrapper").slideToggle("fast");});function isValidEmailAddress(emailAddress){var pattern=new RegExp(/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/);return pattern.test(emailAddress);}
