// JavaScript Document
var GabeHelper = {};

GabeHelper.initCkeditor = function(editor, option) {
	CKFinder.SetupCKEditor(editor,'../js/ckfinder/');
	if(option.toolbar) {
		editor.config.height = '170px';
		editor.config.toolbar_GabeSimple=[['Source','-','Preview','-','Templates'],['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print','SpellChecker','Scayt'],['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['Link','Unlink','Anchor'],['Image','Flash','Table','HorizontalRule']];
		editor.config.toolbar = 'GabeSimple';
	} else {
		editor.config.height = '300px';
		editor.config.toolbar_Gabe=[['Source','-','Preview','-','Templates'],['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print','SpellChecker','Scayt'],['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],'/',['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['Link','Unlink','Anchor'],['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],'/',['Styles','Format','Font','FontSize'],['TextColor','BGColor'],['Maximize','ShowBlocks','-','About']];
		editor.config.toolbar = 'Gabe';	
	}
	
}

GabeHelper.createCkeditor = function(form, editorname, fieldid, fieldname, option) {
	if(!option) {
		option = {};	
	}
	var editor = CKEDITOR.replace(editorname);	
	GabeHelper.initCkeditor(editor, option);
	jQuery("input[type='submit'], input[type='image']", jQuery(form)).mouseover(function(event) {
		if(!document.getElementById(fieldid)) {
			jQuery(form).append("<textarea name='" + fieldname + "' id='" + fieldid + "' style='display:none'></textarea>");
		}
		jQuery('#' + fieldid).val(GabeUtil.cleanCkeditorData(editor.getData()));
	});
	return editor;
	
}
