(function() {
  var __bind = function(func, context) {
    return function(){ return func.apply(context, arguments); };
  };
  jQuery.fn.htmlClean = function() {
    var filtered;
    filtered = this.contents().filter(__bind(function() {
      if (this.nodeType !== 3) {
        $(this).htmlClean();
        return false;
      } else {
        return !/\S/.test(this.nodeValue);
      }
    }, this));
    filtered.remove();
    return this;
  };
  jQuery.fn.remove_whitespace = function() {
    this.each(function(i, el) {
      return (el.innerHTML = el.innerHTML.replace(/>\s+</gi, '><'));
    });
    return this;
  };
  jQuery(document).ready(function($) {
    var $sidebar, $window, offset, topPadding;
    $('body').css('overflow', 'auto');
    $('#siteContainer, #search, #siteContentGroup, .widget > header, .category-projects .widgetBody, .category-news .widgetBody, .category-talking-stick .widgetBody, .posts article').remove_whitespace();
    if ($('#about').maxlength) {
      $('#about').maxlength();
    }
    $('#fancybox-title-left').live('click', function() {
      return $(this).parent().toggleClass('off').toggleClass('on');
    });
    $sidebar = $("#toolbar");
    if (Modernizr.csstransitions) {
      $window = $(window);
      offset = $sidebar.offset();
      topPadding = 0;
      $window.scroll(function() {
        return offset && $window.scrollTop() > offset.top ? $sidebar.css({
          marginTop: $window.scrollTop() - offset.top + topPadding
        }) : null;
      });
    } else {
      $sidebar.css({
        'position': 'fixed',
        'right': '1014px'
      });
    }
    $('.ajax_fancybox').live('mouseover', function() {
      return $(this).fancybox({
        'zoomSpeedIn': 600,
        'zoomSpeedOut': 300,
        'zoomOpacity': true,
        'overlayShow': true,
        'enableEscapeButton': true,
        'centerOnScroll': true,
        'overlayColor': '#000',
        'overlayOpacity': 0.8,
        'hideOnOverlayClick': true,
        'imageScale': true,
        'easingIn': 'easeOutBack',
        'easingOut': 'easeInBack'
      });
    });
    $('.gallery a, .fancybox').live('mouseover', function() {
      return $(this).fancybox({
        'zoomSpeedIn': 600,
        'zoomSpeedOut': 300,
        'zoomOpacity': true,
        'overlayShow': true,
        'enableEscapeButton': true,
        'centerOnScroll': true,
        'overlayColor': '#000',
        'overlayOpacity': 0.8,
        'hideOnOverlayClick': true,
        'hideOnContentClick': true,
        'imageScale': true,
        'easingIn': 'easeOutBack',
        'easingOut': 'easeInBack'
      });
    });
    $('#s').focus(function() {
      $(this).attr('value', '');
      return $(this).siblings('img').css({
        'opacity': 1
      });
    });
    $('#s').blur(function() {
      $(this).attr('value', 'search');
      return $(this).siblings('img').css({
        'opacity': 0.2
      });
    });
    return $('#toolbar .tools > *').qtip({
      content: {
        text: false
      },
      position: {
        corner: {
          tooltip: 'bottomMiddle',
          target: 'topMiddle'
        }
      },
      style: {
        border: {
          width: 2,
          radius: 5
        },
        padding: 3,
        textAlign: 'center',
        tip: {
          size: {
            x: 12,
            y: 6
          },
          corner: 'bottomMiddle'
        },
        name: 'light'
      }
    });
  });
})();

