var eventsapi=eventsapi||{},eventModal;(function(n){n(document).ready(function(){sitecoreUtil.isPageEditor()||(eventsapi.fetcheventresourcespage=function(t,i,r,u){var f={source:t,filter:i,sort:r,page:1};return typeof u=="number"&&(f.page=u),n.ajax({dataType:"json",contentType:"application/json; charset=utf-8",method:"POST",url:"/api/eventsapi/searchresourcespage",data:JSON.stringify(f)})},eventsapi.fetcheventresourcesfirstpage=function(t,i,r,u){var f={source:t,filter:i,sort:r,page:1};return typeof u=="number"&&(f.page=u),n.ajax({dataType:"json",contentType:"application/json; charset=utf-8",method:"POST",url:"/api/eventsapi/searchresourcesfirstpage",data:JSON.stringify(f)})},eventsapi.fetchalleventspage=function(t,i,r,u,f){var e={source:t,typeSearch:r,textSearch:i,page:1},o;return u!=null&&(e.startDateSearch=u.startDate,e.endDateSearch=u.endDate),typeof f=="number"&&(e.page=f),o=JSON.stringify(e),n.ajax({dataType:"json",contentType:"application/json; charset=utf-8",method:"POST",url:"/api/eventsapi/searchalleventspage",data:o})},eventsapi.fetchalleventsfirstpage=function(t,i,r,u,f){var e={source:t,typeSearch:r,textSearch:i,page:1},o;return u!=null&&(e.startDateSearch=u.startDate,e.endDateSearch=u.endDate),typeof f=="number"&&(e.page=f),o=JSON.stringify(e),n.ajax({dataType:"json",contentType:"application/json; charset=utf-8",method:"POST",url:"/api/eventsapi/searchalleventsfirstpage",data:o})},eventsapi.fetchevent=function(t,i){var r={source:t,id:i};return n.ajax({dataType:"json",contentType:"application/json; charset=utf-8",method:"POST",url:"/api/eventsapi/searchalleventsbyid",data:JSON.stringify(r)})})})})(jQuery);eventModal=eventModal||{},function(n){n(document).ready(function(){var u=n("#eventmodal-template").text(),f=_.template(u),e=n("#eventmodal-item-template").text(),r=_.template(e),t=n("#modal-placeholder"),o=n("#modal-event-detail-carousel",u),i;o.carousel({interval:!1});eventModal.fetchAndShowDefault=function(){};i=null;eventModal.showWithNavigation=function(u,e,o){var h=r,c=f({item:u,renderItem:h}),s;t.html(c);eventModal.initmodalnavigationclick(e,o);i=u;eventModal.initNewView();s=n("#modal-event-detail",t);s.modal("show")};eventModal.fetchevent=function(t,i){var r=n.Deferred();return eventsapi.fetchevent(t,i).done(function(n){n==null||_.isEmpty(n.items)||r.resolve(n.items[0])}),r.promise()};eventModal.displayModal=function(u){var o=r,s=f({item:u,renderItem:o}),e;t.html(s);i=u;eventModal.initNewView(!0);e=n("#modal-event-detail",t);e.modal("show")};eventModal.showSingle=function(n,t){eventModal.fetchevent(n,t).done(function(n){eventModal.displayModal(n)})};eventModal.initmodalnavigationclick=function(r,u){if(typeof r!="undefined")n(".left.carousel-control",t).on("click",function(n){n.preventDefault();r(n,i)});if(typeof u!="undefined")n(".right.carousel-control",t).on("click",function(n){n.preventDefault();u(n,i)})};eventModal.replaceView=function(u){var f=n(".carousel-inner .item.active",t),e;f.length==1&&(i=u,e=n(r(u)),f.replaceWith(e),eventModal.initNewView())};eventModal.initGoogleMaps=function(){var f,u,r,e;i.address!=null&&((f=n("body").data("googlemaps-appid"),u=encodeURIComponent(i.address.formattedCalendar),_.isEmpty(u))||(r="http://maps.googleapis.com/maps/api/staticmap?center=",r+=u,r+="&zoom=16&scale=false&size=250x160&markers=color:red|",r+=u,r+="&maptype=roadmap&format=png&visual_refresh=true&key=",r+=f,e=n(".googlemapimg",t),e.attr("src",r)))};eventModal.initNewView=function(i){addtocalendar.load();eventModal.initGoogleMaps();typeof i=="boolean"&&i==!0&&n(".carousel-control",t).hide();n(".printcta",t).on("click",function(n){n.preventDefault();window.print()})}})}(jQuery)