tinyMCEPopup.requireLangPack();

var ExplorerDialog = {
	init : function() {
		// Get the selected contents as text and place it in the input
		document.forms[0].texto.value = tinyMCEPopup.editor.selection.getContent({format : 'text'});
		document.getElementById('filebrowsercontainer').innerHTML = getBrowserHTML('filebrowser','src','media','media');
		//f.somearg.value = tinyMCEPopup.getWindowArg('some_custom_arg');
	},

	insert : function() {
		// Insert the contents from the input into the document
		var link = document.forms[0].src.value;
		if (!document.forms[0].texto.value){
			var slash = '/'
			if (link.match(/\\/)) {
				slash = '\\'
			}
			var element = link.substring(link.lastIndexOf(slash) + 1)
		}else{
			var element = document.forms[0].texto.value
		}
		tinyMCEPopup.editor.execCommand('mceInsertContent', 0, tinyMCEPopup.editor.dom.createHTML('a', {href : link, target : '_blank'}, element));

		//tinyMCEPopup.editor.execCommand('mceInsertContent', false, elm);
		tinyMCEPopup.close();
	}
};

tinyMCEPopup.onInit.add(ExplorerDialog.init, ExplorerDialog);