(function(A){window.vBulletin=window.vBulletin||{};vBulletin.hv=vBulletin.hv||{};vBulletin.hv.reset=function(B){var C;if($(".humanverify.humanverify_image").length>0){$(".humanverify.humanverify_image .refresh_imagereg").click();C=$(".humanverify.humanverify_image .imageregt")}else{if($(".humanverify.humanverify_recaptcha").length>0&&Recaptcha&&typeof Recaptcha.reload=="function"){Recaptcha.reload()}else{if($(".humanverify.humanverify_question").length>0){$.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/render/humanverify",data:{action:"register"},type:"post",dataType:"json",success:function(D){$(".humanverify.humanverify_question").replaceWith(D);if(B){$(".humanverify.humanverify_question .answer").focus()}}});C=$(".humanverify.humanverify_question .answer")}}}if(B&&C&&C.length>0){C.focus()}};vBulletin.hv.imagereg=vBulletin.hv.imagereg||{};vBulletin.hv.imagereg.init=function(B){if(typeof B=="undefined"||B.length==0){B=$(document)}$(".humanverify_image",B).each(function(){var C=$(this);$(".refresh_imagereg",C).off("click").on("click",C,vBulletin.hv.imagereg.fetch_image);$(".imagereg",C).off("click").on("click",C,vBulletin.hv.imagereg.fetch_image);$(".refresh_imagereg",C).removeClass("h-hide")})};vBulletin.hv.imagereg.fetch_image=function(C){var B=C.data;$(".progress_imagereg",B).removeClass("h-hide");$.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/hv/generateToken",type:"post",dataType:"json",success:function(D){if(!D.errors){var E=D.hash;$("input.hash",B).val(E);$(".imagereg",B).attr("src",pageData.baseurl+"/hv/image?hash="+E);$(".imageregt",B).val("")}},complete:function(){$(".progress_imagereg",B).addClass("h-hide")}});return false};vBulletin.hv.initHvForPostAction=function(B){if(!pageData.showhv_post||B.closest(".edit-post").length>0){return }$(".content-entry-box .humanverify").remove();$.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/render/humanverify",type:"POST",data:({action:"post"}),dataType:"json",success:function(C){console.log("/ajax/render/humanverify");if(C&&!C.errors){$(".content_entry_box_buttons",B).before(C);if($(".humanverify.humanverify_image",B).length>0){vBulletin.hv.imagereg.init(B)}}else{console.log("/ajax/render/humanverify successful, but response was not valid: "+JSON.stringify(C));openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"})}},error:function(E,D,C){console.log("/ajax/render/humanverify failed, error: "+C);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_loading_delete_form_x",E.status),iconType:"error"})}})};$(document).ready(function(){vBulletin.hv.imagereg.init();if(typeof (window.vBulletin.hv_script)!="undefined"&&typeof (window.vBulletin.delayedInit)!="undefined"&&window.vBulletin.delayedInit){$.getScript(window.vBulletin.hv_script,function(){reloadRecaptcha()})}})})(jQuery);