function KwText() { };
KwText.cn = 'kw-text';
KwText.init_value = false;
KwText.locs = Array();
KwText.editors = Array();

KwText.init = function() {
	if (KwText.init_value == false) {
		KwText.init_value = true;
		
		KwText.locs = KwLoc.getLocs(KwText.cn, KwLang.getLk('kw_lang_interface'));
	}
};
KwText.loc = function(loc_name, replace, tp) {
	KwText.init();
	return KwLoc.locFunction(KwText.cn, KwText.locs, loc_name, replace, tp);
};
KwText.onChangeSelectFe = function(id, sel) {
	KwText.init();
	if (KwText.editors[id] != null) {
		KwText.destroyFullEditor(id, KwText.editors[id]);
		KwText.editors[id] = null;	
	}
	for (var i = 1; i < sel.options.length; i++) {
    	if (sel.options[i].selected == true) {
    		KwText.replaceWithFullEditor(id, sel.options[i].value);
        }
    }
};
KwText.replaceWithFullEditor = function(id,fe) {
	KwText.init();
	switch (fe) {
		case 'kw-ckeditor':	
			KwCkeditor.replace(id);
			KwText.editors[id] = 'kw-ckeditor';
			break;
		case 'kw-tinymce':	
			KwTinymce.replace(id);
			KwText.editors[id] = 'kw-tinymce';
			break;
	}
};

KwText.destroyFullEditor = function(id, fe) {
	KwText.init();
	
	switch (fe) {
		case 'kw-ckeditor':
			KwCkeditor.destroy(id);
			break;
		case 'kw-tinymce':	
			KwTinymce.destroy(id);
			break;
	}
};

