
$('.report').click(function(){$.facebox('<div class="report_box"><div class="frame"><div class="report_box_1"><center><img src="'+SITE_URL+'img/loading.gif" alt="" style="margin-top: 100px;" /></center></div><div class="report_box_2"><p>Enter two words as shown below. If you cannot read the words, click the refresh icon.</p><div id="recaptcha_div" class="recaptcha_div"><img src="'+SITE_URL+'img/loading.gif" alt="" style="margin-top: 40px;" /></div><center><input type="button" value="SEND REPORT" style="margin-bottom: 5px;" id="sendreport" /></center><p><a href="#" class="share_prev">back</a></p></div></div></div>');$.ajax({type:"POST",url:SITE_URL+"pdf_report/get",data:"permalink="+permalink,success:function(data){$('.report_box_1').html(data);$('.report_box_1 input, .report_box_1 select').keypress(function(e){if(e.which==13){$('.popup #rsubmit').click();}});$('.popup #rsubmit').click(function(){if(validation_report()){share_next_report(function(){$('#sendreport').val('SEND REPORT').attr('disabled','').show();$('.lj').remove();share_prev_button_report();Recaptcha.create(recaptcha_publickey,"recaptcha_div",{theme:"white",callback:recaptcha_callback_report});});}
else{alert(validation_error);}});},error:function(XMLHttpRequest,textStatus,errorThrown){alert('Ajax: '+textStatus+'. Please try again later. If this error persists, please contact admin@pdfcast.org.');}});$('#sendreport').click(function(){if($(this).attr('disabled')=='disabled')return false;$('#sendreport').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_report/post",data:"permalink="+permalink+"&name="+escape($('#rname').val())+"&email="+$('#remail').val()+"&phone="+escape($('#rphone').val())+"&address="+escape($('#raddress').val())+"&country="+$('#rcountry').val()+"&reason="+$('#rreason').val()+"&msg="+escape($('#rmsg').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']);$('#sendreport').val('SEND REPORT').attr('disabled','').show();$('.lj').remove();Recaptcha.reload();}
else if(data['status']==1){alert(data['msg']);close_pop();}
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.');}});});return false;});share_prev_button_report=function(){$('a.share_prev').click(function(){share_prev_report();return false;});}
share_next_report=function(event){$('.popup .frame').animate({marginLeft:parseInt($('.popup .frame').css('margin-left'))-370},event);}
share_prev_report=function(){$('.popup .frame').animate({marginLeft:parseInt($('.popup .frame').css('margin-left'))+370});}
close_pop=function(){$('.close .close_image').click();}
recaptcha_callback_report=function(){$('#recaptcha_response_field').keypress(function(e){if(e.which==13){$('.popup #sendreport').click();}});}
var validation_error;validation_report=function(){validation_error='';if($('#rname').val()==''){validation_error=validation_error+'Name is required\n';}
if($('#remail').val()==''){validation_error=validation_error+'Email is required\n';}
if($('#remail').val()!=''&&!is_valid_email($('#remail').val())){validation_error=validation_error+'Invalid email format\n';}
if($('#rphone').val()==''){validation_error=validation_error+'Phone is required\n';}
if($('#raddress').val()==''){validation_error=validation_error+'Address is required\n';}
if($('#rcountry').val()==''){validation_error=validation_error+'Country is required\n';}
if($('#rreason').val()==''){validation_error=validation_error+'Reason is required\n';}
if($('#rmsg').val()==''){validation_error=validation_error+'Message is required\n';}
if(validation_error!='')return false;else return true;}
