/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.1.9 Patch Level 4
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2016 vBulletin Solutions Inc. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
window.vBulletin=window.vBulletin||{};window.vBulletin.phrase=window.vBulletin.phrase||{};window.vBulletin.phrase.precache=window.vBulletin.phrase.precache||[];window.vBulletin.phrase.precache=$.merge(window.vBulletin.phrase.precache,["error","error_trying_to_change_user_status","error_x","follow","following","following_pending","following_remove","invalid_server_response_please_try_again","profile_guser","edit_avatar","invalid_data","no_permission","invalid_url","unable_to_upload_profile_photo","profile_media","album","album_saved","please_enter_message_x_chars","please_enter_title_x_chars","unable_to_contact_server_please_try_again"]);window.vBulletin.options=window.vBulletin.options||{};window.vBulletin.options.precache=window.vBulletin.options.precache||[];window.vBulletin.options.precache=$.merge(window.vBulletin.options.precache,["postminchars","statusMaxChars"]);var albumPhotoCount=0;(function(A){var B=[".profile-sidebar-widget"];if(!vBulletin.pageHasSelectors(B)){return false}if(vBulletin.isAlreadyLoaded("profile")){}A(document).ready(function(){var C=A(".profile-widget"),H=A("#profileTabs");if(H.length>0){var F=H.find(".ui-tabs-nav > li"),N=F.filter(".ui-tabs-selected"),M=N.index(),T,D,I=A(".subscribed-tab",H),P=A(".conversation-list",I),L=A(".activities-tab",H),G=A(".conversation-list",L),O,Q,R={},K=F.parent().data("allow-history")=="1",E=new vBulletin.history.instance(K),J=C.find(".js-module-top-anchor").attr("id");if(M==-1){M=0;N=F.first()}T=N.find("> a").attr("href");F.removeClass("ui-state-disabled");function S(X,W,Z,V){if(E.isEnabled()){var Y=E.getState();if(V||!Y||A.isEmptyObject(Y.data)){var U={from:X,tab:W,page:typeof Z=="undefined"?undefined:Z};E.setDefaultState(U,document.title,location.href)}}}vBulletin.tabify.call(H,{tabHistory:E,getTabIndexByHash:function(U){U=U||T;return F.filter('li:has(a[href*="'+U+'"])').first().index()},allowHistory:K,tabParamAsQueryString:false,hash:J,tabOptions:{selected:M,select:function(U,V){if(D){D.hideFilterOverlay()}if(O){O.hideFilterOverlay()}},show:function(U,b){var W=b.panel.id,d=A(b.panel),Y=A(this);if(typeof R[W]=="undefined"){R[W]=A(".conversation-toolbar-wrapper",b.panel).data("allow-history")=="1"}if(b.tab.hash=="#activities-tab"){if(!D){D=new vBulletin.conversation.filter({context:L,allowHistory:R[W],tabParamAsQueryString:false,onContentLoad:function(){vBulletin.conversation.processPostContent(G);vBulletin.truncatePostContent(G);if(vBulletin.upload){vBulletin.upload.initializePhotoUpload(L)}}});if(T==b.tab.hash){vBulletin.truncatePostContent(G);vBulletin.conversation.processPostContent(G);if(vBulletin.upload){vBulletin.upload.initializePhotoUpload(L)}D.lastFilters={filters:D.getSelectedFilters(A(".toolbar-filter-overlay",L))}}}else{D.setOption("context",L);if(typeof D.lastFilters!="undefined"&&A(".conversation-empty:not(.h-hide)",b.panel).length>0){delete D.lastFilters}}D.applyFilters(false,true)}else{if(b.tab.hash=="#subscribed-tab"){if(!O){O=new vBulletin.conversation.filter({context:I,allowHistory:R[W],tabParamAsQueryString:false,onContentLoad:function(){vBulletin.conversation.processPostContent(P);vBulletin.truncatePostContent(P)}});if(T==b.tab.hash){vBulletin.truncatePostContent(P);vBulletin.conversation.processPostContent(P);O.lastFilters={filters:O.getSelectedFilters(A(".toolbar-filter-overlay",I))}}}else{O.setOption("context",I);if(typeof O.lastFilters!="undefined"&&A(".conversation-empty:not(.h-hide)",b.panel).length>0){delete O.lastFilters}}O.applyFilters(false,true)}else{if(b.tab.hash=="#about-tab"){if(T==b.tab.hash){S("tabs","about");return }var Z=A(".js-profile-about-container",b.panel);if(A(".section",Z).length==0){A.post(vBulletin.getAjaxBaseurl()+"/profile/fetchAbout",{userid:Z.data("user-id")},function(e){Z.html(e)},"html")}}else{if(b.tab.hash=="#media-tab"){var a=Number(A("#mediaCurrentPage").val());if(T==b.tab.hash){S("media_filter","media",a,true);vBulletin.media.setHistoryStateChange();d.data("media-statechange-set",true);return }var V=A(".js-profile-media-container",b.panel);if(A(".item-album",V).length==0){var X=0;if(typeof (vBulletin.contentEntryBox)=="undefined"){X=1}A.post(vBulletin.getAjaxBaseurl()+"/profile/fetchMedia",{userid:V.data("user-id"),perpage:V.data("perpage"),allowHistory:1,includeJs:X,isAjaxTemplateRender:true},function(e){V.html(e);if(T!=b.tab.hash){var f=Number(A("#mediaCurrentPage").val());S("media_filter","media",f,true)}vBulletin.media.setHistoryStateChange(true);d.data("media-statechange-set",true);vBulletin.contentEntryBox.init()},"json")}else{if(!d.data("media-statechange-set")){S("media_filter","media",a,true);vBulletin.media.setHistoryStateChange();d.data("media-statechange-set",true)}}}else{if(b.tab.hash=="#infractions-tab"){var a=Number(A(".pagenav-form .js-pagenum",b.panel).val())||1;if(T==b.tab.hash){if(A(".pagenav-form",d).length&&!d.data("pagination-instance")){var c=new vBulletin.pagination({context:d,tabParamAsQueryString:false,allowHistory:d.find(".conversation-toolbar-wrapper").data("allow-history")==1,onPageChanged:function(e,f){vBulletin.infraction.loadUserInfractions({container:d,userid:d.data("userid"),pageNumber:e,replaceState:true})}});d.data("pagination-instance",true)}S("infraction_filter","infractions",a,true);vBulletin.infraction.setHistoryStateChange();d.data("infraction-statechange-set",true);return }if(A(".infraction-list",b.panel).length==0){S("infraction_filter","infractions",a,true);vBulletin.infraction.loadUserInfractions({container:d,userid:A(b.tab).data("userid"),pageNumber:a,callback:function(){vBulletin.infraction.setHistoryStateChange();d.data("infraction-statechange-set",true)}})}else{if(!d.data("infraction-statechange-set")){S("infraction_filter","infractions",a,true);vBulletin.infraction.setHistoryStateChange();d.data("infraction-statechange-set",true)}}}}}}}}}});A(".customize-theme").off("click").on("click",function(V){var U=A(".profile_custom_edit");if(U.is(":hidden")){if(A(".profileNavTabs",U).length>0){U.removeClass("h-hide");vBulletin.animateScrollTop(U.offset().top,{duration:"slow"})}else{A.post(vBulletin.getAjaxBaseurl()+"/ajax/render/profile_custom_edit",{userid:U.data("page-userid")},function(W){U.html(W);U.prependTo("#content").removeClass("h-hide");vBulletin.animateScrollTop(U.offset().top,{duration:"slow"})},"json").error(function(){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})}).complete(function(){})}}else{vBulletin.animateScrollTop(U.offset().top,{duration:"slow"})}})}else{A(".customize-theme").addClass("h-hide-imp")}A(".profileDetailTabs").tabs();A(".toggle_customizations").off("click").on("click",function(W){var U=A(this),V;if(U.attr("data-action")=="show"){V=1}else{V=0}A.ajax({url:vBulletin.getAjaxBaseurl()+"/profile/toggle-profile-customizations",data:{showusercss:V},type:"POST",dataType:"json",complete:function(){A("body").css("cursor","auto")},success:function(X){window.location.reload()},error:function(Z,Y,X){console.log("/profile/toggle-profile-customizations error: "+X);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error"),iconType:"error",onAfterClose:function(){window.location.reload()}})}})});if(H.length>0){C.off("click",".list-item-poll .view-more-ctrl").on("click",".list-item-poll .view-more-ctrl",function(V){var U=A(this).closest("form.poll");var W=U.find("ul.poll");A(this).addClass("h-hide");W.css("max-height","none").find("li.h-hide").slideDown(100,function(){U.find(".action-buttons").removeClass("h-hide").next(".view-less-ctrl").removeClass("h-hide");vBulletin.animateScrollTop(U.offset().top,{duration:"fast"})});return false});C.off("click",".list-item-poll .view-less-ctrl").on("click",".list-item-poll .view-less-ctrl",function(V){var U=A(this).closest("form.poll");vBulletin.conversation.limitVisiblePollOptionsInAPost(U,3);U.find("ul.poll").css("max-height","").find("li.h-hide").slideUp(100);return false});A(document).off("click",".unsubscribe-close").on("click",".unsubscribe-close",function(){var U=A(this).parents(".unsubscribe-overlay");A(U).dialog("close").remove()});A(document).off("click",".unsubscribe-delete").on("click",".unsubscribe-delete",function(){vBulletin.subscribe.removeUnsubscribeOptions(this,O)});A(document).off("click",".profileTabs .action_button").on("click",".profileTabs .action_button",function(){if(!A(this).hasClass("subscribepending_button")){var U=A(this);var W=parseInt(U.attr("data-userid"));var V="";if(U.hasClass("subscribe_button")){V="add"}else{if(U.hasClass("unsubscribe_button")){V="delete"}}if((typeof (W)=="number")&&V){A.ajax({url:vBulletin.getAjaxBaseurl()+"/profile/follow_button?do="+V+"&follower="+W+"&type=follow_members",type:"POST",dataType:"json",success:function(Y){if(Y==1||Y==2){if(V=="add"){var X=(Y==1)?"subscribed":"subscribepending";var Z=(Y==1)?"following":"following_pending";U.removeClass("subscribe_button").addClass(X+"_button").find(".button-text-primary").text(vBulletin.phrase.get(Z))}else{if(V=="delete"){U.removeClass("subscribed_button unsubscribe_button special").addClass("subscribe_button secondary").find(".button-text-primary").text(vBulletin.phrase.get("follow"))}}location.reload()}else{if(Y.errors){openAlertDialog({title:vBulletin.phrase.get("profile_guser"),message:vBulletin.phrase.get(Y.errors[0]),iconType:"error"})}}},error:function(){openAlertDialog({title:vBulletin.phrase.get("profile_guser"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})}})}}});A(document).off("mouseover",".profileTabs .action_button.subscribed_button").on("mouseover",".profileTabs .action_button.subscribed_button",function(U){A(this).html(vBulletin.phrase.get("following_remove")).toggleClass("subscribed_button unsubscribe_button special secondary")});A(document).off("mouseout",".profileTabs .action_button.unsubscribe_button").on("mouseout",".profileTabs .action_button.unsubscribe_button",function(U){A(this).html(vBulletin.phrase.get("following")).toggleClass("subscribed_button unsubscribe_button special secondary")});A(document).off("click",".js-updata-status-btn").on("click",".js-updata-status-btn",function(){var V=A(this).closest(".section-content").find(".js-user-status-text");var U=A.trim(V.val());if(V.hasClass("placeholder")&&U==V.attr("placeholder")){U=""}var W=window.vBulletin.options.get("statusMaxChars");if(U.length>W){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_enter_user_status_with_at_most_x_characters",W),iconType:"warning"});return false}A.ajax({url:vBulletin.getAjaxBaseurl()+"/profile/updateStatus",type:"POST",data:({userid:pageData.userid,status:U}),dataType:"json",success:function(X){if(X){if(X.errors){var Y=vBulletin.phrase.get("error_trying_to_change_user_status");if(X.errors&&A.isArray(X.errors)&&A.isArray(X.errors[0])){A.each(X.errors,function(Z,a){A.each(a,function(c,b){if(c>0){a[c]=vBulletin.phrase.get(b)}});X.errors[Z]=vBulletin.phrase.get(a)});Y=X.errors.join("<br />")}else{if(X.errors){Y=vBulletin.phrase.get(X.errors)}}openAlertDialog({title:vBulletin.phrase.get("profile_guser"),message:Y,iconType:"warning"})}else{A("#userStatus").text('"'+X+'"');V.val("")}}else{if(X===""){A("#userStatus").text("");V.val("")}else{openAlertDialog({title:vBulletin.phrase.get("profile_guser"),message:vBulletin.phrase.get("error_trying_to_change_user_status"),iconType:"error"})}}},error:function(){openAlertDialog({title:vBulletin.phrase.get("profile_guser"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"})}})});vBulletin.conversation.bindEditFormEventHandlers("all");C.off("click",".js-post-control__ip-address").on("click",".js-post-control__ip-address",vBulletin.conversation.showIp);C.off("click",".js-post-control__vote").on("click",".js-post-control__vote",function(U){if(A(U.target).closest(".bubble-flyout").length==1){vBulletin.conversation.showWhoVoted.apply(U.target,[U])}else{vBulletin.conversation.votePost.apply(this,[U])}return false});C.off("click",".js-post-control__edit").on("click",".js-post-control__edit",vBulletin.conversation.editPost);C.off("click",".js-post-control__flag").on("click",".js-post-control__flag",vBulletin.conversation.flagPost);C.off("click",".js-post-control__comment").on("click",".js-post-control__comment",vBulletin.conversation.toggleCommentBox);C.off("click",".js-comment-entry__post").on("click",".js-comment-entry__post",function(U){vBulletin.conversation.postComment.apply(this,[U,function(){location.reload()}])});C.off("click",".post-controls .replyCtrl").on("click",".post-controls .replyCtrl",function(){alert("Not implemented yet")})}if(A("body").is(".view-mode")){A("#editProfilePicture").off("click").on("click",editProfilePhoto);A("#btnProfilePhotoSave").off("click").on("click",cropProfilePhoto)}A("#btnProfilePhotoContinue").off("click").on("click",function(){var V=A("[name=profile-img-option]:checked").val();switch(parseInt(V)){case 2:var U=A("#profilePhotoUrl").val();if(!U){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get("upload_invalid_url"),iconType:"error"});break}initIAS();A("#profilePicImgCrop").attr("src",U);case 1:A("div#cropFrame").removeClass("h-hide");A("#btnProfilePhotoSave").removeClass("h-hide-imp");A("#btnProfilePhotoContinue").addClass("h-hide-imp");A("div#uploadFrame").addClass("h-hide");A("#btnProfilePhotoClose").focus();break;case 4:resetAvatar();break}});A("#btnProfilePhotoClose").off("click").on("click",function(){closeUploader();resetCropValues();A("div#uploadFrame").removeClass("h-hide");A("div#cropFrame").addClass("h-hide");A("#btnProfilePhotoSave").addClass("h-hide-imp");A("#btnProfilePhotoContinue").removeClass("h-hide-imp");A("#editProfilePhotoDlg").dialog("close").find("form").trigger("reset")});A(document).off("click",".gallery-upload-form .files a:not([target^=_blank])").on("click",".gallery-upload-form .files a:not([target^=_blank])",function(U){U.preventDefault();A('<iframe style="display:none;"></iframe>').prop("src",this.href).appendTo("body")});A("#editProfilePhotoDlg .frmprofilePhoto").ajaxForm({success:function(V,Y,a,U){if(V){if(V.errors){if(typeof (V.errors[0])=="undefined"){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get(V.errors),iconType:"error"})}else{openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get(V.errors[0][0]),iconType:"error"})}}else{if(V["0"]){var X=V["0"].indexOf("?")==-1?"?":"&";var Z=A("#profilePicImg").attr("src",pageData.baseurl_core+"/"+V["0"]+X+"random="+Math.random()).attr("src");A(".avatar-"+pageData.userid).attr("src",Z);var W=A("#editProfilePhotoDlg");W.find("form").trigger("reset");W.dialog("close")}}}else{openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get("unable_to_upload_profile_photo"),iconType:"error"})}},error:function(U){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})},complete:function(W,V){var U=A("#editProfilePhotoDlg");U.find(".upload-progress-bar").addClass("h-hide");U.find("input,button").prop("disabled",false);U.find(".custom-upload-button").removeClass("h-disabled")},dataType:"json",beforeSerialize:function(){var U=A("#editProfilePhotoDlg");var V=A('[name="profile-img-option"]:checked',U);if(V.val()=="2"&&A.trim(A(".profilePhotoUrl",U).val())!=""){U.find("button, input").prop("disabled",true);V.closest(".profile-img-option-container").find(".profile-img-option-field input").prop("disabled",false)}return true},beforeSubmit:function(a,U,Y){var b=A('[name="profile-img-option"]:checked',U);var Z=b.val(),X=true;if(Z=="1"){if(A(".fileText",U).val()==""){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:"Please browse an image to upload.",iconType:"warning",onAfterClose:function(){b.focus()}});X=false}}else{if(Z=="2"){if(A.trim(A(".profilePhotoUrl",U).val())==""){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:"Please specify the image URL from a hosting site.",iconType:"warning",onAfterClose:function(){A(".profilePhotoUrl",U).focus()}});X=false}}else{if(Z=="3"){var W=A(".avatarHolder .defaultAvatarSet.defaultAvatarSelected").data("avatarid");if(!W){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:"Please select a default profile photo.",iconType:"warning",onAfterClose:function(){b.focus()}})}else{setDefaultAvatar(W)}X=false}}}if(X){var V=A("#editProfilePhotoDlg");V.find(".action-buttons .upload-progress-bar").removeClass("h-hide");V.find(".custom-upload-button").addClass("h-disabled")}return X}})})})(jQuery);var ias=null;editProfilePhoto=function(D){$(".defaultAvatarSet").removeClass("defaultAvatarSelected");$("#defaultAvatars").html("");var A=$("#editProfilePhotoDlg").dialog({width:734,title:vBulletin.phrase.get("edit_avatar"),autoOpen:false,modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,dialogClass:"dialog-container edit-profile-photo-dialog-container dialog-box"}).dialog("open");$(".profile-img-option-container .browse-option").off("click").on("click",function(E){$(".avatarHolder .defaultAvatarSet.defaultAvatarSelected").removeClass("defaultAvatarSelected")});$(".profile-img-option-container .url-option").off("click").on("click",function(E){var F=$(this);$(".avatarHolder .defaultAvatarSet.defaultAvatarSelected").removeClass("defaultAvatarSelected");setTimeout(function(){F.closest(".profile-img-option-container").find(".profilePhotoUrl").trigger("focus.photourl")},10)});$(".profile-img-option-container .default-option").off("click").on("click",function(E){if($("#defaultAvatars .avatarHolder").length==0){var F=$(this);F.closest(".profile-img-option-container").find(".upload-progress-bar").removeClass("h-hide");$.ajax({url:vBulletin.getAjaxBaseurl()+"/profile/getdefaultavatars",type:"POST",dataType:"html",success:function(G){if(G){if(G.errors){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get(G.errors[0][0]),iconType:"error"})}else{$("#defaultAvatars").html(G);$(".defaultAvatarSet").off("click").on("click",function(){$(".defaultAvatarSet").removeClass("defaultAvatarSelected");$(this).addClass("defaultAvatarSelected");$(".profile-img-option-container .default-option").trigger("click")})}}else{openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"})}},error:function(G){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"})},complete:function(){F.closest(".profile-img-option-container").find(".upload-progress-bar").addClass("h-hide")}})}});var C=$("#editProfilePicture").data("avatarmaxsize");var B=false;$("#profilePhotoFile").off("click").on("click",function(){$(this).closest(".profile-img-option-container").find(".browse-option").trigger("click")}).fileupload({url:vBulletin.getAjaxBaseurl()+"/profile/upload_profilepicture",dropZone:null,dataType:"json",add:function(I,H){if(!H.crop){B=H;var G="undefined";var F=(typeof window.createObjectURL!==G&&window)||(typeof URL!==G&&URL)||(typeof webkitURL!==G&&webkitURL);var E=F?F.createObjectURL(H.files[0]):$(H.fileInput).val();var J=H.files[0].fileName||H.files[0].name;$(".profile-img-option-container .fileText").val(J);if(!F){B.fileInput.attr("name","profilePhotoFull");B.submit();B.fileInput.attr("name","profilePhotoFile");closeUploader()}else{$("#btnProfilePhotoContinue").trigger("click");initIAS();$("#profilePicImgCrop").attr("src",E)}}else{H.crop.resized_width=$("#profilePicImgCrop").width();H.crop.resized_height=$("#profilePicImgCrop").height();B.formData=H.crop;B.formData.securitytoken=pageData.securitytoken;B.submit();closeUploader()}},done:function(I,H){var F=H.result;if(F){if(F.errors){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get(F.errors[0]),iconType:"error"});return false}else{if(F.imageUrl){$("#profilePhotoUrl").val(F.imageUrl).data("filedataid",F.filedataid);$("#profilePhotoUrl").trigger("focus");$("#btnProfilePhotoContinue").trigger("click");return false}else{$("#defaultAvatars").html(F);$(".defaultAvatarSet").off("click").on("click",function(){$(".defaultAvatarSet").removeClass("defaultAvatarSelected");$(this).addClass("defaultAvatarSelected");$(".profile-img-option-container .default-option").trigger("click")})}}}else{openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"});return false}var G=F.avatarpath.indexOf("?")==-1?"?":"&";var E=F.avatarpath?(F.avatarpath+G+"random="+Math.random()):F[0];var J=$("#profilePicImg").attr("src",pageData.baseurl_core+"/"+E).attr("src");$(".avatar-"+pageData.userid).attr("src",J);$("#profilePicImgCrop").attr("src","");$("#btnProfilePhotoClose").trigger("click")},fail:function(H,F){var G=vBulletin.phrase.get("error_uploading_image");var E="error";if(F&&F.files.length>0){switch(F.files[0].error){case"acceptFileTypes":G=vBulletin.phrase.get("invalid_image_allowed_filetypes_are");E="warning";break}}openAlertDialog({title:vBulletin.phrase.get("upload"),message:G,iconType:E,onAfterClose:function(){A.find(".fileText").val("");A.find(".browse-option").focus()}})},always:function(F,E){A.find(".action-buttons .upload-progress-bar").addClass("h-hide");A.find("input,button").prop("disabled",false);A.find(".custom-upload-button").removeClass("h-disabled");return false}});$("#profilePhotoUrl").off("focus").on("focus",function(){$(this).closest(".profile-img-option-container").find(".url-option").trigger("click")})};cropProfilePhoto=function(G){var B=$("#profilePicImgCrop").attr("src");if(B==""){closeUploader();openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get("please_select_a_image_to_crop"),iconType:"error"});$("#btnProfilePhotoSave").addClass("h-hide-imp");$("#btnProfilePhotoContinue").removeClass("h-hide-imp");$("div#cropFrame").addClass("h-hide");$("div#uploadFrame").removeClass("h-hide");return false}var F={crop:{}};var A=$("#editProfilePicture");var E=A.data("avatarmaxwidth");var D=A.data("avatarmaxheight");F.crop["x1"]=$("#x1").val()||0;F.crop["x2"]=$("#x2").val()||E;F.crop["y1"]=$("#y1").val()||0;F.crop["y2"]=$("#y2").val()||D;F.crop["width"]=$("#width").val()||E;F.crop["height"]=$("#height").val()||D;F.crop["resized_width"]=$("#profilePicImgCrop").width();F.crop["resized_height"]=$("#profilePicImgCrop").height();F.securitytoken=pageData.securitytoken;var C=$("[name=profile-img-option]:checked").val();if(C=="1"){F.files=$("#profilePhotoFile");F.url=pageData.baseurl+"/profile/upload_profilepicture";$("#profilePhotoFile").fileupload("add",F)}else{if(C=="2"){F.profilePhotoUrl=$("#profilePhotoUrl").val();F.filedataid=$("#profilePhotoUrl").data("filedataid");vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/profile/upload_profilepicture",data:F,success:function(I){var J=I.avatarpath.indexOf("?")==-1?"?":"&";var H=I.avatarpath?(I.avatarpath+J+"random="+Math.random()):I[0];var K=$("#profilePicImg").attr("src",pageData.baseurl_core+"/"+H).attr("src");$(".avatar-"+pageData.userid).attr("src",K);$("#profilePicImgCrop").attr("src","");$("#btnProfilePhotoClose").trigger("click");$("#profilePhotoUrl").data("filedataid","")}})}}resetCropValues()};resetCropValues=function(){$("#x1").val("");$("#x2").val("");$("#y1").val("");$("#y2").val("")};initIAS=function(){var E=false;var B=$("#profilePicImgCrop");var A=$("#editProfilePicture");var D=A.data("avatarmaxwidth");var C=A.data("avatarmaxheight");B.off("load").on("load",function(){if(E){return }if(B.width()>D||B.height()>C){E=true;var F=Math.min(D,C,B.width(),B.height());ias=B.imgAreaSelect({aspectRatio:"1:1",handles:true,zIndex:1012,enable:true,show:true,x1:0,y1:0,x2:F,y2:F,onSelectChange:setDimensions,instance:true})}else{$("#btnProfilePhotoSave").trigger("click")}})};setDefaultAvatar=function(B){var A=$("#editProfilePhotoDlg");A.find(".action-buttons .upload-progress-bar").removeClass("h-hide");A.find("button, input").prop("disabled",true);A.find(".custom-upload-button").addClass("h-disabled");$.ajax({url:vBulletin.getAjaxBaseurl()+"/profile/set_defaultavatar?avatarid="+B,type:"POST",dataType:"json",success:function(C){if(C){if(C.errors){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get(C.errors[0][0]),iconType:"error"})}else{var D=$("#profilePicImg").attr("src",pageData.baseurl_core+"/"+C.avatarpath).attr("src");$(".avatar-"+pageData.userid).attr("src",D);A.dialog("close");A.find("form").trigger("reset")}}else{openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"})}},error:function(){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error"})},complete:function(){A.find(".action-buttons .upload-progress-bar").addClass("h-hide");A.find("input,button").prop("disabled",false);A.find(".custom-upload-button").removeClass("h-disabled")}})};setDimensions=function(A,B){$("#x1").val(B.x1);$("#y1").val(B.y1);$("#x2").val(B.x2);$("#y2").val(B.y2);$("#width").val(B.width);$("#height").val(B.height)};resetAvatar=function(){vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/profile/resetAvatar",success:function(A){var C=$("#profilePicImg").attr("src",pageData.baseurl_core+"/"+A.avatarpath).attr("src");$(".avatar-"+pageData.userid).attr("src",C);$("#btnProfilePhotoClose").trigger("click");var B=$("#editProfilePhotoDlg");B.find("form").trigger("reset")},complete:function(){var A=$("#editProfilePhotoDlg");A.find(".action-buttons .upload-progress-bar").addClass("h-hide");A.find("input,button").prop("disabled",false);A.find(".custom-upload-button").removeClass("h-disabled")}})};closeUploader=function(){$("#profilePicImgCrop").imgAreaSelect({remove:true});if(ias!=null){ias=null}$("#profilePhotoFile").fileupload("destroy");$("#profilePhotoFile").removeData(["fileupload","blueimp.fileupload.form"])};