+function(n,t){"use strict";var r=window.ContractFX=window.ContractFX||{},i,u;r.Controls=r.Controls||{};r.Controls.ERFx=r.Controls.ERFx||{};i="Something went wrong. Please try again later.";u=r.Controls.ERFx.ChannelHead=function(r,u,f,e,o,s,h,c,l,a,v,y,p,w,b,k,d,g,nt,tt,it,rt,ut,ft,et,ot,st,ht,ct,lt,at,vt,yt,pt){function pi(n){ri==null||ri.hasClass("disabled-notification")||(n.target.closest("[data-NotificationLevel]")?wt=parseInt(n.target.closest("[data-NotificationLevel]").getAttribute("data-NotificationLevel")):wt===5&&(wt=wt=parseInt(a.dataset.notification_lavel)),gi(n),c.Show())}function rr(n){switch(n){case 2:yi();break;case 3:wi;break;case 4:bi();break;case 5:ki();break;default:yi()}}function ur(){var i,t,n,r,u;if(hi()){for(si(wt),i=[],t=0;t<=kt.length-1;t++)n=kt[t],n.IsPhoneNotification!==undefined&&(r={AreaCode:n.phone_AreaCode,Number:n.phone_Number,Extension:n.phone_Extension,CountryCode:n.phone_CountryCode},d.SetValueO(r),d.GetIsValid()===!1&&n.IsPhoneNotification===!1&&(d.Reset(),d.SetCountry("","1"))),u={fk_media_Channel:parseInt(ei),fk_Email_Notification_Lavel:parseInt(n.fk_Email_Notification_Lavel),IsEmailNotification:n.IsEmailNotification,CustomEmailForNotification:n.CustomEmailForNotification!=null?n.CustomEmailForNotification:"",IsPhoneNotification:n.IsPhoneNotification,cbCarriers:n.fk_Mobile_Carrier,pfnMobile:d.GetIsValid()?d.GetCountryCode()+d.GetValue():""},i.push(u);cr(i)}}function fr(){si(wt);gt.addClass("active");ni.removeClass("active");ti.removeClass("active");ii.removeClass("active");fi.removeClass("active");wt=parseInt(l.dataset.notification_lavel);oi(kt,wt);ft.SetText(vi);ut.SetVisible(!0)}function yi(){hi()&&(si(wt),gt.removeClass("active"),ni.addClass("active"),ti.removeClass("active"),ii.removeClass("active"),fi.removeClass("active"),wt=parseInt(a.dataset.notification_lavel),oi(kt,wt),ft.SetText(vi),ut.SetVisible(!0))}function wi(){hi()&&(si(wt),gt.removeClass("active"),ni.removeClass("active"),ti.addClass("active"),ii.removeClass("active"),fi.removeClass("active"),wt=parseInt(v.dataset.notification_lavel),oi(kt,wt),ft.SetText(vi),ut.SetVisible(!0))}function bi(){hi()&&(si(wt),gt.removeClass("active"),ni.removeClass("active"),ti.removeClass("active"),ii.addClass("active"),fi.removeClass("active"),wt=parseInt(y.dataset.notification_lavel),oi(kt,wt),ft.SetText(vi),ut.SetVisible(!0))}function ki(){hi()&&(si(wt),gt.removeClass("active"),ni.removeClass("active"),ti.removeClass("active"),ii.removeClass("active"),fi.addClass("active"),wt=parseInt(rt.dataset.notification_lavel),oi(kt,wt),ft.SetText(tu),ut.SetVisible(!1))}function er(){w.SetEnabled(p.GetChecked())}function or(){ri==null||ri.hasClass("disabled-notification")||c.Hide();const n=new URLSearchParams(window.location.search);n!=null&&(n.get("g")!=null||n.get("op")!=null)&&window.location.replace(window.location.origin+"/videos/last")}function sr(){k.SetEnabled(b.GetChecked());d.SetEnabled(b.GetChecked())}function hr(n){dt!=null&&dt.hasClass("subscribed")?k12PopupEFX.Confirm("<div class='d-flex justify-content-center' style='text-align: center;'>Are you sure you want to unsubscribe from this channel?<\/div>",function(){di(n)},function(){return!1}):di(n)}function di(n){dt!=null&&ei!=null&&(loading.Show(),$.ajax({url:"/Services/EventsService.asmx/SubscribeUnsubscribeFromChannel",type:"POST",data:JSON.stringify({fk_media_Channel:ei}),contentType:"application/json; charset=utf-8",dataType:"json",async:!0,success:function(t){loading.Hide();t!=null&&t.d!=null&&(t.d.isOk?(t.d.retVals!=null&&t.d.retVals.isSubscribed!=null&&t.d.retVals.isSubscribed.toLowerCase()=="true"?(dt.text("Unsubscribe"),dt.addClass("subscribed"),dt.attr("title","Unsubscribe"),ri.removeClass("disabled-notification"),typeof it!="undefined"&&typeof it!="string"&&it.PerformCallback(),pi(n)):t.d.retVals!=null&&t.d.retVals.isSubscribed!=null&&t.d.retVals.isSubscribed.toLowerCase()=="false"&&(dt.removeClass("subscribed"),dt.text("SUBSCRIBE TO CHANNEL"),dt.attr("title","Subscribe to channel"),ri.addClass("disabled-notification"),typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert("You've been Unsubscribed from this channel."):alert("You've been Unsubscribed from this channel.")),typeof it!="undefined"&&typeof it!="string"&&it.PerformCallback(),u.PerformCallback()):t.d.Message?typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert(ci(t.d.Message),undefined,340):alert(ci(t.d.Message)):typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert(i):alert(i))},error:function(){loading.Hide();typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert("Subscribe Service not responding."):alert("Subscribe Service not responding.")}}))}function gi(){ei!=null&&(typeof loading!="undefined"&&loading.Show(),$.ajax({url:"/Services/EventsService.asmx/GetSubscriptionNotificationOptions",type:"POST",data:JSON.stringify({fk_media_Channel:ei,fk_Email_Notification_Lavel:parseInt(wt)}),contentType:"application/json; charset=utf-8",dataType:"json",async:!0,success:function(n){typeof loading!="undefined"&&loading.Hide();n!=null&&n.d!=null&&(n.d.isOk?n.d.ReturnObject!=null&&(kt=n.d.ReturnObject,oi(kt,wt),rr(wt)):n.d.Message?document.addEventListener("DOMContentLoaded",function(){typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert(n.d.Message,function(){const n=new URLSearchParams(window.location.search);n!=null&&(n.get("g")!=null||n.get("op")!=null)&&window.location.replace(window.location.origin+"/videos/last")},400,null,function(){const n=new URLSearchParams(window.location.search);n!=null&&(n.get("g")!=null||n.get("op")!=null)&&window.location.replace(window.location.origin+"/videos/last")}):alert(n.d.Message)}):typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert(i):alert(i))},error:function(){loading.Hide();typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert("Email Notification Service Not Responding."):alert("Email Notification Service Not Responding.")}}))}function cr(n){ei!=null&&(loading.Show(),$.ajax({url:"/Services/EventsService.asmx/SaveSubscriptionNotificationOptions",type:"POST",data:JSON.stringify({notificationSettings:JSON.stringify(n)}),contentType:"application/json; charset=utf-8",dataType:"json",async:!0,success:function(n){loading.Hide();n!=null&&n.d!=null&&(n.d.isOk?(typeof it!="undefined"&&typeof it!="string"&&it.PerformCallback(),typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert("<div class='d-flex justify-content-center'>Notification settings were saved!<\/div>",function(){const n=new URLSearchParams(window.location.search);n!=null&&(n.get("g")!=null||n.get("op")!=null)&&window.location.replace(window.location.origin+"/videos/last")},380,null,function(){const n=new URLSearchParams(window.location.search);n!=null&&(n.get("g")!=null||n.get("op")!=null)&&window.location.replace(window.location.origin+"/videos/last")}):alert("<div class='d-flex justify-content-center'>Notification settings were saved!<\/div>"),c.Hide()):n.d.Message?typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert(n.d.Message):alert(n.d.Message):typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert(i):alert(i))},error:function(){loading.Hide();typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert("Email Subscription Notification Service Not Responding."):alert("Email Subscription Notification Service Not Responding.")}}))}function oi(n,t){var u=nr(n,t),i=n[u],r;i!==undefined?(p.SetChecked(i.IsEmailNotification),i.CustomEmailForNotification!==""?w.SetValue(i.CustomEmailForNotification):"",w.Validate(),w.SetEnabled(i.IsEmailNotification),b.SetChecked(i.IsPhoneNotification),k.SetValue(i.fk_Mobile_Carrier),k.SetEnabled(i.IsPhoneNotification),d.SetEnabled(i.IsPhoneNotification),i.phone_Number!=null?(r={AreaCode:i.phone_AreaCode,Number:i.phone_Number,Extension:i.phone_Extension,CountryCode:i.phone_CountryCode.replace("+","")},d.SetValueO(r),d.SetCountry("",i.phone_CountryCode)):(d.Reset(),d.SetCountry("","1"))):(p.SetChecked(!0),w.SetValue(tt),w.Validate(),w.SetEnabled(!0),b.SetChecked(!1),k.SetSelectedIndex(0),k.SetEnabled(!1),d.SetEnabled(!1),d.Reset(),d.SetCountry("","1"),t==5&&(p.SetChecked(!1),w.SetValue(tt),w.SetEnabled(!1)))}function si(n){var t=[],i;t.fk_Email_Notification_Lavel=n;t.IsEmailNotification=p.GetChecked();t.CustomEmailForNotification=w.GetValue();t.IsPhoneNotification=b.GetChecked();t.fk_Mobile_Carrier=k.GetValue();d.tbxNumber.GetValue()!=null&&(t.phone_AreaCode=d.tbxArea.GetValue(),t.phone_Number=d.tbxNumber.GetValue(),t.phone_Extension=d.tbxExtention.GetValue(),t.phone_CountryCode=d.ddlCountry.GetValue().replace("+",""));i=nr(kt,n);i===-1?kt.push(t):kt[i]=t}function nr(n,t){for(var r=-1,i=0;i<n.length;i++)if(n[i].fk_Email_Notification_Lavel===t){r=i;break}return r}function hi(){w.Validate();var n=p.GetChecked()?w.isValid:!1,t=b.GetChecked()?d.GetIsValid():!1;if(n===!1&&p.GetChecked()===!0?n=!1:p.GetChecked()===!1&&(n=!0),t===!1&&b.GetChecked()===!0?t=!1:b.GetChecked()===!1&&(t=!0),b.GetChecked()){if(k.GetValue()===-1||k.GetValue()===undefined)return typeof k12PopupEFX!="undefined"?(k12PopupEFX.Alert("Please select Mobile Carrier!"),!1):(alert("Please select Mobile Carrier!"),!1);if(d.tbxArea.GetValue()===null||d.tbxNumber.GetValue()===null)return typeof k12PopupEFX!="undefined"?(k12PopupEFX.Alert("Please enter Mobile Number!"),!1):(alert("Please enter Mobile Number!"),!1);if(!d.GetIsValid())return typeof k12PopupEFX!="undefined"?(k12PopupEFX.Alert("Mobile Number is not valid!"),!1):(alert("Mobile Number is not valid!"),!1)}return lr(),n&&t}function lr(){d.ddlCountry.ClearControlCellStyles();d.tbxArea.ClearControlCellStyles();d.tbxNumber.ClearControlCellStyles()}function ar(){k12PopupEFX.Alert(wr(),undefined,360)}function tr(n,t){$.ajax({url:"/Services/EventsService.asmx/ChangeDisplayChannelSetting",type:"POST",data:JSON.stringify({displayChannelSetting:n,channelId:t}),contentType:"application/json; charset=utf-8",dataType:"json",async:!0,success:function(t){if(loading.Hide(),t!=null&&t.d!=null)if(t.d.isOk){let t="";n?(ui.data("is-display-channel",1),t="Channel's content is displaying."):(ui.data("is-display-channel",0),t="Channel's content is hidden.");typeof t!="undefined"&&t&&(typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert(t):alert(t));st.PerformCallback()}else t.d.Message?typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert(t.d.Message):alert(t.d.Message):typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert(i):alert(i)},error:function(){loading.Hide();let n="Channel Display Settings Service Not Responding.";typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert(n):alert(n)}})}function vr(){if(li!=null){let n=li.data("channel-id"),t=ui.data("is-display-channel");t==1?k12PopupEFX.Alert("Channel and it's associated content already displaying."):n!=null&&n>0&&ei!=null&&(loading.Show(),tr(!0,n))}}function yr(){if(ai!=null){let n=ai.data("channel-id"),t=ui.data("is-display-channel");if(t==0)k12PopupEFX.Alert("Channel and it's associated content already hidden.");else if(n!=null&&n>0){let t=!1;k12PopupEFX.Confirm("Are you sure you do not want to display this channel and it's associated videos? <\/br><\/br> You can change the setting back by using the Display Settings in the FILTERS section in the left panel.",function(){pr(t,n)})}}}function pr(n,t){loading.Show();tr(n,t)}function wr(){var f=document.createDocumentFragment(),e=document.createElement("div"),t=document.createElement("div"),i=document.createElement("A"),n,r,u;return i.setAttribute("href","#"),i.setAttribute("onclick","k12PopupEFX.Hide(); ShowLoginPopup(ContractFX.Controls.Auth.LoginPopup.TYPE_CLIENT); return false;"),i.setAttribute("style","margin-right: 4px; padding:10px 0; font-size: 16px;"),i.innerText="Sign In",n=document.createElement("A"),n.setAttribute("href","#"),window.location.pathname.indexOf("view")!==-1?n.setAttribute("onclick","k12PopupEFX.Hide(); window.location.href = window.location.origin + '/AttendeeReg.aspx?rs=1&view=' +   window.location.pathname.replace('/view/', '')"):n.setAttribute("onclick","k12PopupEFX.Hide(); window.location.href = window.location.origin + '/AttendeeReg.aspx'"),n.setAttribute("style","margin-left: 4px; padding: 10px 0; font-size: 16px;"),n.innerText="Sign Up ",r=document.createElement("span"),r.innerHTML=" to set display settings for this channel.",u=document.createElement("span"),u.innerText="/",t.appendChild(n),t.appendChild(u),t.appendChild(i),t.appendChild(r),f.appendChild(t),e.appendChild(f),e.children}function br(){var n;if(typeof at!="undefined"&&at&&at.toLowerCase()=="true"){if(ui!=null){let t=ui.data("channel-id");if(t!=null&&t>0){let t=$("."+ht);typeof t!="undefined"&&t!=null&&(t.is(":visible")?(n=$(".div-display-channel-settings"),[].forEach.call(n,function(n){$(n).hide(200)}),t.hide(200)):(n=$(".div-display-channel-settings"),[].forEach.call(n,function(n){$(n).hide(200)}),t.show(200)))}}}else ar(null)}function ci(n){var e=document.createDocumentFragment(),o=document.createElement("div"),i=document.createElement("div"),r,t,u,f;return i.setAttribute("class","d-flex align-items-center"),r=document.createElement("A"),r.setAttribute("href","#"),r.setAttribute("onclick","k12PopupEFX.Hide(); ShowLoginPopup(ContractFX.Controls.Auth.LoginPopup.TYPE_CLIENT); return false;"),r.setAttribute("style","margin-right: 4px; padding:10px 0; font-size: 16px;"),r.innerText="Sign In",t=document.createElement("A"),t.setAttribute("href","#"),window.location.pathname.indexOf("view")!==-1?t.setAttribute("onclick","k12PopupEFX.Hide(); window.location.href = window.location.origin + '/AttendeeReg.aspx?rs=1&view=' +   window.location.pathname.replace('/view/', '')"):t.setAttribute("onclick","k12PopupEFX.Hide(); window.location.href = window.location.origin + '/AttendeeReg.aspx'"),t.setAttribute("style","padding: 10px 0; font-size: 16px;"),t.innerText="Sign Up ",u=document.createElement("span"),u.innerHTML=n,f=document.createElement("span"),f.innerText="/",i.appendChild(t),i.appendChild(f),i.appendChild(r),i.appendChild(u),e.appendChild(i),o.appendChild(e),o.children}function kr(){try{let n=document.getElementsByClassName("js--channel-link");n[0].select();n[0].setSelectionRange(0,99999);document.execCommand("copy");k12PopupEFX.Alert('<div style="text-align: center; padding-bottom: 10px;">Link Copied!<\/div>')}catch(n){return k12PopupEFX.Alert("<div style='text-align: center; padding-bottom: 10px;'>Copy the Link Failed!<\/div>"),!1}return!1}var bt=this,dr,gr,nu,dt,ir,ui,li,ai,ri,gt,ni,ti,ii,fi,ei=s,wt=1,kt=[],vi="Send me email notifications when there is new content on this channel",tu="Email me Newsletters:";this.ChangeSubmite=new t.Event.Event(this);this.Init=function(){dr=n("#"+r);gr=n("#"+f);nu=n("#"+e);ir=n("#"+et);ui=n("#"+ot);li=n("#"+ct);ai=n("#"+lt);gt=n(l);ni=n(a);ti=n(v);ii=n(y);fi=n(rt);bt.Init_cbpChannelSubscribeStatus_References();ir.click(br.bind(this));li.click(vr.bind(this));ai.click(yr.bind(this));typeof it!="undefined"&&typeof it!="string"&&it.EndCallback.AddHandler(bt.cbpChannelSubscribeStatus_EndCallback,bt);this.ResetEmailNotificationmenu();gt.click(fr.bind(this));ni.click(yi.bind(this));ti.click(wi.bind(this));ii.click(bi.bind(this));fi.click(ki.bind(this));p.CheckedChanged.AddHandler(er.bind(this));b.CheckedChanged.AddHandler(sr.bind(this));nt.Click.AddHandler(ur.bind(this));g.Click.AddHandler(or.bind(this));d.SetVisible(!0);d.SetCountry("","1");d.SetRequiredStyle(!1);var i="";const t=new URLSearchParams(window.location.search);t!=null&&t.get("g")!=null&&(i=t.get("g"));(i!=""||t.get("op")!=null)&&gi();let u=n("#btnChannelLink");u&&u.click(kr)};bt.Init_cbpChannelSubscribeStatus_References=function(){bt.divJoinMembershipButton=document.querySelector("#"+vt);bt.divViewMembershipButton=document.querySelector("#"+yt);dt=n("#"+o);ri=n("#"+h);bt.divJoinMembershipButton.addEventListener("click",bt.OpenJoinMembershipPopup);bt.divViewMembershipButton.addEventListener("click",function(){window.location.href=window.location.origin+"/ng/channel/"+pt+"?tab=membership"});dt.click(hr.bind(this));ri.click(pi.bind(this))};bt.cbpChannelSubscribeStatus_EndCallback=function(){bt.Init_cbpChannelSubscribeStatus_References()};bt.createPopupWin=function(n,t,i,r,u){let f=screen.width/2-r/2,e=screen.height/2-u/2;return window.open(n,t,"width="+r+", height="+u+", top="+e+", left="+f)};bt.OpenJoinMembershipPopup=function(){var n,t;at=="True"?(n=bt.createPopupWin("/ng/join-membership/"+pt,"joinMembership","join membership",800,600),n&&(t=setInterval(function(){n.closed&&(clearInterval(t),typeof it!="undefined"&&typeof it!="string"&&it.PerformCallback())},1e3))):typeof k12PopupEFX!="undefined"?k12PopupEFX.Alert(ci("to subscribe to this channel."),undefined,340):alert(ci(data.d.Message))};this.ResetEmailNotificationmenu=function(){gt[0]!=null&&gt[0].style.display!="none"?(wt=parseInt(l.dataset.notification_lavel),gt.addClass("active"),ni.removeClass("active"),ti.removeClass("active"),ii.removeClass("active")):(wt=parseInt(a.dataset.notification_lavel),ni.addClass("active"),gt.removeClass("active"),ti.removeClass("active"),ii.removeClass("active"))};this.Init()}}(jQuery,K12Api)