!function($){var timer;Date.now||(Date.now=function(){return+new Date}),$.fn.jAlert=function(options){$("body").focus(),$("body").blur();var alert_id,sizeAliases={xsmall:"xsm",small:"sm",medium:"md",large:"lg",xlarge:"xlg"},styles=[],classes=["animated"],backgroundClasses=[];if(1<this.length)return this.each(function(){$.fn.jAlert(options)}),this;if(void 0!==$(this)[0]&&"undefined"!=$(this)[0].jAlert)return $(this)[0].jAlert;$.each($.fn.jAlert.defaults,function(key,val){var lowerKey=key.toLowerCase();void 0!==options[lowerKey]&&(options[key]=options[lowerKey])}),alert_id=(options=$.extend({},$.fn.jAlert.defaults,options)).id?options.id:"ja_"+(Date.now().toString()+Math.floor(1e5*Math.random()));var alert={set:function(key,val){return alert[key]=val,alert},__set:function(key,val){return alert.set(key,val)},get:function(key){return alert[key]},__get:function(key){return alert.get(key)},animateAlert:function(which){return"hide"==which?(alert.instance.data("jAlert").blurBackground&&$("body").removeClass("ja_blur"),alert.instance.removeClass(alert.showAnimation).addClass(alert.hideAnimation)):(alert.instance.data("jAlert").blurBackground&&$("body").addClass("ja_blur"),alert.instance.addClass(alert.showAnimation).removeClass(alert.hideAnimation).show()),alert},closeAlert:function(remove,onClose){return 0!=remove&&(remove=!0),alert.instance&&(alert.animateAlert("hide"),window.setTimeout(function(){var alertWrap=alert.instance.parents(".ja_wrap");remove?alertWrap.remove():alertWrap.hide(),toggleFocusTrap(),"function"==typeof onClose?onClose(alert.instance):"function"==typeof alert.onClose&&alert.onClose(alert.instance),0===$(".jAlert:visible").length&&$("html,body").css("overflow","")},alert.animationTimeout)),alert},showAlert:function(replaceOthers,removeOthers,onOpen,onClose){0!=replaceOthers&&(replaceOthers=!0),!1!==removeOthers&&(removeOthers=!0),replaceOthers&&$(".jAlert:visible").data("jAlert").jAlert().closeAlert(removeOthers);var wrap=alert.instance.parents(".ja_wrap");return $("body").append(wrap),alert.animateAlert("show"),"function"==typeof onClose&&(alert.onClose=onClose),window.setTimeout(function(){"function"==typeof onOpen&&onOpen(alert.instance)},alert.animationTimeout),alert}};if($.each(options,function(key,val){alert.set(key,val)}),alert.set("id",alert_id),alert.content&&0===alert.content.indexOf("#")&&0<$(alert.content).length&&(alert.content=$(alert.content).html()),"object"==typeof alert.content&&alert.jquery&&(alert.content=alert.content.html()),alert.video&&-1<alert.video.indexOf("youtube.com/watch?v=")&&-1===alert.video.indexOf("embed")&&(alert.video=alert.video.replace("watch?v=","embed/")),"confirm"==alert.type&&(alert.content||(alert.content=alert.confirmQuestion),alert.btns=[{text:alert.confirmBtnText,theme:"green",class:"confirmBtn",closeAlert:!0,onClick:alert.onConfirm},{text:alert.denyBtnText,theme:"red",class:"denyBtn",closeAlert:!0,onClick:alert.onDeny}],alert.autofocus=alert.confirmAutofocus),alert.color&&(alert.theme=alert.color),-1==$.inArray(alert.theme,["default","green","dark_green","red","dark_red","black","brown","gray","dark_gray","blue","dark_blue","yellow","custom"]))return console.log("jAlert Config Error: Invalid theme selection."),!1;if(classes.push("ja_"+alert.theme),alert.class&&classes.push(alert.class),alert.classes&&classes.push(alert.classes),alert.fullscreen&&classes.push("ja_fullscreen"),alert.noPadContent&&classes.push("ja_no_pad"),alert.title||classes.push("ja_noTitle"),alert.width&&(alert.size=alert.width),alert.size&&"object"==typeof alert.size&&(void 0===alert.size.width||void 0===alert.size.height))return console.log("jAlert Config Error: Invalid size selection (try a preset or make sure you're including height and width in your size object)."),!1;if(alert.size?"object"==typeof alert.size?(styles.push("width: "+alert.size.width+";"),styles.push("height: "+alert.size.height+";"),classes.push("ja_setheight")):(void 0!==sizeAliases[alert.size]&&(alert.size=sizeAliases[alert.size]),-1<$.inArray(alert.size,["xsm","sm","md","lg","xlg","full","auto"])?classes.push("ja_"+alert.size):styles.push("width: "+alert.size+";")):classes.push("ja_sm"),-1==$.inArray(alert.backgroundColor,["white","black"]))return console.log("jAlert Config Error: Invalid background color selection."),!1;backgroundClasses.push("ja_wrap_"+alert.backgroundColor),alert.onOpen=[alert.onOpen];var loader="<div class='ja_loader'>Loading...</div>";alert.picture&&(alert.image=alert.picture),alert.image?(alert.noPadContent=!0,alert.content="<div class='ja_media_wrap'>"+loader+"<img src='"+alert.image+"' class='ja_img' onload='$.fn.jAlert.mediaLoaded($(this))''",alert.imageWidth&&(alert.content+=" style='width: "+alert.imageWidth+"'"),alert.content+="></div>",alert.onOpen.unshift(function(elem){var img_elem=elem.find(".ja_img");img_elem.on("load",function(){elem.css("width",img_elem.width()+"px"),elem.css("height",img_elem.height()+"px")})})):alert.video?(alert.content="<div class='ja_media_wrap'>"+loader+"<div class='ja_video'></div></div>",alert.onOpen.unshift(function(elem){var iframe=document.createElement("iframe");iframe.src=elem.data("jAlert").video,iframe.addEventListener?iframe.addEventListener("load",function(){$.fn.jAlert.mediaLoaded($(this))},!0):iframe.attachEvent?iframe.attachEvent("onload",function(){$.fn.jAlert.mediaLoaded($(this))}):iframe.onload=function(){$.fn.jAlert.mediaLoaded($(this))},elem.find(".ja_video").append(iframe)})):alert.iframe?(alert.iframeHeight||classes.push("ja_stretch_height"),alert.content="<div class='ja_media_wrap'>"+loader+"</div>",alert.onOpen.unshift(function(elem){var iframe=document.createElement("iframe");iframe.src=elem.jAlert().iframe,iframe.className="ja_iframe",iframe.addEventListener?iframe.addEventListener("load",function(){$.fn.jAlert.mediaLoaded($(this))},!0):iframe.attachEvent?iframe.attachEvent("onload",function(){$.fn.jAlert.mediaLoaded($(this))}):iframe.onload=function(){$.fn.jAlert.mediaLoaded($(this))},elem.find(".ja_media_wrap").append(iframe)})):alert.ajax&&(alert.content="<div class='ja_media_wrap'>"+loader+"</div>",onAjaxCallbacks=alert.onOpen,alert.onOpen=[function(elem){$.ajax(elem.jAlert().ajax,{async:!0,complete:function(jqXHR,textStatus){elem.find(".ja_media_wrap").replaceWith(jqXHR.responseText),$.each(onAjaxCallbacks,function(index,onAjax){onAjax(elem)})},error:function(jqXHR,textStatus,errorThrown){alert.onAjaxFail(elem,"Error getting content: Code: "+jqXHR.status+" : Msg: "+jqXHR.statusText)}})}]);function getBtnHTML(btn){var unique;return void 0===btn.href&&(btn.href=""),void 0===btn.class&&(btn.class=""),void 0===btn.theme?btn.class+=" ja_btn_default":btn.class+=" ja_btn_"+btn.theme,void 0===btn.text&&(btn.text=""),void 0===btn.id&&(unique=Date.now().toString()+Math.floor(1e5*Math.random()),btn.id="ja_btn_"+unique),void 0===btn.target&&(btn.target="_self"),void 0===btn.closeAlert&&(btn.closeAlert=!0),$("body").off("click","#"+btn.id),$("body").on("click","#"+btn.id,function(e){var button=$(this);alert=button.parents(".jAlert").jAlert(),btn.closeAlert&&alert.closeAlert();var callbackResponse=!0;return"function"==typeof btn.onClick&&(callbackResponse=btn.onClick(e,button,alert)),!callbackResponse||btn.closeAlert?(e.preventDefault(),!1):callbackResponse}),"<a href='"+btn.href+"' id='"+btn.id+"' target='"+btn.target+"' class='ja_btn "+btn.class+"'>"+btn.text+"</a> "}function addAlert(content){var html="";html+='<div class="ja_wrap '+backgroundClasses.join(" ")+'"><div class="jAlert '+classes.join(" ")+'" style="'+styles.join(" ")+'" id="'+alert.id+'"><div>',alert.closeBtn&&(html+="<div tabindex=0 role='button' aria-pressed='false' class='closejAlert ja_close",alert.closeBtnAlt?html+=" ja_close_alt":alert.closeBtnRoundWhite?html+=" ja_close_round_white":alert.closeBtnRound&&(html+=" ja_close_round"),html+="'>&times;</div>"),alert.title&&(html+="<div class='ja_title'><div>"+alert.title+"</div></div>"),html+='<div class="ja_body">'+content,alert.btns&&(html+='<div class="ja_btn_wrap ',alert.btnBackground&&(html+="optBack"),html+='">'),"object"==typeof alert.btns[0]?$.each(alert.btns,function(index,btn){"object"==typeof btn&&(html+=getBtnHTML(btn))}):"object"==typeof alert.btns?html+=getBtnHTML(alert.btns):alert.btns&&console.log("jAlert Config Error: Incorrect value for btns (must be object or array of objects): "+alert.btns),alert.btns&&(html+="</div>");var alertHTML=$(html+="</div></div></div></div>");return alert.replaceOtherAlerts&&$(".jAlert:visible").each(function(){$(this).jAlert().closeAlert()}),$("body").append(alertHTML),$(".jAlert:last").data("jAlert",alert),alert.instance=$("#"+alert.id),alert.instance[0].jAlert=alert,$("html,body").css("overflow","hidden"),alert.animateAlert("show"),alert.closeBtn&&(alert.instance.on("click",".closejAlert",function(e){return e.preventDefault(),$(this).parents(".jAlert:first").closeAlert(),!1}),alert.instance.on("keydown",".closejAlert",function(e){if("Enter"===e.originalEvent.key)return e.preventDefault(),$(this).parents(".jAlert:first").closeAlert(),!1})),alert.closeOnClick&&($(document).off("mouseup touchstart",$.fn.jAlert.onMouseUp),$(document).on("mouseup touchstart",$.fn.jAlert.onMouseUp)),alert.closeOnEsc&&($(document).off("keydown",$.fn.jAlert.onEscKeyDown),$(document).on("keydown",$.fn.jAlert.onEscKeyDown)),alert.onOpen.push(toggleFocusTrap),$.each(alert.onOpen,function(index,onOpen){onOpen(alert.instance)}),alert.autofocus?alert.instance.find(alert.autofocus).focus():alert.instance.focus(),alert.autoClose&&$.fn.closeTimer(function(){var currentAlert=$.jAlert("current");!1!==currentAlert&&currentAlert.closeAlert()},alert.autoClose),alert.instance}return this.initialize=function(){return alert.content||alert.image||alert.video||alert.iframe||alert.ajax?(alert.content||(alert.content=""),addAlert(alert.content)):(console.log("jAlert potential error: No content defined"),addAlert(""))},this.initialize(),alert},$.fn.closeTimer=(jQuery,timer=0,function(callback,ms){clearTimeout(timer),timer=setTimeout(callback,ms)}),$.fn.jAlert.defaults={title:!1,content:!1,noPadContent:!1,fullscreen:!1,image:!1,imageWidth:"auto",video:!1,ajax:!1,onAjaxFail:function(alert,errorThrown){alert.jAlert().closeAlert(),errorAlert(errorThrown)},iframe:!1,iframeHeight:!1,class:"",classes:"",id:!1,showAnimation:"fadeInUp",hideAnimation:"fadeOutDown",animationTimeout:600,theme:"default",backgroundColor:"black",blurBackground:!1,size:!1,replaceOtherAlerts:!1,closeOnClick:!1,closeOnEsc:!0,closeBtn:!0,closeBtnAlt:!1,closeBtnRound:!0,closeBtnRoundWhite:!1,btns:!1,autoClose:!1,btnBackground:!0,autofocus:!1,onOpen:function(alert){return!1},onClose:function(alert){return!1},type:"modal",confirmQuestion:"Are you sure?",confirmBtnText:"Yes",denyBtnText:"No",confirmAutofocus:".confirmBtn",onConfirm:function(e,btn){return e.preventDefault(),console.log("confirmed"),!1},onDeny:function(e,btn){return e.preventDefault(),!1}};var toggleFocusTrap=function(){var curAlert=$.jAlert("current");curAlert?document.querySelectorAll("*").forEach(function(el){function visible(element){return $.expr.filters.visible(element)&&!$(element).parents().addBack().filter(function(){return"hidden"===$.css(this,"visibility")}).length}var element,map,mapName,img,nodeName,isTabIndexNotNaN;nodeName=(element=el).nodeName.toLowerCase(),isTabIndexNotNaN=!isNaN($.attr(element,"tabindex")),("area"!==nodeName?(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:"a"===nodeName&&element.href||isTabIndexNotNaN)&&visible(element):(map=element.parentNode,mapName=map.name,!(!element.href||!mapName||"map"!==map.nodeName.toLowerCase())&&(!!(img=$("img[usemap=#"+mapName+"]")[0])&&visible(img))))&&($.contains(curAlert.instance[0],el)?$(el).removeClass("trap-disabled").attr("tabindex",0).attr("aria-hidden",!1):$(el).addClass("trap-disabled").attr("tabindex",-1).attr("aria-hidden",!0))}):$(".trap-disabled").removeClass("trap-disabled").attr("tabindex",0).attr("aria-hidden",!1)};$.fn.jAlert.onMouseUp=function(e){var target=e.target?e.target:e.srcElement,lastVisibleAlert=$(".jAlert:visible:last");0<lastVisibleAlert.length&&lastVisibleAlert.data("jAlert").closeOnClick&&($(target).is(".jAlert *")||lastVisibleAlert.data("jAlert").closeAlert())},$.fn.jAlert.onEscKeyDown=function(e){var lastVisibleAlert;27!==e.keyCode||0<(lastVisibleAlert=$(".jAlert:visible:last")).length&&lastVisibleAlert.data("jAlert").closeOnEsc&&lastVisibleAlert.data("jAlert").closeAlert()},$.fn.attachjAlert=function(e){return e.preventDefault(),$.jAlert($(this).data()),!1},$.jAlert=function(options){if("current"!=options)return"attach"==options?($("[data-jAlert]").off("click",$.fn.attachjAlert),$("[data-jAlert]").on("click",$.fn.attachjAlert),$("[data-jalert]").off("click",$.fn.attachjAlert),$("[data-jalert]").on("click",$.fn.attachjAlert),!1):$.fn.jAlert(options);var latest=$(".jAlert:visible:last");return 0<latest.length&&latest.data("jAlert")},$.fn.alertOnClick=function(options){$(this).on("click",function(e){return e.preventDefault(),$.jAlert(options),!1})},$.alertOnClick=function(selector,options){$("body").on("click",selector,function(e){return e.preventDefault(),$.jAlert(options),!1})},$.fn.closeAlert=function(remove,onClose){$(this).data("jAlert")&&$(this).data("jAlert").closeAlert(remove,onClose)},$.fn.jAlert.mediaLoaded=function(elem){var wrap=elem.parents(".ja_media_wrap"),vid_wrap=wrap.find(".ja_video"),jalert=elem.parents(".jAlert:first").data("jAlert");wrap.find(".ja_loader").remove(),0<vid_wrap.length?vid_wrap.fadeIn("fast"):elem.fadeIn("fast"),jalert.iframeHeight&&(elem.css("flex","unset"),elem.height(jalert.iframeHeight))}}(jQuery);
