Ajax.ArticleUpdater = Class.create();
Object.extend(Object.extend(Ajax.ArticleUpdater.prototype, Ajax.Updater.prototype), {
  updateContent: function() {
    var receiver = this.container[this.success() ? 'success' : 'failure'];
    var response = this.transport.responseText;

    if (!this.options.evalScripts) response = response.stripScripts();

    if (receiver = $(receiver)) {
      if (this.options.insertion)
        new this.options.insertion(receiver, response);
      else
        receiver.update(response);
    }

    if (this.success()) {
      if (this.onComplete)
        setTimeout(this.onComplete.bind(this), 10);
      if(this.options.postfunc)
    		return this.options.postfunc(this);
    }
  }
});

function getArticle(action, odwSite, containerId, assetLogicalName, assetId){
	var container = document.getElementById(containerId);
	if(container.innerHTML == '') {
		new Ajax.ArticleUpdater(containerId, action, {
			parameters: { logicalName:assetLogicalName, id:assetId, site:odwSite},
			postfunc: showArticleModal,
			targetId: containerId
		});
	} else {
		showmodal(containerId, 'Close');
	}
}

function showArticleModal(articleUpdater){
	showmodal(articleUpdater.options.targetId, 'Close');
}