<!--
var isIE  = (document.all) ? true : false;
var editor_focus = false;
var save_draft_timer;
var palette_mode;

function set_editor() {
	var source = '<link rel="stylesheet" type="text/css" href="'+src_path+'/include/css/content.css" /><style type"text/css">body{margin:0;padding:0;font-size:12px;font-family:돋움;color:#333;line-height:150%;} p{font-size:12px;font-family:돋움;margin:0;} a:link { color:#01888e; text-decoration:none; } a:visited { color:#01888e; text-decoration:none; } a:hover { color:#01888e; text-decoration:underline; } div div{border:0 none;} object, embed{background-color:#eee;} iframe{width:560px;height:315px;overflow:hidden;}</style>';
	htmleditor.document.designMode = 'On';
	htmleditor.document.open('text/html');
	htmleditor.document.write(source);
	htmleditor.document.close();
	/*htmleditor.document.body.style.fontSize = '12px';
	htmleditor.document.body.style.color = '#333';
	htmleditor.document.body.style.fontFamily= '돋움';
	htmleditor.document.body.style.lineHeight= '150%';*/
	var innerBody = htmleditor.document.body;
	innerBody.onblur = function() { save_pos(); }
	innerBody.onfocus = function() { save_pos(); editor_focus = true; }
	innerBody.onkeydown = function() { onkeypress_html_body(); }
	set_body();
	keepalive();
}

function save_pos() {
	try { htmleditor.document.currentPos =  htmleditor.document.selection.createRange().duplicate(); }
	catch(e) { }
}

function onclick_editor_com(com) {
	htmleditor.focus();
	save_pos();

	htmleditor.document.execCommand(com, false, null);
	htmleditor.focus();
}

function onclick_editor_font(com, val) {
	htmleditor.document.execCommand(com, null, val);
	htmleditor.focus();
}

function display_palette() {
	document.getElementById('editor_palette').style.display = 'block';
}

function ck_color(color) {
	htmleditor.focus();
	if (palette_mode == '1') {
		htmleditor.document.execCommand('ForeColor', false, color);
	} else {
	       if (isIE){
			htmleditor.document.execCommand('BackColor', null, color );
		}else{
			htmleditor.document.execCommand('hilitecolor', null, color );
		}
	}
	document.getElementById('editor_palette').style.display = 'none';
}

function set_emoticon(src) {
	htmleditor.focus();

	if (isIE) {
		save_pos();
		var sText = htmleditor.document.currentPos;
		if (!sText) return false;
		htmleditor.document.body.focus();
		sText.pasteHTML('<img src="'+src+'">');
		sText.select();
	} else {
		htmleditor.focus();
		htmleditor.document.execCommand('insertHTML', false, '<img src="'+src+'" align="absmiddle">');
		htmleditor.focus();
	}
}

function set_text(text) {
	if (isIE) {
		var sText = htmleditor.document.currentPos;
		if (!sText) return false;
		htmleditor.document.body.focus();
		sText.pasteHTML(text);
		sText.select();
	} else {
		htmleditor.focus();
		htmleditor.document.execCommand('insertHTML', false, 'text');
		htmleditor.focus();
	}
}

function set_movie(movie_tag) {
	htmleditor.focus();
	if (isIE) {
		save_pos();
		var sText = htmleditor.document.currentPos;
		if (!sText) return false;
		htmleditor.document.body.focus();
		sText.pasteHTML(movie_tag);
		sText.select();
	} else {
		htmleditor.focus();
		htmleditor.document.execCommand('insertHTML', false, movie_tag);
		htmleditor.focus();
	}
}

function set_image(path, width, height, caption, align) {
	htmleditor.focus();
	var paste_text = '<img src="'+path+'" class="upimg" alt="" />';
	if (caption != '') caption = '<p class="caption">'+caption+'</p>';
	if (align == '1') paste_text = '<div class="images simg"><div class="img_left">' + paste_text + caption+'</div></div>';
	if (align == '2') paste_text = '<div class="images simg"><div class="img_center" style=\"width:'+width+'px\">' + paste_text + caption+'</div></div>';
	if (align == '3') paste_text = '<div class="images simg"><div class="img_right">' + paste_text + caption+'</div></div>';
	if (isIE) {
		save_pos();
		var sText = htmleditor.document.currentPos;
		if (!sText) return false;
		htmleditor.document.body.focus();
		sText.pasteHTML(paste_text);
		sText.select();
	} else {
		htmleditor.focus();
		htmleditor.document.execCommand('insertHTML', false, paste_text);
		htmleditor.focus();

	}
}

function set_image2(path1, width1, height1, caption1, path2, width2, height2, caption2, align) {
	var paste_text1 = '<img src="'+path1+'" class="upimg" alt="" />';
	var paste_text2 = '<img src="'+path2+'" class="upimg" alt="" />';

	htmleditor.focus();

	var align_str = '';
	if (align == '1') align_str = 'dimg_left';
	if (align == '2') align_str = 'dimg_center';
	if (align == '3') align_str = 'dimg_right';
	paste_text = '<div class="images dimg"><div class="img1">' + paste_text1 + '<p class="caption">' + caption1 + '</p></div><div class="img2">' + paste_text2 + '<p class="caption">' + caption2 + '</p></div></div>';
	if (isIE) {
		save_pos();
		var sText = htmleditor.document.currentPos;
		if (!sText) return false;
		htmleditor.document.body.focus();
		sText.pasteHTML(paste_text);
		sText.select();
	} else {
		htmleditor.focus();
		htmleditor.document.execCommand('insertHTML', false, paste_text);
		htmleditor.focus();
	}
}

function resizeImage(user_img){
	var maxImageWidth = '690';
	if(user_img.width > maxImageWidth){ 
		user_img.style.width = maxImageWidth;
		user_img.width= maxImageWidth;
	}
}
function set_user_image(path) {
	htmleditor.focus();
	var paste_text = '<img src="'+path+'" class="editorAttachedImage" onclick="popView(this.src)" onload="resizeImage(this)" alt="" />';
	if (isIE) {
		save_pos();
		var sText = htmleditor.document.currentPos;
		if (!sText) return false;
		htmleditor.document.body.focus();
		sText.pasteHTML(paste_text);
		sText.select();
	} else {
		htmleditor.focus();
		htmleditor.document.execCommand('insertHTML', false, paste_text);
		htmleditor.focus();
	}
}


function onclick_attach_image() {
	window.open('editor_pop_attach_image.php','a_i','width=400,height=370');
}

function onclick_editor_link(obj) {
	viewObj('div_link_keyword');
	document.getElementById('link_keyword').focus();
	document.getElementById('link_keyword').value = obj.text;
	auto_suggest_request(document.getElementById('link_keyword'));
}

var ctrl_mode = 0;
function obj_link(){  // 문서링크 버튼 클릭시
	htmleditor.focus();
	htmleditor.document.currentPos2 =  htmleditor.document.selection.createRange().duplicate();	 onclick_editor_link(htmleditor.document.currentPos2);
}
function onkeypress_html_body() {
	var kc = htmleditor.event.keyCode;

	if (ctrl_mode == 1 && (kc == 32 || kc == 81)) { htmleditor.document.currentPos2 =  htmleditor.document.selection.createRange().duplicate();	 onclick_editor_link(htmleditor.document.currentPos2); }
	if (kc == 17) ctrl_mode = 1; else ctrl_mode = 0;

	// if (save_draft_timer) window.clearInterval(save_draft_timer);
	// save_draft_timer = window.setInterval('save_draft()', 5000);
}

function onclick_move_page(fid) {
	var kw;
	if(!fid){
		kw = $('suggest').value;
		// var kw = $('kwsub').value;
	}else if(fid=='footsearch'){
		kw = $('kwsub2').value;
	}else if(fid=='qnasearch'){
		kw = $('kwsub3').value;
		window.location.href='http://qna.plaync.co.kr/aion/list.php?ts='+encodeURIComponent(kw);
		return;
	}else{
		kw = fid;
	}
	var url = src_path + 'ajax_exe_con.php';
	pars = 'mode=insert_search_log';
	pars += '&keyword='+trim(kw);
	var myAjax = new Ajax.Request(url, { method: 'post', postBody: pars, onComplete: get_move_page });
}

function get_move_page(originalRequest) {
	var result = originalRequest.responseText;
	// alert(result);
	window.location.href=src_path+'doc_create.php?kw='+result;
}

function onkeyup_kwsub(obj) {
	if (event.keyCode == '38') {
		onkeyup_kwsub_up();
		return false;
	} else if (event.keyCode == '40') {
		onkeyup_kwsub_down();
		return false;
	} else document.getElementById('kwsub_cursor').value = '';

	var url = src_path + 'ajax_exe.php';
	pars = 'mode=auto_suggest';
	pars += '&keyword='+obj.value;

	var myAjax = new Ajax.Request(url, { method: 'post', postBody: pars, onComplete: receive_onkeyup_kwsub });
}

function receive_onkeyup_kwsub(originalRequest) {
	var result = originalRequest.responseText;
	document.getElementById('kwsub_result').style.display = 'none';
	document.getElementById('kwsub_result').innerHTML=result;
	if (result.length != 0) document.getElementById('kwsub_result').style.display = 'block';
}

function onkeyup_kwsub_up() {
	var cursor_obj = document.getElementById('kwsub_cursor');
	if (cursor_obj.value == '') cursor_obj.value = -1;
	var li1 = document.getElementById('kw_li_'+cursor_obj.value);
	cursor_obj.value = parseInt(cursor_obj.value)-1;
	var li2 = document.getElementById('kw_li_'+(cursor_obj.value));
	if (li2 != null) {
		li2.className='on'; 		// li2.style.backgroundColor='#FEE6CA';
		if (li1 != null) li1.className=''; 		// li1.style.backgroundColor='#FFFFFF';
	} else cursor_obj.value = parseInt(cursor_obj.value)+1;
}

function onkeyup_kwsub_down() {
	var cursor_obj = document.getElementById('kwsub_cursor');
	if (cursor_obj.value == '') cursor_obj.value = -1;
	var li1 = document.getElementById('kw_li_'+cursor_obj.value);
	cursor_obj.value = parseInt(cursor_obj.value)+1;
	var li2 = document.getElementById('kw_li_'+(cursor_obj.value));
	if (li2 != null) {
		li2.className='on'; 		// li2.style.backgroundColor='#FEE6CA';
		if (li1 != null) li1.className=''; 		// li1.style.backgroundColor='#FFFFFF';
	} else cursor_obj.value = parseInt(cursor_obj.value)-1;
}

function auto_suggest_request(obj) {
	var url = src_path + 'ajax_exe.php';
	pars = 'mode=auto_suggest2';
	pars += '&keyword='+obj.value;
	var myAjax = new Ajax.Request(url, { method: 'post', postBody: pars, onComplete: receive_auto_suggest_request });
}

function onkeyup_kwsub2(obj) {
	if (event != null) {
		if (event.keyCode == '38') {
			onkeyup_kwsub_up2();
			return false;
		} else if (event.keyCode == '40') {
			onkeyup_kwsub_down2();
			return false;
		} else document.getElementById('kwsub_cursor2').value = '';
	}
}

function receive_auto_suggest_request(originalRequest) {
	var result = originalRequest.responseText;
	document.getElementById('kwsub_result2').style.display = 'none';
	document.getElementById('kwsub_result2').innerHTML=result;
	if (result.length != 0) document.getElementById('kwsub_result2').style.display = 'block';

}

function onkeyup_kwsub_up2() {
	var cursor_obj = document.getElementById('kwsub_cursor2');
	if (cursor_obj.value == '') cursor_obj.value = -1;
	var li1 = document.getElementById('kw2_li_'+cursor_obj.value);
	cursor_obj.value = parseInt(cursor_obj.value)-1;
	var li2 = document.getElementById('kw2_li_'+(cursor_obj.value));
	if (li2 != null) {
		li2.className='on';
		if (li1 != null) li1.className='';
	} else cursor_obj.value = parseInt(cursor_obj.value)+1;
}

function onkeyup_kwsub_down2() {
	var cursor_obj = document.getElementById('kwsub_cursor2');
	if (cursor_obj.value == '') cursor_obj.value = -1;
	var li1 = document.getElementById('kw2_li_'+cursor_obj.value);
	cursor_obj.value = parseInt(cursor_obj.value)+1;
	var li2 = document.getElementById('kw2_li_'+(cursor_obj.value));
	if (li2 != null) {
		li2.className='on';
		if (li1 != null) li1.className='';
	} else cursor_obj.value = parseInt(cursor_obj.value)-1;
}

function onclick_paste_keyword2() {
	var cursor_obj = document.getElementById('kwsub_cursor2');
	if (cursor_obj.value != '') {
		htmleditor.document.body.focus();
		if (htmleditor.document.currentPos2) htmleditor.document.currentPos = htmleditor.document.currentPos2;
		set_text('<a href="' + doc_path + document.getElementById('hd2_li_'+cursor_obj.value).value+'">'+document.getElementById('hd3_li_'+cursor_obj.value).value+'</a>');
		hideObj('div_link_keyword');
	} else {
		var url = src_path + 'ajax_exe.php';
		pars = 'mode=get_urlencode';
		pars += '&keyword='+document.getElementById('link_keyword').value;
		var myAjax = new Ajax.Request(url, { method: 'post', postBody: pars, onComplete: get_link_keyword });
	}

}

function get_link_keyword(originalRequest) {
	var result = originalRequest.responseText;
	htmleditor.document.body.focus();
	if (htmleditor.document.currentPos2) htmleditor.document.currentPos = htmleditor.document.currentPos2;
	set_text('<a href="' + doc_path + result+'">'+trim(document.getElementById('link_keyword').value)+'</a>');
	hideObj('div_link_keyword');
}


/* powrebook keyword search */
function print_powerbookkeyword(title, query, where){
	var default_action = doc_path;
	var wrap = $("wrap_powerbookkw");
	var list = [];
	var keywordTemplate = new Template('<li><a href="#{url}" title="#{kw}">#{displaykw}</a></li>');
	for(i = 0; i < 10 ; i++) { // popularkwd_arr.count  powerbook_keywords
		var _displaykw = popularkwd_arr[i].keyword.cut(26);
		var _kw = popularkwd_arr[i].keyword;
		// var _url = default_action + "?where=" + where + "&query=" + encodeURIComponent(_kw)+ "&pos=popkwd";
		var _url = default_action +''+ encodeURIComponent(_kw);
		var kwTemplate = keywordTemplate.evaluate({kw : _kw , displaykw : _displaykw , url : _url});
		list[ list.length] = kwTemplate;
	}
	var tit = '<h2><strong>'+title+'</strong> 검색</h2>';
	wrap.insert(tit);
	var ul = new Element('ul');
	ul.update(list.join(''));
	wrap.insert(ul);
}
String.prototype.cut = function(len) {
	var str = this;
	var l = 0;
	for (var i=0; i<str.length; i++) {
			l += (str.charCodeAt(i) > 33) ? 2 : 1;
			if (l > len) return str.substring(0,i) + "..";
	}
	return str;
}


-->
