
function DoceboImage(editor) {
    this.editor = editor;
	var cfg = editor.config;
	var self = this;

	cfg.registerButton({
        id       : "doceboimage",
        tooltip  : this._lc("Load Image"),
        image    : editor.imgURL("ed_image.gif", "DoceboImage"),
        textMode : false,
        action   : function(editor) {
                     self.buttonPress(editor);
                   }
    });

	cfg.addToolbarElement("doceboimage", "insertimage", 0);
}

DoceboImage._pluginInfo = {
	name          : "DoceboImage",
	version       : "1.0.0",
	developer     : "Fabio Provano",
	license       : "htmlArea"
};

DoceboImage.prototype._lc = function(string) {
    return HTMLArea._lc(string, 'DoceboImage');
};

DoceboImage.prototype.buttonPress  = function(editor) {
	// Costruzione dell'oggetto parametri da passare alla dialog.
	outparam = {
		content : editor.getSelectedHTML()
	}; // Fine costruzione parametri per il passaggio alla dialog.
	editor._popupDialog( '../../mod_media/index_xinha.php?sn=' + DoceboSession, function( html ) {
		if ( !html ) {
			//user must have pressed Cancel
			return false;
		}

		if(html.type == 'flash') {

			var oItem 		= document.createElement('embed');
			oItem.src 		= html.url;
			oItem.bgcolor 	= html.bgcolor;
			oItem.width 	= html.width;
			oItem.height 	= html.height;
			oItem.type 		= "application/x-shockwave-flash";
			editor.insertNode(oItem);
		} else if (html.type == 'image') {

			editor.insertHTML( '<img src="' + html.url + '" alt = "' + html.alt_text + '" title="' + html.title_text + '" />' );
		}
		else if (html.type == 'audio' || html.type == 'video') {
			var parsed = unescape(html.embed_code);
			parsed = parsed.parseJSON();
			editor.insertHTML( parsed.code );
		}

	}, outparam);
};
