
tinyMCE.init({
		mode : "specific_textareas",
		editor_selector : "editor",
		theme : "advanced",
		plugins : "spellchecker,table,save,advimage,advlink,preview,zoom,flash,searchreplace,print,paste,fullscreen,contextmenu,ibrowser",
		language: "pt_br",
		remove_script_host : false,
		theme_advanced_buttons2_add : "|,ibrowser,flash",
		theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,separator,search,replace",
		theme_advanced_buttons3_add_before : "tablecontrols,separator",
		theme_advanced_buttons3_add : "separator,print,spellchecker,fullscreen,preview,zoom",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		content_css : "example_full.css",
		accessibility_warnings : false,
	    extended_valid_elements : "hr[class|width|size|noshade]",
		external_link_list_url : "example_link_list.js",
		file_browser_callback : "openWindow",
		paste_use_dialog : false,
		theme_advanced_resizing : true,
		theme_advanced_resize_horizontal: false,
		apply_source_formatting : true,
		theme_advanced_disable : 'help',
		spellchecker_languages : "+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv",
		relative_urls: false,
		convert_urls: false,
		remove_script_host : true
	});

	var dest_win;
	
	function openWindow(field_name, url, type, win) {
		//alert("Example of filebrowser callback: field_name: " + field_name + ", url: " + url + ", type: " + type);
		url = document.URL;
		path = url.substr(url.indexOf("modules"));
		tokens = path.split("/");
		moduleDir = tokens[1]; //diretório do módulo - retirado da URL
		window.open("../../upload.php?moduleDir="+moduleDir+"&field_name="+field_name+"&type="+type,"upload", "width=350,height=30,top=200,left=200resizable=no,status=no,location=no,scrollbars=no,menubar=no");
		dest_win = win;

	}

	function insertImage(field_name, file) {
		url = document.URL;
		path = url.substring(0, url.indexOf("/modules"));
		tokens1 = path.split("/");
		rootDir = tokens1[(tokens1.length-1)];
		host = url.substring(0, url.indexOf(rootDir));

		module = url.substr(url.indexOf("modules"));
		tokens2 = module.split("/");
		moduleDir = tokens2[1];

		final_url = host + "_upload/" + moduleDir + "/" + file;
		len  = window.location.host.length;
		last_url = host.substring(host.indexOf(window.location.host)+len);
		
		final_url = last_url + "_upload/" + moduleDir + "/" + file;
		
		if (dest_win) {
			dest_win.document.forms[0].elements[field_name].value = final_url;
		} else {
			document.forms[0].elements[field_name].value = final_url;
		}
	}
