
Event.addBehavior({
  'body': function() {
  },
  '.upload_link:click': function(e) {
    Modalbox.show($('popup_upload'), {
      title: "Upload image or pdf",
      width:500,
      overlayDuration:0
    });
    $('newspost_media_name').clear();
    $('newspost_media_uploaded_data').clear();
    e.stop();
  },
  '.ajax-form form' : Remote.Form,
  '.delete_asset:click':function() {
    this.hide();
  },
  '.insert_image:click' : function () {
    str = "<img src='" + this.id + "'>";
    append_mce_text(str);
  },
  '.insert_pdf:click' : function () {
    short_id = this.readAttribute('short_id');
    str = "<a href='" + this.id + "'>"+ short_id +"</a>";
    append_mce_text(str);
  }
});

function process_upload(e) {
  Modalbox.deactivate($('popup_upload'));
  $('upload_status').innerHTML='Please wait...';
  Modalbox.resizeToContent($('popup_upload'));
}

function append_mce_text(str) {
  a=tinyMCE.activeEditor.getContent();
  a=tinyMCE.activeEditor.setContent(a + str);
  return false;
}


