window.log = function(){
  log.history = log.history || [];
  log.history.push(arguments);
  if(this.console){
    console.log( Array.prototype.slice.call(arguments) );
  }
};

(function($) {

  /* ----------------------------------------------------------------
    Browsers
  ---------------------------------------------------------------- */
  var isOpera = ($.browser.opera),
      isWebkit = ($.browser.webkit),
      isIE = ($.browser.msie),
      bodyClass;
  if (isOpera) {
    bodyClass = 'opera';
  }
  if (isWebkit) {
    bodyClass = 'webkit';
  }

  // add classes to body tag
  $('body').addClass(bodyClass);


  /* ----------------------------------------------------------------
    header slider
  ---------------------------------------------------------------- */
  $('#cycle').cycle({
    timeout: 6000
  });


  /* ----------------------------------------------------------------
    external links
  ---------------------------------------------------------------- */
  $('a[href^=http]').each(function() {
    if(this.href.indexOf(location.hostname) == -1) {
      $(this)
        .addClass('external')
        .click(function() {
          window.open(this.href);
          return false;
        });
    }
  });
  $('a[href$=pdf]').click(function() {
    window.open(this.href);
    return false;
  });


  /* ----------------------------------------------------------------
    buttons - add span for flowers
  ---------------------------------------------------------------- */
  $('.button').wrapInner('<span />');


  /* ----------------------------------------------------------------
    lightbox
  ---------------------------------------------------------------- */
  $('a[rel=lightbox]').not('#press-list a').fancybox({
    titlePosition: 'over',
    transitionIn: 'elastic',
    transitionOut: 'elastic'
  });

  /* ----------------------------------------------------------------
    music
  ---------------------------------------------------------------- */
  var $collapser = $('.collapser'),
      $trigger = $('.collapser-trigger');
  if (location.hash != '#collapser') {
    $collapser.hide();
  }
  $trigger.click(function() {
    if ($collapser.is(':hidden')) {
      $collapser.slideDown();
    } else {
      $collapser.slideUp();
    }
    return false;
  });


  /* ----------------------------------------------------------------
    forms
  ---------------------------------------------------------------- */
  $('.nospam').hide();
  $('.nospam input').val('no' + 'spam');

})(window.jQuery);
