(function($){

var ns = "ReadMore";

window[ns] = function ( options ) {
  this.options = options;
  this.anchor = $(options.anchor);
  this.observe();
}

window[ns].prototype = {
  
  observe: function () {
    this.anchor.click( $.proxy( this.click, this ) );
  },
  
  register: function ( button ) {
    button.click( $.proxy( this.click, this ) );
  },
  
  click: function ( event ) {
    event.preventDefault();
    var element = $(event.currentTarget);
    var target = element;
    var max = 10;

    do {
      max--;
      target = target.parent();
    } while ( ! target.hasClass('content') || max < 0 );
    
    if ( max < 0 ) return;
    target.find('.more').show();
    element.remove();
    
/*
    do {
      max--;
      target = target.parent();
    } while ( ! target.next().hasClass('more') || max < 0 );
*/
    
  }
  
};

})(jQuery);
