var Cinemark;(function(n){var t;(function(t){var f=function(){function n(){}return n}(),i,r,u;t.Elements=f;i=function(){function t(t){this.routeToGetTheatersBySearchText="Theater/GetTheatersbyText?";this.contentId=t;this.theatersUpdated=new n.Models.Observer}return t.prototype.findTheatersBySearchText=function(t){var i=""+n.getBaseUmbracoApiUrl()+this.routeToGetTheatersBySearchText+"contentId="+this.contentId+"&searchText="+t;this.headlineText=t;this.callApi(i)},t.prototype.callApi=function(t){var i=this;$.ajax({type:"GET",cache:!1,url:t,success:function(n){i.successCallback(n)},error:function(){i.errorCallback()}});n.stopSpinner()},t.prototype.successCallback=function(t){this.theatersUpdated.notify(t);(new n.WatchList).initialize()},t.prototype.errorCallback=function(){},t}();t.Model=i;r=function(){function n(n,t,i){this.elements=n;this.model=t;this.controller=i;this.init()}return n.prototype.init=function(){var n=this;typeof this.elements.form!="undefined"&&(this.elements.form.onsubmit=function(t){return n.elements.changeTheatersAnchor!==undefined&&n.elements.changeTheatersAnchor.click(),n.controller.formOnSubmit(t,n.elements.searchText.value)});this.model.theatersUpdated.attach(function(t){n.updateTargetDiv(t)})},n.prototype.updateTargetDiv=function(n){this.model.headlineText!==undefined&&(this.elements.headline.innerText=this.model.headlineText);jQuery("#SearchResults")[0].innerHTML=n;var t=this.elements.contentTheatreList.getElementsByClassName("theateridsdiv"),i=t!==undefined&&t!=null&&t.length>0?t[0].getAttribute("data-theaterIds"):"";jQuery(document).trigger("TheaterSearchComplete",{theaterIds:i})},n}();t.View=r;u=function(){function n(n){this.model=n}return n.prototype.formOnSubmit=function(n,t){n.preventDefault();this.model.findTheatersBySearchText(t)},n}();t.Controller=u})(t=n.Theater||(n.Theater={}))})(Cinemark||(Cinemark={}));$(document).ready(function(){var n=new Cinemark.Theater.Elements;n.changeTheatersAnchor=jQuery("#changeLocationDropdown")[0];n.contentTheatreList=$("#SearchResults")[0];n.form=jQuery("#TheaterSearchForm")[0];n.searchText=jQuery("#SearchText")[0];n.headline=jQuery("#Headline")[0];var t=new Cinemark.Theater.Model(typeof contentId!="undefined"?contentId:0),i=new Cinemark.Theater.Controller(t),u=new Cinemark.Theater.View(n,t,i),r=new Cinemark.Showtimes.Controller;r.init("#showTimes",currentMovieId,currentTheaterId,currentTheaterIds,Cinemark.Showtimes.GetShowtimesMode.ByTheater)})