$(function(){
  // Make all links that have a "new_window" class open in a new window
  $('a.new_window').attr('target', '_blank');

  // Move the #share element into the sidebar
  $('#share').appendTo('#sidebar_social_links');

  // Animate the sidebar icon navigation
  $('#sidebar_icon_navigation').after('<div id="sidebar_icon_navigation_text" class="no_border"></div>')
    .children('li').hover(function() {
      $('#sidebar_icon_navigation_text').text($('img', this).attr('alt'));
    }, function() {
      $('#sidebar_icon_navigation_text').text('');
    });
	
  // Set up tabs
  if ($("#content_container ul.tabs").length > 0) {
    (function() {
      var tabsElem = $("#content_container ul.tabs"),
          currURL = window.location.href;

      $(window).scrollTop(0);

      if (currURL.indexOf('#') > -1) {
        currURL = currURL.slice(0, currURL.lastIndexOf('#'));
        currURL = currURL.slice(currURL.lastIndexOf('/') + 1);
      }

      tabsElem.addClass("tabs-js").tabs('div.pane > div');

      $('a').click(function(e) {
        var href = $(this).attr('href');
        
        if (href.indexOf('#') > -1) {
          href = href.split('#');
        }

        if (currURL == href[0]) {
          tabsElem.data('tabs').getTabs().each(function(i) {
            if ($(this).attr('href') == '#' + href[1]) {
              tabsElem.data('tabs').click(i);
            }
          });
        }
      });
    })();
  }
	
  $('#content_container div.gallery')
    .after('<ul class="switcher">')
    .cycle({
      fx: 'fade',
      speed: 'fast',
      pager: '.switcher',
      pause: '1',
      pagerAnchorBuilder: function(idx, slide) {
        return '<li><a href="#">' + (idx + 1) + '</a></li>';
      }
  });

  $('.bubbleInfo').each(function () {
      var distance = 10;
      var time = 150;
      var hideDelay = 200;

      var hideDelayTimer = null;

      var beingShown = false;
      var shown = false;
      var trigger = $('.trigger', this);
      var info = $('.popup', this).css('left', '-9999px');

      $([trigger.get(0), info.get(0)]).mouseover(function () {
          if (hideDelayTimer) clearTimeout(hideDelayTimer);
          if (beingShown || shown) {
              // don't trigger the animation again
              return;
          } else {
              // reset position of info box
              beingShown = true;
              
              infoTop = $(this).css('top');
              infoTop = infoTop.substring(0, infoTop.length - 2);
              infoTop = infoTop - info.height() + 16;
              
              infoLeft = $(this).css('left');
              infoLeft = infoLeft.substring(0, infoLeft.length - 2);
              infoLeft = Number(infoLeft) + 10 - (info.width() / 2);
              
              info.css({
                  top: infoTop + 'px',
                  left: infoLeft + 'px'
              }).animate({
                  top: '-=' + distance + 'px'
              }, time, 'swing', function() {
                  beingShown = false;
                  shown = true;
              });
          }

          return false;
      }).mouseout(function () {
          if (hideDelayTimer) clearTimeout(hideDelayTimer);
          hideDelayTimer = setTimeout(function () {
              hideDelayTimer = null;
              info.animate({
                  top: '-=' + distance + 'px'
              }, time, 'swing', function () {
                  shown = false;
                  info.css('left', '-9999px');
              });

          }, hideDelay);

          return false;
      });
  });
  
//colorbox from outdoor/landscape_photos.html
$(function() {
  	$('.landscape_thumbs a').colorbox({rel:'example1'});
	});

//colorbox from partners/2010banquet.html
$(function() {
        $('.awards_thumbs a').colorbox({rel:'example1'});
    });

//colorbox from partners/2011banquet.html
$(function() {
        $('.awards_thumbs a').colorbox();
    });



});



