/*=======================================================================*\
|| ###################################################################### ||
|| # 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_adding_search_tips_code_x","invalid_json_string","invalid_search_syntax","invalid_server_response_please_try_again","search_tag_cloud","please_select_past_date","please_select_valid_date_range","content_type_Text","content_type_Gallery","content_type_Link","content_type_Photo","content_type_Poll","content_type_PrivateMessage","content_type_Video","save_as_search_module","saved_search_module_as_x","search_module_already_exists","search_module_not_found","please_enter_search_module_name","error_saving_search_module_x"]);(function(A){var B=[".search-fields-widget",".search-results-widget","#search-config-dialog"];if(!vBulletin.pageHasSelectors(B)){return false}window.vBulletin.search=window.vBulletin.search||{};window.vBulletin.search.SearchControl=function(G){var C=A(G),F=false,D=false,K=function(){var Q=C.find(".searchSwitchToAdvanced");var O=C.find(".searchSwitchToForm");var M=Q.is(":visible");var P=O.is(":visible");if(M==P){Q.toggle(true);O.toggle(false);C.find(".form_row.form-row-json").addClass("h-hide-imp").nextAll().show()}Q.off("click").on("click",function(){var T=J();if(!T){return false}var U=JSON.stringify(T);C.find(".searchFields_searchJSON").val(U);C.find(".form_row.form-row-json").removeClass("h-hide-imp").nextAll().hide();Q.toggle(false);O.toggle(true)});O.off("click").on("click",function(){if(I(C.find(".searchFields_searchJSON").val())){Q.toggle(true);O.toggle(false);C.find(".form_row.form-row-json").addClass("h-hide-imp").nextAll().show()}});var N=C.find(".advSearchForm");if(N.length>0){N.submit(H)}var R=C.find(".searchSubmitBtn");if(R.length>0){R.off("click").on("click",H)}var S=C.find(".searchResetBtn");if(S.length>0){S.off("click").on("click",function(){I("{}")})}F=new vBulletin.tagEditor.instance("{0}-searchFields_tag".format(G.replace(/\#/g,".")),true);var L=C.find(".searchFields_author");if(L.length>0){D=new vBulletin_Autocomplete(L,{apiClass:"user",containerClass:"entry-field h-clearfix"})}C.find(".searchFields_keywords").off("keydown").on("keydown",function(T){if(T.which==13){if(N.length>0){N.submit()}}});C.find(".searchFields_last_visit").off("click").on("click",function(T){C.find(".datefield").prop("disabled",A(this).prop("checked"));if(A(this).is(":checked")){C.find(".searchFields_from_date").datepicker("disable");C.find(".searchFields_to_date").datepicker("disable")}else{C.find(".searchFields_from_date").datepicker("enable");C.find(".searchFields_to_date").datepicker("enable")}});C.find(".searchFields_channel_param").off("click").on("click",function(T){if(A(this).prop("checked")){C.find(".searchFields_channel").selectBox("disable")}else{C.find(".searchFields_channel").selectBox("enable")}});C.find(".search-tips").off("click").on("click",function(T){A(".search-tips-dialog").first().dialog({title:vBulletin.phrase.get("search_tips"),autoOpen:false,modal:true,resizable:false,closeOnEscape:true,showCloseButton:true,width:500,dialogClass:"dialog-container search-tips-dialog-container dialog-box"}).dialog("open");T.stopPropagation();return false});C.find(".searchFields_channel").selectBox();C.find(".searchFields_order_field").selectBox();C.find(".searchFields_order_direction").selectBox();C.find(".searchFields_view").selectBox()},H=function(M){if(!C.find(".searchAdvancedFields").is(":visible")){var L=J();if(!L){return false}if(!L.author&&!L.channel&&!L.keywords&&!L.tag&&!L.type&&!L.date&&!L.last_visit){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_no_criteria"),iconType:"warning"});return false}C.find(".searchFields_searchJSON").val(JSON.stringify(L));C.find("form.advSearchForm").append(A("<input>").attr("name","humanverify[input]").attr("type","hidden").val(A('div.humanverify [name="humanverify[input]"]').val())).append(A("<input>").attr("name","humanverify[hash]").attr("type","hidden").val(A('div.humanverify [name="humanverify[hash]"]').val()))}},J=function(){var P={};if(C.find(".searchSwitchToForm").is(":visible")){P=JSON.parse(C.find(".searchFields_searchJSON").val()||"{}");if(P.length==0){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("invalid_json_string"),iconType:"warning"});return }return P}C.find("input[placeholder].placeholder").each(function(){if(A(this).val()==A(this).attr("placeholder")){A(this).val("")}});var o=C.find(".searchFields_keywords");if(o.length>0&&A.trim(o.val()).length>0){P.keywords=A.trim(o.val())}var L=C.find(".searchFields_title_only");if(L.length>0&&L.prop("checked")){P.title_only=1}var k=C.find(".searchFields_starter_only");if(k.length>0&&k.prop("checked")){P.starter_only=1}var O=C.find(".searchFields_myFriends");var d=C.find(".searchFields_iFollow");if(O.length>0&&O.prop("checked")){P.author="myFriends"}else{if(d.length>0&&d.prop("checked")){P.author="iFollow"}else{if(D){var n=D.getLabels();if(n.length>0){P.author=n}}}}var X=C.find(".tag-input");if(X.length>0){var N=C.find(".tag-input").val();if(N.length>0){var a=N.split(",");if(a.length>0){P.tag=a}}}var j=C.find(".searchFields_last_visit");if(j.length>0&&j.prop("checked")){P.last_visit=1}else{var M={};var R=C.find(".searchFields_from_days");if(R.length>0&&A.trim(R.val()).length>0){M.from=A.trim(R.val())}else{var h=C.find(".searchFields_from_date");var g=new Date();var i=g.getTime();if(h.length>0&&A.trim(h.val()).length>0){var Y=Date.parse(h.val());if(Y<=0){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("invalid_start_date"),iconType:"warning"});return false}else{if(Y>i){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_select_past_date"),iconType:"warning"});return false}}M.from=A.trim(h.val())}var b=C.find(".searchFields_to_date");if(b.length>0&&A.trim(b.val()).length>0){var W=Date.parse(b.val());if(W<=0){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("invalid_end_date"),iconType:"warning"});return false}else{if(W>i){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_select_past_date"),iconType:"warning"});return false}}if(Y&&Y>W){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_select_valid_date_range"),iconType:"warning"});return false}M.to=A.trim(b.val())}}if(!A.isEmptyObject(M)){P.date=M}}var c=C.find(".searchFields_featured");if(c.length>0&&c.prop("checked")){P.featured=1}var V=C.find(".searchFields_my_following");if(V.length>0&&V.prop("checked")){P.my_following=1}var Z=[];C.find(".searchFields_type:checked").each(function(p,q){Z.push(A(q).val())});if(A(Z).length>0){P.type=Z}var f=C.find(".searchFields_channel_param");if(f.length>0&&f.prop("checked")){P.channel={param:"channelid"}}else{var l=C.find("select.searchFields_channel");if(l.length>0){var S=l.val();if(S){P.channel=S}}}var Q=C.find(".searchFields_order_field");var U=C.find(".searchFields_order_direction");if(Q.length>0&&U.length>0&&Q.val()!=""){P.sort=Q.val();if(U.val()!=""){P.sort={};P.sort[Q.val()]=U.val()}}var T=C.find(".searchFields_view");if(T.length>0){P.view=T.val()}var m=C.find(".searchFields_exclude");if(m.length>0&&A.trim(m.val()).length>0){P.exclude=A.trim(m.val()).split(",")}var e=C.find(".searchFields_exclude_type");if(e.length>0&&A.trim(e.val()).length>0){P.exclude_type=A.trim(e.val()).split(",")}return P},I=function(f,j,u,R){var P=f;if(typeof f=="string"){try{f=JSON.parse(f||"{}");if(f.length==0){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("invalid_json_string"),iconType:"warning"});return false}}catch(q){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("invalid_json_string"),iconType:"warning"});return false}}else{P=JSON.stringify(f)}var L=C.find(".searchFields_keywords");if(L.length>0){L.val(f.keywords||"");delete f.keywords}var i=C.find(".searchFields_title_only");if(i){i.prop("checked",f.title_only?true:false);delete f.title_only}var N=C.find(".searchFields_myFriends");var d=false;if(N.length>0){if(f.author&&f.author=="myFriends"){d=true;delete f.author}N.prop("checked",d)}var c=C.find(".searchFields_iFollow");var k=false;if(c.length>0){if(f.author&&f.author=="iFollow"){k=true;delete f.author}c.prop("checked",k)}var U=C.find(".searchFields_author");if(U.length>0){var Y=false;if(A.isArray(f.author)){Y=f.author}else{if(f.exactname){Y=[f.author]}}if(Y){D.setElements(Y);delete f.author;delete f.exactname}}var W=C.find(".searchFields_starter_only");if(W.length>0){W.prop("checked",f.starter_only?true:false);delete f.starter_only}var o=C.find(".tag-input");if(o.length>0){var n=f.tag||[];o.val(n);F.setTags(n);C.find(".tag-list span").html(n.join(", "));delete f.tag}var O=C.find(".searchFields_last_visit");var Q=false;if(f.last_visit||(f.date&&f.date.from&&f.date.from=="lastVisit")){Q=true}if(O.length>0){O.prop("checked",Q);C.find(".datefield").prop("disabled",Q);if(f.last_visit){delete f.last_visit}if(f.date&&f.date.from&&f.date.from=="lastVisit"){delete f.date["from"]}}var r=C.find(".searchFields_from_date");var w=C.find(".searchFields_to_date");var M=C.find(".searchFields_from_days");if(!Q){if(r.length>0){var g="";if(f.date&&f.date.from){g=f.date.from;delete f.date["from"]}r.val(g)}if(w.length>0){var t="";if(f.date&&f.date.to){t=f.date.to;delete f.date["to"]}w.val(t)}if(M.length>0){var g="";if(f.date&&f.date.from){g=f.date.from;delete f.date["from"]}M.val(g)}if(A.isEmptyObject(f.date)){delete f.date}}if(r.length>0){r.datepicker(O.is(":checked")?"disable":"enable")}if(w.length>0){w.datepicker(O.is(":checked")?"disable":"enable")}var m=C.find(".searchFields_featured");if(m.length>0){m.prop("checked",f.featured?true:false);delete f.featured}var V=C.find(".searchFields_my_following");if(V.length>0){V.prop("checked",f.my_following?true:false);delete f.my_following}var s=C.find(".searchFields_type_container");if(s.length>0){if(j){var X=s.find(".field-desc");X.prevAll().remove();A.each(j,function(y,x){if(y!="vBForum_PrivateMessage"){X.before(A('<label><input type="checkbox" name="searchFields[type][]" class="searchFields_type" value="'+y+'" /><span>'+vBulletin.phrase.get("content_type_"+x["class"])+"</span></label>"))}})}C.find(".searchFields_type").val(f.type||[]);delete f.type;delete f.exclude_type}var p=C.find(".searchFields_channel_param");var a=false;if(p.length>0){if(typeof f.channel=="object"&&f.channel.param){a=true;delete f.channel}p.prop("checked",a)}var l=C.find(".searchFields_channel");if(l.length>0){var v=false;if(p.length>0){l.prop("disabled",a)}if(u){l.children().remove();E(u,l);v=true}if(!a){l.val(f.channel||"");delete f.channel;v=true}if(v){resetSelectBox(l)}}var b=C.find("select.searchFields_order_direction");var S=C.find("select.searchFields_order_field");var h="";var Z="";if(f.sort){if(typeof f.sort=="string"){h=f.sort}else{if(typeof f.sort=="object"){A.each(f.sort,function(x,y){h=x;Z=y})}}delete f.sort}if(b.length>0){b.val(Z);resetSelectBox(b)}if(S.length>0){S.val(h);resetSelectBox(S)}var e=C.find("select.searchFields_view");if(e.length>0){e.val(f.view||"");resetSelectBox(e);delete f.view}if(!A.isEmptyObject(f)){var T=C.find(".searchSwitchToAdvanced");if(T.length>0){C.find(".form_row.form-row-json").removeClass("h-hide-imp").nextAll().hide();T.hide();C.find(".searchSwitchToForm").show();C.find(".searchFields_searchJSON").val(P)}return false}return true},E=function(L,M){A.each(L,function(O,N){M.append(A("<option></option>").val(O).html(str_repeat("&nbsp;",N.depth*3).concat(N.htmltitle)));if(N.channels){E(N.channels,M)}})};this.load=function(){return J()};this.set=function(O,M,L,N){return I(O,M,L,N)};K()};A(document).ready(function(){var C=A("#advancedSearchFields"),J=A(".search-results-widget");vBulletin.truncatePostContent(J);if(C.length>0){var D=new vBulletin.search.SearchControl(C.selector);searchJSONStr=C.find(".searchFields_searchJSON").val();if(searchJSONStr.length>0&&searchJSONStr!=C.find(".searchFields_searchJSON").attr("placeholder")){D.set(searchJSONStr,false,false,true)}C.find(".searchFields_from_date").datepicker({showOn:"both",gotoCurrent:true,maxDate:(new Date()),buttonImage:vBulletin.getAjaxBaseurl()+"/images/calendar-blue.png",buttonImageOnly:true,changeMonth:true,changeYear:true,onSelect:function(P,O){C.find(".searchFields_to_date").datepicker("option","minDate",new Date(P))}});C.find(".searchFields_to_date").datepicker({showOn:"both",gotoCurrent:true,maxDate:(new Date()),buttonImage:vBulletin.getAjaxBaseurl()+"/images/calendar-blue.png",buttonImageOnly:true,changeMonth:true,changeYear:true,onSelect:function(R,Q){var O=new Date();var P=new Date(R);if(O.getTime()>P.getTime()){O=P}var S=C.find(".searchFields_from_date");S.datepicker("option","maxDate",O)}})}var K=A(".sort-controls",J);if(K.length>0){K.find(".searchFields_order_field").selectBox().change(function(){var P=M.find(".searchResults_searchJSON").val()||"{}";var O=JSON.parse(P);O.sort={};O.sort[A(this).val()]=K.find(".searchFields_order_direction").selectBox().val();M.find(".searchResults_searchJSON").val(JSON.stringify(O));A(".resultSearchForm").submit()});K.find(".searchFields_order_direction").selectBox().change(function(){var P=M.find(".searchResults_searchJSON").val()||"{}";var O=JSON.parse(P);O.sort={};O.sort[K.find(".searchFields_order_field").selectBox().val()]=A(this).val();M.find(".searchResults_searchJSON").val(JSON.stringify(O));A(".resultSearchForm").submit()});K.removeClass("h-invisible")}var M=A(".search-controls",J);if(M.length>0){var I=false;var N=false;M.find(".resultPopupControl").off("click").on("click",function(O){if(A(this).hasClass("open")){A(this).removeClass("open");A(this).siblings(".PopupContent").hide()}else{M.find(".resultPopupControl.open").each(function(Q,P){A(P).siblings(".PopupContent").hide();A(P).removeClass("open")});A(this).addClass("open");A(this).siblings(".PopupContent").show()}O.stopPropagation();return false});var E=M.find(".searchFields_author");if(E.length>0){I=new vBulletin_Autocomplete(E,{apiClass:"user",containerClass:"entry-field h-clearfix"});M.find(".search-controls-members .removable-element .element-text").each(function(P,O){I.addElement(A(O).html())})}if(M.find(".searchResultTagEditor").length>0){N=new vBulletin.tagEditor.instance(".search-controls .searchResultTagEditor",true);M.find(".search-controls-tags .removable-element .element-text").each(function(P,O){N.addTag(A(O).html())})}M.find(".searchPopupBody button").off("click").on("click",function(Q){var R=M.find(".searchResults_searchJSON").val()||"{}";var O=JSON.parse(R);var P=A(this).val();switch(P){case"keywords":O.keywords=M.find(".searchFields_keywords").val();O.title_only=M.find(".searchFields_title_only").is(":checked");break;case"author":O.author=I.getLabels();O.starter_only=M.find(".searchFields_starter_only").is(":checked");break;case"tags":O.tag=N.getTags();break;default:return ;break}M.find(".searchResults_searchJSON").val(JSON.stringify(O));A(".resultSearchForm").submit()});M.find(".removable-element .element-x").off("click").on("click",function(S){var T=M.find(".searchResults_searchJSON").val()||"{}";var P=JSON.parse(T);var R=A(this).parents(".search-control-popup");if(R.hasClass("search-controls-members")){A(this).parents(".removable-element").remove();var O=[];R.find(".removable-element .element-text").each(function(V,U){O.push(A(U).html())});P.author=O;if(O.length==0){delete P.author}}if(R.hasClass("search-controls-tags")){A(this).parents(".removable-element").remove();var Q=[];R.find(".removable-element .element-text").each(function(V,U){Q.push(A(U).html())});P.tag=Q;if(Q.length==0){delete P.tag}}M.find(".searchResults_searchJSON").val(JSON.stringify(P));A(".resultSearchForm").submit()})}var G=A(".search-stats",J);if(G.length>0){}A("html").off("click.searchpopup").on("click.searchpopup",function(O){var P=A(O.target);if(M.length>0&&P.closest(".PopupContent").length==0&&P.closest(".ui-autocomplete").length==0&&M.find(".resultPopupControl.open").length>0&&(A(".tag-editor-container").length==0||A(".tag-editor-container").dialog("isOpen")!==true)){M.find(".resultPopupControl.open").siblings(".PopupContent").hide();M.find(".resultPopupControl.open").removeClass("open")}});if(vBulletin.inlinemod&&typeof vBulletin.inlinemod.init=="function"){vBulletin.inlinemod.init(J)}J.off("click",".js-post-control__ip-address").on("click",".js-post-control__ip-address",vBulletin.conversation.showIp);J.off("click",".js-post-control__vote").on("click",".js-post-control__vote",function(O){if(A(O.target).closest(".bubble-flyout").length==1){vBulletin.conversation.showWhoVoted.apply(O.target,[O])}else{vBulletin.conversation.votePost.apply(this,[O])}return false});J.off("click",".js-post-control__edit").on("click",".js-post-control__edit",vBulletin.conversation.editPost);J.off("click",".js-post-control__flag").on("click",".js-post-control__flag",vBulletin.conversation.flagPost);J.off("click",".js-post-control__comment").on("click",".js-post-control__comment",vBulletin.conversation.toggleCommentBox);J.off("click",".js-comment-entry__post").on("click",".js-comment-entry__post",function(O){vBulletin.conversation.postComment.apply(this,[O,function(P){location.reload()}])});var F=(typeof J.data("keywords")!="undefined")?J.data("keywords").toString():"";if(F.length>0){var L;A(F.split(" ")).each(function(P,O){L=O.toUpperCase();if(L=="OR"||L=="AND"){return }A(".post-header",J).highlight(O);if(!A(".searchFields_title_only",J).attr("checked")){A(".post-content",J).highlight(O)}})}if(J.length==1){var H=A(".pagenav-form",J).attr("action");if(H){A(".pagenav .button",J).each(function(){var O=A(this);if(!O.prop("href")){O.prop("href",H+"&p="+parseInt(O.data("page"),10))}})}}})})(jQuery);function resetSelectBox(A){A.selectBox("destroy");A.removeData("selectBoxControl");A.removeData("selectBoxSettings");A.selectBox()};