(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  this.UI.Home = (function() {
    function Home() {}
    Home.init = function() {
      if ($('#wrapper.layout-home').size()) {
        this.Slideshow.init();
        this.News.init();
      }
      return this;
    };
    Home.Video = (function() {
      function Video() {}
      Video.init = function() {
        $('#content-header .play-video').css('display', 'none').css('visibility', 'visible');
        $('#content-header .play-video-button').click(__bind(function() {
          return this.start();
        }, this));
        return $('#content-header .play-video .close').click(__bind(function() {
          return this.stop();
        }, this));
      };
      Video.start = function() {
        $('#content-header .play-video-button').fadeOut(UI.Home.Slideshow.fadeTime);
        return $('#content-header .play-video').fadeIn(UI.Home.Slideshow.fadeTime, function() {
          return flowplayer(0).play();
        });
      };
      Video.stop = function() {
        flowplayer(0).stop();
        $('#content-header .play-video-button').fadeIn(UI.Home.Slideshow.fadeTime);
        return $('#content-header .play-video').fadeOut(UI.Home.Slideshow.fadeTime);
      };
      return Video;
    })();
    Home.News = (function() {
      function News() {}
      News.current = 0;
      News.count = 0;
      News.selectors = {};
      News.slides = {};
      News.fadeTime = 500;
      News.timeOut = {};
      News.wait = 8000;
      News.playing = false;
      News.init = function() {
        var height, heights, self;
        this.selectors = $('.section-news .swipes .swipe');
        this.slides = $('.section-news .pages .page');
        this.count = this.selectors.size();
        self = this;
        heights = [];
        this.slides.each(function(x, item) {
          return heights.push($(item).height());
        });
        height = heights.sort(function(a, b) {
          return a - b;
        }).reverse()[0];
        $('.section-news .pages').height(height);
        this.selectors.click(function() {
          return self.select($(self.selectors).index(this));
        });
        return this.timer();
      };
      News.timer = function() {
        var self;
        self = this;
        this.timeOut = setTimeout((function() {
          var index;
          index = self.current + 1;
          if (index > (self.count - 1)) {
            index = 0;
          }
          return self.select(index);
        }), this.wait);
        return this;
      };
      News.select = function(index) {
        if (index !== this.current && !this.playing) {
          if (this.timeOut != null) {
            clearTimeout(this.timeOut);
          }
          this.playing = false;
          this.slides.eq(this.current).fadeOut(this.fadeTime);
          this.slides.eq(index).fadeIn(this.fadeTime, __bind(function() {
            this.playing = false;
            return this.timer;
          }, this));
          this.selectors.eq(this.current).removeClass("active");
          this.selectors.eq(index).addClass("active");
          this.current = index;
          this.timer();
          return this;
        }
      };
      return News;
    })();
    Home.Slideshow = (function() {
      function Slideshow() {}
      Slideshow.current = 0;
      Slideshow.count = 0;
      Slideshow.selectors = {};
      Slideshow.slides = {};
      Slideshow.fadeTime = 500;
      Slideshow.timeOut = {};
      Slideshow.wait = 7500;
      Slideshow.playing = false;
      Slideshow.init = function() {
        var self;
        this.selectors = $('#content-header .slideshow .selectors .selector');
        this.slides = $('#content-header .slideshow .slides .slide');
        this.count = this.selectors.size();
        self = this;
        this.selectors.click(function() {
          return self.select($(self.selectors).index(this));
        });
        return this.timer();
      };
      Slideshow.timer = function() {
        var self;
        self = this;
        if (this.timeOut != null) {
          clearTimeout(this.timeOut);
        }
        this.timeOut = setTimeout((function() {
          var index;
          index = self.current + 1;
          if (index > (self.count - 1)) {
            index = 0;
          }
          return self.select(index);
        }), this.wait);
        return this;
      };
      Slideshow.select = function(index) {
        if (index !== this.current && !this.playing) {
          if (this.timeOut != null) {
            clearTimeout(this.timeOut);
          }
          this.playing = false;
          this.slides.eq(this.current).fadeOut(this.fadeTime);
          this.slides.eq(index).fadeIn(this.fadeTime, __bind(function() {
            this.playing = false;
            return this.timer;
          }, this));
          this.selectors.eq(this.current).removeClass("active");
          this.selectors.eq(index).addClass("active");
          this.current = index;
          this.timer();
          return this;
        }
      };
      return Slideshow;
    })();
    return Home;
  }).call(this);
}).call(this);

