!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(t){var e=-1,o=-1,n=function(t){return parseFloat(t)||0},a=function(e){var o=1,a=t(e),i=null,r=[];return a.each(function(){var e=t(this),a=e.offset().top-n(e.css("margin-top")),s=r.length>0?r[r.length-1]:null;null===s?r.push(e):Math.floor(Math.abs(i-a))<=o?r[r.length-1]=s.add(e):r.push(e),i=a}),r},i=function(e){var o={
byRow:!0,property:"height",target:null,remove:!1};return"object"==typeof e?t.extend(o,e):("boolean"==typeof e?o.byRow=e:"remove"===e&&(o.remove=!0),o)},r=t.fn.matchHeight=function(e){var o=i(e);if(o.remove){var n=this;return this.css(o.property,""),t.each(r._groups,function(t,e){e.elements=e.elements.not(n)}),this}return this.length<=1&&!o.target?this:(r._groups.push({elements:this,options:o}),r._apply(this,o),this)};r.version="0.7.2",r._groups=[],r._throttle=80,r._maintainScroll=!1,r._beforeUpdate=null,
r._afterUpdate=null,r._rows=a,r._parse=n,r._parseOptions=i,r._apply=function(e,o){var s=i(o),h=t(e),l=[h],c=t(window).scrollTop(),p=t("html").outerHeight(!0),u=h.parents().filter(":hidden");return u.each(function(){var e=t(this);e.data("style-cache",e.attr("style"))}),u.css("display","block"),s.byRow&&!s.target&&(h.each(function(){var e=t(this),o=e.css("display");"inline-block"!==o&&"flex"!==o&&"inline-flex"!==o&&(o="block"),e.data("style-cache",e.attr("style")),e.css({display:o,"padding-top":"0",
"padding-bottom":"0","margin-top":"0","margin-bottom":"0","border-top-width":"0","border-bottom-width":"0",height:"100px",overflow:"hidden"})}),l=a(h),h.each(function(){var e=t(this);e.attr("style",e.data("style-cache")||"")})),t.each(l,function(e,o){var a=t(o),i=0;if(s.target)i=s.target.outerHeight(!1);else{if(s.byRow&&a.length<=1)return void a.css(s.property,"");a.each(function(){var e=t(this),o=e.attr("style"),n=e.css("display");"inline-block"!==n&&"flex"!==n&&"inline-flex"!==n&&(n="block");var a={
display:n};a[s.property]="",e.css(a),e.outerHeight(!1)>i&&(i=e.outerHeight(!1)),o?e.attr("style",o):e.css("display","")})}a.each(function(){var e=t(this),o=0;s.target&&e.is(s.target)||("border-box"!==e.css("box-sizing")&&(o+=n(e.css("border-top-width"))+n(e.css("border-bottom-width")),o+=n(e.css("padding-top"))+n(e.css("padding-bottom"))),e.css(s.property,i-o+"px"))})}),u.each(function(){var e=t(this);e.attr("style",e.data("style-cache")||null)}),r._maintainScroll&&t(window).scrollTop(c/p*t("html").outerHeight(!0)),
this},r._applyDataApi=function(){var e={};t("[data-match-height], [data-mh]").each(function(){var o=t(this),n=o.attr("data-mh")||o.attr("data-match-height");n in e?e[n]=e[n].add(o):e[n]=o}),t.each(e,function(){this.matchHeight(!0)})};var s=function(e){r._beforeUpdate&&r._beforeUpdate(e,r._groups),t.each(r._groups,function(){r._apply(this.elements,this.options)}),r._afterUpdate&&r._afterUpdate(e,r._groups)};r._update=function(n,a){if(a&&"resize"===a.type){var i=t(window).width();if(i===e)return;e=i;
}n?o===-1&&(o=setTimeout(function(){s(a),o=-1},r._throttle)):s(a)},t(r._applyDataApi);var h=t.fn.on?"on":"bind";t(window)[h]("load",function(t){r._update(!1,t)}),t(window)[h]("resize orientationchange",function(t){r._update(!0,t)})});
/*!* jQuery Form Plugin*/!function(r){"function"==typeof define&&define.amd?define(["jquery"],r):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),r(t),t}:r(jQuery)}(function(q){"use strict";var m=/\r?\n/g,S={};S.fileapi=void 0!==q('<input type="file">').get(0).files,S.formdata=void 0!==window.FormData;var _=!!q.fn.prop;function o(e){var t=e.data;e.isDefaultPrevented()||(e.preventDefault(),q(e.target).closest("form").ajaxSubmit(t))}function i(e){var t=e.target,r=q(t);if(!r.is("[type=submit],[type=image]")){var a=r.closest("[type=submit]");if(0===a.length)return;t=a[0]}var n,o=t.form;"image"===(o.clk=t).type&&(void 0!==e.offsetX?(o.clk_x=e.offsetX,o.clk_y=e.offsetY):"function"==typeof q.fn.offset?(n=r.offset(),o.clk_x=e.pageX-n.left,o.clk_y=e.pageY-n.top):(o.clk_x=e.pageX-t.offsetLeft,o.clk_y=e.pageY-t.offsetTop)),setTimeout(function(){o.clk=o.clk_x=o.clk_y=null},100)}function N(){var e;q.fn.ajaxSubmit.debug&&(e="[jquery.form] "+Array.prototype.join.call(arguments,""),window.console&&window.console.log?window.console.log(e):window.opera&&window.opera.postError&&window.opera.postError(e))}q.fn.attr2=function(){if(!_)return this.attr.apply(this,arguments);var e=this.prop.apply(this,arguments);return e&&e.jquery||"string"==typeof e?e:this.attr.apply(this,arguments)},q.fn.ajaxSubmit=function(M,e,t,r){if(!this.length)return N("ajaxSubmit: skipping submit process - no element selected"),this;var O,a,n,o,X=this;"function"==typeof M?M={success:M}:"string"==typeof M||!1===M&&0<arguments.length?(M={url:M,data:e,dataType:t},"function"==typeof r&&(M.success=r)):void 0===M&&(M={}),O=M.method||M.type||this.attr2("method"),n=(n=(n="string"==typeof(a=M.url||this.attr2("action"))?q.trim(a):"")||window.location.href||"")&&(n.match(/^([^#]+)/)||[])[1],o=/(MSIE|Trident)/.test(navigator.userAgent||"")&&/^https/i.test(window.location.href||"")?"javascript:false":"about:blank",M=q.extend(!0,{url:n,success:q.ajaxSettings.success,type:O||q.ajaxSettings.type,iframeSrc:o},M);var i={};if(this.trigger("form-pre-serialize",[this,M,i]),i.veto)return N("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(M.beforeSerialize&&!1===M.beforeSerialize(this,M))return N("ajaxSubmit: submit aborted via beforeSerialize callback"),this;var s=M.traditional;void 0===s&&(s=q.ajaxSettings.traditional);var u,c,C=[],l=this.formToArray(M.semantic,C,M.filtering);if(M.data&&(c=q.isFunction(M.data)?M.data(l):M.data,M.extraData=c,u=q.param(c,s)),M.beforeSubmit&&!1===M.beforeSubmit(l,this,M))return N("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[l,this,M,i]),i.veto)return N("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;var f=q.param(l,s);u&&(f=f?f+"&"+u:u),"GET"===M.type.toUpperCase()?(M.url+=(0<=M.url.indexOf("?")?"&":"?")+f,M.data=null):M.data=f;var d,m,p,h=[];M.resetForm&&h.push(function(){X.resetForm()}),M.clearForm&&h.push(function(){X.clearForm(M.includeHidden)}),!M.dataType&&M.target?(d=M.success||function(){},h.push(function(e,t,r){var a=arguments,n=M.replaceTarget?"replaceWith":"html";q(M.target)[n](e).each(function(){d.apply(this,a)})})):M.success&&(q.isArray(M.success)?q.merge(h,M.success):h.push(M.success)),M.success=function(e,t,r){for(var a=M.context||this,n=0,o=h.length;n<o;n++)h[n].apply(a,[e,t,r||X,X])},M.error&&(m=M.error,M.error=function(e,t,r){var a=M.context||this;m.apply(a,[e,t,r,X])}),M.complete&&(p=M.complete,M.complete=function(e,t){var r=M.context||this;p.apply(r,[e,t,X])});var v=0<q("input[type=file]:enabled",this).filter(function(){return""!==q(this).val()}).length,g="multipart/form-data",x=X.attr("enctype")===g||X.attr("encoding")===g,y=S.fileapi&&S.formdata;N("fileAPI :"+y);var b,T=(v||x)&&!y;!1!==M.iframe&&(M.iframe||T)?M.closeKeepAlive?q.get(M.closeKeepAlive,function(){b=w(l)}):b=w(l):b=(v||x)&&y?function(e){for(var r=new FormData,t=0;t<e.length;t++)r.append(e[t].name,e[t].value);if(M.extraData){var a=function(e){var t,r,a=q.param(e,M.traditional).split("&"),n=a.length,o=[];for(t=0;t<n;t++)a[t]=a[t].replace(/\+/g," "),r=a[t].split("="),o.push([decodeURIComponent(r[0]),decodeURIComponent(r[1])]);return o}(M.extraData);for(t=0;t<a.length;t++)a[t]&&r.append(a[t][0],a[t][1])}M.data=null;var n=q.extend(!0,{},q.ajaxSettings,M,{contentType:!1,processData:!1,cache:!1,type:O||"POST"});M.uploadProgress&&(n.xhr=function(){var e=q.ajaxSettings.xhr();return e.upload&&e.upload.addEventListener("progress",function(e){var t=0,r=e.loaded||e.position,a=e.total;e.lengthComputable&&(t=Math.ceil(r/a*100)),M.uploadProgress(e,r,a,t)},!1),e});n.data=null;var o=n.beforeSend;return n.beforeSend=function(e,t){M.formData?t.data=M.formData:t.data=r,o&&o.call(this,e,t)},q.ajax(n)}(l):q.ajax(M),X.removeData("jqxhr").data("jqxhr",b);for(var j=0;j<C.length;j++)C[j]=null;return this.trigger("form-submit-notify",[this,M]),this;function w(e){var t,r,l,f,o,d,m,p,a,n,h,v,i=X[0],g=q.Deferred();if(g.abort=function(e){p.abort(e)},e)for(r=0;r<C.length;r++)t=q(C[r]),_?t.prop("disabled",!1):t.removeAttr("disabled");(l=q.extend(!0,{},q.ajaxSettings,M)).context=l.context||l,o="jqFormIO"+(new Date).getTime();var s=i.ownerDocument,u=X.closest("body");if(l.iframeTarget?(n=(d=q(l.iframeTarget,s)).attr2("name"))?o=n:d.attr2("name",o):(d=q('<iframe name="'+o+'" src="'+l.iframeSrc+'" />',s)).css({position:"absolute",top:"-1000px",left:"-1000px"}),m=d[0],p={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(e){var t="timeout"===e?"timeout":"aborted";N("aborting upload... "+t),this.aborted=1;try{m.contentWindow.document.execCommand&&m.contentWindow.document.execCommand("Stop")}catch(e){}d.attr("src",l.iframeSrc),p.error=t,l.error&&l.error.call(l.context,p,t,e),f&&q.event.trigger("ajaxError",[p,l,t]),l.complete&&l.complete.call(l.context,p,t)}},(f=l.global)&&0==q.active++&&q.event.trigger("ajaxStart"),f&&q.event.trigger("ajaxSend",[p,l]),l.beforeSend&&!1===l.beforeSend.call(l.context,p,l))return l.global&&q.active--,g.reject(),g;if(p.aborted)return g.reject(),g;(a=i.clk)&&(n=a.name)&&!a.disabled&&(l.extraData=l.extraData||{},l.extraData[n]=a.value,"image"===a.type&&(l.extraData[n+".x"]=i.clk_x,l.extraData[n+".y"]=i.clk_y));var x=1,y=2;function b(t){var r=null;try{t.contentWindow&&(r=t.contentWindow.document)}catch(e){N("cannot get iframe.contentWindow document: "+e)}if(r)return r;try{r=t.contentDocument?t.contentDocument:t.document}catch(e){N("cannot get iframe.contentDocument: "+e),r=t.document}return r}var c=q("meta[name=csrf-token]").attr("content"),T=q("meta[name=csrf-param]").attr("content");function j(){var e=X.attr2("target"),t=X.attr2("action"),r=X.attr("enctype")||X.attr("encoding")||"multipart/form-data";i.setAttribute("target",o),O&&!/post/i.test(O)||i.setAttribute("method","POST"),t!==l.url&&i.setAttribute("action",l.url),l.skipEncodingOverride||O&&!/post/i.test(O)||X.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"}),l.timeout&&(v=setTimeout(function(){h=!0,A(x)},l.timeout));var a=[];try{if(l.extraData)for(var n in l.extraData)l.extraData.hasOwnProperty(n)&&(q.isPlainObject(l.extraData[n])&&l.extraData[n].hasOwnProperty("name")&&l.extraData[n].hasOwnProperty("value")?a.push(q('<input type="hidden" name="'+l.extraData[n].name+'">',s).val(l.extraData[n].value).appendTo(i)[0]):a.push(q('<input type="hidden" name="'+n+'">',s).val(l.extraData[n]).appendTo(i)[0]));l.iframeTarget||d.appendTo(u),m.attachEvent?m.attachEvent("onload",A):m.addEventListener("load",A,!1),setTimeout(function e(){try{var t=b(m).readyState;N("state = "+t),t&&"uninitialized"===t.toLowerCase()&&setTimeout(e,50)}catch(e){N("Server abort: ",e," (",e.name,")"),A(y),v&&clearTimeout(v),v=void 0}},15);try{i.submit()}catch(e){document.createElement("form").submit.apply(i)}}finally{i.setAttribute("action",t),i.setAttribute("enctype",r),e?i.setAttribute("target",e):X.removeAttr("target"),q(a).remove()}}T&&c&&(l.extraData=l.extraData||{},l.extraData[T]=c),l.forceSync?j():setTimeout(j,10);var w,S,k,D=50;function A(e){if(!p.aborted&&!k){if((S=b(m))||(N("cannot access response document"),e=y),e===x&&p)return p.abort("timeout"),void g.reject(p,"timeout");if(e===y&&p)return p.abort("server abort"),void g.reject(p,"error","server abort");if(S&&S.location.href!==l.iframeSrc||h){m.detachEvent?m.detachEvent("onload",A):m.removeEventListener("load",A,!1);var t,r="success";try{if(h)throw"timeout";var a="xml"===l.dataType||S.XMLDocument||q.isXMLDoc(S);if(N("isXml="+a),!a&&window.opera&&(null===S.body||!S.body.innerHTML)&&--D)return N("requeing onLoad callback, DOM not available"),void setTimeout(A,250);var n=S.body?S.body:S.documentElement;p.responseText=n?n.innerHTML:null,p.responseXML=S.XMLDocument?S.XMLDocument:S,a&&(l.dataType="xml"),p.getResponseHeader=function(e){return{"content-type":l.dataType}[e.toLowerCase()]},n&&(p.status=Number(n.getAttribute("status"))||p.status,p.statusText=n.getAttribute("statusText")||p.statusText);var o,i,s,u=(l.dataType||"").toLowerCase(),c=/(json|script|text)/.test(u);c||l.textarea?(o=S.getElementsByTagName("textarea")[0])?(p.responseText=o.value,p.status=Number(o.getAttribute("status"))||p.status,p.statusText=o.getAttribute("statusText")||p.statusText):c&&(i=S.getElementsByTagName("pre")[0],s=S.getElementsByTagName("body")[0],i?p.responseText=i.textContent?i.textContent:i.innerText:s&&(p.responseText=s.textContent?s.textContent:s.innerText)):"xml"===u&&!p.responseXML&&p.responseText&&(p.responseXML=F(p.responseText));try{w=E(p,u,l)}catch(e){r="parsererror",p.error=t=e||r}}catch(e){N("error caught: ",e),r="error",p.error=t=e||r}p.aborted&&(N("upload aborted"),r=null),p.status&&(r=200<=p.status&&p.status<300||304===p.status?"success":"error"),"success"===r?(l.success&&l.success.call(l.context,w,"success",p),g.resolve(p.responseText,"success",p),f&&q.event.trigger("ajaxSuccess",[p,l])):r&&(void 0===t&&(t=p.statusText),l.error&&l.error.call(l.context,p,r,t),g.reject(p,"error",t),f&&q.event.trigger("ajaxError",[p,l,t])),f&&q.event.trigger("ajaxComplete",[p,l]),f&&!--q.active&&q.event.trigger("ajaxStop"),l.complete&&l.complete.call(l.context,p,r),k=!0,l.timeout&&clearTimeout(v),setTimeout(function(){l.iframeTarget?d.attr("src",l.iframeSrc):d.remove(),p.responseXML=null},100)}}}var F=q.parseXML||function(e,t){return window.ActiveXObject?((t=new ActiveXObject("Microsoft.XMLDOM")).async="false",t.loadXML(e)):t=(new DOMParser).parseFromString(e,"text/xml"),t&&t.documentElement&&"parsererror"!==t.documentElement.nodeName?t:null},L=q.parseJSON||function(e){return window.eval("("+e+")")},E=function(e,t,r){var a=e.getResponseHeader("content-type")||"",n=("xml"===t||!t)&&0<=a.indexOf("xml"),o=n?e.responseXML:e.responseText;return n&&"parsererror"===o.documentElement.nodeName&&q.error&&q.error("parsererror"),r&&r.dataFilter&&(o=r.dataFilter(o,t)),"string"==typeof o&&(("json"===t||!t)&&0<=a.indexOf("json")?o=L(o):("script"===t||!t)&&0<=a.indexOf("javascript")&&q.globalEval(o)),o};return g}},q.fn.ajaxForm=function(e,t,r,a){if(("string"==typeof e||!1===e&&0<arguments.length)&&(e={url:e,data:t,dataType:r},"function"==typeof a&&(e.success=a)),(e=e||{}).delegation=e.delegation&&q.isFunction(q.fn.on),e.delegation||0!==this.length)return e.delegation?(q(document).off("submit.form-plugin",this.selector,o).off("click.form-plugin",this.selector,i).on("submit.form-plugin",this.selector,e,o).on("click.form-plugin",this.selector,e,i),this):(e.beforeFormUnbind&&e.beforeFormUnbind(this,e),this.ajaxFormUnbind().on("submit.form-plugin",e,o).on("click.form-plugin",e,i));var n={s:this.selector,c:this.context};return!q.isReady&&n.s?(N("DOM not ready, queuing ajaxForm"),q(function(){q(n.s,n.c).ajaxForm(e)})):N("terminating; zero elements found by selector"+(q.isReady?"":" (DOM not ready)")),this},q.fn.ajaxFormUnbind=function(){return this.off("submit.form-plugin click.form-plugin")},q.fn.formToArray=function(e,t,r){var a=[];if(0===this.length)return a;var n,o,i,s,u,c,l,f,d,m,p=this[0],h=this.attr("id"),v=(v=e||void 0===p.elements?p.getElementsByTagName("*"):p.elements)&&q.makeArray(v);if(h&&(e||/(Edge|Trident)\//.test(navigator.userAgent))&&(n=q(':input[form="'+h+'"]').get()).length&&(v=(v||[]).concat(n)),!v||!v.length)return a;for(q.isFunction(r)&&(v=q.map(v,r)),o=0,c=v.length;o<c;o++)if((m=(u=v[o]).name)&&!u.disabled)if(e&&p.clk&&"image"===u.type)p.clk===u&&(a.push({name:m,value:q(u).val(),type:u.type}),a.push({name:m+".x",value:p.clk_x},{name:m+".y",value:p.clk_y}));else if((s=q.fieldValue(u,!0))&&s.constructor===Array)for(t&&t.push(u),i=0,l=s.length;i<l;i++)a.push({name:m,value:s[i]});else if(S.fileapi&&"file"===u.type){t&&t.push(u);var g=u.files;if(g.length)for(i=0;i<g.length;i++)a.push({name:m,value:g[i],type:u.type});else a.push({name:m,value:"",type:u.type})}else null!=s&&(t&&t.push(u),a.push({name:m,value:s,type:u.type,required:u.required}));return e||!p.clk||(m=(d=(f=q(p.clk))[0]).name)&&!d.disabled&&"image"===d.type&&(a.push({name:m,value:f.val()}),a.push({name:m+".x",value:p.clk_x},{name:m+".y",value:p.clk_y})),a},q.fn.formSerialize=function(e){return q.param(this.formToArray(e))},q.fn.fieldSerialize=function(n){var o=[];return this.each(function(){var e=this.name;if(e){var t=q.fieldValue(this,n);if(t&&t.constructor===Array)for(var r=0,a=t.length;r<a;r++)o.push({name:e,value:t[r]});else null!=t&&o.push({name:this.name,value:t})}}),q.param(o)},q.fn.fieldValue=function(e){for(var t=[],r=0,a=this.length;r<a;r++){var n=this[r],o=q.fieldValue(n,e);null==o||o.constructor===Array&&!o.length||(o.constructor===Array?q.merge(t,o):t.push(o))}return t},q.fieldValue=function(e,t){var r=e.name,a=e.type,n=e.tagName.toLowerCase();if(void 0===t&&(t=!0),t&&(!r||e.disabled||"reset"===a||"button"===a||("checkbox"===a||"radio"===a)&&!e.checked||("submit"===a||"image"===a)&&e.form&&e.form.clk!==e||"select"===n&&-1===e.selectedIndex))return null;if("select"!==n)return q(e).val().replace(m,"\r\n");var o=e.selectedIndex;if(o<0)return null;for(var i=[],s=e.options,u="select-one"===a,c=u?o+1:s.length,l=u?o:0;l<c;l++){var f=s[l];if(f.selected&&!f.disabled){var d=(d=f.value)||(f.attributes&&f.attributes.value&&!f.attributes.value.specified?f.text:f.value);if(u)return d;i.push(d)}}return i},q.fn.clearForm=function(e){return this.each(function(){q("input,select,textarea",this).clearFields(e)})},q.fn.clearFields=q.fn.clearInputs=function(r){var a=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var e=this.type,t=this.tagName.toLowerCase();a.test(e)||"textarea"===t?this.value="":"checkbox"===e||"radio"===e?this.checked=!1:"select"===t?this.selectedIndex=-1:"file"===e?/MSIE/.test(navigator.userAgent)?q(this).replaceWith(q(this).clone(!0)):q(this).val(""):r&&(!0===r&&/hidden/.test(e)||"string"==typeof r&&q(this).is(r))&&(this.value="")})},q.fn.resetForm=function(){return this.each(function(){var t=q(this),e=this.tagName.toLowerCase();switch(e){case"input":this.checked=this.defaultChecked;case"textarea":return this.value=this.defaultValue,!0;case"option":case"optgroup":var r=t.parents("select");return r.length&&r[0].multiple?"option"===e?this.selected=this.defaultSelected:t.find("option").resetForm():r.resetForm(),!0;case"select":return t.find("option").each(function(e){if(this.selected=this.defaultSelected,this.defaultSelected&&!t[0].multiple)return t[0].selectedIndex=e,!1}),!0;case"label":var a=q(t.attr("for")),n=t.find("input,select,textarea");return a[0]&&n.unshift(a[0]),n.resetForm(),!0;case"form":return"function"!=typeof this.reset&&("object"!=typeof this.reset||this.reset.nodeType)||this.reset(),!0;default:return t.find("form,input,label,select,textarea").resetForm(),!0}})},q.fn.enable=function(e){return void 0===e&&(e=!0),this.each(function(){this.disabled=!e})},q.fn.selected=function(r){return void 0===r&&(r=!0),this.each(function(){var e,t=this.type;"checkbox"===t||"radio"===t?this.checked=r:"option"===this.tagName.toLowerCase()&&(e=q(this).parent("select"),r&&e[0]&&"select-one"===e[0].type&&e.find("option").selected(!1),this.selected=r)})},q.fn.ajaxSubmit.debug=!1});
$.fn.modal.Constructor.prototype.enforceFocus=function(){var e=this.$element;$(document).on("focusin.modal",function(t){var n=$(t.target.parentNode);e[0]===t.target||e.has(t.target).length||n.hasClass("cke_dialog_ui_input_select")||n.hasClass("cke_dialog_ui_input_text")||e.focus()})};var version=detectIE();function detectIE(){var e=window.navigator.userAgent;if(navigator.userAgent.toLowerCase().indexOf("firefox")>-1)return!1;var t=e.indexOf("MSIE ");if(t>0)return parseInt(e.substring(t+5,e.indexOf(".",t)),10);if(e.indexOf("Trident/")>0){var n=e.indexOf("rv:");return parseInt(e.substring(n+3,e.indexOf(".",n)),10)}var r=e.indexOf("Edge/");return r>0&&parseInt(e.substring(r+5,e.indexOf(".",r)),10)}!1!==version&&version<12&&$("#iedetect").removeClass("hidden").html("You are using an older version of Internet Explorer and the site may not function properly.  Please upgrade to Edge or Chrome."),$(function(){$('[data-toggle="tooltip"]').tooltip()});var delay=function(){var e=0;return function(t,n){clearTimeout(e),e=setTimeout(t,n)}}();function getSafe(e,t){try{return e()}catch(e){return t}}function copy_text(e){document.getElementById(e).select(),document.execCommand("copy")}$(".flip-card").hover(function(e){var t=$(this);t.hasClass("flipped")?t.removeClass("flipped"):t.addClass("flipped")});
$("#strucCol .inner").css('min-height',$(window).height());
;(function($){
    $.fn.extend({
        donetyping: function(callback,timeout){
            timeout = timeout || 1e3; // 1 second default timeout
            var timeoutReference,
                doneTyping = function(el){
                    if (!timeoutReference) return;
                    timeoutReference = null;
                    callback.call(el);
                };
            return this.each(function(i,el){
                var $el = $(el);
                // Chrome Fix (Use keyup over keypress to detect backspace)
                // thank you @palerdot
                $el.is(':input') && $el.on('keyup keypress paste',function(e){
                    // This catches the backspace button in chrome, but also prevents
                    // the event from triggering too preemptively. Without this line,
                    // using tab/shift+tab will make the focused element fire the callback.
                    if (e.type=='keyup' && e.keyCode!=8) return;
                    
                    // Check if timeout has been set. If it has, "reset" the clock and
                    // start over again.
                    if (timeoutReference) clearTimeout(timeoutReference);
                    timeoutReference = setTimeout(function(){
                        // if we made it here, our timeout has elapsed. Fire the
                        // callback
                        doneTyping(el);
                    }, timeout);
                }).on('blur',function(){
                    // If we can, fire the event since we're leaving the field
                    doneTyping(el);
                });
            });
        }
    });
})(jQuery);
jQuery.fn.shake = function(interval,distance,times){interval=typeof interval=="undefined"?100:interval;distance=typeof distance =="undefined"?10:distance;times=typeof times=="undefined"?7:times;var jTarget = $(this);jTarget.css('position','relative');for(var iter=0;iter<(times+1);iter++){jTarget.animate({left:((iter%2==0?distance:distance*-1))}, interval);}return jTarget.animate({left:0},interval);}

function dropdownToggle($this) {
    // select the main dropdown button element
    var dropdown = $this.parent().parent().prev();

    // change the CONTENT of the button based on the content of selected option
    dropdown.html($this.html() + '&nbsp;</i><span class="caret"></span>');

    // change the VALUE of the button based on the data-value property of selected option
    dropdown.val($this.prop('data-value'));
}
function ShowForm(){
	document.getElementById('htmlc').style.display='none';
	document.getElementById('jsc').style.display='none';
	document.getElementById('phpc').style.display='none';
	which=document.myform.type.options[document.myform.type.options.selectedIndex].value;
    if(which=='HTML'){ 
     	document.getElementById('htmlc').style.display='';
    }
    if(which=='PHP'){ 
     	document.getElementById('phpc').style.display='';
    }
    if(which=='JS'){ 
     	document.getElementById('jsc').style.display='';
    }
}
var delay = (function(){
  var timer = 0;
  return function(callback, ms){
    clearTimeout (timer);
    timer = setTimeout(callback, ms);
  };
})();

// Short-circuiting, and saving a parse operation
function isInt(value) {
  var x;
  if (isNaN(value)) {
    return false;
  }
  x = parseFloat(value);
  return (x | 0) === x;
}

//Wait for document to load completely.
function fieldinuse(fieldid,table,col,okmsg,errmsg,sectime,sechash,formid) {
	//Find the textbox we'll be checking, load its current value into textBoxVal.
	var msgid='msgbox';
	var textBoxVal = $("#"+fieldid).val();
	var content;
	
	var $field = $('#'+fieldid);

	//On keyup event from our textbox, check if current value != old value.
	$field.keyup(function() {
		if ($field.val() != content) {
			//Set the variable to == the current value.
			content = $field.val();

			//Perform AJAX call.
			$.post("/ajax_processor.php",{ f:"valueInUse",t:table,c:col,v:$field.val(),time:sectime,sec:sechash },
				function(feedback) {
					$closest = $field.closest('.control-group');
					//AJAX returns blank or 1. 1 == true.
					if(feedback=='1') {
						//Remove all classes from our output span. Add "error" class to it.
						$closest.removeClass('error success');
						$closest.addClass('error');
						$field.nextAll('.help-inline').remove();
						$field.after('<span class="help-inline">'+errmsg+'</span>');
					} else if(feedback=='0') {
						//Remove all classes from our output span. Add "ok" class to it.
						$('#'+formid).children('button').css('display','block');
						$closest.removeClass('error success');
						$closest.addClass('success');
						$field.nextAll('.help-inline').remove();
						$field.after('<span class="help-inline">'+okmsg+'</span>');
						//$field.removeClass().addClass('formFieldValidationOk');
					} else {
						alert(feedback);
					}
				});
		}
	});
};

function lj_fieldInUse(fieldid,table,col,okmsg,errmsg,sectime,sechash,formid) {
	//Find the textbox we'll be checking, load its current value into textBoxVal.
	var textBoxVal = $("#"+fieldid).val();
	var content;
	
	var $field = $('#'+fieldid);
	var $parentform = $("#"+fieldid).closest('form');

	//On keyup event from our textbox, check if current value != old value.
	$field.keyup(function() {
		delay(function(){
			if ($field.val() != content && $field.val() != "") {
				//Set the variable to == the current value.
				content = $field.val();
		
				//Perform AJAX call.
				$.post("/ajax_processor.php",{ f:"valueInUse",t:table,c:col,v:$field.val(),time:sectime,sec:sechash },
					function(feedback) {
						$closest = $field.closest('.control-group');
						//AJAX returns blank or 1. 1 == true.
						if(feedback=='1') {
							//Remove all classes from our output span. Add "error" class to it.
							$closest.removeClass('error success');
							$closest.addClass('error');
							$field.nextAll('.help-inline').remove();
							$field.after('<span class="help-inline">'+errmsg+'</span>');
							$btn = $parentform.find(':submit').addClass('hidden');
						} else if(feedback=='0') {
							//Remove all classes from our output span. Add "ok" class to it.
							$('#'+formid).children('button').css('display','block');
							$closest.removeClass('error success');
							$closest.addClass('success');
							$field.nextAll('.help-inline').remove();
							$field.after('<span class="help-inline">'+okmsg+'</span>');
							$btn = $parentform.find(':submit').removeClass('hidden');
							//$field.removeClass().addClass('formFieldValidationOk');
						} else {
							//alert(feedback);
						}
					});
			}
		},300);
	});
};


//Return table
//Works with ajax_processor to return the results from a table
function returnTable(fieldid,table,col,sectime,sechash) {
	//Load current value of the id
	var resultid = 'results';

	//On keyup event from our textbox, check if current value != old value.
	$('#'+fieldid).change(function() {
		if ($('#'+fieldid).val() != content) {
			//Set the variable to == the current value.
			var content = $('#'+fieldid).val();

			//Perform AJAX call.
			$.post("/ajax_processor.php",{ f:"returnTable",t:table,c:col,v:content,time:sectime,sec:sechash },
				function(feedback) {
					//AJAX returns blank or 1. 1 == true.
					if(feedback!='1') {
						$("#"+resultid).html(feedback);
					} else {
						$("#"+resultid).html(feedback);
					}
				});
		}
	});
};


//Update column
//Works with ajax_processor to update a single value in a table based on a comparison column
function updateColumn(table,wherecol,whereval,setcol,setval,sectime,sechash) {
	$.post("/ajax_processor.php",{ f:"updateColumn",t:table,w:wherecol,i:whereval,s:setcol,v:setval,time:sectime,sec:sechash },
		function(feedback) {
			if(!Boolean(feedback)){alert('Error. Not saved. '+feedback);}
		});
};

//Update column
//Works with ajax_processor to update a single value in a table based on a comparison column
function updateScore(context,table,wherecol,whereval,setcol,setval,sectime,sechash,season) {
	console.log("Updating");
	$.post("/ajax_processor.php",{ f:"updateColumn",t:table,w:wherecol,i:whereval,s:setcol,v:setval,time:sectime,sec:sechash },
		function(feedback) {
			console.log("Return: "+feedback);
			if(!Boolean(feedback)){alert('Error. Not saved. '+feedback);}
			context.closest("td").find(".icon-check-sign").removeClass("hidden");
			$tr = context.closest("tr");
			var home = parseInt($tr.find(".home").val());
			var away = parseInt($tr.find(".away").val());
			/*if(home>0 && away>0)
				$tr.fadeOut('slow',function($tr){ $tr.remove(); }); 
			if(feedback==1 && setcol=="rainout")
				$tr.fadeOut('slow',function($tr){ $tr.remove(); }); 
			*/
			if(home>0 || away>0)
				$tr.addClass('done'); 
			if(feedback==1 && setcol=="rainout")
				$tr.addClass('done');
			lj_refreshStandings(season,sectime,sechash);
		});
};

//Update table
//Works with ajax_processor to update a key/data table
//Deletes data in the table based on the col/id pairing before re-inserting data based on serialized data
//Best used with a sortable list
function updateTable_sortablelist(table,col,id,keycol,data,sectime,sechash) {
	$.post("/ajax_processor.php",{ f:"updateTable_sortablelist",t:table,c:col,i:id,k:keycol,d:data,time:sectime,sec:sechash },
	function(feedback) {
		if(!Boolean(feedback)){alert('Error. Not saved. '+feedback);}
	});
};
//Return options
//Works with ajax_processor to return results from a table in <option> format to be placed
//in a select
function returnOptions(fieldid,table,id_col,display_col,where_col,results,blank,sectime,sechash) {
	//Set the variable to == the current value.
	var content = $('#'+fieldid).val();

	//Perform AJAX call.
	$.post("/ajax_processor.php",{ f:"returnOptions",t:table,i:id_col,d:display_col,w:where_col,v:content,b:blank,time:sectime,sec:sechash },
		function(feedback) {
			//AJAX returns blank or 1. 1 == true.
			if(feedback!='1') {
				$("#"+results).html(feedback);
			} else {
				$("#"+results).html(feedback);
			}
		});
};

//Call class function
//Works with ajax_processor to call a class function
function callClass(fieldid,table,id_col,display_col,where_col,results,blank,sectime,sechash) {
	//Set the variable to == the current value.
	var content = $('#'+fieldid).val();
	var senddata = '';
	senddata += 'f=callClassFunction';
	senddata += '&time=' + this.time();
	senddata += '&sec=' + this.hash();
	senddata += '&func=getFreeAgents';
	senddata += '&m=teams';
	senddata += '&format=json';
	senddata += '&per_page=' + options.pageSize;
	senddata += '&page=' + (options.pageIndex + 1);

	$.ajax(url, {
		// Set JSONP options for Team API
		data:senddata,
		dataType: 'json',
		type: 'POST'

	}).done(function (response) {
			alert(JSON.stringify(response));
			// Prepare data to return to Datagrid
			var data = response.result.items;
			var count = response.result.total;
			var startIndex = (response.result.page - 1) * response.result.perpage;
			var endIndex = startIndex + response.result.perpage;
			var end = (endIndex > count) ? count : endIndex;
			var pages = response.result.pages;
			var page = response.result.page;
			var start = startIndex + 1;

			// Return data to Datagrid
			callback({ data: data, start: start, end: end, count: count, pages: pages, page: page });
	});
};


// Basically sends Ajax vars through to the class function specified for processing
function callClassFunc(func,mod,options,sectime,sechash) {
	console.log(options);
	$.ajax('/ajax_processor.php', {
		// Set JSONP options for Team API
		data:{
			f: 'callClassFunction',
			time: sectime,
			sec: sechash,
			func: func,
			m: mod,
			format: 'json',
			per_page: options.pageSize,
			page: (options.pageIndex + 1),
			options:options,
			form:options.form,
		},
		return_func:options.return_func,
		return_target:options.return_target,
		return_class:options.return_class,
		dataType: "json",
		type: 'POST',
		success: function(data){
			console.log("Success: "+data);
			if(data.Success)
				alertify.success(data.Message);
			else
				alertify.error(data.Message);
		},
		error: function(jqXHR, exception) {
			console.log("Error: "+exception);
			console.log(jqXHR);
			if (jqXHR.status === 0) {
				console.log("Not connect.\n Verify Network.");
			} else if (jqXHR.status == 404) {
				console.log("Requested page not found. [404]");
			} else if (jqXHR.status == 500) {
				console.log("Internal Server Error [500].");
			} else if (exception === "parsererror") {
				console.log("Requested JSON parse failed.");
			} else if (exception === "timeout") {
				console.log("Time out error.");
			} else if (exception === "abort") {
				console.log("Ajax request aborted.");
			} else {
				console.log("Uncaught Error.\n" + jqXHR.responseText);
			}
		}
	}).done(function (response) {
		console.log(response);
		$(".preventDouble").prop('disabled', false);
		switch(this.return_func){
			case 'toggleClass':
				$("#"+this.return_target).toggleClass(this.return_class);
				break;
			default:
				return true;
				break;
		}
	});
};

//Set sort variables
function setSort(colname,dir,sectime,sechash,url){
	//Perform AJAX call.
	$.post("/ajax_processor.php",{ f:"setsort",c:colname,d:dir,time:sectime,sec:sechash },
		function(feedback) {
			//AJAX returns blank or 1. 1 == true.
			if(feedback=='1') {
				//Success
				//var loc = window.location.href;
				window.location.href = url;
				//window.location.reload()
				return false;
			} else {
				//Fail for some reason
				alert(feedback);
			}
		}
	);
};


//setValue
function setValue(id,value){
	$('#'+id).val(value);
};
//getValue
//Executes synchronously so use only where speed is reliable
function getValue(id,table,col,wherecol,compare,sectime,sechash){
	//Perform AJAX call.
	$.post("/ajax_processor.php",{ f:"getValue",t:table,c:col,w:wherecol,x:compare,time:sectime,sec:sechash },
		function(feedback) {
			if(feedback!='-1'){setValue(id,feedback);}
			return false;
		}
	);
};

//setValue
//Executes synchronously so use only where speed is reliable
function setHtmlValue(id,value){
	$('#'+id).html(value);
};
//getValue
//Executes synchronously so use only where speed is reliable
function getHtmlValue(id,table,col,wherecol,compare,sectime,sechash){
	//Perform AJAX call.
	$.post("/ajax_processor.php",{ f:"getValue",t:table,c:col,w:wherecol,x:compare,time:sectime,sec:sechash },
		function(feedback) {
			if(feedback!='-1'){setHtmlValue(id,feedback);}
			return false;
		}
	);
};


//getValue
//Executes synchronously so use only where speed is reliable
function setDismissCookie(sectime,sechash){
	return false;
};
//getValue
//Executes synchronously so use only where speed is reliable
function setCookie(name,val){
	//Perform AJAX call.
	$.post("/ajax_processor.php",{ f:"setCookie",c:name,v:val },
		function(feedback) {
			console.log("Set Cookie"+feedback);
			return false;
		}
	);
};

//Clear inputs on first click
function clearField(form) {
	$(form).find("input.text, textarea").each(function(){
		this.defaultValue = this.value;
		$(this).click(function(){
			if(this.value == this.defaultValue){
				$(this).val("");
			}
			return false;
		});
		$(this).blur(function(){
			if(this.value == ""){
				$(this).val(this.defaultValue);
			}
		});
	});
}
function resetSelect(x){
	$("."+x+" option:selected").prop("selected", false);
	$("."+x+" option:first").prop("selected", "selected");
}

function format_rankings(x){
	switch(x){
		case 10:
			return 'A+';
		case 9:
			return 'A';
		case 8:
			return 'B+';
		case 7:
			return 'B';
		case 6:
			return 'C+';
		case 5:
			return 'C';
		case 4:
			return 'D+';
		case 3:
			return 'D';
		case 2:
			return 'D-';
		case 1:
			return 'N';
		}	
	return 0;
}


//lj_saveRules
//Executes synchronously so use only where speed is reliable
function lj_saveRules(id,content,type,lid,sid,sectime,sechash){
	//Perform AJAX call.
	$.post("/ajax_processor.php",{ f:"saveRules",id:id,t:type,l:lid,s:sid,c:content,time:sectime,sec:sechash },
		function(feedback) {
			if(feedback=="1") location.reload();
		}
	);
};

function lj_refreshStandings(sid,sectime,sechash){
	//Perform AJAX call.
	$.post("/ajax_processor.php",{ f:"refreshStandings",s:sid,time:sectime,sec:sechash },
		function(feedback) {
			console.log("Standings");
			console.log(feedback);
		}
	);
};


//lj_saveRules
//Executes synchronously so use only where speed is reliable
function lj_saveProgress(lpi,type,data,sectime,sechash){
	//Perform AJAX call.
	$.post("/ajax_processor.php",{ f:"saveRegProgress",id:lpi,t:type,c:data,time:sectime,sec:sechash },
		function(feedback) {
			console.log(feedback);
		}
	);
};

//Executes synchronously so use only where speed is reliable
function lj_refreshTeam(turl,lid,sid,sectime,sechash){
	//Perform AJAX call.
	$.post("/ajax_processor.php",{ f:"updateTeamView",t:turl,l:lid,s:sid,time:sectime,sec:sechash },
		function(feedback) {
			if(feedback=="1") location.reload();
		}
	);
};

function clearSearch(sectime,sechash){
	clearSearch("",sectime,sechash);
};
function clearSearch(searchid,sectime,sechash){
	//Perform AJAX call.
	$.post("/ajax_processor.php",{ f:"clearSearch",s:searchid,time:sectime,sec:sechash },
		function(feedback) {
			//alert(feedback);
			if(feedback=="1"){ location.reload(); }
			return false;
		}
	);
}

function setTooltip(btn, message) {
  $(btn).attr('data-original-title', message)
    .tooltip('show');
}
function hideTooltip(btn) {
    $(btn).tooltip('hide');
}
function AdjustDays(mon,selectid){
  mon = parseInt(mon);
  if(mon==2){
  	  days=29;
	  $("#"+selectid+" option[value='30']").remove();
	  $("#"+selectid+" option[value='31']").remove();
  }else if(mon==9||mon==4||mon==6||mon==11){
  	  days=30;
  	  $("#"+selectid+" option[value='31']").remove();
  }else
  	  days=31;
  	  //Remove nothing
  
  //lets create the days of that month
  for (var d = 30; d <= days; d++){
	var dayElem = document.createElement("option");
	dayElem.value = d; 
	dayElem.textContent = d;
	$("#"+selectid).append(dayElem);
  }
}    
$(window).on("load", function(){
	var domainhn = window.location.hostname.split(".").reverse();
	var domainHref = domainhn[1] + "." + domainhn[0];
	var domainSub = domainhn[2];
	$.expr[":"].external = function(a) {
		var linkhn = a.hostname.split(".").reverse();
		var linkHref = linkhn[1] + "." + linkhn[0];
		return !a.href.match(/^javascript\:/) && !a.href.match(/^mailto\:/) && !a.href.match(/^tel\:/) && linkHref !== domainHref;
	};
	/*
	$("a:external").addClass("ext_link");
	$(function() {
		$("a.ext_link").click(function(e) {
			var link = $(this).attr('href');
			if(link=="javascript:void(0);"||link=="javascript:void(0)"||link==""||typeof link==="undefined")
				return true;				 
			if($(this).parents(".cke_inner").length||$(this).parents(".fc-day").length){
				return true;
			}

			$("<p>By clicking \"Proceed\" you will be transferred to a web site not controlled by League Joe. League Joe is not responsible for any of the info or services provided by this web site. The web site you are about to access is not covered by League Joe\'s privacy policy or security statement. <br /> <strong>Are you sure you want to proceed?</strong></p>").dialog({
			  title: "External Link Warning",
			  modal : true,
			  overlay: { },
			  buttons: {
				"Yes, Proceed": function() {
				  $(this).dialog("close").remove();
				  window.open(link);
				},
				"Cancel": function() {
				  $(this).dialog("close").remove();
				  return false;
				}
			  }
			});
		
			return false;
		});
		
	});  */
});
$('.preventDouble').click(function(e){
	e.preventDefault();
	$(this).prop("disabled",true);
	var form = $(this).attr("data-form");
	var label = $(this).html();
	label = '<i class="fas fa-cog fa-spin"></i> '+label;
	$(this).html(label);
	console.log("preventDouble: "+form);
	$("#"+form).submit();
});
$('.internal-tabs a').on('click', function (e) {
  $(this).tab('show');
  $('.content-filter__item').removeClass('content-filter__item--active');
  $(this).parent('.content-filter__item').addClass('content-filter__item--active');
});
function scrollToAnchor(aid){
    var aTag = $("a[name='"+ aid +"']");
    $('html,body').animate({scrollTop: aTag.offset().top},'fast');
}

function validateEmail(email) {
	email = email.trim();
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	return re.test(email);
}

$("#sportprofile").submit(function(e){
	e.preventDefault();
	var sport = $("#sportselect").val();
	location.href = "/account/sports/?sport="+sport;
	return false;
});
$("#sportprofile2").submit(function(e){
	e.preventDefault();
	var sport = $("#sportselect").val();
	location.href = "/trading-cards/?sport="+sport;
	return false;
});
$("#select-sport").change(function () {
	var sport = $(this).val();
	sport = sport.replaceAll(' ', '-');
	location.href = "?sport="+sport;
});
$("input.radiogroup-opt").click(function(){
	$(this).closest(".radiogroup").removeClass( "error" );
});
function base64ToBlob(base64Data) {
	const byteCharacters = atob(base64Data.split(',')[1]);
	const byteArrays = [];
	for (let i = 0; i < byteCharacters.length; i++) {
		byteArrays.push(byteCharacters.charCodeAt(i));
	}
	return new Blob([new Uint8Array(byteArrays)], { type: 'image/png' });
}
$(".editclick").click(function(e){
	e.preventDefault();
	$(".editblock").toggleClass("hidden");
});
$(document).ready(function(){
	var ws = $("#wsmobileheader");
	var l = ws.height();
	if($("#pagesubnav").length)
		l += 40;
    ws.addClass("wsfixed");
    if(window.innerWidth <992)
    	$("#topsection").css("height",l+"px").css("border","1px solid");
});
$('.imgpop').magnificPopup({type:'image'});
$('.field-tooltip').tooltip({'trigger':'focus'});