(function() {
  var menu_hover, show_notes;
  if (navigator.userAgent.match(/MSIE/gi)) {
    window.location = "http://www.ninedots.es/old/";
  } else {
    window.need = function(file) {
      file = file.replace('.js', '') + '.js';
      if ($('script[src="application/js/' + file + '"]').length === 0) {
        return document.writeln('<script src="application/js/' + file + '" type="text/javascript"></script>');
      }
    };
    window.audio = function(song, play) {
      var audio;
      if (play == null) {
        play = true;
      }
      audio = new Audio();
      audio.src = Modernizr.audio.ogg ? 'application/sounds/' + song + '.ogg' : (Modernizr.audio.mp3 ? 'application/sounds/' + song + '.mp3' : void 0, Modernizr.audio.wav ? 'application/sounds/' + song + '.wav' : null);
      if (audio.src && play) {
        return audio.play();
      }
    };
    menu_hover = function(menu) {
      var $menu, easy_in, easy_out, menu_pos, mpos, mwidth, timer, window_w;
      timer = 200;
      easy_in = 'swing';
      easy_out = 'swing';
      $menu = $(menu);
      mpos = $menu.position();
      mwidth = $menu.width() + 10;
      $menu.parent().css({
        "position": "absolute",
        "width": mwidth + 'px',
        'left': mpos.left + 'px',
        'top': mpos.top + 'px'
      });
      $menu.css({
        "position": "absolute",
        "width": mwidth + 'px',
        'z-index': 10
      });
      $(menu + ' li:not(.active)').each(function() {
        var $this, new_id, pos;
        $this = $(this);
        pos = $this.position();
        new_id = menu.replace('#', '') + '_' + $this.attr('class');
        $this.data(menu + '_hover_id', new_id);
        $menu.parent().prepend('<div id="' + new_id + '" class="menu_hover"></div>');
        $('#' + new_id).css({
          'z-index': 5,
          "position": "absolute",
          "top": (pos.top - $this.height()) + 'px',
          "left": pos.left + 'px',
          "width": ($this.width() + 22) + 'px',
          'height': $this.height() + 'px'
        });
        return $this.hover(function() {
          var $el;
          window.audio('menu');
          $el = $('#' + $(this).data(menu + '_hover_id'));
          $el.css({
            "top": pos.top - $this.height()
          });
          return $el.stop().animate({
            top: '+=' + $this.height()
          }, timer, easy_in);
        }, function() {
          var $el;
          $el = $('#' + $(this).data(menu + '_hover_id'));
          $el.css({
            "top": pos.top
          });
          return $el.stop().animate({
            top: '-=' + $this.height()
          }, timer, easy_out);
        });
      });
      menu_pos = $menu.position();
      window_w = $(window).width();
      return $(window).resize(function() {
        var dw, posx;
        dw = $(window).width() - window_w;
        posx = menu_pos.left + dw / 2;
        return $menu.css({
          left: posx + 'px'
        });
      });
    };
    show_notes = function() {
      var $note, $notes, height;
      height = 110;
      $notes = $('.note');
      if ($notes.length > 0) {
        $note = $('.note').first();
        return $note.stop().animate({
          bottom: '+=' + height
        }, 1000, 'swing', function() {
          return setTimeout(function() {
            return $note.stop().animate({
              bottom: '-=' + height
            }, 1000, 'swing', function() {
              $note.remove();
              if ($('.note').length > 0) {
                return show_notes();
              }
            });
          }, 5000);
        });
      }
    };
    window.need('jquery.qtip.pack.js');
    $(function() {
      var tip_link_opt, tip_social_opt;
      menu_hover('#main_menu');
      show_notes();
      tip_social_opt = {
        position: {
          my: 'bottom left',
          at: 'top center',
          target: 'event',
          viewport: $(window),
          adjust: {
            x: 0,
            y: -5
          },
          resize: true,
          method: 'flip'
        },
        style: {
          classes: 'ui-tooltip-shadow ui-tooltip-blue'
        }
      };
      tip_link_opt = {
        position: {
          my: 'bottom left',
          at: 'top left',
          target: 'event',
          viewport: $(window),
          adjust: {
            x: 0,
            y: 0
          },
          resize: true
        },
        style: {
          classes: 'ui-tooltip-shadow ui-tooltip-blue'
        }
      };
      $('a[rel="tip"]').qtip(tip_link_opt);
      return $('a[rel="stip"]').qtip(tip_social_opt);
    });
  }
}).call(this);

