$(function(){
  setup_nav();
  setup_read_mores();
});

function setup_nav(){
  
  var bar = $('#navbar'),
      nav = $('#nav', bar);

  nav.find('.drop-trigger a').each(function(){
    var subs = $(this).next().children();
    $(this).data('subs', subs);
    $(this).parent().data('subs', subs);
  });

  nav.find('.drop-trigger a').click(function(){
    $(this).data('subs').not('.current-menu-item').animate({
      height: 'show',
      opacity: 'show'
    });
  });
  
  nav.children().mouseleave(function(){
    $(this).data('subs').not('.current-menu-item').animate({
      height: 'hide',
      opacity: 'hide'
    });
  });
}

function setup_read_mores(){
  $('.read-more').each(function(){
    var $this = $(this);
    var body = $this.closest('.post').find('.post-body');
    body.hide();
    $this.show();
    $this.click(function(){ body.slideDown(); $this.hide()});
  })
  
}

$.extend($.fn.disableTextSelect = function() {
  return this.each(function(){
    if($.browser.mozilla){//Firefox
      $(this).css('MozUserSelect','none');
    }else if($.browser.msie){//IE
      $(this).bind('selectstart',function(){return false;});
    }else{//Opera, etc.
      $(this).mousedown(function(){return false;});
    }
  });
});
