(function($){

var ns = "VideoViewer";

window[ns] = function ( options ) {
  this.options = options;
  
  this.item = $(options.item);
  
  this.buttons = this.item.find('span.play');
  
  this.observe();
}

window[ns].prototype = {
  
  observe: function () {
    this.buttons.click( $.proxy( this.click, this ) );
  },
  
  register: function ( button ) {
    button.click( $.proxy( this.click, this ) );
  },
  
  click: function ( event ) {
    event.preventDefault();
    var element = $(event.currentTarget);
    
    var area = element.parent();
    var code = area.next().find('textarea').val();
    area.html(code);
  }
  
};

})(jQuery);
