var __hasProp=Object.prototype.hasOwnProperty,__extends=function(child,parent){for(var key in parent){if(__hasProp.call(parent,key))child[key]=parent[key]}function ctor(){this.constructor=child}ctor.prototype=parent.prototype;child.prototype=new ctor;child.__super__=parent.prototype;return child};namespace('tgv',function(exports){var self;self=exports;return self.Controller=(function(){var closePromo;__extends(Controller,Backbone.Controller);function Controller(){Controller.__super__.constructor.apply(this,arguments)}Controller.prototype.routes={'!/':'movieList','!/movie/:movieID':'movieDetail','!/book':'book','!/about':'about','!/about/:page':'about','!/cinemas':'cinema','!/cinemas/:cinemaID':'cinema','!/careers':'careers','!/faqs':'faqs','!/contact':'contact','!/comingsoon':'comingsoon','!/media/:page':'media','!/sitemap':'sitemap','!/entertainment/:page':'entertainment','!/showtimes':'fullshowtimes','!/imax':'imax'};closePromo=function(){if($('.promo-pane-toggle').hasClass('active')){$('.promo-pane-toggle.active').parent().animate({'right':'-200px'},300);return $('.promo-pane-toggle.active').removeClass('active')}};Controller.prototype.initialize=function(){if(window.location.href.indexOf('/#!/')<1&&window.location.href.indexOf('_escaped_fragment')<1){window.location.href="#!/"}return $('a.back').live('click',function(){return window.location.href="#!/"})};Controller.prototype.movieList=function(){if($('#sorter .back').length>0){$('#sorter .back').remove();$('#sorter .label').show();if($('body').hasClass('mobile')){$('#sorter .option-set').show()}}$('body').removeClass('static-pages').addClass('home');$('#content').addClass('loading').children().fadeOut(500);$('#movie-listing').siblings().remove().end().fadeIn(500);$('#content').removeClass('loading');return $('#movie-listing').find('.featured:first').trigger('click')};Controller.prototype.movieDetail=function(movieID){var movieId;$('#content').addClass('loading').children().hide();if($('#sorter .back').length<1){$('#sorter .inner').prepend('<a class="back" href="#!/">Back To Movies</a>');$('#sorter .label').hide();if($('body').hasClass('mobile')){$('#sorter .option-set').hide()}}movieId=tgv.movies.list.get(movieID);if(typeof self.movies!=="undefined"){return this.movieDetailView=new self.movies.DetailView({model:movieId})}else{return this.movieDetailView=new tgv.movies.DetailView({model:movieId})}};Controller.prototype.book=function(){self=this;return this.static(function(){return self.view=new exports.static.Booking})};Controller.prototype.fullshowtimes=function(){self=this;return this.static(function(){return self.view=new tgv.static.Fullshowtimes})};Controller.prototype.static=function(callback){if($('#static').length<1){$('#content').addClass('loading').children().hide();$('body').removeClass('home').addClass('static-pages');$('#filter_cinema').change(function(){$('#static').fadeOut(500,function(){return $('#static').remove()});return $('#movie-listing').fadeIn(500)});closePromo();return this.view=new exports.static.StaticView(callback)}else{return callback()}};Controller.prototype.about=function(page){self=this;closePromo();if(page!=null){if($('#about').length<1){return this.static(function(){return self.view=new exports.static.About({page:page})})}else{return self.view=new exports.static.About.Content({page:page})}}else{return window.location.href='#!/about/overview'}};Controller.prototype.cinema=function(cinemaID){self=this;closePromo();if(cinemaID!=null){if($('#cinemas').length<1){this.static(function(){return self.view=new exports.static.Cinemas({cinema:cinemaID})})}return $.getJSON("/cinema/"+cinemaID,function(data){var model;model=tgv.cinemas.list.find(function(c){var cid;cid=c.get('cinemaID');if(cid===cinemaID){return c}});model.set(data);return model.view=new tgv.static.CinemaDetails({model:model})})}else{return window.location.href="#!/"}};Controller.prototype.careers=function(){closePromo();self=this;return this.static(function(){return self.view=new exports.static.Careers})};Controller.prototype.faqs=function(){closePromo();self=this;return this.static(function(){return self.view=new exports.static.FAQs})};Controller.prototype.contact=function(){closePromo();self=this;return this.static(function(){return self.view=new exports.static.Contact})};Controller.prototype.comingsoon=function(){closePromo();self=this;return this.static(function(){return self.view=new exports.static.ComingSoon})};Controller.prototype.media=function(page){closePromo();self=this;if(page!=null){if($('#media').length<1){return this.static(function(){return new exports.static.Media({page:page})})}else{return self.view=new exports.static.Media.Content({page:page})}}else{return window.location.href='#!/media/press'}};Controller.prototype.sitemap=function(){closePromo();self=this;return this.static(function(){return self.view=new exports.static.Sitemap})};Controller.prototype.imax=function(){closePromo();self=this;return this.static(function(){return self.view=new exports.static.Imax})};Controller.prototype.entertainment=function(page){closePromo();self=this;if(page!=null){if($('#entertainment').length<1){return this.static(function(){return self.view=new exports.static.Entertainment({page:page})})}else{return self.view=new exports.static.Entertainment.Content({page:page})}}else{return window.location.href='#!/entertainment/overview'}};return Controller})()});
var __hasProp=Object.prototype.hasOwnProperty,__extends=function(child,parent){for(var key in parent){if(__hasProp.call(parent,key))child[key]=parent[key]}function ctor(){this.constructor=child}ctor.prototype=parent.prototype;child.prototype=new ctor;child.__super__=parent.prototype;return child};namespace('tgv.user',function(exports){return exports.UserInfo=(function(){__extends(UserInfo,Backbone.Model);function UserInfo(){UserInfo.__super__.constructor.apply(this,arguments)}return UserInfo})()});namespace('tgv.movies',function(exports){return exports.Movie=(function(){__extends(Movie,Backbone.Model);function Movie(){Movie.__super__.constructor.apply(this,arguments)}Movie.prototype.idAttribute='movieID';return Movie})()});namespace('tgv.cinemas',function(exports){exports.Cinema=(function(){__extends(Cinema,Backbone.Model);function Cinema(){Cinema.__super__.constructor.apply(this,arguments)}return Cinema})();return exports.Showtime=(function(){__extends(Showtime,Backbone.Model);function Showtime(){Showtime.__super__.constructor.apply(this,arguments)}return Showtime})()});
var __hasProp=Object.prototype.hasOwnProperty,__extends=function(child,parent){for(var key in parent){if(__hasProp.call(parent,key))child[key]=parent[key]}function ctor(){this.constructor=child}ctor.prototype=parent.prototype;child.prototype=new ctor;child.__super__=parent.prototype;return child};namespace('tgv.movies',function(exports){var self;self=exports;return self.MoviesCollection=(function(){__extends(MoviesCollection,Backbone.Collection);function MoviesCollection(){MoviesCollection.__super__.constructor.apply(this,arguments)}MoviesCollection.prototype.model=self.Movie;MoviesCollection.prototype.url='/movie';MoviesCollection.prototype.initialize=function(){this.view=new self.ListView({collection:this});return this.parseHTML()};MoviesCollection.prototype.parse=function(response){var r;r=_.uniq(response);return r};MoviesCollection.prototype.parseHTML=function(){self=this;return $(this.view.el).find('a.label').each(function(){var model;model={id:$(this).attr('data-movieid'),movieID:$(this).attr('data-movieid'),movieTitle:$(this).attr('title')};return self.add(model)})};MoviesCollection.prototype.update=function(options){var c,cinema,date,url;date=$('#filter-date .active a').data('filterDate');cinema=$('#filter_cinema :selected').data('filterCinema');url="/movie/list/"+date+"/"+cinema;c=this;return $.get(url,function(data){data.push('0900000003');c.activeMovies=data;if(cinema==='all'){cinema='KLC'}tgv.user.info.set({date:date,cinema:cinema});return c.view.update()})};return MoviesCollection})()});namespace('tgv.cinemas',function(exports){return exports.Cinemas=(function(){__extends(Cinemas,Backbone.Collection);function Cinemas(){Cinemas.__super__.constructor.apply(this,arguments)}Cinemas.prototype.model=exports.Cinema;Cinemas.prototype.initialize=function(){var self;self=this;return $('#filter_cinema option').each(function(){if($(this).val()!=='all'){return self.add({cinemaName:$(this).text(),cinemaID:$(this).val()})}})};return Cinemas})()});

/*
TGV - Backbone - View
*/

var _base, _ref, _templateCache;
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };

if ((_ref = (_base = $.fn).appendWebshim) == null) {
  _base.appendWebshim = $.fn.append;
}

_templateCache = {
  'about': tgv.templates.about.layout,
  'about-about-tanjong-plc': tgv.templates.about.corporate,
  'about-overview': tgv.templates.about.overview,
  'about-about-copyright': tgv.templates.about.copyright,
  'booking': tgv.templates.booking.index,
  'booking-seats': tgv.templates.booking.seats,
  'booking-tickets': tgv.templates.booking.tickets,
  'careers': tgv.templates.careers.index,
  'cinemas-layout': tgv.templates.cinemas.layout,
  'cinemas-details': tgv.templates.cinemas.details,
  'faqs': tgv.templates.faqs.index,
  'movie-single': tgv.templates.movie.single,
  'movie-detail': tgv.templates.movie.detail,
  'static': tgv.templates.static.layout,
  'static-nav': tgv.templates.static.nav,
  'contact': tgv.templates.contact.index,
  'media': tgv.templates.media.layout,
  'media-press': tgv.templates.media.index,
  'media-announcement': tgv.templates.media.announcement,
  'sitemap': tgv.templates.sitemap.index,
  'imax': tgv.templates.imax.index,
  'entertainment': tgv.templates.entertainment.layout,
  'entertainment-overview': tgv.templates.entertainment.index,
  'entertainment-conditions': tgv.templates.entertainment.conditions,
  'entertainment-bookings': tgv.templates.entertainment.bookings,
  'entertainment-vouchers': tgv.templates.entertainment.vouchers,
  'entertainment-contact': tgv.templates.entertainment.contact,
  'comingsoon': tgv.templates.comingsoon,
  'fullshowtimes': tgv.templates.fullshowtimes.index
};

Backbone.View.prototype.template = {
  render: function(name, scope, locals) {
    var fn, result;
    fn = _templateCache[name];
    result = fn.call(scope, locals);
    return result;
  }
};

namespace('tgv.movies', function(exports) {
  exports.DetailView = (function() {

    __extends(DetailView, Backbone.View);

    function DetailView() {
      DetailView.__super__.constructor.apply(this, arguments);
    }

    DetailView.prototype.initialize = function() {
      var v;
      v = this;
      $('#content').addClass('loading');
      return v.model.fetch({
        success: function() {
          tgv.user.info.set({
            movie: v.model.get('movieID')
          });
          v.attr = v.model.toJSON();
          return v.render();
        }
      });
    };

    DetailView.prototype.render = function() {
      var selected_cinema, tmpl;
      tgv.user.info.set({
        movie: this.attr.id
      });
      tmpl = this.template.render('movie-detail', this, {
        movie: this.attr
      });
      selected_cinema = tgv.user.info.get('cinema');
      if (typeof selected_cinema === "undefined") selected_cinema = "KLC";
      $.getJSON(("/book/" + selected_cinema + "/") + this.attr.id, function(data) {
        return selected_cinema = data.cinemas[0].cinemaID;
      });
      $.getJSON(("/book/" + selected_cinema + "/") + tgv.user.info.get('movie'), function(data) {
        var cinema, selectedCinema, _i, _len, _ref2;
        _ref2 = data.cinemas;
        for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
          cinema = _ref2[_i];
          if (cinema.cinemaID === selected_cinema) {
            $('#cinema_select').append("<option value=\"" + cinema.cinemaID + "\" selected>" + cinema.cinemaName + "</option>");
          } else {
            $('#cinema_select').append("<option value=\"" + cinema.cinemaID + "\">" + cinema.cinemaName + "</option>");
          }
        }
        selectedCinema = $('#cinema_select').val();
        $.getJSON(("/book/" + selectedCinema + "/") + tgv.user.info.get('movie'), function(d) {
          var c, date, day, st, _results;
          _results = [];
          for (st in d.showtimes.showtimes) {
            day = "";
            _results.push((function() {
              var _results2;
              _results2 = [];
              for (c in d.showtimes.showtimes[st]) {
                if (day === '') {
                  day = d.showtimes.showtimes[st][c].dayName;
                  $('#showtimeList').append("<li class=\"day\">" + day + " - " + st + "</li>");
                } else if (day !== d.showtimes.showtimes[st][c].dayName) {
                  day = d.showtimes.showtimes[st][c].dayName;
                  date = d.showtimes.showtimes[st][c].date;
                  $('#showtimeList').append("<li class=\"day\">" + day + " - " + st + "</li>");
                }
                _results2.push($('#showtimeList').append("<li class=\"time\">                    <a href=\"#\" id=\"" + d.showtimes.showtimes[st][c].sessionID + "\">                      " + d.showtimes.showtimes[st][c].time + "                    </a>                  </li>"));
              }
              return _results2;
            })());
          }
          return _results;
        });
        $('#cinema_select').change(function(e) {
          selected_cinema = $('#cinema_select').val();
          return $.getJSON(("/book/" + selected_cinema + "/") + tgv.user.info.get('movie'), function(data) {
            var c, day, st, _results;
            $('#showtimeList').html('');
            _results = [];
            for (st in data.showtimes.showtimes) {
              day = '';
              _results.push((function() {
                var _results2;
                _results2 = [];
                for (c in data.showtimes.showtimes[st]) {
                  if (day === '') {
                    day = data.showtimes.showtimes[st][c].dayName;
                    $('#showtimeList').append("<li class=\"day\">" + day + " - " + st + "</li>");
                  } else if (day !== data.showtimes.showtimes[st][c].dayName) {
                    day = data.showtimes.showtimes[st][c].dayName;
                    $('#showtimeList').append("<li class=\"day\">" + day + " - " + st + "</li>");
                  }
                  _results2.push($('#showtimeList').append("<li class=\"time\"><a href=\"#\" id=\"" + data.showtimes.showtimes[st][c].sessionID + "\">" + data.showtimes.showtimes[st][c].time + "</a></li>"));
                }
                return _results2;
              })());
            }
            return _results;
          });
        });
        return $('.time a').live('click', function(e) {
          var sessionId;
          window.location.replace("#!/book");
          sessionId = $(this).attr('id');
          tgv.user.info.set({
            cinema: selected_cinema,
            showtime: $(this).attr('id')
          });
          return false;
        });
      });
      $(this.el).appendWebshim(tmpl).hide();
      tgv.elems.init(this.el);
      $('#content').appendWebshim(this.el).removeClass('loading');
      return $(this.el).fadeIn(500);
    };

    return DetailView;

  })();
  return exports.ListView = (function() {

    __extends(ListView, Backbone.View);

    function ListView() {
      ListView.__super__.constructor.apply(this, arguments);
    }

    ListView.prototype.initialize = function() {
      this.el = $('#movie-listing');
      this.isotopeInit();
      this.bindToggleBig();
      return tgv.user.info.set({
        movie: $(".featured").attr("id")
      });
    };

    ListView.prototype.featuredMovies = function(movies) {
      var movie, r, randomFeatured, _i, _len;
      if (movies != null) {
        for (_i = 0, _len = movies.length; _i < _len; _i++) {
          movie = movies[_i];
          $(movie.view.el).addClass('featured');
          $(movie.view.el).prependTo('#movie-listing');
        }
        r = Math.floor(Math.random() * movies.length);
        randomFeatured = movies[r];
        $(randomFeatured.view.el).addClass('big');
        return tgv.user.info.set({
          movie: movies[r].get('movieID')
        });
      }
    };

    ListView.prototype.isotopeInit = function() {
      var attr;
      attr = {
        filter: '.show',
        layoutMode: 'masonry',
        masonry: {
          columnWidth: 10
        },
        sortBy: 'priority',
        sortAscending: false,
        getSortData: {
          id: function($elem) {
            return $elem.attr('id');
          },
          priority: function($elem) {
            return $elem.data('priority');
          }
        }
      };
      if ($('body').hasClass('desktop')) {
        attr.animationEngine = 'jquery';
      } else {
        attr.animationEngine = 'best-available';
      }
      return $(this.el).isotope(attr);
    };

    ListView.prototype.update = function() {
      var activeMovie, activeMovies, counter, movies, _i, _len, _results;
      movies = this.collection;
      activeMovies = this.collection.activeMovies;
      $('.show').removeClass('show');
      $('#movie-listing .book').hide();
      counter = 0;
      _results = [];
      for (_i = 0, _len = activeMovies.length; _i < _len; _i++) {
        activeMovie = activeMovies[_i];
        $("#" + activeMovie).addClass('show');
        $(".book a[data-movieid=" + activeMovie + "]").parent().show();
        counter++;
        if (counter === activeMovies.length) {
          $('.show.featured:first').addClass('big');
          _results.push($(this.el).isotope({
            filter: '.show'
          }));
        } else {
          _results.push(void 0);
        }
      }
      return _results;
    };

    ListView.prototype.bindToggleBig = function() {
      var self;
      self = this;
      $(this.el).find('.article').live('click', function() {
        $(this).toggleClass('big').siblings().removeClass('big');
        return $(self.el).isotope('reLayout');
      });
      return $(this.el).find('.article a.label').click(function() {
        return tgv.user.info.set({
          movie: $(this).attr('data-movieid')
        });
      });
    };

    return ListView;

  })();
});

namespace('tgv.static', function(exports) {
  exports.StaticNav = (function() {

    __extends(StaticNav, Backbone.View);

    function StaticNav() {
      StaticNav.__super__.constructor.apply(this, arguments);
    }

    StaticNav.prototype.className = 'nav';

    StaticNav.prototype.id = 'static-nav';

    StaticNav.prototype.initialize = function() {
      return this.render();
    };

    StaticNav.prototype.render = function() {
      if ($('#sorter .back').length < 1) {
        $('#sorter .inner').prepend('<a class="back" href="#!/">Back To Movies</a>');
        return $('#sorter .label').hide();
      }
      /*
            tmpl = @template.render 'static-nav'
            $(@el).appendWebshim tmpl
            $('#main').prepend @el
      */
    };

    return StaticNav;

  })();
  exports.StaticView = (function() {

    __extends(StaticView, Backbone.View);

    function StaticView() {
      StaticView.__super__.constructor.apply(this, arguments);
    }

    StaticView.prototype.id = 'static';

    StaticView.prototype.initialize = function(callback) {
      new exports.StaticNav;
      return this.render(callback);
    };

    StaticView.prototype.render = function(callback) {
      var tmpl;
      tmpl = this.template.render('static');
      $(this.el).appendWebshim(tmpl);
      $('#content').append(this.el);
      return callback();
    };

    return StaticView;

  })();
  exports.About = (function() {

    __extends(About, Backbone.View);

    function About() {
      About.__super__.constructor.apply(this, arguments);
    }

    About.prototype.id = 'about';

    About.prototype.initialize = function() {
      return this.render();
    };

    About.prototype.render = function() {
      var tmpl;
      tmpl = this.template.render('about');
      $(this.el).appendWebshim(tmpl);
      $('#static-content-wrapper').empty().append(this.el);
      return new exports.About.Content({
        page: this.options.page
      });
    };

    return About;

  })();
  exports.About.Content = (function() {

    __extends(Content, Backbone.View);

    function Content() {
      Content.__super__.constructor.apply(this, arguments);
    }

    Content.prototype.initialize = function() {
      this.id = 'about-' + this.options.page;
      return this.render();
    };

    Content.prototype.render = function() {
      var page, tmpl;
      page = this.options.page;
      tmpl = this.template.render("about-" + page);
      $(this.el).appendWebshim(tmpl);
      $('#about-content').empty().append(this.el);
      $(".static-sidebar #nav-" + page).addClass('active').siblings().removeClass('active');
      $('#static').fadeIn(500);
      return $('#content').removeClass('loading');
    };

    return Content;

  })();
  exports.Cinemas = (function() {

    __extends(Cinemas, Backbone.View);

    function Cinemas() {
      Cinemas.__super__.constructor.apply(this, arguments);
    }

    Cinemas.prototype.id = 'cinemas';

    Cinemas.prototype.initialize = function() {
      return this.render();
    };

    Cinemas.prototype.render = function() {
      var attr, tmpl;
      attr = {
        cinemas: (function() {
          var arr;
          arr = [];
          tgv.cinemas.list.each(function(c) {
            var obj;
            obj = {
              cinemaID: c.get('cinemaID'),
              cinemaName: c.get('cinemaName')
            };
            return arr.push(obj);
          });
          return arr;
        })()
      };
      tmpl = this.template.render('cinemas-layout', this, attr);
      $(this.el).appendWebshim(tmpl);
      $('#static-content-wrapper').empty().append(this.el);
      $('#static').fadeIn(500);
      return $('#content').removeClass('loading');
    };

    return Cinemas;

  })();
  exports.CinemaDetails = (function() {

    __extends(CinemaDetails, Backbone.View);

    function CinemaDetails() {
      CinemaDetails.__super__.constructor.apply(this, arguments);
    }

    CinemaDetails.prototype.id = 'cinema-detail';

    CinemaDetails.prototype.initialize = function() {
      return this.render();
    };

    CinemaDetails.prototype.render = function() {
      var attr, cinemaID, tmpl;
      cinemaID = this.model.get('cinemaID');
      $(".static-sidebar #nav-" + cinemaID).addClass('active').siblings().removeClass('active');
      attr = this.model.toJSON();
      tmpl = this.template.render('cinemas-details', this, attr);
      $(this.el).appendWebshim(tmpl);
      $('#cinemas-content').empty().append(this.el);
      $('#cinemas-content').removeClass('loading');
      return this.loadMap(attr);
    };

    CinemaDetails.prototype.loadMap = function(attr) {
      var contentString, infowindow, latLng, map, marker, options;
      latLng = new google.maps.LatLng(attr.details.map.lat, attr.details.map.long);
      options = {
        zoom: 15,
        center: latLng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      map = new google.maps.Map(document.getElementById("cinema-map"), options);
      contentString = "<div class=\"map-info\">\n<h4>" + attr.cinemaName + "</h4>\n<address>" + (attr.details.contact.address.replace(/\n/g, '<br/>')) + "<address>\n<a href='http://maps.google.com.my/?q=" + attr.details.map.keyword + "' target='_blank'>View larger map</a>\n</div>";
      infowindow = new google.maps.InfoWindow({
        content: contentString
      });
      marker = new google.maps.Marker({
        position: latLng,
        map: map,
        title: attr.cinemaName
      });
      return google.maps.event.addListener(marker, 'click', function() {
        return infowindow.open(map, marker);
      });
    };

    return CinemaDetails;

  })();
  exports.FAQs = (function() {

    __extends(FAQs, Backbone.View);

    function FAQs() {
      FAQs.__super__.constructor.apply(this, arguments);
    }

    FAQs.prototype.id = 'faqs';

    FAQs.prototype.initialize = function() {
      return this.render();
    };

    FAQs.prototype.render = function() {
      var tmpl;
      tmpl = this.template.render('faqs');
      $(this.el).appendWebshim(tmpl);
      $('#static-content-wrapper').empty().append(this.el);
      $(this.el).find('.tabs-pane').each(function() {
        return $(this).find('dt').each(function(i, e) {
          return $(this).prepend("" + (i + 1) + ". ");
        });
      });
      tgv.elems.init(this.el);
      $('#static').fadeIn(500);
      return $('#content').removeClass('loading');
    };

    return FAQs;

  })();
  exports.Careers = (function() {

    __extends(Careers, Backbone.View);

    function Careers() {
      Careers.__super__.constructor.apply(this, arguments);
    }

    Careers.prototype.id = 'careers';

    Careers.prototype.initialize = function() {
      return this.render();
    };

    Careers.prototype.render = function() {
      var tmpl;
      tmpl = this.template.render('careers');
      $(this.el).appendWebshim(tmpl);
      $('#static-content-wrapper').empty().append(this.el);
      tgv.elems.init(this.el);
      $('#static').fadeIn(500);
      return $('#content').removeClass('loading');
    };

    return Careers;

  })();
  exports.Fullshowtimes = (function() {

    __extends(Fullshowtimes, Backbone.View);

    function Fullshowtimes() {
      Fullshowtimes.__super__.constructor.apply(this, arguments);
    }

    Fullshowtimes.prototype.id = 'fullshowtimes';

    Fullshowtimes.prototype.initialize = function() {
      var attr;
      $('#movie-detail').empty();
      attr = {
        cinemas: tgv.cinemas.list.map(function(cinema) {
          var c;
          c = {
            cinemaID: cinema.get('cinemaID'),
            cinemaName: cinema.get('cinemaName')
          };
          return c;
        }),
        movies: tgv.movies.list.map(function(movie) {
          var m;
          m = {
            movieID: movie.get('movieID'),
            movieTitle: movie.get('movieTitle')
          };
          return m;
        })
      };
      attr.selected_cinema = tgv.user.info.get('cinema');
      if (typeof attr.selected_cinema === "undefined") {
        attr.selected_cinema = "KLC";
      }
      return this.render(attr);
    };

    Fullshowtimes.prototype.render = function(attr) {
      var currDate, dateMonth, dateMonth2, dateStr, dateStr2, dayNames, dayStr, defaultCinema, htmlDates, i, show, showToday, shows, template, unique, _i, _len;
      $('#movie-detail').empty();
      template = this.template.render('fullshowtimes', this, attr);
      defaultCinema = tgv.user.info.get("cinema");
      unique = function(origArr) {
        var found, newArr, origLen, x, y;
        newArr = [];
        origLen = origArr.length;
        found = void 0;
        x = void 0;
        y = void 0;
        x = 0;
        while (x < origLen) {
          found = undefined;
          y = 0;
          while (y < newArr.length) {
            if (origArr[x].time === newArr[y].time) {
              found = true;
              break;
            }
            y++;
          }
          if (!found) newArr.push(origArr[x]);
          x++;
        }
        return newArr;
      };
      if (typeof defaultCinema === "undefined") defaultCinema = "KLC";
      currDate = new Date();
      if (currDate.getDate() < 10) {
        dateStr = "0" + (currDate.getDate());
      } else {
        dateStr = currDate.getDate();
      }
      if (currDate.getMonth() + 1 < 10) {
        dateMonth = "0" + (currDate.getMonth() + 1);
      } else {
        dateMonth = currDate.getMonth() + 1;
      }
      showToday = "" + dateStr + "-" + dateMonth + "-" + (currDate.getFullYear());
      shows = [];
      dayNames = {
        '0': 'Sun',
        '1': 'Mon',
        '2': 'Tue',
        '3': 'Wed',
        '4': 'Thu',
        '5': 'Fri',
        '6': 'Sat'
      };
      htmlDates = "";
      i = 0;
      while (i < 7) {
        if (i > 0) currDate.setTime(currDate.getTime() + 86400000);
        if (currDate.getDate() < 10) {
          dateStr2 = "0" + (currDate.getDate());
        } else {
          dateStr2 = currDate.getDate();
        }
        if (currDate.getMonth() + 1 < 10) {
          dateMonth2 = "0" + (currDate.getMonth() + 1);
        } else {
          dateMonth2 = currDate.getMonth() + 1;
        }
        dayStr = dayNames[currDate.getDay()];
        shows.push("" + dateStr2 + "-" + dateMonth2 + "-" + (currDate.getFullYear()) + " " + dayStr);
        i++;
      }
      for (_i = 0, _len = shows.length; _i < _len; _i++) {
        show = shows[_i];
        if (show === showToday) {
          htmlDates += "<option selected='selected'>" + show + "</option>";
        } else {
          htmlDates += "<option>" + show + "</option>";
        }
      }
      $.getJSON("/getbigmovies/" + defaultCinema + "/" + showToday, function(data) {
        var htmlMovies, movie, movieId, movieTitle, poster, showTime, uniqueShows, _j, _k, _len2, _len3, _ref2;
        htmlMovies = "";
        _ref2 = data.sort();
        for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
          movie = _ref2[_j];
          movieId = movie.movieID;
          movieTitle = movie.movieTitle;
          uniqueShows = unique(movie.showtimes);
          if (typeof movie.poster !== "undefined") {
            poster = movie.poster;
          } else {
            poster = "http://placehold.it/54x80&text=MOVIE";
          }
          htmlMovies += "<div class='movieSingle' id='" + movieId + "' ><div class='movie-title' style='padding-top:25px; font-size:20px;'><span><a href='http://tgv.com.my/#!/movie/" + movieId + "'>" + movieTitle + "</a></span></div><div class='movie-showtime'><span class='showtimeBigList' id='" + movieId + "'>";
          if (movie.showtimes.length < 1) {
            htmlMovies += "<font color='red'>This movie has no showtimes for selected Cinema & Day</font>";
          } else {
            for (_k = 0, _len3 = uniqueShows.length; _k < _len3; _k++) {
              showTime = uniqueShows[_k];
              htmlMovies += "<a class='showFilm' id='" + showTime.sessionID + "' href='#' movieId='" + movieId + "'>" + showTime.time + "</a>&nbsp;&nbsp;";
            }
          }
          htmlMovies += "</span></div></div>";
          $("select#date_choose").html(htmlDates);
          $("#showtimeBigList").html(htmlMovies);
          $("#content").removeClass("loading");
          $("#movie-detail").remove();
        }
        $("select#cinema_choose").change(function(e) {
          var selectCinema, selectDate;
          htmlMovies = "";
          selectCinema = $(this).val();
          selectDate = $("select#date_choose").val().split(" ");
          $("#showtimeBigList").empty();
          $("#showtimeBigList").addClass("loading");
          return $.getJSON("/getbigmovies/" + selectCinema + "/" + selectDate[0], function(data) {
            var movie, showTime, _l, _len4, _len5, _m;
            for (_l = 0, _len4 = data.length; _l < _len4; _l++) {
              movie = data[_l];
              movieId = movie.movieID;
              movieTitle = movie.movieTitle;
              uniqueShows = unique(movie.showtimes);
              if (typeof movie.poster !== "undefined") {
                poster = movie.poster;
              } else {
                poster = "http://placehold.it/54x80&text=MOVIE";
              }
              htmlMovies += "<div class='movieSingle' id='" + movieId + "' ><div class='movie-title' style='padding-top:25px; font-size:20px;'><span><a href='http://tgv.com.my/#!/movie/" + movieId + "'>" + movieTitle + "</a></span></div><div class='movie-showtime'><span class='showtimeBigList' id='" + movieId + "'>";
              if (movie.showtimes.length < 1) {
                htmlMovies += "<font color='red'>This movie has no showtimes for selected Cinema & Day</font>";
              } else {
                for (_m = 0, _len5 = uniqueShows.length; _m < _len5; _m++) {
                  showTime = uniqueShows[_m];
                  htmlMovies += "<a class='showFilm' id='" + showTime.sessionID + "' href='#' movieId='" + movieId + "'>" + showTime.time + "</a>&nbsp;&nbsp;";
                }
              }
              htmlMovies += "</span></div></div>";
            }
            $("#showtimeBigList").html(htmlMovies);
            return $("#showtimeBigList").removeClass("loading");
          });
        });
        $("select#date_choose").change(function(e) {
          var selectCinema, selectDate;
          htmlMovies = "";
          selectCinema = $("select#cinema_choose").val();
          selectDate = $(this).val().split(" ");
          $("#showtimeBigList").empty();
          $("#showtimeBigList").addClass("loading");
          return $.getJSON("/getbigmovies/" + selectCinema + "/" + selectDate[0], function(data) {
            var movie, showTime, _l, _len4, _len5, _m;
            for (_l = 0, _len4 = data.length; _l < _len4; _l++) {
              movie = data[_l];
              movieId = movie.movieID;
              movieTitle = movie.movieTitle;
              uniqueShows = unique(movie.showtimes);
              if (typeof movie.poster !== "undefined") {
                poster = movie.poster;
              } else {
                poster = "http://placehold.it/54x80&text=MOVIE";
              }
              htmlMovies += "<div class='movieSingle' id='" + movieId + "' ><div class='movie-title' style='padding-top:25px; font-size:20px;'><span><a href='http://tgv.com.my/#!/movie/" + movieId + "'>" + movieTitle + "</a></span></div><div class='movie-showtime'><span class='showtimeBigList' id='" + movieId + "'>";
              if (movie.showtimes.length < 1) {
                htmlMovies += "<font color='red'>This movie has no showtimes for selected Cinema & Day</font>";
              } else {
                for (_m = 0, _len5 = uniqueShows.length; _m < _len5; _m++) {
                  showTime = uniqueShows[_m];
                  htmlMovies += "<a class='showFilm' id='" + showTime.sessionID + "' href='#' movieId='" + movieId + "'>" + showTime.time + "</a>&nbsp;&nbsp;";
                }
              }
              htmlMovies += "</span></div></div>";
            }
            $("#showtimeBigList").html(htmlMovies);
            return $("#showtimeBigList").removeClass("loading");
          });
        });
        return $('#showtimeBigList a.showFilm').live('click', function(e) {
          var selectedCinema, sessionId;
          selectedCinema = $("select#cinema_choose").val();
          window.location.replace("#!/book");
          sessionId = $(this).attr('id');
          movie = $(this).attr("movieId");
          tgv.user.info.set({
            cinema: selectedCinema,
            movie: $(this).attr("movieId"),
            showtime: sessionId
          });
          return false;
        });
      });
      $("#content").addClass("loading");
      $(this.el).appendWebshim(template);
      $('#static-content-wrapper').empty().append(this.el);
      $('#static').fadeIn(500);
      return tgv.elems.init(this.el);
    };

    return Fullshowtimes;

  })();
  exports.Booking = (function() {

    __extends(Booking, Backbone.View);

    function Booking() {
      Booking.__super__.constructor.apply(this, arguments);
    }

    Booking.prototype.id = 'booking';

    Booking.prototype.initialize = function() {
      var attr;
      attr = {
        cinemas: tgv.cinemas.list.map(function(cinema) {
          var c;
          c = {
            cinemaID: cinema.get('cinemaID'),
            cinemaName: cinema.get('cinemaName')
          };
          return c;
        }),
        movies: tgv.movies.list.map(function(movie) {
          var m;
          m = {
            movieID: movie.get('movieID'),
            movieTitle: movie.get('movieTitle')
          };
          return m;
        })
      };
      return this.render(attr);
    };

    Booking.prototype.render = function(attr) {
      var tmpl;
      tgv.booking.init();
      tmpl = this.template.render('booking', this, attr);
      $(this.el).appendWebshim(tmpl);
      $('#static-content-wrapper').empty().append(this.el);
      $('#static').fadeIn(500);
      return $('#content').removeClass('loading');
    };

    return Booking;

  })();
  exports.Contact = (function() {

    __extends(Contact, Backbone.View);

    function Contact() {
      Contact.__super__.constructor.apply(this, arguments);
    }

    Contact.prototype.id = 'contact';

    Contact.prototype.initialize = function() {
      return this.render();
    };

    Contact.prototype.render = function() {
      var tmpl;
      tmpl = this.template.render('contact');
      $(this.el).appendWebshim(tmpl);
      $('#static-content-wrapper').empty().append(this.el);
      tgv.elems.init(this.el);
      $('#static').fadeIn(500);
      return $('#content').removeClass('loading');
    };

    return Contact;

  })();
  exports.ComingSoon = (function() {

    __extends(ComingSoon, Backbone.View);

    function ComingSoon() {
      ComingSoon.__super__.constructor.apply(this, arguments);
    }

    ComingSoon.prototype.id = 'comingsoon';

    ComingSoon.prototype.initialize = function() {
      return this.render();
    };

    ComingSoon.prototype.render = function() {
      var tmpl;
      tmpl = this.template.render('comingsoon');
      $(this.el).appendWebshim(tmpl);
      $('#static-content-wrapper').empty().append(this.el);
      tgv.elems.init(this.el);
      $('#static').fadeIn(500);
      return $('#content').removeClass('loading');
    };

    return ComingSoon;

  })();
  exports.Media = (function() {

    __extends(Media, Backbone.View);

    function Media() {
      Media.__super__.constructor.apply(this, arguments);
    }

    Media.prototype.id = 'media';

    Media.prototype.initialize = function() {
      return this.render();
    };

    Media.prototype.render = function() {
      var tmpl;
      tmpl = this.template.render('media');
      $(this.el).appendWebshim(tmpl);
      $('#static-content-wrapper').empty().append(this.el);
      tgv.elems.init(this.el);
      $('#static').fadeIn(500);
      return $('#content').removeClass('loading');
    };

    return Media;

  })();
  exports.Sitemap = (function() {

    __extends(Sitemap, Backbone.View);

    function Sitemap() {
      Sitemap.__super__.constructor.apply(this, arguments);
    }

    Sitemap.prototype.id = 'sitemap';

    Sitemap.prototype.initialize = function() {
      return this.render();
    };

    Sitemap.prototype.render = function() {
      var tmpl;
      tmpl = this.template.render('sitemap');
      $(this.el).appendWebshim(tmpl);
      $('#static-content-wrapper').empty().append(this.el);
      tgv.elems.init(this.el);
      $('#static').fadeIn(500);
      return $('#content').removeClass('loading');
    };

    return Sitemap;

  })();
  exports.Imax = (function() {

    __extends(Imax, Backbone.View);

    function Imax() {
      Imax.__super__.constructor.apply(this, arguments);
    }

    Imax.prototype.id = 'imax';

    Imax.prototype.initialize = function() {
      return this.render();
    };

    Imax.prototype.render = function() {
      var tmpl;
      tmpl = this.template.render('imax');
      $(this.el).appendWebshim(tmpl);
      $('#static-content-wrapper').empty().append(this.el);
      tgv.elems.init(this.el);
      $('#static').fadeIn(500);
      return $('#content').removeClass('loading');
    };

    return Imax;

  })();
  exports.Entertainment = (function() {

    __extends(Entertainment, Backbone.View);

    function Entertainment() {
      Entertainment.__super__.constructor.apply(this, arguments);
    }

    Entertainment.prototype.id = 'entertainment';

    Entertainment.prototype.initialize = function() {
      return this.render();
    };

    Entertainment.prototype.render = function() {
      var tmpl;
      tmpl = this.template.render('entertainment');
      $(this.el).appendWebshim(tmpl);
      $('#static-content-wrapper').empty().append(this.el);
      return new exports.Entertainment.Content({
        page: this.options.page
      });
    };

    return Entertainment;

  })();
  exports.Entertainment.Content = (function() {

    __extends(Content, Backbone.View);

    function Content() {
      Content.__super__.constructor.apply(this, arguments);
    }

    Content.prototype.initialize = function() {
      this.id = 'entertainment-' + this.options.page;
      return this.render();
    };

    Content.prototype.render = function() {
      var page, tmpl;
      page = this.options.page;
      tmpl = this.template.render("entertainment-" + page);
      $(this.el).appendWebshim(tmpl);
      $('#entertainment-content').empty().append(this.el);
      $(".static-sidebar #nav-entertainment-" + page).addClass('active').siblings().removeClass('active');
      $('#static').fadeIn(500);
      return $('#content').removeClass('loading');
    };

    return Content;

  })();
  exports.Media = (function() {

    __extends(Media, Backbone.View);

    function Media() {
      Media.__super__.constructor.apply(this, arguments);
    }

    Media.prototype.id = 'media';

    Media.prototype.initialize = function() {
      return this.render();
    };

    Media.prototype.render = function() {
      var tmpl;
      tmpl = this.template.render('media');
      $(this.el).appendWebshim(tmpl);
      $('#static-content-wrapper').empty().append(this.el);
      return new exports.Media.Content({
        page: this.options.page
      });
    };

    return Media;

  })();
  return exports.Media.Content = (function() {

    __extends(Content, Backbone.View);

    function Content() {
      Content.__super__.constructor.apply(this, arguments);
    }

    Content.prototype.initialize = function() {
      this.id = 'media-' + this.options.page;
      return this.render();
    };

    Content.prototype.render = function() {
      var page, tmpl;
      page = this.options.page;
      tmpl = this.template.render("media-" + page);
      $(this.el).appendWebshim(tmpl);
      $('#media-content').empty().append(this.el);
      $(".static-sidebar #nav-media-" + page).addClass('active').siblings().removeClass('active');
      $('#static').fadeIn(500);
      return $('#content').removeClass('loading');
    };

    return Content;

  })();
});


