
$('.comments input.name').focus(function(){if($('.comments input.name').val()=='Name'){$('.comments input.name').val('').css({color:'#000'});}});$('.comments input.name').blur(function(){if($('.comments input.name').val()==''){$('.comments input.name').val('Name').css({color:'#aaa'});}});$('.comments input.email').focus(function(){if($('.comments input.email').val()=='Email'){$('.comments input.email').val('').css({color:'#000'});}});$('.comments input.email').blur(function(){if($('.comments input.email').val()==''){$('.comments input.email').val('Email').css({color:'#aaa'});}});$('.comments input.url').focus(function(){if($('.comments input.url').val()=='Website (Optional)'){$('.comments input.url').val('http://').css({color:'#000'});}});$('.comments input.url').blur(function(){if($('.comments input.url').val()==''||$('.comments input.url').val()=='http://'){$('.comments input.url').val('Website (Optional)').css({color:'#aaa'});}});$('.comments textarea').focus(function(){if($('.comments textarea').val()=='Type your comment here.'){$('.comments textarea').val('').css({color:'#000'});}});$('.comments textarea').blur(function(){if($('.comments textarea').val()==''){$('.comments textarea').val('Type your comment here.').css({color:'#aaa'});}});$('.comments input#cname, .comments input#cemail, .comments input#curl').keypress(function(e){if(e.which==13){$('#csubmit').click();return false;}});$('.comments input.url').change(function(){if(!$(this).val().match(/^https?:\/\/(.*)$/)){$(this).val('http://'+$(this).val());}});$(function(){$('#csubmit').click(function(){if($('#cmsg').val()==''||$('#cmsg').val()=='Type your comment here.'){alert('Please say something in the comment box.');}
else if($('#cname').val()==''||$('#cname').val()=='Name'){alert('Name is required.');}
else if($('#cemail').val()==''||$('#cname').val()=='Email Address'){alert('Email address is required.');}
else if(!is_valid_email($('#cemail').val())){alert('Invalid email format.');}
else if($('#curl').val()!=''&&$('#curl').val()!='Website (Optional)'&&!is_valid_url($('#curl').val())){alert('Invalid url format.');}
else{$.facebox('<p style="text-align: center;"><b>Human Verification</b></p><p style="text-align: center;">Please enter two words as shown below. If you cannot read the words, please click the refresh icon.</p><div id="recaptcha_div" class="recaptcha_div"><img src="'+SITE_URL+'img/loading.gif" alt="loading" style="margin-top: 40px;" /></div><p style="text-align: center; margin-bottom: 20px;"><input type="button" value="POST COMMENT" id="ccaptcha" /></p>');Recaptcha.create(recaptcha_publickey,"recaptcha_div",{theme:"white",callback:function(){$('#recaptcha_response_field').keypress(function(e){if(e.which==13){$('.popup #ccaptcha').click();}});}});$('.popup #ccaptcha').click(function(){if($(this).attr('disabled')=='disabled')return false;$(this).val('loading').attr('disabled','disabled');$(this).after('<img src="'+SITE_URL+'img/loading2.gif" alt="" class="lj" />').hide();$.ajax({type:"POST",url:SITE_URL+"pdf_comment",data:"permalink="+permalink+"&cmsg="+encodeURIComponent($('#cmsg').val())+"&cname="+encodeURIComponent($('#cname').val())+"&curl="+$('#curl').val()+"&cemail="+$('#cemail').val()+"&crating="+$('#crating').val()+"&recaptcha_challenge_field="+$('#recaptcha_challenge_field').val()+"&recaptcha_response_field="+escape($('#recaptcha_response_field').val()),success:function(rdata){eval('data='+rdata);if(data['status']==0){alert(data['msg']);$('.popup #ccaptcha').val('SEND').attr('disabled','').show();$('.lj').remove();Recaptcha.reload();}
else if(data['status']==1){alert(data['msg']);window.location=pdf_permalink;}
else{alert('Error. Please try again later. If this error persists, please contact admin@pdfcast.org.');}},error:function(XMLHttpRequest,textStatus,errorThrown){alert('Ajax: '+textStatus+'. Please try again later. If this error persists, please contact admin@pdfcast.org.');}});});}});});
