	///////////////////////////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////////////////////////
	// WebEditor - Copyrightⓒ 2004 fantaplan.co.kr
	//
	// A WYSIWYG editor Tool
	// Developed By Sanjuck(mg_kang@hotmail.com)
	// modify shroh
	///////////////////////////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////////////////////////

	/////////////////////////////////////////////////////////////////////////////////////////////////
	// config Start
	/////////////////////////////////////////////////////////////////////////////////////////////////
	
	// Basic Directory
	var WebEditor_Basic_Dir = '/include/fantaeditor';
	
	// Basic skin Directory
	if(typeof(WebEditor_Skin_Dir) == 'undefined' ) {var WebEditor_Skin_Dir = '/new';}

	// Basic skin Directory
	if(typeof(WebEditor_User_Dir) == 'undefined' ) {var WebEditor_User_Dir = '';}

	// Basic Btn Lists
	// '|' is separator 
	var WebEditor_Btns = {
		'Basic'		:['Source','|','Cut','Copy','Paste','|','Undo','Redo','|','Bold','Italic','Underline','StrikeThrough','|','Subscript','Superscript','|','SelectAll','RemoveFormat','|','JustifyLeft','JustifyCenter','JustifyRight','JustifyFull','|','InsertOrderedList','InsertUnorderedList','Indent','Outdent'],
		'Extend'	:['FontName','FontSize','ForeColor','BackColor','|','CreateLink','Unlink','|','InsertHorizontalRule','|','Preview','|','Emoticon'],
		'Advanced'	:['Table','TableProperties','TdProperties','|','TableAddRow','TableDelRow','|','TableAddCol','TableDelCol','|','TableAddCell','TableDelCell','|','TableSpanRow','TableSpanCol','||','Image','ImageMapRectangle','ImageMapCircle','Flash']
	};
//		'Advanced'	:['Table','TableProperties','TdProperties','|','TableAddRow','TableDelRow','|','TableAddCol','TableDelCol','|','TableAddCell','TableDelCell','|','TableSpanRow','TableSpanCol','||','Image','ImageMapRectangle','ImageMapCircle','|','Flash','Media','About']

	// Emoticon Popup Size(Width, Height);
	var WebEditor_Emoticon_popup_size = new Array("700px", "500px");
	
	// Emoticon Icon Directory
	var WebEditor_Emoticon_Dir = WebEditor_Basic_Dir + "/emoticon/fun";
	
	// Emoticon Icon, Row Print Icon Number;
	var WebEditor_Emoticon_Num = 10;
	
	// UpLoad Directory
	if(typeof(WebEditor_Upload_Dir) == 'undefined' ) {var WebEditor_Upload_Dir = '/upfiles' + WebEditor_User_Dir + '/_webeditor';}
	
	// UpLoad Size
	var WebEditor_Upload_Size = 2048; // KB (1MB = 1024KB)
	
	// User CSS & Preview CSS
	var WebEditor_User_CSS = WebEditor_Basic_Dir + '/css/user.css';
	
	// P tag to br tag
	var WebEditor_Convert_Tag_P = false;
	
	/////////////////////////////////////////////////////////////////////////////////////////////////
	// End
	/////////////////////////////////////////////////////////////////////////////////////////////////


// js 인클루드
function include_JS_CSS (path) {
	this.js_path = path;
}
include_JS_CSS.prototype.include_js = function() {
  var js_list= this.include_js.arguments;
  for ( var i=0; i<js_list.length; i++ ) {
		document.write( '<scr' + 'ipt type="text/javascript" src="' + this.js_path + js_list[i] + '"><\/scr' + 'ipt>' ) ;
  }
}
include_JS_CSS.prototype.include_css = function() {
  var css_list= this.include_css.arguments;
  for ( var i=0; i<css_list.length; i++ ) {
		document.write( '<link href="' + this.js_path + css_list[i] + '" type="text/css" rel="stylesheet" />' ) ;
  }
}

var include_js =  new include_JS_CSS(WebEditor_Basic_Dir + "/js/");
include_js.include_js(
	"scripts.js",
//	"base.js",
	"class.toolbar.js",
	"class.btn.js",
	"class.fontname.js",
	"class.fontsize.js",
//	"class.colorpicker.js",
	"class.context.js",
	"class.table.js",
	"class.img.js",
	"class.WebEditor.js",
	"webeditor.js"
);
delete include_js;

var include_css =  new include_JS_CSS(WebEditor_Basic_Dir + "/css/");
include_css.include_css(
	"style.css"
//	"class.fontname.js",
//	"class.fontsize.js"
);
delete include_css;

//전역변수
var textareaName = new Array(); //type이 "editor"인 textarea 배열
var editorarea = new Array(); //type이 "editor"인 textarea 배열

function autoWebEditor(){ // textarea type="editor" 자동 웹에디터
	var c = 0;
	var oTextarea = document.getElementsByTagName('textarea');
	for (var i=0;i<oTextarea.length;i++){
		if(oTextarea[i].getAttribute("type")=="editor"){
			textareaName[c] = oTextarea[i].getAttribute("name");
			c++;
		}
	}
	for (var i=0;i<textareaName.length;i++){
		editorarea[textareaName[i]] = new WebEditor(textareaName[i]);
		editorarea[textareaName[i]].generate();
	}
}









function FantaEditor (elm) {
//	var orgTextarea = document.getElementsByName(elm)[0];
	var orgTextarea = getRef(elm);

	if(typeof(orgTextarea) == "object") {

		// 원 소스 텍스트 에어리어
		orgTextarea.className = 'orgTextarea';
		orgTextarea.style.backgroundColor="#F0F0F0";
		orgTextarea.style.color="#336699";
		orgTextarea.style.fontSize="9pt";
		orgTextarea.style.fontFamily="Tahoma";
		orgTextarea.style.display="none";

		//아이프레임생성
		oEditorFrame = document.createElement("iframe");
		oEditorFrame.setAttribute("id","iframe"+elm);
		oEditorFrame.setAttribute("scrolling","yes");
		oEditorFrame.setAttribute("frameBorder","no");
		oEditorFrame.setAttribute("wrap","virtual");
		oEditorFrame.className = 'webeditor';
		oEditorFrame.style.width = orgTextarea.style.width;
		oEditorFrame.style.height = orgTextarea.style.height;
		oEditorFrame.style.border = "1px solid #D0D0D0";
	//		oEditorFrame.onmouseover = new Function("viewLayer('"+i+"');");
		orgTextarea.parentNode.insertBefore(oEditorFrame,orgTextarea);

		var doc = oEditorFrame.contentWindow.document;
		oEditorFrame.src = WebEditor_Basic_Dir + "/html/iframe.php?comment="+orgTextarea.value;
		doc.designMode = "on";
/*
		var doc = getRef("iframe"+elm).contentWindow.document;
		getRef("iframe"+elm).src = "/include/fantaeditor/html/iframe.php?comment="+orgTextarea.value;
		doc.designMode = "on";
*/

		// 버튼바 생성
		var oBtnsBar = document.createElement('DIV');
		oBtnsBar.setAttribute("id","BtnsBar"+elm);
		oBtnsBar.className = 'buttonsbar';
		oBtnsBar.style.width = '100%';
//		oBtnsBar.innerHTML = "dd";

		oEditorFrame.parentNode.insertBefore(oBtnsBar,oEditorFrame);

		// 상태바 생성
		var oStatusbar = document.createElement('div');
		oStatusbar.setAttribute("id","BtnsBar"+elm);
		oStatusbar.className = 'statusbar';
		oStatusbar.style.width = '100%';
//		oStatusbar.innerHTML = '<div align="right">' + this.CopyRight() + '</div>';
		oStatusbar.innerHTML = '<div align="right">' + "sdfdsfsd " + '</div>';
		
		oEditorFrame.parentNode.insertBefore(oStatusbar,orgTextarea);

		this.init();
		
		// 버튼바 생성
		var oBtnsBars = this.BtnsBar();
		for( var sKey in oBtnsBars ) {
			oBtnsBar.appendChild( oBtnsBars[sKey].getElement() );
		}
/*
		for( var sKey in oToolbars ) {
			if (typeof(oToolbars[sKey]) == "function"){continue;}
			oBtnsBar.appendChild( oToolbars[sKey].getElement() );
		}
*/
	}

//	this.config();

	return true;
}

FantaEditor.prototype.BtnsBar = function(){
	var sValue = null;
	var OBtn = null;
	oToolbars = new Object();


	for( var sKey in WebEditor_Btns ){
		oToolbars[sKey] = new toolbar();
		for( var iKey = 0; iKey < WebEditor_Btns[sKey].length ; iKey++ ){
			sValue = WebEditor_Btns[sKey][iKey];
			if(sValue == '|') oToolbars[sKey].token();
			else if(sValue == '||') oToolbars[sKey].wideToken();
			else{
				OBtn = this.oBtns[sValue];
				if(OBtn.getType() == 'BUTTON' && OBtn.sImgSrc.indexOf(WebEditor_Basic_Dir, 0) == -1) OBtn.sImgSrc = WebEditor_Basic_Dir + '/' + OBtn.sImgSrc;
				oToolbars[sKey].add(OBtn.getElement());
			}
		}
//			});
		oToolbars[sKey].newLine();
	}
	return oToolbars;
}

	FantaEditor.prototype.oTextArea; 
	FantaEditor.prototype.oWE; 
	FantaEditor.prototype.oToolbar_Area; 
	FantaEditor.prototype.oEditor_Area; 
	FantaEditor.prototype.oSource_Area; 
	FantaEditor.prototype.oStatusbar_Area; 
	FantaEditor.prototype.oBtns = new Array(); 
	FantaEditor.prototype.oBtnTables = new Array(); 
	FantaEditor.prototype.oBtnImages = new Array(); 

FantaEditor.prototype.config = function(){

	oToolbars = this.Toolbars();
		for( var sKey in oToolbars ) this.oToolbar_Area.appendChild( oToolbars[sKey].getElement() );

}



function loadScript (url) {
    var script = document.createElement('script');
    script.defer = true;
    script.src = url;
    document.getElementsByTagName('head')[0].appendChild(script);
}
// 동적 Js 호출(파일명, 로드 완료 후 콜백함수)
function include_js(file, callBackFunction)
{
    var html_doc = document.getElementsByTagName('head')[0];

    js = document.createElement('script');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', file);

    html_doc.appendChild(js);

    // This will load the javascript for Safari, but it won't
    // let us know when it's been loaded.  The following will.

    if(/WebKit|Khtml/i.test(navigator.userAgent))
    {
        var iframe = document.createElement('iframe');
        iframe.style.display = 'none';
        iframe.setAttribute('src',file);

        document.getElementsByTagName('body').item(0).appendChild(iframe);

        // Fires in Saf
        iframe.onload = function() {
             callbackFunction();
             alert('JS iframe fired');
        }
    }

    // Fires in IE, also modified the test to cover both states
    js.onreadystatechange = function () {
        if (/complete|loaded/.test(js.readyState)) {
            callBackFunction();
            alert('JS onreadystate fired');
        }
    }

    // Fires in FF
    js.onload = function () {        
        callBackFunction();
        alert('JS onload fired');
    }

    return false;
}


