jQuery(function ($) {
  
  /* ---------------------------------------------------------------- 
  	search input focus
  ---------------------------------------------------------------- */
  $('#search').focus(function () {
    var defaultValue = $(this).val();
    $(this).val('');
    $(this).blur(function() {
      if ($.trim(this.value) == '') {
        $(this).val(defaultValue);
      }
    });
  });
  
  
  /* ---------------------------------------------------------------- 
  	dropup menu
  ---------------------------------------------------------------- */
  var dropdown = $('#menu > li').not('.selected');
  dropdown.find('ul').hide();
  dropdown.hoverIntent({
  	sensitivity: 3, 
  	interval: 50, 
  	over: function() {
      $('ul', this).stop().slideDown(150);
    }, 
  	timeout: 500, 
  	out: function() {
      $('ul', this).stop().slideUp(150, function() {
        $(this).css({'height': 'auto'});
      });
    }
  });
  
  
  /* ---------------------------------------------------------------- 
  	corners

  $.fn.corners = function(options) {
    var opts = $.extend({}, $.fn.corners.defaults, options);
    return this.each(function() {
      $this = $(this);
      
      var cornerDivs = '';
      if (opts.topLeft) { cornerDivs += '<div class="top-left"></div>'; }
      if (opts.topRight) { cornerDivs += '<div class="top-right"></div>'; }
      if (opts.bottomLeft) { cornerDivs += '<div class="bottom-left"></div>'; }
      if (opts.bottomRight) { cornerDivs += '<div class="bottom-right"></div>'; }
      
      var margin = $this.css('margin-top') + ' ' + $this.css('margin-right') + ' ' + $this.css('margin-bottom') + ' ' + $this.css('margin-left'); 
      $this.css({'margin': '0px'});
      
      var borderLeft = '';
      if (parseInt($this.css('border-left-width')) == 'NaN') {
        borderLeft = parseInt($this.css('border-left-width'));
      } else {
        borderLeft = 0;
      }
      
      var borderRight = '';
      if (parseInt($this.css('border-right-width')) == 'NaN') {
        borderRight = parseInt($this.css('border-right-width'));
      } else {
        borderRight = 0;
      }
      
      var widthDiv = parseInt($this.width()) + borderLeft + borderRight + parseInt($this.css('padding-left')) + parseInt($this.css('padding-right'));
      var isFloated = $this.css('float');
      
      $this.wrap('<div class="corners"></div>').parent().css({'margin': margin, 'width': widthDiv+'px', 'float': isFloated}).append(cornerDivs);
      
    });
  };
  // corners defaults
  $.fn.corners.defaults = {
    topLeft: true,
    topRight: true,
    bottomLeft: true,
    bottomRight: true
  };
  
  // init corners
  $('#content, #sider-left, #sider-right').corners();
  
  ---------------------------------------------------------------- */
  
});
