var NavigationBar;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
NavigationBar = (function() {
  function NavigationBar() {
    this.showSection = __bind(this.showSection, this);
    this.didScroll = __bind(this.didScroll, this);    this.navigation = $('#navigation').clone().addClass('floating');
    this.navigation.insertAfter($('#navigation'));
    this.listen();
  }
  NavigationBar.prototype.didScroll = function(event) {
    var aboutUsBoundary, careersBoundary, productsBoundary, scrollTop;
    scrollTop = $(document).scrollTop() + $(this.navigation).height();
    productsBoundary = $('#products').offset().top;
    aboutUsBoundary = $('#aboutUs').offset().top;
    careersBoundary = $('#careers').offset().top;
    if (scrollTop < productsBoundary) {
      return $('#navigation').css('opacity', 1) && $(this.navigation).hide() && $(this.navigation).find('.selected').removeClass('selected');
    } else if (scrollTop > productsBoundary && scrollTop < aboutUsBoundary) {
      $('#navigation').css('opacity', 0) && $(this.navigation).attr('class', 'floating products').show();
      return $(this.navigation).find('.products').addClass('selected').siblings('.selected').removeClass('selected');
    } else if (scrollTop > aboutUsBoundary && scrollTop < careersBoundary) {
      $(this.navigation).attr('class', 'floating aboutUs').show();
      return $(this.navigation).find('.aboutUs').addClass('selected').siblings('.selected').removeClass('selected');
    } else if (scrollTop > careersBoundary) {
      $(this.navigation).attr('class', 'floating careers').show();
      return $(this.navigation).find('.careers').addClass('selected').siblings('.selected').removeClass('selected');
    }
  };
  NavigationBar.prototype.listen = function() {
    $(document).scroll(this.didScroll);
    return $('#navigation .internal a, #footer a.logo').click(this.showSection);
  };
  NavigationBar.prototype.showSection = function(event) {
    var destination, offset, section;
    event.preventDefault();
    section = $(event.currentTarget).attr('href');
    destination = $(section).offset().top;
    offset = 1;
    if (section === '#products' && $(window).scrollTop() < destination) {
      offset = -1;
    }
    return $('html:not(:animated), body:not(:animated)').animate({
      scrollTop: (destination - this.navigation.height()) + offset
    }, {
      duration: 500,
      complete: function() {
        return window.location.hash = section;
      }
    });
  };
  return NavigationBar;
})();
$(function() {
  return new NavigationBar;
});
