(function($){
  
  // thanks nlogax
  $.fn.outerHtml = function(){
    return this.clone().wrap('<div/>').parent().html();
  };

})(jQuery);

// javascript number format
// '12,345'.replace(/\d(?=(?:\d\d\d)+(?!\d))/g,'$&,'); //=> 12,345

(function($){
  $(document).ready(function(){
    
    // navigation
    $('#navigation li').hover(
      function(){ $(this).addClass('over');     },
      function(){ $(this).removeClass('over');  }
    );
    
    // buttons
    $('button').each(function(){
      var self = $(this);
      var i = self.find('img');
      self.hover(
        function(){
          // mimick javascript negative lookbehind
          // http://blog.stevenlevithan.com/archives/mimic-lookbehind-javascript
          i.attr({src: i.attr('src').replace(/(_on)?\.gif$/, function($0, $1){ return $1?$0:'_on.gif'; })});
        },
        function(){
          i.attr({src: i.attr('src').replace(/_on\.gif$/, '.gif')});
        }
      );    
    });
    
    
    // qtip
    $('.qtip-help').each(function(){
      var self = $(this);
      self.find('a').qtip({
        content: {
          text: self.find('.content')
        },
        position: {
          corner: {
             tooltip: 'topRight',
             target: 'bottomLeft'
          }
        },
        // debug
        // show: {
        //   when: {
        //     event: 'click'
        //   }
        // },
        // hide: {
        //   when: {
        //     event: 'click'
        //   }
        // },
        style: {
          tip: true,
          textAlign: 'left',
          padding: '5px',
          name: 'green'
        }
      })
      .click(function(){
        return false;
      });
    });
  
    
  });
})(jQuery);

//  table highlighter
//  (function($){
//    $(document).ready(function(){
//      $('table.striped tr:even:not(:first)').addClass('even');
//    });
//  })(jQuery);