var DftToolbarName = "Simple001";
var DftObjectName = "Editor1";

function SetEditor(pToolbarSetName, pObjectName, pDefaultValue, pConfigPath, pSkinName)
{
	var oFCKeditor = new FCKeditor(pObjectName) ;
	oFCKeditor.BasePath	= '/_Common/Editor/';
	
	oFCKeditor.Width = '100%';
	oFCKeditor.Height = '100%';
	
	if(pDefaultValue)
		oFCKeditor.Value = pDefaultValue;
		
	if(pConfigPath)
		oFCKeditor.Config['CustomConfigurationsPath'] = pConfigPath
		
	if(pSkinName)
	{
		var sSkinPath = '/_Common/Editor/editor/skins/' + pSkinName + '/' ;
		oFCKeditor.Config['SkinPath'] = sSkinPath ;

		// The following switch is optional. It is done to enhance the loading
		// time of the toolbar, by preloading the images used on it.
		switch ( pSkinName )
		{
			case 'office2003' :
				oFCKeditor.Config['PreloadImages'] =
					sSkinPath + 'images/toolbar.start.gif' + ';' +
					sSkinPath + 'images/toolbar.end.gif' + ';' +
					sSkinPath + 'images/toolbar.bg.gif' + ';' +
					sSkinPath + 'images/toolbar.buttonarrow.gif' ;
				break ;
				
			case 'silver' :
				oFCKeditor.Config['PreloadImages'] =
					sSkinPath + 'images/toolbar.start.gif' + ';' +
					sSkinPath + 'images/toolbar.end.gif' + ';' +
					sSkinPath + 'images/toolbar.buttonbg.gif' + ';' +
					sSkinPath + 'images/toolbar.buttonarrow.gif' ;
				break ;
		}
	}
		
	oFCKeditor.ToolbarSet	= pToolbarSetName ;
	oFCKeditor.Create();
	
	return oFCKeditor;
}




//----------------------------------------------------------------------


//±âº» ¿¡µðÅÍ ¸¸µé±â
function SetDftEditor(pDefaultValue)
{
	SetEditor(DftToolbarName, DftObjectName, pDefaultValue, null, "silver");
}


//¿¡µðÅÍ¿¡ ³»¿ëÃß°¡
function AddHTML(pHTML)
{
	var oEditor = FCKeditorAPI.GetInstance(DftObjectName);
	if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
	{
		oEditor.InsertHtml(pHTML);
	}
	else
		alert('¼Ò½ºº¸±â¿¡¼­´Â Ãß°¡ÇÒ ¼ö ¾ø½À´Ï´Ù.') ;
}


//¿¡µðÅÍ ³»¿ë º¯°æ
function SetHTML(pHTML)
{
	var oEditor = FCKeditorAPI.GetInstance(DftObjectName) ;
	oEditor.SetHTML(pHTML) ;
}


//¿¡µðÅÍ ³»¿ë °¡Á®¿À±â
function GetHTML()
{
	var oEditor = FCKeditorAPI.GetInstance(DftObjectName) ;
	return oEditor.GetXHTML(true);
}


//Æ÷Ä¿½º
function FocusHTML()
{
	AddHTML('');
}



//----------------------------------------------------------------------
//2°³ ÀÌ»ó ¿¡µðÅÍ ¸¸µé¶§


//±âº» ¿¡µðÅÍ ¸¸µé±â
function HtmlEditor_Set(pObjectName, pDefaultValue)
{
	SetEditor(DftToolbarName, pObjectName, pDefaultValue, null, "silver");
}


//¿¡µðÅÍ¿¡ ³»¿ëÃß°¡
function HtmlEditor_AddHTML(pObjectName, pHTML)
{
	var oEditor = FCKeditorAPI.GetInstance(pObjectName);
	if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
	{
		oEditor.InsertHtml(pHTML);
	}
	else
		alert('¼Ò½ºº¸±â¿¡¼­´Â Ãß°¡ÇÒ ¼ö ¾ø½À´Ï´Ù.') ;
}


//¿¡µðÅÍ ³»¿ë º¯°æ
function HtmlEditor_SetHTML(pObjectName, pHTML)
{
	var oEditor = FCKeditorAPI.GetInstance(pObjectName) ;
	oEditor.SetHTML(pHTML) ;
}


//¿¡µðÅÍ ³»¿ë °¡Á®¿À±â
function HtmlEditor_GetHTML(pObjectName)
{
	var oEditor = FCKeditorAPI.GetInstance(pObjectName) ;
	return oEditor.GetXHTML(true);
}


//Æ÷Ä¿½º
function HtmlEditor_Focus(pObjectName)
{
	AddHTML(pObjectName, '');
}
