/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.4.0 Release Candidate 1
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2018 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","upload_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");if(F.length==0){F=H.find(".profile-tabs-nav > li")}var N=F.filter(".ui-tabs-active");if(N.length==0){N=F.filter(".b-comp-menu-dropdown__content-item--current")}if(N.length==0){function X(a,Z){var c=[];a.find(".ui-tabs-nav > li > a, .widget-tabs-panel").each(function(f,h){var g=A(this).data("url-path");if(A.inArray(g,c)==-1){c.push(g)}});var b=new RegExp("\\/("+c.join("|")+")/?$"),e=location.pathname.match(b);if(e){var d=false;Z.each(function(){var f=A(this);if(f.find("a").data("url-path")==e[1]){d=f;return false}});if(d){return d}}return A()}N=X(H,F)}var M=N.index(),Y,D,I=A(".subscribed-tab",H),Q=A(".conversation-list",I),L=A(".activities-tab",H),G=A(".conversation-list",L),P,R,S={},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()}Y=N.find("> a").attr("href");F.removeClass("ui-state-disabled");function V(c,b,e,a){if(E.isEnabled()){var d=E.getState();if(a||!d||A.isEmptyObject(d.data)){var Z={from:c,tab:b,page:typeof e=="undefined"?undefined:e};E.setDefaultState(Z,document.title,location.href)}}}var U=function(b,a,Z){a.setOption("context",b);if(typeof a.lastFilters!="undefined"&&A(".conversation-empty:not(.h-hide)",Z).length>0){delete a.lastFilters}};var O=function(Z){vBulletin.truncatePostContent(Z);vBulletin.conversation.processPostContent(Z)};var W=function(e,Z,d,c,a,f){var b=new vBulletin.conversation.filter({context:e,allowHistory:c,tabParamAsQueryString:false,onContentLoad:function(){O(Z);if(a){a()}}});if(d){O(Z);if(f){f()}b.lastFilters={filters:b.getSelectedFilters(A(".toolbar-filter-overlay",e))}}return{filter:b}};var T=function(a,Z,e){var d=Z.id,l=A(Z),c=(Y==e);if(typeof S[d]=="undefined"){S[d]=A(".conversation-toolbar-wrapper",Z).data("allow-history")=="1"}if(e=="#activities-tab"){if(!D){var m=function(){if(vBulletin.upload){vBulletin.upload.initializePhotoUpload(L)}};var f=W(L,G,c,S[d],m,m);D=f.filter}else{U(L,D,Z)}D.applyFilters(false,true)}else{if(e=="#subscribed-tab"){if(!P){var h=W(I,Q,c,S[d],null,null);P=h.filter}else{U(I,P,Z)}P.applyFilters(false,true)}else{if(e=="#about-tab"){if(c){V("tabs","about");return }var j=A(".js-profile-about-container",Z);if(A(".section",j).length==0){A.post(vBulletin.getAjaxBaseurl()+"/profile/fetchAbout",{userid:j.data("user-id")},function(n){j.html(n)},"html")}}else{if(e=="#media-tab"){var i=Number(A("#mediaCurrentPage").val());if(c){V("media_filter","media",i,true);vBulletin.media.setHistoryStateChange();l.data("media-statechange-set",true);return }var b=A(".js-profile-media-container",Z);if(A(".item-album",b).length==0){var g=0;if(typeof (vBulletin.contentEntryBox)=="undefined"){g=1}A.post(vBulletin.getAjaxBaseurl()+"/profile/fetchMedia",{userid:b.data("user-id"),perpage:b.data("perpage"),allowHistory:1,includeJs:g,isAjaxTemplateRender:true},function(n){b.html(n);if(c){var o=Number(A("#mediaCurrentPage").val());V("media_filter","media",o,true)}vBulletin.media.setHistoryStateChange(true);l.data("media-statechange-set",true);if(typeof (vBulletin.contentEntryBox)!="undefined"){vBulletin.contentEntryBox.init()}},"json")}else{if(!l.data("media-statechange-set")){V("media_filter","media",i,true);vBulletin.media.setHistoryStateChange();l.data("media-statechange-set",true)}}}else{if(e=="#infractions-tab"){var i=Number(A(".pagenav-form .js-pagenum",Z).val())||1;if(c){if(A(".pagenav-form",Z).length&&!l.data("pagination-instance")){var k=new vBulletin.pagination({context:l,tabParamAsQueryString:false,allowHistory:l.find(".conversation-toolbar-wrapper").data("allow-history")==1,onPageChanged:function(n,o){vBulletin.infraction.loadUserInfractions({container:l,userid:l.data("userid"),pageNumber:n,replaceState:true})}});l.data("pagination-instance",true)}V("infraction_filter","infractions",i,true);vBulletin.infraction.setHistoryStateChange();l.data("infraction-statechange-set",true);return }if(A(".infraction-list",Z).length==0){V("infraction_filter","infractions",i,true);vBulletin.infraction.loadUserInfractions({container:l,userid:l.data("userid"),pageNumber:i,callback:function(){vBulletin.infraction.setHistoryStateChange();l.data("infraction-statechange-set",true)}})}else{if(!l.data("infraction-statechange-set")){V("infraction_filter","infractions",i,true);vBulletin.infraction.setHistoryStateChange();l.data("infraction-statechange-set",true)}}}}}}}};vBulletin.tabify.call(H,{tabHistory:E,getTabIndexByHash:function(Z){Z=Z||Y;return F.filter('li:has(a[href*="'+Z+'"])').first().index()},allowHistory:K,tabParamAsQueryString:false,hash:J,tabOptions:{active:M,beforeActivate:function(Z,a){if(D){D.hideFilterOverlay()}if(P){P.hideFilterOverlay()}},create:function(Z,a){T(a.tab,a.panel,a.panel.selector)},activate:function(Z,a){T(a.newTab,a.newPanel,a.newPanel.selector)}}});A(".customize-theme").off("click").on("click",function(b){var a=A(".profile_custom_edit");if(a.is(":hidden")){var Z=function(){a.removeClass("h-hide");vBulletin.animateScrollTop(a.offset().top,{duration:"slow"})};if(A(".profileNavTabs",a).length>0){Z()}else{vBulletin.AJAX({call:"/ajax/render/profile_custom_edit",userid:a.data("page-userid"),success:function(c){a.html(c);a.prependTo("#content");Z()},error_phrase:"unable_to_contact_server_please_try_again"})}}else{vBulletin.animateScrollTop(a.offset().top,{duration:"slow"})}})}else{A(".customize-theme").addClass("h-hide-imp")}A(".profileDetailTabs").tabs();A(".toggle_customizations").off("click").on("click",function(b){var Z=A(this),a;if(Z.attr("data-action")=="show"){a=1}else{a=0}A.ajax({url:vBulletin.getAjaxBaseurl()+"/profile/toggle-profile-customizations",data:{showusercss:a},type:"POST",dataType:"json",complete:function(){A("body").css("cursor","auto")},success:function(c){window.location.reload()},error:function(e,d,c){console.log("/profile/toggle-profile-customizations error: "+c);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(a){var Z=A(this).closest("form.poll");var b=Z.find("ul.poll");A(this).addClass("h-hide");b.css("max-height","none").find("li.h-hide").slideDown(100,function(){Z.find(".js-button-group").removeClass("h-hide").next(".view-less-ctrl").removeClass("h-hide");vBulletin.animateScrollTop(Z.offset().top,{duration:"fast"})});return false});C.off("click",".list-item-poll .view-less-ctrl").on("click",".list-item-poll .view-less-ctrl",function(a){var Z=A(this).closest("form.poll");vBulletin.conversation.limitVisiblePollOptionsInAPost(Z,3);Z.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 Z=A(this).parents(".unsubscribe-overlay");A(Z).dialog("close").remove()});A(document).off("click",".unsubscribe-delete").on("click",".unsubscribe-delete",function(){vBulletin.subscribe.removeUnsubscribeOptions(this,P)});A(document).off("click",".profileTabs .action_button").on("click",".profileTabs .action_button",function(){if(!A(this).hasClass("subscribepending_button")){var Z=A(this);var b=parseInt(Z.attr("data-userid"));var a="";if(Z.hasClass("subscribe_button")){a="add"}else{if(Z.hasClass("unsubscribe_button")){a="delete"}}if((typeof (b)=="number")&&a){A.ajax({url:vBulletin.getAjaxBaseurl()+"/profile/follow-button?do="+a+"&follower="+b+"&type=follow_members",type:"POST",dataType:"json",success:function(d){if(d==1||d==2){if(a=="add"){var c=(d==1)?"subscribed":"subscribepending";var e=(d==1)?"following":"following_pending";Z.removeClass("subscribe_button").addClass(c+"_button b-button").find(".js-button__text-primary").text(vBulletin.phrase.get(e))}else{if(a=="delete"){Z.removeClass("subscribed_button unsubscribe_button b-button b-button--special").addClass("subscribe_button b-button b-button--secondary").find(".js-button__text-primary").text(vBulletin.phrase.get("follow"))}}location.reload()}else{if(d.errors){openAlertDialog({title:vBulletin.phrase.get("profile_guser"),message:vBulletin.phrase.get(d.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(Z){A(this).html(vBulletin.phrase.get("following_remove")).addClass("b-button").toggleClass("subscribed_button unsubscribe_button b-button--special b-button--secondary")});A(document).off("mouseout",".profileTabs .action_button.unsubscribe_button").on("mouseout",".profileTabs .action_button.unsubscribe_button",function(Z){A(this).html(vBulletin.phrase.get("following")).addClass("b-button").toggleClass("subscribed_button unsubscribe_button b-button--special b-button--secondary")});A(document).off("click",".js-updata-status-btn").on("click",".js-updata-status-btn",function(){var a=A(this).closest(".section-content").find(".js-user-status-text");var Z=A.trim(a.val());if(a.hasClass("placeholder")&&Z==a.attr("placeholder")){Z=""}var b=window.vBulletin.options.get("statusMaxChars");if(Z.length>b){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_enter_user_status_with_at_most_x_characters",b),iconType:"warning"});return false}vBulletin.AJAX({call:"/profile/update-status",data:{userid:pageData.userid,status:Z},title_phrase:"profile_guser",error_phrase:"error_trying_to_change_user_status",success:function(c){A("#userStatus").text('"'+c+'"');a.val("")},emptyResponse:function(){A("#userStatus").text("");a.val("")}})});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(Z){if(A(Z.target).closest(".bubble-flyout").length==1){vBulletin.conversation.showWhoVoted.apply(Z.target,[Z])}else{vBulletin.conversation.votePost.apply(this,[Z])}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(Z){vBulletin.conversation.postComment.apply(this,[Z,function(){location.reload()}])})}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 a=A("[name=profile-img-option]:checked").val();switch(parseInt(a)){case 2:var Z=A("#profilePhotoUrl").val();if(!Z){vBulletin.error("edit_avatar","upload_invalid_url");break}initIAS();A("#profilePicImgCrop").attr("src",Z);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(Z){Z.preventDefault();A('<iframe style="display:none;"></iframe>').prop("src",this.href).appendTo("body")});A("#editProfilePhotoDlg .frmprofilePhoto").ajaxForm({success:function(a,d,f,Z){if(a){if(a.errors){if(typeof (a.errors[0])=="undefined"){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get(a.errors),iconType:"error"})}else{openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get(a.errors[0][0]),iconType:"error"})}}else{if(a["0"]){var c=a["0"].indexOf("?")==-1?"?":"&";var e=A("#profilePicImg").attr("src",pageData.baseurl_core+"/"+a["0"]+c+"random="+Math.random()).attr("src");A(".avatar-"+pageData.userid).attr("src",e);var b=A("#editProfilePhotoDlg");b.find("form").trigger("reset");b.dialog("close")}}}else{openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get("unable_to_upload_profile_photo"),iconType:"error"})}},error:function(Z){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})},complete:function(b,a){var Z=A("#editProfilePhotoDlg");Z.find(".js-upload-progress").addClass("h-hide");Z.find("input,button").prop("disabled",false);Z.find(".js-upload-button").removeClass("h-disabled")},dataType:"json",beforeSerialize:function(){var Z=A("#editProfilePhotoDlg");var a=A('[name="profile-img-option"]:checked',Z);if(a.val()=="2"&&A.trim(A(".profilePhotoUrl",Z).val())!=""){Z.find("button, input").prop("disabled",true);a.closest(".profile-img-option-container").find(".profile-img-option-field input").prop("disabled",false)}return true},beforeSubmit:function(f,Z,d){var g=A('[name="profile-img-option"]:checked',Z);var e=g.val(),c=true;if(e=="1"){if(A(".fileText",Z).val()==""){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:"Please browse an image to upload.",iconType:"warning",onAfterClose:function(){g.focus()}});c=false}}else{if(e=="2"){if(A.trim(A(".profilePhotoUrl",Z).val())==""){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:"Please specify the image URL from a hosting site.",iconType:"warning",onAfterClose:function(){A(".profilePhotoUrl",Z).focus()}});c=false}}else{if(e=="3"){var b=A(".avatarHolder .defaultAvatarSet.defaultAvatarSelected").data("avatarid");if(!b){openAlertDialog({title:vBulletin.phrase.get("edit_avatar"),message:"Please select a default profile photo.",iconType:"warning",onAfterClose:function(){g.focus()}})}else{setDefaultAvatar(b)}c=false}}}if(c){var a=A("#editProfilePhotoDlg");a.find(".js-upload-progress").removeClass("h-hide");a.find(".js-upload-button").addClass("h-disabled")}return c}})})})(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",close:function(){modifyIasForTouch("disable")},}).dialog("open");A.on("vbulletin:dialogresize",function(E){resizeAvatarEditDialog()});$(".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(".js-upload-progress").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(".js-upload-progress").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(".js-upload-progress").addClass("h-hide");A.find("input,button").prop("disabled",false);A.find(".js-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,B=$("#profilePicImgCrop"),A=$("#editProfilePicture"),D=A.data("avatarmaxwidth"),C=A.data("avatarmaxheight");B.off("load").on("load",function(){if(E){return }B[0].style.setProperty("max-width","none","important");B[0].style.setProperty("max-height","none","important");var H=B.width(),F=B.height();B[0].style.setProperty("max-width","");B[0].style.setProperty("max-height","");if(H>D||F>C){E=true;var G=B.width(),J=B.height(),I=Math.min(D,C,G,J);ias=B.imgAreaSelect({aspectRatio:"1:1",handles:true,zIndex:1012,enable:true,show:true,x1:0,y1:0,x2:I,y2:I,onSelectChange:setDimensions,resizeMargin:(("ontouchstart" in document)?30:15),instance:true,keys:true,persistent:true,});modifyIasForTouch("enable");resizeAvatarEditDialog()}else{$("#btnProfilePhotoSave").trigger("click")}})};function resizeAvatarEditDialog(){var D=$("#editProfilePhotoDlg");D.dialog("option","position",{my:"center",at:"center",of:window,collision:"flipfit",});var I=$(".profile-photo-wrapper",D);I.height("auto");var J=$(window).height(),P=D.closest(".edit-profile-photo-dialog-container"),N=P.height(),M=I.height(),B=$("#profilePicImgCrop"),C=B.imgAreaSelect({instance:true});if(N>J){var E=N-J,A=M-E;I.height(A);var L=$("#editProfilePicture"),O=L.data("avatarmaxwidth"),K=L.data("avatarmaxheight"),G=B.width(),F=B.height(),H=Math.min(O,K,G,F);B.imgAreaSelect({x1:0,y1:0,x2:H,y2:H})}C.update()}function modifyIasForTouch(C){function A(J){var I=J.originalEvent.touches;if(I.length>1){return }var K={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",touchcancel:"mouseout",};if(typeof K[J.type]=="undefined"){return }var H=I[0],G={bubbles:true,cancelable:false,view:window,detail:1,screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:false,altKey:false,shiftKey:false,metaKey:false,button:0,buttons:0,relatedTarget:null,};try{G.screenX=H.screenX;G.screenY=H.screenY;G.clientX=H.clientX;G.clientY=H.clientY}catch(E){}if(J.type=="touchstart"){G.buttons=0;var F=new MouseEvent("mousemove",G);J.target.dispatchEvent(F)}G.buttons=1;var D=new MouseEvent(K[J.type],G);J.target.dispatchEvent(D);if(J.target.className.match(/imgareaselect-/)){J.preventDefault();return false}}function B(D){if(!("ontouchstart" in document)){return }if(D=="enable"){$(document).off(".iastouch").on("touchstart.iastouch touchmove.iastouch touchend.iastouch touchcancel.iastouch",A);$("#editProfilePhotoDlg").css("-webkit-touch-callout","none");$("body, html").addClass("h-prevent-scroll-v")}else{$(document).off(".iastouch");$("#editProfilePhotoDlg").css("-webkit-touch-callout","default");$("body, html").removeClass("h-prevent-scroll-v")}}B(C)}setDefaultAvatar=function(B){var A=$("#editProfilePhotoDlg");A.find(".js-upload-progress").removeClass("h-hide");A.find("button, input").prop("disabled",true);A.find(".js-upload-button").addClass("h-disabled");$.ajax({url:vBulletin.getAjaxBaseurl()+"/profile/set-default-avatar?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(".js-upload-progress").addClass("h-hide");A.find("input,button").prop("disabled",false);A.find(".js-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(".js-upload-progress").addClass("h-hide");A.find("input,button").prop("disabled",false);A.find(".js-upload-button").removeClass("h-disabled")}})};closeUploader=function(){modifyIasForTouch("disable");$("#profilePicImgCrop").imgAreaSelect({remove:true});if(ias!=null){ias=null}$("#profilePhotoFile").fileupload("destroy");$("#profilePhotoFile").removeData(["fileupload","blueimp.fileupload.form"])};