/*2007-02-23 20:24:45*/var Extend=function(o,tmp){for(k in tmp)o[k]=tmp[k]};Extend(String.prototype,{trim:function(){return this.replace(/^\s+|\s+$/g,'')},getComma:function(){return this.replace(/^(\d{1,3})((?:\d{3})+)$/,function(a,b,c){return b+c.replace(/\d{3}/g,',$&')})}});Extend(Array.prototype,{pushObjectClone:function(obj){var clone=this[this.length]=new Object();for(m in obj){clone[m]=obj[m]}},hasValue:function(val){for(var i=0,s=this.length;i<s;i++){if(this[i]===val)return true};return false},removeValue:function(val){for(var i=0,s=this.length;i<s;i++){if(this[i]==val){this.splice(i,1);return true}}},getClone:function(){var cArr=[];for(i=0,s=this.length;i<s;i++){cArr[i]=this[i]};return cArr}});var trace=function(code,append){var pannel=document.getElementById("dev_trace_viewer_area");if(!pannel){pannel=document.createElement('TEXTAREA');pannel.id='dev_trace_viewer_area';with(pannel.style){position='absolute';width='600px';height='300px';top='200px';left='300px';zIndex=400;font='12px lucida console'};pannel.ondblclick=function(){this.style.display="none"};document.body.appendChild(pannel)};pannel.style.display="block";pannel.value=append?pannel.value+code:code};var oTrace=function(obj,append){if(!append)trace('');for(p in obj){if(typeof(obj[p])=="object"){oTrace(obj[p],1)}else{trace(p+"::::"+obj[p]+"\n",1)}}};var getXHR=function(){var req;try{req=new ActiveXObject("MSXML2.XMLHTTP")}catch(e){try{req=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){try{req=new XMLHttpRequest()}catch(e){req=false}}};return req};var El={getAbsOffset:function(el){var margin={left:0,top:0};while(el){margin.left+=el.offsetLeft;margin.top+=el.offsetTop;el=el.offsetParent};return margin},setEmpty:function(el){if(el){while(el.hasChildNodes())el.removeChild(el.firstChild)}},remove:function(el){if(el)el.parentNode.removeChild(el)},toggleDisplay:function(el){if(!el.style.display||el.style.display=="none")el.style.display="block";else el.style.display="none"},getTable:function(doc,row,col){var table=doc.createElement("TABLE");var tbody=table.appendChild(doc.createElement("TBODY"));with(table){cellSpacing="0px";cellPadding="0px";border="0px"};var tr,td,i,j;for(i=0;i<row;i++){tr=tbody.appendChild(doc.createElement("TR"));for(j=0;j<col;j++)tr.appendChild(doc.createElement("TD"))};return table},getSpacer:function(doc,w,h){var img=doc.createElement("IMG");img.width=w+'px';img.height=h+'px';img.style.width=w+'px';img.style.height=h+'px';return img},getIframe:function(doc){var iframe=doc.createElement("iframe");iframe.frameBorder="0px";return iframe}};F=function(){this.toggleCnt=0;this.frameCnt=0;this.frameList=[{parentWindow:null,elementId:null,contentWindow:top,index:0,dialogObject:null}];this.frameGroupStack=[];this.eventHandlers={};this.stack=new F.S();this.stack.push(new F.S.L());this.hiddenFL=-1};F.prototype={registerFrame:function(parentWindow,elementId,dialogObject){if(!parentWindow)return;for(m in this.eventHandlers){this.__attachEvent(this.eventHandlers[m],parentWindow)};if(elementId)this.__registerFrameId(parentWindow,elementId,dialogObject);else this.registerFrameInWindow(parentWindow);this.attachAllEvents()},registerFrameInWindow:function(window){var iframes=window.document.getElementsByTagName('iframe');for(var i=0;i<iframes.length;i++){this.__registerFrameObject(window,iframes[i])}},__registerFrameId:function(parentWindow,elementId,dialogObject){if(this.__isRegisteredId(elementId,parentWindow))return;var frameEl=parentWindow.document.getElementById(elementId);var frameWin=frameEl.contentWindow;var info={parentWindow:parentWindow,elementId:elementId,contentWindow:frameWin,frameObject:frameEl,dialogObject:dialogObject};this.stack.top.append(info)},__registerFrameObject:function(parentWindow,frameObj){if(this.__isRegisteredObject(frameObj)){return};var frameInfo={parentWindow:parentWindow,elementId:frameObj.id,frameObject:frameObj,contentWindow:frameObj.contentWindow};this.stack.top.append(frameInfo)},getFrameContainerDialogObject:function(contentWindow){var f=this.stack.findFrameInfoByContentWindow(contentWindow);if(f)return f.dialogObject;return null},__isRegistered:function(parentWindow,elementId){},__isRegisteredId:function(elementId,parentWindow){return this.stack.findFrameInfoById(elementId,parentWindow)},__isRegisteredObject:function(frameObject){return this.stack.findFrameInfo(frameObject)},unregisterFrame:function(parentWindow,elementId){if(elementId){var oFrameInfo=this.stack.findFrameInfoById(elementId,parentWindow);if(oFrameInfo){this.stack.removeFrame(oFrameInfo.frameObject,parentWindow)}};else{if(parentWindow!=top){var iframes=parentWindow.document.getElementsByTagName('iframe');for(var i=0;i<iframes.length;i++)this.stack.removeFrame(iframes[i])}}},hideSelect:function(){this.stack.removeEmpties();this.stack.hideSelect()},showSelect:function(){this.stack.showSelect()},__getParentInfo:function(fwin){return this.stack.findFrameInfoByContentWindow(fwin)},registerEventHandler:function(info){this.eventHandlers[info.handlerId]={element:info.element,clientObject:info.clientObject,clientMethod:info.clientMethod,type:info.type,func:function(){info.clientMethod.apply(info.clientObject)}};this.attachAllEvents()},attachAllEvents:function(){var wins=this.getWindowsList();for(m in this.eventHandlers){var wins=this.getWindowsList();for(var i=0,s=wins.length;i<s;i++){this.__attachEvent(this.eventHandlers[m],wins[i])}}},__attachEvent:function(handler,w){try{if(!w)return;switch(handler.element){case "body":if(!w.document||!w.document.body)return;;el=w.document.body;break;case "window":el=w;b;default:el=w.document.getElementById(handler.element)};if(!el)return;el.detachEvent(handler.type,handler.func);el.attachEvent(handler.type,handler.func)};catch(e){}},unregisterEventHandlerFromAllBody:function(handlerId){var wins=this.getWindowsList();var handler=this.eventHandlers[handlerId];for(var i=0,s=wins.length;i<s;i++){if(wins[i].document&&wins[i].document.body){wins[i].document.body.detachEvent(handler.type,handler.func)}};delete this.eventHandlers[handlerId]},getWindowsList:function(){var windowList=[top];var frameList=this.stack.getFrameList();for(var i=0,s=frameList.length;i<s;i++){windowList.push(frameList[i].contentWindow)};return windowList},getOffsetMargin:function(fwin){var info=this.__getParentInfo(fwin);var fMargin,margin={top:0,left:0};while(info&&info.parentWindow){fMargin=El.getAbsOffset(info.frameObject);margin.top+=fMargin.top;margin.left+=fMargin.left;info=this.__getParentInfo(info.parentWindow)};return margin},getEventObect:function(){var wins=this.getWindowsList();for(var i=0,s=wins.length;i<s;i++){if(wins[i].event)return wins[i].event}}};F.S=function(){this.FIs=new Array();this.length=0};F.S.prototype={hideSelect:function(){if(this.top)this.top.hideSelect();this.push(new F.S.L())},getFrameList:function(){var list=[];for(var i=0;i<this.FIs.length;i++){list=list.concat(this.FIs[i].getFrameList())};return list},showSelect:function(){if(this.length==0)return;this.pop();if(this.top)this.top.showSelect()},push:function(frameInfoList){if(!frameInfoList)return;this.FIs.push(frameInfoList);this.top=frameInfoList;this.length++},pop:function(){if(this.length==0)return;this.FIs.pop();this.top=this.getItem(this.FIs.length-1);this.length--},getItem:function(index){if(index<0)return null;else return this.FIs[index]},getState:function(){var state='stack state\n';for(var i=0;i<this.length;i++){state+='stack length: '+this.length+'\nstack.getitem('+i+').state \n';state+=this.getItem(i).getState()};return state},findFrameInfoByContentWindow:function(contentWindow){if(this.length==0)return null;var f=null;for(var i=0;i<this.length;i++){f=this.getItem(i).findFrameInfoByContentWindow(contentWindow);if(f)return f};return null},findFrameInfoById:function(elementId,parentWindow){if(this.length==0)return null;var f=null;for(var i=0;i<this.length;i++){if(i<this.length){f=this.getItem(i).findFrameInfoById(elementId,parentWindow);if(f)return f}};return null},remove:function(index){if(this.length<2)return;this.FIs.splice(index,1);this.length--},removeFrame:function(frameObject){var frameInfoList=this.findFrameInfoListByFrame(frameObject);frameInfoList.remove(frameObject);if(frameInfoList.length==0)this.removeEmpties()},findFrameInfoListByFrame:function(frameObject){for(var i=this.length-1;i>=0;i--){if(this.getItem(i).findFrameInfo(frameObject))return this.getItem(i)};return null},findFrameInfo:function(frameObject){if(this.length==0)return null;var f=null;for(var i=0;i<this.length;i++){f=this.getItem(i).findFrameInfo(frameObject);if(f)return f};return null},removeEmpties:function(){if(this.length==0)return;var oFrameInfoList=null;for(var i=this.length-1;i>=0;i--){oFrameInfoList=this.getItem(i);oFrameInfoList.removeEmptyFrames();if(oFrameInfoList.length==0)this.remove(i)}}};F.S.L=function(){this.list=new Array();this.length=0;this.onIE7=/MSIE 7\.0/.test(navigator.userAgent)};F.S.L.prototype={append:function(frameInfo){this.list.push(frameInfo);this.length++},remove:function(frameInfo){this.list.removeValue(frameInfo);this.length--},getItem:function(index){if(this.length==0||index<0)return null;return this.list[index]},hideSelect:function(){if(this.onIE7)return;for(var i=0;i<this.list.length;i++){if(this.list[i].contentWindow){var selects=this.list[i].contentWindow.document.getElementsByTagName('select');for(var j=0;j<selects.length;j++){selects[j].style.visibility="hidden"}}}},getFrameList:function(){var list=[];for(var i=0;i<this.list.length;i++){list.push(this.list[i])};return list},showSelect:function(){if(this.onIE7)return;var log="";for(var i=0;i<this.list.length;i++){log+=i+", ";if(this.list[i].contentWindow){var sels=this.list[i].contentWindow.document.getElementsByTagName('select');for(var j=0;j<sels.length;j++)sels[j].style.visibility="visible"}}},findFrameInfo:function(frameObject){if(!frameObject)return null;for(var i=0;i<this.list.length;i++){if(this.list[i].frameObject==frameObject){return this.list[i]}};return null},findFrameInfoByContentWindow:function(contentWindow){if(!contentWindow)return null;for(var i=0;i<this.list.length;i++){if(this.list[i].contentWindow==contentWindow)return this.list[i]};return null},getState:function(index){if(index){return this.getFrameState(index)};var state="L state\n";for(var i=0;i<this.length;i++)state+=this.getFrameState(i);return state},getFrameState:function(index){var state='';var frameInfo=this.getItem(index);state+='fl['+index+'] state \n';state+='fid: '+frameInfo.elementId+'\n';state+='fo : '+frameInfo.frameObject+'\n';state+='pw : '+frameInfo.parentWindow.document.location+'\n\n';return state},findFrameInfoById:function(elementId,parentWindow){if(!elementId)return null;for(var i=0;i<this.list.length;i++){if(this.list[i].elementId==elementId&&this.list[i].parentWindow==parentWindow)return this.list[i]};return null},removeEmptyFrames:function(){if(this.length==0)return;for(var i=this.length-1;i>=0;i--){try{var accesible=this.list[i].contentWindow.document}catch(e){this.remove(this.list[i])}}}};Dialog=function(){};Dialog.Counter=0;Dialog.prototype={open:function(args){this.args=args;this.setLayer();switch(args.contentType){case "FullHTMLString":var w=this.getContentFrameWindow(false);var d=w.document;d.open('text/html');d.write('<html><head><link type="text/css" rel="stylesheet" href="'+top.skin+'/css/telate.css" />');w.attachEvent("onload",function(){top.Dialog.setSize(w)});d.write(top.cco.getUserStyleText()+'</head><body style="overflow:hidden"><div id="dialogArea">'+this.args.content+'</div></body></html>');d.close();break;case "BodyHTMLString":var w=this.getContentFrameWindow(true);var d=w.document;d.open('text/html');d.write('<html><head><link type="text/css" rel="stylesheet" href="'+top.skin+'/css/telate.css" />');w.attachEvent("onload",function(){top.Dialog.setSize(w)});d.write(top.cco.getUserStyleText()+'</head><body style="overflow:hidden"><table id="dialogArea" cellspacing=0 cellpadding=0 border=0><tr><td class="usrBrdInset1">'+this.args.content+'</td></tr><tr><td class="defDialogFooter usrFrameBack"><input type=button class="defBtnDialog usrBrdButton1 usrFrameBack" value="확인" onclick="if(top.Dialog.executeClientMethod(self)){top.Dialog.close(self)}"></td></tr></table></body></html>');d.close();break;case "function":var w=this.getContentFrameWindow(true);this.args.content.call(this.args.clientObject,this.iframe);break;default:var w=this.getContentFrameWindow(true);this.iframe.src=args.content};this.createBackButtonFrame();return w},setLayer:function(){if(!this.args.innerBoxStyle)this.args.innerBoxStyle={};if(!this.args.outerBoxStyle)this.args.outerBoxStyle={};this.index=++Dialog.Counter;this.win=this.args.win?this.args.win:top;this.doc=this.win.document;this.layer=El.getTable(this.doc,1,1);this.layer.className="defDialogLayer";this.layer.style.zIndex=this.index+15;this.outerBox=this.layer.firstChild.firstChild.firstChild;this.outerBox.style.verticalAlign=this.args.outerBoxStyle.verticalAlign?this.args.outerBoxStyle.verticalAlign:"middle";this.outerBox.style.textAlign=this.args.outerBoxStyle.textAlign?this.args.outerBoxStyle.textAlign:"center";if(this.args.outerBoxStyle.padding){this.outerBox.style.padding=this.args.outerBoxStyle.padding};this.doc.body.appendChild(this.layer)},getContentFrameWindow:function(withBasicTitle){var str='<table cellspacing="0" cellpadding="0" border="0" class="usrBrdOutset1 usrFrameBack">';if(withBasicTitle){str+='	<tr><td style="vertical-align:top;height:24px;padding-right:1px">'+'		<table cellspacing=0 cellpadding=0 border=0 width="100%" height="23px">'+'		<tr><td class="defTitleBar" style="font-family:dotum" id="dialogTitle'+this.index+'"></td>'+'			<td class="defTitleBar" style="padding-right:2px;text-align:right">'+'				<input type=button id="dialogCloseBtn'+this.index+'" class="usrFrameBack usrBrdButton1 defTitleBarBtn">'+'			</td>'+'		</tr>'+'		</table>'+'		<div class="defTitleBottom usrTitleBottom"></div>'+'		</td>'+'	</tr>'};str+='<tr><td id="iframeContainer'+this.index+'" style="vertical-align:top;padding:3px"></td></tr></table>';this.outerBox.innerHTML=str;this.innerBox=this.outerBox.firstChild;this.innerBox.style.width=this.args.innerBoxStyle.width?this.args.innerBoxStyle.width:"500px";this.innerBox.style.height=this.args.innerBoxStyle.height?this.args.innerBoxStyle.height:"200px";if(this.args.innerBoxStyle.top){this.innerBox.style.position="relative";this.innerBox.style.top=this.args.innerBoxStyle.top};if(this.args.innerBoxStyle.left)this.innerBox.style.left=this.args.innerBoxStyle.left;if(withBasicTitle){this.setTitleText(this.args.title);this.setCloseBtnText(this.args.closeBtnText?this.args.closeBtnText:"취소");var This=this;this.doc.getElementById('dialogCloseBtn'+this.index).onclick=function(){This.close()}};var iframeContainer=this.doc.getElementById('iframeContainer'+this.index);this.iframe=iframeContainer.appendChild(this.doc.createElement("IFRAME"));this.iframe.id='dialog_frame'+this.index;this.iframe.scroll="no";top.fmo.hideSelect();top.fmo.registerFrame(top,this.iframe.id,this);return this.iframe.contentWindow},setSize:function(el){var h=el.offsetHeight;var w=el.offsetWidth;this.iframe.style.height=h+'px';this.iframe.style.width=w+'px';var contentContainer=this.doc.getElementById('iframeContainer'+this.index);if(contentContainer){var diffHeight=h-contentContainer.offsetHeight;var diffWidth=w-contentContainer.offsetWidth;var dWidth=parseInt(this.outerBox.firstChild.style.height)+diffHeight;var dHeight=parseInt(this.outerBox.firstChild.style.width)+diffWidth;this.innerBox.style.height=dWidth+'px';this.innerBox.style.width=dHeight+'px'}},createBackButtonFrame:function(){if(!this.historyCounter)this.historyCounter=1;else this.historyCounter++;this.backButtonFrameId='history_frame'+Dialog.Counter+'_'+this.historyCounter;this.backButtonFrame=document.createElement('iframe');this.backButtonFrame.id=this.backButtonFrameId;this.backButtonFrame.style.display="none";document.body.appendChild(this.backButtonFrame);top.fmo.registerFrame(top,this.backButtonFrameId,this);var d=this.backButtonFrame.contentWindow.document;d.open('text/html');d.write('<html><head><script>top.Dialog.close(self, "backButton")</'+'script></head><body></body></html>');d.close();d.open('text/html');d.write('<html><body></body></html>');d.close()},removeBackButtonFrame:function(){if(!this.backButtonFrame)return;this.backButtonFrame.parentNode.removeChild(this.backButtonFrame);delete this.backButtonFrame;top.cmo.removeContextMenu()},close:function(byBackButton){if(!this.backButtonFrameInitiated){this.backButtonFrameInitiated=true;return};if(byBackButton&&this.args.msgOnBackButton){if(confirm(this.args.msgOnBackButton)){this.__close()}else{this.removeBackButtonFrame();this.backButtonFrameInitiated=false;this.createBackButtonFrame()}}else{this.__close()}},__close:function(){this.iframe.src='';top.fmo.showSelect();this.doc.body.removeChild(this.layer);this.removeBackButtonFrame();Dialog.Counter--;if(this.args.clientCloseMethod){this.args.clientCloseMethod.apply(this.args.clientObject)}},setTitleText:function(text){var titleBox=this.doc.getElementById('dialogTitle'+this.index);if(titleBox){El.setEmpty(titleBox);titleBox.appendChild(this.doc.createTextNode(text))}},setCloseBtnText:function(text){var btn=this.doc.getElementById('dialogCloseBtn'+this.index);if(btn)btn.value=text},executeClientMethod:function(win){return this.args.clientMethod.call(this.args.clientObject,win,this.args.clientProperty)}};Extend(Dialog,{close:function(win,byBackButton){var dialog=top.fmo.getFrameContainerDialogObject(win);dialog.close(byBackButton)},setSize:function(win){if(!win||!win.document)return;var area=win.document.getElementById('dialogArea');if(!area)return;var dialog=top.fmo.getFrameContainerDialogObject(win);dialog.setSize(area)},setCloseBtnText:function(win,text){var dialog=top.fmo.getFrameContainerDialogObject(win);dialog.setCloseBtnText(text)},setTitleText:function(win,text){var dialog=top.fmo.getFrameContainerDialogObject(win);dialog.setTitleText(text)},getClientObject:function(win){var dialog=top.fmo.getFrameContainerDialogObject(win);return dialog.args.clientObject},setActionOnClosed:function(win,clientObject,clientCloseMethod){var dialog=top.fmo.getFrameContainerDialogObject(win);dialog.args.clientObject=clientObject;dialog.args.clientCloseMethod=clientCloseMethod},executeClientMethod:function(win){var dialog=top.fmo.getFrameContainerDialogObject(win);return dialog.executeClientMethod(win)}});var cco={win:top,initiate:function(){this.defaultStyleSheet=this.getStyleSheet(this.win,'default_style');this.userStyleSheet=this.getStyleSheet(this.win,'usr_style')},getStyleSheet:function(win,id){if(!win.document||!win.document.styleSheets)return false;var styleSheets=win.document.styleSheets;for(var i=0,s=styleSheets.length;i<s;i++){if(styleSheets[i].id==id)return styleSheets[i]};return false},setUserStyle:function(selector,property,value,toAllFrame){if(value==this.getCssValue(selector,property))return;var val=this.getCssValueBySheet(this.userStyleSheet,selector,property);if(val===false){this.userStyleSheet.cssText+=(selector+'{}')};var rules=this.userStyleSheet.rules;for(var s=rules.length,i=0;i<s;i++){if(rules[i].selectorText==selector){rules[i].style[property]=value;break}};if(toAllFrame){this.applyToAllFrames()}},getCssValue:function(selector,property){var val=this.getCssValueBySheet(this.userStyleSheet,selector,property);if(!val){val=this.getCssValueBySheet(this.defaultStyleSheet,selector,property)};return val},applyToAllFrames:function(){var windows=fmo.getWindowsList();var _cssText=this.userStyleSheet.cssText;var _userStyleSheet;for(var i=0,s=windows.length;i<s;i++){if(windows[i]==this.win)continue;_userStyleSheet=this.getStyleSheet(windows[i],'usr_style');if(_userStyleSheet)_userStyleSheet.cssText=_cssText}},getUserStyleText:function(){return '<style type="text/css" id="usr_style">'+this.userStyleSheet.cssText.replace(/\n|\r|\t/g,'')+'</style>'},getCssValueBySheet:function(styleSheet,selector,property){var rules=styleSheet.rules;for(var s=rules.length,i=0;i<s;i++){if(rules[i].selectorText==selector){return rules[i].style[property]}};return false},getResultToSave:function(){return this.userStyleSheet.cssText.replace(/\n|\r|\t/g,'')}};var cmo={zIndeX:500,menus:[],focused:[],showMenu:function(info){var absMargin=fmo.getOffsetMargin(info.clientWindow);var e=info.clientWindow.event;var menu=this.getContainer();menu.style.left=absMargin.left+e.clientX+1;menu.style.top=absMargin.top+e.clientY+1;info.depth=0;var contentsNode=this.getMenu(info);menu.appendChild(contentsNode);var Size=this.getSize(menu);menu.style.width=Size.width;menu.style.height=Size.height;var bw=parseInt(top.document.body.clientWidth);var bh=parseInt(top.document.body.clientHeight);var mw=parseInt(menu.style.width);var mh=parseInt(menu.style.height);var mw=parseInt(menu.style.width);var mt=parseInt(menu.style.top);var ml=parseInt(menu.style.left);if(bw<mw+ml){menu.style.left=ml-mw-4};if(parseInt(top.document.body.clientHeight)<mh+mt){menu.style.top=bh-mh-4};menu.style.display="block"},getContainer:function(){var div=top.document.createElement("div");div.className="defCM";div.style.zIndex=this.zIndeX+this.menus.length;div.onmousedown=function(){top.fmo.getEventObect().cancelBubble=true};top.document.body.appendChild(div);this.menus.push(div);return div},getSize:function(menu){var d=top.document;var container=d.createElement("div");with(container.style){visibility="hidden";position="absolute";zIndex=11;width="0px";height="0px";top="0px";left="0px";whiteSpace="nowrap"};d.body.appendChild(container);container.innerHTML=menu.innerHTML;var ret={width:container.firstChild.offsetWidth,height:container.firstChild.offsetHeight};d.body.removeChild(container);return ret},hideMenu:function(depth){if(!depth)depth=0;while(this.menus.length>depth){var menu=this.menus.pop();top.document.body.removeChild(menu)}},showSubmenu:function(info){if(!info)return;var menu=this.getContainer();if(info.type==="builtInSubmenu"){menu.innerHTML=this.builtInSubmenu.getMenu(info)}else{menu.appendChild(this.getMenu(info))};var Size=this.getSize(menu);menu.style.width=Size.width;menu.style.height=Size.height;var pMenu=this.menus[info.depth-1];menu.style.left=parseInt(pMenu.style.left)+parseInt(pMenu.style.width)+2;menu.style.top=El.getAbsOffset(this.focused[info.depth-1]).top;var bw=parseInt(top.document.body.clientWidth);var bh=parseInt(top.document.body.clientHeight);var mw=parseInt(menu.style.width);var mh=parseInt(menu.style.height);var mw=parseInt(menu.style.width);var mt=parseInt(menu.style.top);var ml=parseInt(menu.style.left);if(bw<mw+ml){menu.style.left=parseInt(pMenu.style.left)-mw-2};if(bh<mh+mt){menu.style.top=bh-mh-4};menu.style.display="block"},getMenu:function(info){var This=this;var d=top.document;var table=d.createElement("table");table.cellSpacing=0;table.cellPadding=0;table.border=0;var tbody=table.appendChild(d.createElement("tbody"));var tr,td,div,span,item,title;for(var i=0,s=info.items.length;i<s;i++){item=info.items[i];if(item._skip)continue;tr=tbody.appendChild(d.createElement("tr"));td=tr.appendChild(d.createElement("td"));if(item==='|'){td.style.height="5px";div=td.appendChild(d.createElement("div"));div.className="defCMSep";continue};td.className="defCMCell";title=item.title.replace(/\n/g," ");span=td.appendChild(d.createElement("span"));span.appendChild(d.createTextNode(title));td.text=title;td.depth=info.depth;if(item.disabled){td.style.color="#aaa";td.onmouseover=function(){This.releaseFocus(this.depth)}}else{switch(item.type){case "builtInSubmenu":td.info={clientObject:info.clientObject,type:"builtInSubmenu",menuId:item.menuId,clientMethod:item.method,depth:info.depth+1};td.onmouseover=function(){This.moveFocus(this)};break;case "clientMethod":td.object=info.clientObject;td.method=item.method;td.property=item.property;td.onmouseover=function(){This.moveFocus(this)};td.onmouseout=function(){This.unfocusCell(this)};td.onmouseup=function(){var o=this.object;var m=this.method;var p=this.property;This.hideMenu();setTimeout(function(){m.call(o,p)},5)};break}};if(item.style){for(m in item.style){td.style[m]=item.style[m]}}};return table},unfocusCell:function(cell){cell.style.background="white";cell.style.color="black"},focusCell:function(cell){cell.style.background="#3366CC";cell.style.color="white";this.focused[cell.depth]=cell},releaseFocus:function(depth){var oldFocusedCell=this.focused[depth];if(oldFocusedCell){this.unfocusCell(oldFocusedCell);this.hideMenu(depth+1)}},moveFocus:function(newlyFocusedCell){var depth=newlyFocusedCell.depth;var oldFocusedCell=this.focused[depth];if(oldFocusedCell&&newlyFocusedCell!=oldFocusedCell){this.hideMenu(depth+1);this.unfocusCell(oldFocusedCell)};this.focusCell(newlyFocusedCell);this.showSubmenu(newlyFocusedCell.info)},removeContextMenu:function(){cmo.hideMenu()},builtInSubmenu:{getMenu:function(info){this.info=info;this.clientObject=info.clientObject;this.clientMethod=info.clientMethod;switch(info.menuId){case "fontSize":return this.getFontSize();case "fontSizePx":return this.getFontSizePx();case "lineHeight":return this.getLineHeight();case "fontFamily":return this.getFontFamily();case "fontShape":return this.getFontShape();case "CopyCutPaste":return this.getCopyCutPaste()}},execute:function(arg){this.clientMethod.call(this.clientObject,arg);cmo.hideMenu()},getCopyCutPaste:function(){return('<table cellspacing=0 cellpadding=0 border=0><tbody>'+'<tr onmouseover="cmo.builtInSubmenu.mouseover02(this)" onmouseout="cmo.builtInSubmenu.mouseout02(this)" onmouseup="cmo.builtInSubmenu.execute(\'cut\')">'+'<td class="defCMCell" style="padding:4px 0px 0px 5px">잘라내기</td>'+'<td class="defCMHot" style="font:12px lucida console;padding:2px 2px 0px 10px;cursor:default;white-space:nowrap">Ctrl + X</td></tr>'+'<tr onmouseover="cmo.builtInSubmenu.mouseover02(this)" onmouseout="cmo.builtInSubmenu.mouseout02(this)" onmouseup="cmo.builtInSubmenu.execute(\'copy\')">'+'<td class="defCMCell" style="padding:4px 0px 0px 5px">복사하기</td>'+'<td class="defCMHot">Ctrl + C</td></tr>'+'<tr onmouseover="cmo.builtInSubmenu.mouseover02(this)" onmouseout="cmo.builtInSubmenu.mouseout02(this)" onmouseup="cmo.builtInSubmenu.execute(\'paste\')">'+'<td class="defCMCell" style="padding:4px 0px 0px 5px">붙이기</td>'+'<td class="defCMHot">Ctrl + V</td></tr>'+'</tbody></table>')},mouseover01:function(_row){_row.firstChild.style.backgroundColor="#3366cc";_row.firstChild.style.color="#fff";_row.lastChild.style.borderColor="#3366cc"},mouseout01:function(_row){_row.firstChild.style.backgroundColor="#fff";_row.firstChild.style.color="#000";_row.lastChild.style.borderColor="#fff"},mouseover03:function(_row){_row.lastChild.style.backgroundColor="#3366cc";_row.lastChild.style.color="#ffffff"},mouseout03:function(_row){_row.lastChild.style.backgroundColor="#fff";_row.lastChild.style.color="#000"},getFontSize:function(){if(this.cachedFontSizeText)return this.cachedFontSizeText;var _size=[0,10,13,17,18,24,32,48];var text='<table cellspacing=0 cellpadding=0 border=0 style="font:12px gulim"><tbody>';for(var pixel,i=1,s=_size.length;i<s;i++){pixel=_size[i];text+='<tr onmouseover="cmo.builtInSubmenu.mouseover01(this)" onmouseout="cmo.builtInSubmenu.mouseout01(this)">'+'<td style="padding:2px 5px 0px 5px;background-color:#fff;color:#000;font:'+pixel+'px gulim;cursor:default" onmouseup="cmo.builtInSubmenu.execute('+i+')">'+i+'</td>'+'<td style="padding:2px 5px 0px 5px;background-color:#fff;color:#000;font:'+pixel+'px gulim;cursor:default;border:1px solid white" nowrap onmouseup="cmo.builtInSubmenu.execute('+i+')">한글 ABC\'s</td>'+'</tr>\n'};text+='<tr onmouseover="cmo.builtInSubmenu.mouseover03(this)" onmouseout="cmo.builtInSubmenu.mouseout03(this)" onmouseup="cmo.builtInSubmenu.execute(\'baseFontSize\')"><td colspan=2 class="defCMCell">기본값 정하기</td></tr>';text+='</tbody></table>';return this.cachedFontSizeText=text},getFontSizePx:function(){if(this.cachedFontSizeTextPx)return this.cachedFontSizeTextPx;var _size=[9,10,11,12,13,14];var text='<table cellspacing=0 cellpadding=0 border=0 style="font:12px gulim"><tbody>';text+='<tr><td colspan=2 style="height:18px;padding:2p 0px 0px 5px;cursor:default" onmouseover=cmo.focusCell(this) onmouseout=cmo.unfocusCell(this) onmouseup=cmo.builtInSubmenu.openDirectInputBox()>직접 입력...</td></tr>';text+='<tr><td colspan=2><div style="border-bottom:1px solid #cccccc;margin:1px 0px 3px 0px;"><img width=0px height=0px></div></td></tr>';for(var z,i=0,s=_size.length;i<s;i++){z=_size[i];text+='<tr onmouseover="cmo.builtInSubmenu.mouseover01(this)" onmouseout="cmo.builtInSubmenu.mouseout01(this)" onmouseup="cmo.builtInSubmenu.execute('+z+')">'+'<td style="padding:2px 5px 0px 5px;background:#ffffff;color:black;font:'+z+'px gulim;cursor:default">'+z+'</td>'+'<td style="padding:2px 5px 0px 5px;background:#ffffff;color:black;font:'+z+'px gulim;cursor:default;border:1px solid white" nowrap>한글 ABC\'s</td>'+'</tr>'};text+='</tbody></table>';return this.cachedFontSizeTextPx=text},openDirectInputBox:function(){var This=this;var dl=new top.Dialog();var args;switch(this.info.menuId){case 'fontSizePx':args={clientObject:this,clientMethod:this.applyDirectFontSize,title:"글자 크기",contentType:"BodyHTMLString",content:'<table style="width:250px;height:120px"><tr><td style="font:12px verdana;text-align:center"><input type=text id="input_box" style="width:35px;height:19px"> pixel</td></tr></table>'};var dialogWin=dl.open(args);dialogWin.document.getElementById('input_box').onkeypress=function(){if(dialogWin.event.keyCode==13&&This.applyDirectFontSize(this)){top.Dialog.close(dialogWin)}};break};dialogWin.document.getElementById('input_box').focus();cmo.hideMenu()},applyDirectFontSize:function(win){var input=win.document.getElementById('input_box');if(!input.value.match(/^\d{1,3}$/)){alert("입력하신 값이 적절하지 않습니다.");input.value="";input.focus();return false}else{var info=this.info;info.clientMethod.call(info.clientObject,input.value);return true}},mouseover02:function(_row){_row.firstChild.style.backgroundColor="#3366cc";_row.lastChild.style.backgroundColor="#3366cc";_row.firstChild.style.color="#ffffff";_row.lastChild.style.color="#ffffff"},mouseout02:function(_row){_row.firstChild.style.backgroundColor="#ffffff";_row.lastChild.style.backgroundColor="#ffffff";_row.firstChild.style.color="#000000";_row.lastChild.style.color="#000000"},getFontFamily:function(){if(this.cachedFontFamilyText)return this.cachedFontFamilyText;var _family=["굴림","돋움","바탕","궁서","|","Arial","Helvetica","Times New Roman","Verdana","Tahoma","Trebuchet MS","|","굴림체","돋움체","바탕체","궁서체","|","Lucida Console","Courier","Courier New"];var _familyE=["gulim","dotum","batang","gungsuh","|","Arial","Helvetica","Times New Roman","Verdana","Tahoma","Trebuchet MS","|","gulimche","dotumche","batangche","gungsuhche","|","Lucida Console","Courier","Courier New"];var text="<table cellspacing=0 cellpadding=0 border=0><tbody>";for(var z,i=0,s=_family.length;i<s;i++){f=_family[i];fE=_familyE[i];if(f=='|'){text+='<tr><td style="height:5px"><div class="defCMSep"></div></td></tr>'}else{text+='<tr onmouseover="cmo.builtInSubmenu.mouseover02(this)" onmouseout="cmo.builtInSubmenu.mouseout02(this)" onmouseup="cmo.builtInSubmenu.execute(\''+fE+'\')" bgcolor=white><td style="padding:'+(f.match(/^\w/)?0:2)+'px 5px 0px 5px;color:black;font:13px '+fE+';cursor:default;height:17px" nowrap>'+f+'</td></tr>'}};text+='</tbody></table>';return this.cachedFontFamilyText=text},getLineHeight:function(){var text='<table cellspacing=0 cellpadding=0 border=0><tbody>';text+='<tr onmouseover="cmo.builtInSubmenu.mouseover03(this)" onmouseout="cmo.builtInSubmenu.mouseout03(this)" onmouseup="cmo.builtInSubmenu.execute(\'baseLineHeight\')"><td colspan=2 class="defCMCell" style="padding-left:5px">기본값 정하기&nbsp;</td></tr>';text+='</tbody></table>';return text},getFontShape:function(){var text='<table cellspacing=0 cellpadding=0 border=0><tbody>'+'<tr onmouseover="cmo.builtInSubmenu.mouseover02(this)" onmouseout="cmo.builtInSubmenu.mouseout02(this)" onmouseup="cmo.builtInSubmenu.execute(\'bold\')">'+'<td class="defCMCell" style="padding:4px 0px 0px 5px" align="center"><b>굵음</b> ↔ 안 굵음</td>'+'<td class="defCMHot">Ctrl + B</td></tr>'+'<tr onmouseover="cmo.builtInSubmenu.mouseover02(this)" onmouseout="cmo.builtInSubmenu.mouseout02(this)" onmouseup="cmo.builtInSubmenu.execute(\'italic\')">'+'<td class="defCMCell" style="padding:4px 0px 0px 5px" align="center"><i>기울음</i> ↔ 안 기울음</td>'+'<td class="defCMHot">Ctrl + I</td></tr>'+'<tr onmouseover="cmo.builtInSubmenu.mouseover02(this)" onmouseout="cmo.builtInSubmenu.mouseout02(this)" onmouseup="cmo.builtInSubmenu.execute(\'underline\')">'+'<td class="defCMCell" style="padding:4px 0px 0px 5px;cursor" align="center"><u>밑줄 있음</u> ↔ 밑줄 없음</td>'+'<td class="defCMHot">Ctrl + U</td></tr>'+'</tbody></table>';return text}}};var cpo={recentColors:[],open:function(info){this.info=info;new top.Dialog().open({title:info.title,contentType:"function",content:this.draw,clientObject:this,clientCloseMethod:this.onClose})},onClose:function(){delete this.prev_cell},draw:function(dialogFrame){var d=dialogFrame.contentWindow.document;d.open('text/html','replace');d.write('<html><head><link type="text/css" rel="stylesheet" href="'+top.skin+'/css/telate.css">');d.write(top.cco.getUserStyleText());d.write('<style type=text/css>.cell_shape{font:12px gulim;width:42px;height:30px;text-align:center;padding-top:4px;cursor:default}</style></head>');d.write('<body onload="window.focus();top.cpo.initiate(self);top.Dialog.setSize(self);"><div id="dialogArea" style="width:776px" class="usrFrameBack">');d.write('<table cellspacing=0 cellpadding=0 border=0 width="100%">');d.write('<tr><td width=73px height=20px align=center style="padding-top:2px;cursor:default;font:12px gulim">현재 색</td>');d.write('<td rowspan=2 class=usrBrdInset1 height=100%>');d.write('<table class=usrBrdInset2 cellpadding=0px cellspacing=0px><tr><td class="cell_shape" style="padding:3px 0px 0px 10px;white-space:nowrap;width:100%;text-align:left" id="color_preview_area" nowrap></td></tr></table>');d.write('</td>');d.write('</tr>');d.write('<tr><td width=73px align=center><img width="73px" height=0px><br><input type=text style="width:48px;height:20px;font:10px tahoma" id=color_text maxlength=6></td></tr>');d.write('</table>');d.write('<div style="margin-top:10px;height:20px;font:12px gulim;padding:3px 0px 0px 10px;cursor:default">최근에 사용한 색깔들</div>');d.write('<div class=usrBrdInset1 id="recent_color_area">');d.write('</div>');d.write('<table cellspacing=0 cellpadding=0 border=0 style="margin-top:10px">');d.write('<tr><td style="padding:3px 0px 0px 10px;width:120px;cursor:default;font:12px gulim">216가지 색들	</td>');d.write('<td width=165px style="padding-top:3px;cursor:default;font:12px gulim">선택한 색의 밝기만 조절하기</td>');d.write('<td width=230px><input type=button value="-20" class="usrFrameBack usrBrdButton1" style="width:30px;height:19px;font:12px gulim" onclick="top.cpo.shiftBright(self,-20)"><input type=button value="-10" class="usrFrameBack usrBrdButton1" style="width:30px;height:19px;font:12px gulim" onclick="top.cpo.shiftBright(self,-10)"><input type=button value="-1" class="usrFrameBack usrBrdButton1" style="width:30px;height:19px;font:12px gulim" onclick="top.cpo.shiftBright(self,-1)"><input type=text value="128" style="width:24px;height;19px;font:12px gulim" id=bright_text maxlength=3><input type=button value="+1" class="usrFrameBack usrBrdButton1" style="width:30px;height:19px;font:12px gulim" onclick="top.cpo.shiftBright(self,1)"><input type=button value="+10" class="usrFrameBack usrBrdButton1" style="width:30px;height:19px;font:12px gulim" onclick="top.cpo.shiftBright(self,10)"><input type=button value="+20" class="usrFrameBack usrBrdButton1" style="width:30px;height:19px;font:12px gulim" onclick="top.cpo.shiftBright(self,20)"></td>');d.write('<td style="padding-top:3px;cursor:default"><input type=checkbox class="DEF_CHECKBOX01" id="org_bright_check" onclick=top.cpo.retainBrightCheckedState(self,this) checked wordwrap=none readonly diable=true onfocus=this.blur()><label for=org_bright_check> 선택한 색의 원래 밝기임</label></td>');d.write('<td></td>');d.write('</tr></table>');d.write('<div class=usrBrdInset1>');d.write('<div class=usrBrdInset2>');d.write('<table cellspacing=0 cellpadding=0 border=0>');var colors=["000000","333333","666666","999999","CCCCCC","FFFFFF","FF0000","00FF00","0000FF","FFFF00","00FFFF","FF00FF"];var text=this.info.textInCell?'글자':'&nbsp;';var property=this.info.propertyToSet;d.write('<tr>');for(i=0;i<colors.length;i++){d.write('<td class="cell_shape" id="c'+colors[i]+'" style="height:29px;border-right:1px solid black;'+property+':#'+colors[i]+'" onclick=top.cpo.focusCell(self,this)>'+text+'</td>')};d.write('<td><button onclick=top.cpo.getWinApiColor(self,this.nextSibling) style="border:0px;width:130px;height:19px;cursor:hand;margin-left:120px"><div class="DEF_BRD03" style="width:100%;height:100%" ><div style="width:100%;height:100%;font:12px;gulim;padding-top:2px" class="usrFrameBack usrBrdButton1">더 많은 색 찾기</div></div></button><object width=0px height=0px classid="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b"></object></td></tr>');d.write('</tr></table>');d.write('<table cellspacing=0 cellpadding=0 border=0>');var r=g=b=0,rbound=102;function to6Hex(n){var s=n.toString(16);return "000000".substring(s.length)+s};for(i=0;i<12;i++){d.write('<tr>');for(j=0;j<18;j++){var c=to6Hex(r<<16|g<<8|b);d.write('<td  class="cell_shape" id="c'+c+'" style="'+property+':#'+c+';border-top:1px solid black;'+((j<17)?'border-right:1px solid black':'width:41px')+'" onclick=top.cpo.focusCell(self,this)>'+text+'</td>');if(g<255){g+=51}else if(r<rbound){r+=51;g=0}else if(b<255){r=rbound-102;g=0;b+=51}else{rbound=255;r=153;g=b=0}};d.write('</tr>')};d.write('</table></div></div><div align=center style="margin:6px"><input type=button class="defBtnDialog usrFrameBack usrBrdButton1" value="확인" id="dialog_ok_button" onclick=top.cpo.applyColor(self)></div></div></body></html>');d.close()},getWinApiColor:function(win,apiObj){var textBox=win.document.getElementById('color_text');var preview=win.document.getElementById('color_preview_area');var _color=apiObj.ChooseColorDlg(parseInt(textBox.value,16));if(_color){_color=_color.toString(16);this.applyToPreview(win,_color.toString(16))}},applyToPreview:function(win,color,initBright){color=("000000".substring(color.length)+color).toUpperCase();var textBox=win.document.getElementById('color_text');var preview=win.document.getElementById('color_preview_area');textBox.value=color;try{preview.style[this.info.propertyToSet=='color'?"color":"backgroundColor"]=color}catch(e){};this.currentColor=color;if(initBright){this.bco.initiate(color);win.document.getElementById('bright_text').value=this.bco.initialBright;win.document.getElementById('org_bright_check').checked=true}},initiate:function(win){var d=win.document;d.styleSheets[2].rules[0].style.backgroundColor=this.info.backColor;d.styleSheets[2].rules[0].style.color=this.info.foreColor;var color=(this.info.propertyToSet=='color'?this.info.foreColor:this.info.backColor).substring(1).toUpperCase();this.applyToPreview(win,color,true);var This=this;var textBox=d.getElementById('color_text');textBox.onkeyup=function(){if(this.value.match(/^[a-zA-Z0-9]{6}$/)){if(this.value!=This.currentColor){This.applyToPreview(win,this.value,true);This.blurPrevCell()};if(win.event.keyCode==13){This.applyColor(win)}}else if(win.event.keyCode==13){alert('컬러 값이 형식에 맞지 않습니다.')}};textBox.onpaste=function(){if(this.value.match(/^[a-zA-Z0-9]{6}$/)&&this.value!=This.currentColor){This.applyToPreview(win,this.value,true);This.blurPrevCell()}};d.getElementById('bright_text').onkeyup=function(){if(win.event.keyCode!=13)return;var b=parseInt(this.value);if(b>=0&&b<=255){This.applyBright(win,b)}else{alert('0에서 255 사이의 값을 입력해 주세요');this.value=This.bco.initialBright}};var preview=d.getElementById('color_preview_area');if(this.info.fontStyleObject){var s=this.info.fontStyleObject;if(s.fontSize){preview.style.fontSize=s.fontSize};if(s.fontFamily){preview.style.fontFamily=s.fontFamily};if(s.fontWeight){preview.style.fontWeight=s.fontWeight}};var previewText=this.info.previewText;if(previewText){preview.appendChild(d.createTextNode(previewText))};var matchCell=d.getElementById('c'+color);if(matchCell)this.focusCell(win,matchCell,true);this.writeRecentColor(win)},writeRecentColor:function(win){var str='<table cellspacing=0 cellpadding=0 border=0 class=usrBrdInset2 style="background:#ffffff"><tr>';for(var i=0,s=this.recentColors.length;i<s;i++){str+='<td style="width:22px;height:20px';str+=';background-color:#'+this.recentColors[i]+((i<33)?';border-right:1px solid white':';width:21px')+'" onclick=top.cpo.applyToPreview(self,this.style.backgroundColor.substring(1),1)>';str+='<img width=0px height=0px></td>'};for(var i=this.recentColors.length;i<34;i++){str+='<td style="width:22px;height:20px"><img width="0px" height="0px"></td>'};str+='</tr></table>';win.document.getElementById('recent_color_area').innerHTML=str},focusCell:function(win,cell){var color=cell.style[(this.info.propertyToSet=='color')?'color':'backgroundColor'].substring(1);if(!color)return;this.applyToPreview(win,color,true);this.blurPrevCell();this.prev_cell=cell;cell.style.paddingTop='0px';if(this.info.propertyToSet=='color'){cell.innerHTML='<table cellspacing=0px style="font:12px gulim;border:1px solid white" width=100% height=100%><tr><td style="border:1px solid black;padding-top:4px;color:'+cell.style.color+'" align=center>글자</td></tr></table>'}else{cell.innerHTML='<table cellspacing=0px style="font:12px gulim;border:1px solid white" width=100% height=100%><tr><td style="border:1px solid black;padding-top:4px;color:'+win.document.styleSheets[2].rules[0].style.color+'" align=center>'+(this.info.textInCell?'글자':'&nbsp;')+'</td></tr></table>'}},blurPrevCell:function(){if(this.prev_cell){this.prev_cell.style.paddingTop="4px";try{this.prev_cell.innerHTML=this._notext?"&nbsp;":"글자"}catch(e){}}},applyColor:function(win){var colorValue=win.document.getElementById('color_text').value;this.registerToRecentColor(colorValue);this.info.clientMethod.call(this.info.clientObject,colorValue,this.info.clientProperty);Dialog.close(win)},registerToRecentColor:function(val){if(this.recentColors.hasValue(val))return;this.recentColors.push(val);if(this.recentColors.length>34)this.recentColors.shift()},retainBrightCheckedState:function(win,box){if(!box.checked){box.checked=true}else{this.applyToPreview(win,this.bco.initialRGB,true)}},applyBright:function(win,bright){this.applyToPreview(win,this.bco.getRGBFromBright(bright),false);win.document.getElementById('org_bright_check').checked=(bright==this.bco.initialBright)},shiftBright:function(win,step){var el=win.document.getElementById('bright_text');if(step>0&&el.value>=255){el.value=255;return};if(step<0&&el.value<=0){el.value=0;return};var newBright=parseInt(el.value)+step;if(newBright>255){newBright=255}else if(newBright<0){newBright=0};el.value=newBright;this.applyBright(win,newBright)},bco:{initiate:function(rgbhex){this.r=parseInt(rgbhex.substring(0,2),16);this.g=parseInt(rgbhex.substring(2,4),16);this.b=parseInt(rgbhex.substring(4,6),16);this.initialRGB=rgbhex;this.initialBright=Math.round((this.r+this.g+this.b)/3);this.upStep=255-this.initialBright;this.downStep=this.initialBright},getRGBFromBright:function(bright){var diff=parseInt(bright)-this.initialBright;if(!diff){return this.initialRGB};var r=this.getSteppedColor(diff,"r");var g=this.getSteppedColor(diff,"g");var b=this.getSteppedColor(diff,"b");return(r<<16|g<<8|b).toString(16)},getSteppedColor:function(diff,rgb){if(diff>0){if(!this.upStep)return 255;return this[rgb]+Math.round((255-this[rgb])*diff/this.upStep)}else{if(!this.downStep)return 0;return this[rgb]+Math.round(this[rgb]*diff/this.downStep)}}}};var CheckScript={check:function(container){var node=container.firstChild;while(node){if(node.nodeType==1){if(node.getAttribute('bbs_area')=="1"){node=node.nextSibling;continue};switch(node.tagName.toLowerCase()){case 'script':case 'style':nextNode=node.nextSibling;node.parentNode.removeChild(node);node=nextNode;continue};this.check(node);this.removeInlineScript(node)};node=node.nextSibling}},removeInlineScript:function(node){if(node.getAttribute('telate_image'))return;var Attrs=node.attributes;for(m in Attrs){if(Attrs[m]&&Attrs[m].nodeName){if((typeof node.getAttribute(Attrs[m].nodeName))=="function"){node.removeAttribute(Attrs[m].nodeName)}}}}};H=function(){};H.prototype={initiate:function(win,container){this.win=win;this.doc=win.document;this.con=container;this.con.contentEditable=true;var This=this;this.con.attachEvent("onmousedown",function(){This.setRange()});this.con.oncontextmenu=function(){This.setContextRange();top.cmo.showMenu(This.getContextMenuInfo());return false};this.con.onpaste=function(){setTimeout(function(){CheckScript.check(This.con)},1);this.click()};this.con.attachEvent("onfocus",function(){if(This.con.innerHTML=='<P>&nbsp;</P>'){This.setRange();This.range.moveToElementText(This.con.firstChild);This.range.select()}});this.iei=new H.I},blur:function(){this.con.blur()},setRange:function(){this.range=this.doc.selection.createRange()},getRange:function(){var lastP=this.con.lastChild;if(this.range.parentElement()==lastP&&lastP.innerHTML=="&nbsp;"){this.range.moveToElementText(lastP)};this.range.select();return this.range},setContextRange:function(){if(!this.con.lastChild){this.con.innerHTML="<p>&nbsp;</p>"}else if(!this.con.lastChild.tagName||this.con.lastChild.tagName.toLowerCase()!="p"){this.con.innerHTML="<p>"+this.con.innerHTML+"</p>"};var el=this.con.lastChild;var Height=el.offsetHeight;while(el){Height+=el.offsetTop;el=el.offsetParent};this.setRange();if(this.win.event.clientY>Height){try{this.range.moveToElementText(this.con.lastChild);this.range.move("character",this.con.lastChild.innerText.trim()?this.range.text.length:0)}catch(e){}};this.range.select()},execToRange:function(commandName,value){if(!this.range.text.length){this.range.select();this.range.pasteHTML('&nbsp;');this.range.moveStart("character",-1);this.range.select()};this.exec(commandName,value)},exec:function(commandName,value){this.range.execCommand(commandName,false,value);this.range.select()},getContextMenuInfo:function(condition){var infoToContextMenu={clientObject:this,clientWindow:this.win};if(this.win.event&&this.win.event.srcElement){var el=this.win.event.srcElement;if(el.getAttribute("bbs_area")){var el=this.win.event.srcElement;infoToContextMenu.targetNode=el;this.targetBBS=el;var board_id=this.targetBBS.board_id;infoToContextMenu.items=[{title:"게시판 설정...",type:"clientMethod",menuId:"",method:this.openBBSViewConfigurator,property:board_id},{title:"게시판 권한 설정...",type:"clientMethod",menuId:"",method:this.openBbsLevelConfigurator},{title:"게시판 삭제",type:"clientMethod",menuId:"cut",method:this.deleteBBS,property:board_id}];return infoToContextMenu}else if(el.tagName.toLowerCase()=="img"){infoToContextMenu.targetNode=el;this.targetImage=el;if(!this.range.text&&this.range.moveToElementText&&el){try{this.range.moveToElementText(el)}catch(e){}};var anchor=this.getImageParentAnchor(el);var hasTopMargin=el.style.marginTop&&parseInt(el.style.marginTop);infoToContextMenu.items=[{title:"이미지 설정...",type:"clientMethod",menuId:"",method:this.openImageConfigDialog},{title:(hasTopMargin?"이미지 위의 여백 없앰":"이미지 위에 여백 넣음"),type:"clientMethod",menuId:"",method:(hasTopMargin?this.deleteImageTopMargin:this.addImageTopMargin)},{title:"원본 크기로",type:"clientMethod",menuId:"",method:this.setImageToOriginalSize},"|",{title:(anchor?"하이퍼 링크 설정...":"하이퍼 링크 넣기..."),type:"clientMethod",menuId:"hyperLink",method:this.openImageHyperlinkDialog,property:anchor},{title:"편집 ▷",type:"builtInSubmenu",menuId:"fontSize",method:this.setFontSize,disabled:true}];return infoToContextMenu}};infoToContextMenu.targetNode=this.range;switch(condition){default:var anchor=this.getAnchor();infoToContextMenu.items=this.range.text?[{title:anchor?"하이퍼 링크 설정...":"하이퍼 링크 넣기...",type:"clientMethod",menuId:"hyperLink",method:this.openHyperlinkDialog,property:anchor},"|",{title:"왼쪽 정렬",type:"clientMethod",menuId:"",method:this.justifyLeft,style:{textAlign:'left'}},{title:"가운데 정렬",type:"clientMethod",menuId:"",method:this.justifyCenter,style:{textAlign:'center'}},{title:"오른쪽 정렬",type:"clientMethod",menuId:"",method:this.justifyRight,style:{textAlign:'right'}},{title:"줄 간격 ▷",type:"builtInSubmenu",menuId:"lineHeight",method:this.setLineHeight},"|",{title:"글꼴 ▷",type:"builtInSubmenu",menuId:"fontFamily",method:this.setFontFamily},{title:"글자 크기 ▷",type:"builtInSubmenu",menuId:"fontSize",method:this.setFontSize},{title:"글자 모양 ▷",type:"builtInSubmenu",menuId:"fontShape",method:this.setFontShape},"|",{title:"글자 색...",type:"clientMethod",menuId:"",method:this.openFontColorDialog},{title:"글자 배경색...",type:"clientMethod",menuId:"",method:this.openFontBackColorDialog},"|",{title:"편집 ▷",type:"builtInSubmenu",menuId:"CopyCutPaste",method:this.execCopyCutPaste}]: [{title:"이미지 넣기...",type:"clientMethod",menuId:"attachImage",method:this.insertImage},{title:"게시판 넣기...",type:"clientMethod",menuId:"insertBBS",method:this.openBBSViewConfigurator,_skip:top.bbsEditor},"|",{title:"왼쪽 정렬",type:"clientMethod",menuId:"",method:this.justifyLeft,style:{textAlign:'left'}},{title:"가운데 정렬",type:"clientMethod",menuId:"",method:this.justifyCenter,style:{textAlign:'center'}},{title:"오른쪽 정렬",type:"clientMethod",menuId:"",method:this.justifyRight,style:{textAlign:'right'}},{title:"줄 간격 ▷",type:"builtInSubmenu",menuId:"lineHeight",method:this.setLineHeight},"|",{title:"글꼴 ▷",type:"builtInSubmenu",menuId:"fontFamily",method:this.setFontFamily},{title:"글자 크기 ▷",type:"builtInSubmenu",menuId:"fontSize",method:this.setFontSize},{title:"글자 모양 ▷",type:"builtInSubmenu",menuId:"fontShape",method:this.setFontShape},"|",{title:"글자 색...",type:"clientMethod",menuId:"",method:this.openFontColorDialog},{title:"글자 배경색...",type:"clientMethod",menuId:"",method:this.openFontBackColorDialog},"|",{title:"편집 ▷",type:"builtInSubmenu",menuId:"CopyCutPaste",method:this.execCopyCutPaste}]};return infoToContextMenu},getImageParentAnchor:function(el){if(this.range&&this.range.text){return this.getAnchor()}else{return this.getParentAnchor(el)}},getParentAnchor:function(el){try{while(el.tagName){if(el.tagName.toLowerCase()=='a'){return el};el=el.parentNode}}catch(e){};return false},getAnchor:function(){var r=this.range;var d1=r.duplicate();var d2=r.duplicate();var p=r.parentElement();var parentAnchor=this.getParentAnchor(p);if(parentAnchor)return parentAnchor;return getA(p);function getA(el){if(!el.childNodes){return false};for(var i=0,s=el.childNodes.length;i<s;i++){var c=el.childNodes[i];if(!c.tagName)continue;d1.moveToElementText(c);d2.moveToElementText(c);d1.collapse(true);d2.collapse(false);if(r.inRange(d1)||r.inRange(d2)){if(c.tagName.toLowerCase()=='a'){return c}else{return getA(c)}}};return false}},openHyperlinkDialog:function(anchor,fromImage){this.blur();var src=account_url+'?class=Hyperlink&request=show_configurer';if(anchor){src+='&hyperlink='+encodeURIComponent(anchor.href);if(anchor.target)src+='&target='+anchor.target};if(fromImage)src+='&element=image';src+=top.bbsEditor?'&context=bbs&option='+bbsEditor.getUploadOption():'&context=site';new top.Dialog().open({title:"하이퍼링크 넣기",content:src})},openImageHyperlinkDialog:function(anchor){this.openHyperlinkDialog(anchor,"fromImage")},setHyperlink:function(_href,el,link_target){var text=this.range.text;this.exec("Unlink");this.exec("CreateLink",_href);if(this.range.text!=text){this.range.text=text};if(el&&el=='image'){var anchor=this.targetImage.parentNode;anchor.target=link_target;return};if(!this.range.parentElement())return;setTarget(this.range.parentElement());function setTarget(p){__setTarget(p);for(var i=0,s=p.childNodes.length;i<s;i++){setTarget(p.childNodes[i])}};function __setTarget(t){if(t.tagName&&t.tagName.toLowerCase()=='a'){if(link_target){t.target=link_target}else{t.target=t.href.match(/^\//)?"_self":"_blank"}}}},unsetHyperlink:function(){this.exec("Unlink")},openBBSViewConfigurator:function(bid){this.blur();var src=account_url+'?class=BBSConfig&request=print_view_edit_form';if(bid){src+='&bid='+bid;if(top.saver.getTmpViewInfo(bid)){src+='&tmp_info_exists=1'}}else{src+='&bid='+pageEditor.getNewBoardId()+'&create=1'};new top.Dialog().open({title:"게시판 설정",content:src})},openBbsLevelConfigurator:function(bid){if(!bid)bid=this.targetBBS.board_id;this.blur();var src=account_url+'?class=BBSConfig&request=print_level_edit_form&bid='+bid;if(top.saver.getTmpLevelInfo(bid)){src+='&tmp_info_exists=1'};new top.Dialog().open({title:"게시판 권한 설정",content:src})},deleteBBS:function(bid){if(confirm('게시판을 삭제하시겠습니까?')){mei.nodes[mei.getCurrentIndex()].bids.removeValue(bid);this.targetBBS.parentNode.removeChild(this.targetBBS)}},insertImage:function(){this.blur();this.iei.openDialogForUpload(this.win,this.con,this.range)},openImageConfigDialog:function(){this.iei.openDialogForModify(this.win,this.con,this.range,this.targetImage)},setImageToOriginalSize:function(){this.iei.setImageToOriginalSize(this.targetImage)},addImageTopMargin:function(){this.targetImage.style.marginTop='15px'},deleteImageTopMargin:function(){this.targetImage.style.marginTop='0px'},setFontSize:function(val){if(val=='baseFontSize'){this.blur();var dl=new top.Dialog();dl.open({clientObject:this,clientMethod:this.setBaseFontSize,title:"기본값 정하기",contentType:"BodyHTMLString",content:this.getBaseFontSizeMenuContents()})}else{this.execToRange("FontSize",val)}},setBaseFontSize:function(win){var d=win.document;var input=d.getElementsByTagName("input");var _size=[9,10,11,12,13,14,16,18,20,22,24,26,28,32,36];for(var i=0,s=input.length;i<s;i++) {if(input[i].checked){if(!i){if(input[1].value.match(/^\d{1,3}$/)){__setBaseFontSize(input[1].value);return true}else{alert('입력하신 값이 적절하지 않습니다.');input[1].focus();return false}}else if(i>1){__setBaseFontSize(_size[i-2]);return true}}};alert('페이지 기본 글자 크기를 선택해 주세요');return false;function __setBaseFontSize(val){if(top.bbsEditor){top.bbsEditor.setBaseFontSize(val)}else{top.cco.setUserStyle('.usrPage','fontSize',val+'px',true)}}},getBaseFontSizeMenuContents:function(){if(top.bbsEditor){var curSize=bbsEditor.getCurrentFontSize()}else{var curSize=cco.getCssValue('.usrPage','fontSize')};curSize=curSize?parseInt(curSize).toString():'';var _size=[9,10,11,12,13,14,16,18,20,22,24,26,28,32,36];var text='<table cellspacing=0 cellpadding=0 border=0 style="margin:10px"><tbody>';text+='<tr onmousedown="this.firstChild.firstChild.checked=true"><td width="30px" height:25px style="padding-top:2px"><input type="radio" name="base_font_size"></td><td colspan=2 style="padding:2p 0px 0px 5px;cursor:default" onmouseover="" onmouseout="" onmouseup="">직접 입력: <input type=text style="width:40px;height:19px;font:gulim" id="box" value="'+curSize+'" onkeydown="top.hei.setBaseFontSizeMenuContentsKeyDown(self,this);"> 픽셀<script>var b=document.getElementById("box");b.select();b.focus();</'+'script></td></tr>';for(var z,i=0,s=_size.length;i<s;i++){z=_size[i].toString();text+='<tr onmouseover="top.hei.setBaseFontSizeMenuContentsMouseOver(this)" onmouseout="top.hei.setBaseFontSizeMenuContentsMouseOut(this)" onmouseup="top.hei.setBaseFontSizeMenuContentsMouseUp(self,this,'+z+')">'+'<td width="30px" style="padding-top:2px"><input type="radio" name="base_font_size"'+(z==curSize?' checked':'')+'></td>'+'<td style="padding:2px 5px 0px 5px;color:black;font:'+z+'px gulim;cursor:default">'+z+'</td>'+'<td style="padding:2px 5px 0px 5px;color:black;font:'+z+'px gulim;cursor:default" nowrap>한글 ABC\'s</td>'+'</tr>'};text+='</tbody></table>';return text},setBaseFontSizeMenuContentsMouseUp:function(win,_tr,val){_tr.firstChild.firstChild.checked=true;win.document.getElementById("box").value=val},setBaseFontSizeMenuContentsMouseOut:function(_tr){_tr.bgColor="#ffffff";_tr.firstChild.nextSibling.style.color="#000000";_tr.firstChild.nextSibling.nextSibling.style.color="#000000"},setBaseFontSizeMenuContentsMouseOver:function(_tr){_tr.bgColor="#3366cc";_tr.firstChild.nextSibling.style.color="#ffffff";_tr.firstChild.nextSibling.nextSibling.style.color="#ffffff"},setBaseFontSizeMenuContentsKeyDown:function(win,el){if(win.event.keyCode==13){if(this.setBaseFontSize(win)){top.Dialog.close(win)}}else{el.parentNode.previousSibling.firstChild.checked=true}},setLineHeight:function(val){if(val=="baseLineHeight"){this.blur();new top.Dialog().open({clientObject:this,clientMethod:this.setBaseLineHeight,title:"기본값 정하기",contentType:"BodyHTMLString",content:this.getBaseLineHeightMenuContents()})}else{}},setBaseLineHeight:function(win){var d=win.document;var input=d.getElementsByTagName("input");var height=[100,120,150,200];for(var i=0,s=input.length;i<s;i++) {if(input[i].checked){if(!i){if(input[1].value.match(/^\d{1,3}$/)){this.__setBaseLineHeight(input[1].value);return true}else{alert('입력하신 값이 적절하지 않습니다.');input[1].focus();return false}}else if(i>1){this.__setBaseLineHeight(height[i-2]);return true}}};alert('페이지 기본 줄 간격을 선택해 주세요');return false;function __setBaseLineHeight(val){if(top.bbsEditor){top.bbsEditor.setBaseLineHeight(val)}else{top.cco.setUserStyle('.usrPage','lineHeight',(val/100)+'em',true)}}},getBaseLineHeightMenuContents:function(){var curHeight=top.bbsEditor?bbsEditor.getCurrentLineHeight():cco.getCssValue('.usrPage','lineHeight');curHeight=curHeight?(parseFloat(curHeight)*100).toString():'';var height=[100,120,150,200];var text='<table cellspacing=0 cellpadding=0 border=0 style="margin:10px">'+'<tr onmousedown="this.firstChild.firstChild.checked=true;"><td align=center widht=25px style="padding:7px 0px 1px 0p"><input type=radio name=line_height></td><td colspan =2 style="padding:5px 0px 3px 0px;cursor:default;font:12px gulim">&nbsp; 직접 입력 : <input type=text style="width:40px;height:19px;font:12px gulim" id="box" value="'+curHeight+'" onkeydown="top.hei.setBaseLineHeightMenuContentsKeyDown(self,this);">%<script>var b=document.getElementById("box");b.select();b.focus();</'+'script></td></tr>';var _desc;for(var i=0,s=height.length;i<s;i++){_desc='이것이 '+height[i]+'% 줄간격입니다.<br/>이것이 '+height[i]+'% 줄간격입니다.<br/>이것이 '+height[i]+'% 줄간격입니다.';text+='<tr onmouseover="top.hei.setBaseFontSizeMenuContentsMouseOver(this)" onmouseout="top.hei.setBaseFontSizeMenuContentsMouseOut(this)" onmouseup="top.hei.setBaseLineHeightMenuContentsMouseUp(self,this,'+height[i]+')"><td align=center style="font:12px gulim"><input type=radio name="line_height"'+(curHeight==height[i]?' checked':'')+'></td style="cursor:default;"><td style="font:12px gulim">&nbsp; '+height[i]+'% &nbsp; &nbsp; &nbsp;</td><td style="padding:5px 5px 2px 5px;font:12px gulim;cursor:default;line-height:'+(height[i]/100)+'em">'+_desc+'</td><tr>'};text+='</table>';return text},setBaseLineHeightMenuContentsMouseUp:function(win,_tr,val){_tr.firstChild.firstChild.checked=true;win.document.getElementById("box").value=val},setBaseLineHeightMenuContentsKeyDown:function(win,el){if(win.event.keyCode==13){if(this.setBaseLineHeight(win)){top.Dialog.close(win)}}else{el.parentNode.previousSibling.firstChild.checked=true}},justifyLeft:function(){this.exec("JustifyLeft",false)},justifyCenter:function(){this.exec("JustifyCenter",false)},justifyRight:function(){this.exec("JustifyRight",false)},execCopyCutPaste:function(val){this.exec(val,false)},setFontShape:function(val){this.execToRange(val)},setFontFamily:function(val){this.execToRange('FontName',val)},openFontColorDialog:function(){var _back,_fore,el=this.range.parentElement();if(el&&el.tagName.toLowerCase()=='font'){_back=el.style.backgroundColor?el.style.backgroundColor:'#ffffff';_fore=el.color?el.color:'#000000'}else{_back='#ffffff';_fore='#000000'};this.blur();cpo.open({title:"글자 색",clientObject:this,clientMethod:this.setFontColor,clientProperty:null,foreColor:_fore,backColor:_back,previewText:"테스트",textInCell:true,propertyToSet:'color'})},setFontColor:function(val){this.execToRange('ForeColor',val)},openFontBackColorDialog:function(){var _back,_fore,el=this.range.parentElement();if(el&&el.tagName.toLowerCase()=='font'){_back=el.style.backgroundColor?el.style.backgroundColor:'#ffffff';_fore=el.color?el.color:'#000000'}else{_back='#ffffff';_fore='#000000'};cpo.open({title:"배경 색",clientObject:this,clientMethod:this.setFontBackColor,clientProperty:null,foreColor:_fore,backColor:_back,previewText:"테스트",textInCell:true,propertyToSet:'background-color'})},setFontBackColor:function(val){this.execToRange('BackColor',val)}};H.I=function(){};H.I.prototype={openDialogForUpload:function(win,con,range){this.win=win;this.con=con;this.range=range;this.con.blur();this.con.contentEditable=true;this.imageAvailableWidth=con.offsetWidth-2;var src=top.account_url+'?class=ImageOnEditor&request=show_image_editor';if(top.bbsEditor){src+='&context=bbs&option='+bbsEditor.getUploadOption()}else{src+='&context=site&menu_id='+mei.getCurrentIndex()};new top.Dialog().open({title:"이미지 넣기",content:src})},attach:function(infos){this.con.focus();var str='';var userSizeInfo=this.getUserDefinedImageSize();var userWidth,userHeight;for(var i=0,s=infos.length;i<s;i++){var info=infos[i];switch(userSizeInfo._ratioType){case 'byWidth':if(userSizeInfo.width){userWidth=userSizeInfo.width;userHeight=(userWidth*info.originalHeight)/info.originalWidth};break;case 'byHeight':if(userSizeInfo.height){userHeight=userSizeInfo.height;userWidth=(userHeight*info.originalWidth)/info.originalHeight};break;case 'no':if(userSizeInfo.width&&userSizeInfo.height){userWidth=userSizeInfo.width;userHeight=userSizeInfo.height};break};var shownWidth,shownHeight;if(userWidth){shownWidth=userWidth;shownHeight=userHeight}else{var shownWidth=info.originalWidth;var shownHeight=info.originalHeight};if(shownWidth>this.imageAvailableWidth){shownHeight=Math.round(this.imageAvailableWidth*(shownHeight/shownWidth));shownWidth=this.imageAvailableWidth};str+='<img telate_image="1" src="'+info.src+'" width="'+shownWidth+'px" height="'+shownHeight+'px" originalWidth="'+info.originalWidth+'px" originalHeight="'+info.originalHeight+'px" initWidth="'+shownWidth+'px" initHeight="'+shownHeight+'px" tmpWidth="'+shownWidth+'px" tmpHeight="'+shownHeight+'px"'+' onresizestart="top.hei.iei.resizeStart(self,this)" onresize="top.hei.iei.resize(this)" onresizeend="top.hei.iei.resizeEnd(this)"'+this.getCurrentImageAlign()+'>'};var lastP=top.hei.con.lastChild;if(this.range.parentElement()==lastP&&lastP.innerHTML=="&nbsp;"){this.range.moveToElementText(lastP)};this.range.select();this.range.pasteHTML(str)},setCurrentImageAlign:function(val){this.currentImageAlign=val},getCurrentImageAlign:function(){if(!this.currentImageAlign)return '';switch(this.currentImageAlign){case 'left':return ' align="left" style="margin-top:15px;margin-right:15px;margin-bottom:15px"';case 'right':return ' align="right" style="margin-top:15px;margin-left:15px;margin-bottom:15px"';default:return ''}},setUserDefinedImageSize:function(obj){this.userDefinedImageSize=obj},getUserDefinedImageSize:function(){return this.userDefinedImageSize},openDialogForModify:function(win,con,range,img){this.targetImage=img;this.win=win;this.con=con;this.range=range;this.con.blur();this.con.contentEditable=true;new top.Dialog().open({title:"이미지 설정",content:(account_url+'?class=ImageOnEditor&request=modify_image&width='+parseInt(img.width)+'&height='+parseInt(img.height)+'&align='+img.align)})},applyModifiedImageInfo:function(){var img=this.targetImage;var userSizeInfo=this.getUserDefinedImageSize();var _align=this.currentImageAlign;var userWidth,userHeight;var initHeight=parseInt(img.initHeight);var initWidth=parseInt(img.initWidth);switch(userSizeInfo._ratioType){case 'byWidth':if(userSizeInfo.width){userWidth=parseInt(userSizeInfo.width);userHeight=(userWidth*initHeight)/initWidth};break;case 'byHeight':if(userSizeInfo.height){userHeight=parseInt(userSizeInfo.height);userWidth=(userHeight*initWidth)/initHeight};break;case 'no':if(userSizeInfo.width&&userSizeInfo.height){userWidth=parseInt(userSizeInfo.width);userHeight=parseInt(userSizeInfo.height)};break};if(userWidth){userWidth=parseInt(userWidth);userHeight=parseInt(userHeight);try{img.initWidth=img.style.width=userWidth+'px';img.initHeight=img.style.height=userHeight+'px';img.width=userWidth;img.height=userHeight};catch(e){}};if(!img.align&&_align){img.style.marginTop="15px"};switch(_align){case 'left':img.align='left';img.style.marginBottom="15px";img.style.marginLeft="0px";img.style.marginRight="15px";break;case 'right':img.align='right';img.style.marginBottom="15px";img.style.marginLeft="15px";img.style.marginRight="0px";break;default:img.align='';img.style.marginTop="0px";img.style.marginBottom="0px";img.style.marginLeft="0px";img.style.marginRight="0px";break}},resizeStart:function(win,img){this.win=win;img.setAttribute("resizeStarted",true);__onresize="byHandler";img.tmpWidth=parseInt(img.width);img.tmpHeight=parseInt(img.height);img.handlerX=Math.floor((this.win.event.offsetX/img.tmpWidth)*3)-1;img.handlerY=Math.floor((this.win.event.offsetY/img.tmpHeight)*3)-1;img.ratio=img.handlerX*img.handlerY?0:img.tmpHeight/img.tmpWidth},resize:function(img){if(!img.getAttribute("resizeStarted"))return;if(img.handlerX<=-1||img.handlerY<=-1){alert("오른쪽 또는 아래쪽 핸들러를 이용해주세요");return false};if(img.handlerX>=1){if(this.win.event.offsetX<=0)return;img.tmpWidth=this.win.event.offsetX;img.width=img.style.width=img.tmpWidth+"px";if(img.ratio){img.tmpHeight=Math.round(img.tmpWidth*img.ratio);img.height=img.style.height=img.tmpHeight+"px"}};if(img.handlerY>=1){if(this.win.event.offsetY<=0)return;img.tmpHeight=this.win.event.offsetY;img.height=img.style.height=img.tmpHeight+"px";if(img.ratio){img.tmpWidth=Math.round(img.tmpHeight/img.ratio);img.width=img.style.width=img.tmpWidth+"px"}}},resizeEnd:function(img){img.setAttribute("resizeStarted",false);img.removeAttribute("resizeStarted");img.width=img.style.width=img.tmpWidth;img.height=img.style.height=img.tmpHeight},setImageToOriginalSize:function(img){img.width=img.style.width=parseInt(img.getAttribute("originalWidth"));img.height=img.style.height=parseInt(img.getAttribute("originalHeight"))}};M=function(){};M.rootIndex=0;M.homeIndex=1;M.trashIndex=2;M.cellWidth=16;M.memberInfoIndex=-201;M.prototype={nodes:[],initialIndexes:[],initialFoldingState:[],orderedIndexes:[],orderedIndexesFlip:[],initialFoldingState:[],lastChildInfo:[],_rows:[],nextInfo:[],iconSrc:{},moveToMemberInfo:function(){this.focusCell(M.memberInfoIndex)},setCurrentIndex:function(index){this.focusedIndex=index},getCurrentIndex:function(){return this.focusedIndex?this.focusedIndex:1},getCurrentSubject:function(){return this.focusedIndex?this.nodes[this.focusedIndex].subject:''},indexExists:function(index){if(!index)return false;return(this.orderedIndexes.hasValue(index))?index:false},initiate:function(ContainerWin,ContainerId,nodeInfos){this.win=ContainerWin;this.doc=ContainerWin.document;this.con=this.doc.getElementById(ContainerId);this.initiateNodes(nodeInfos);this.initiateView()},initiateNodes:function(nodeInfos,menuToBids){if(menuToBids){menuToBids=json_decode(menuToBids)};nodeInfos=json_decode(nodeInfos);for(var i=0;i<nodeInfos.length;i++){var node={hasNext:0,childNum:0,visChildNum:0};node.index=nodeInfos[i][0];node.parentIndex=nodeInfos[i][1];node.folded=nodeInfos[i][2];node.subject=nodeInfos[i][3];switch(nodeInfos[i][4]){case 0:node.page_type="empty_page";break;case 1:node.page_type="telate_page";break;case 2:node.page_type="custom_page";break};node.url=nodeInfos[i][5];node.level_visible=nodeInfos[i][6];node.level_clickable=nodeInfos[i][7];node._color=nodeInfos[i][8];if(this.isRoot(node.index)){node.depth=0}else{node.depth=this.nodes[node.parentIndex].depth+1};if(menuToBids&&menuToBids[node.index]){node.bids=menuToBids[node.index]};if(node.index==M.trashIndex){node.folded=1};this.nodes[node.index]=node;this.makePrevSiblingHasNextInfo(node.index);this.addChildNumOfParentsNode(node.index);this.orderedIndexes[i]=node.index;this.orderedIndexesFlip[node.index]=i;this.initialIndexes.push(node.index);this.initialFoldingState[node.index]=(node.folded?1:0)}},makePrevSiblingHasNextInfo:function(index){if(this.isRoot(index))return;var pIndex=this.nodes[index].parentIndex;var prevSiblingIndex=this.lastChildInfo[pIndex];if(prevSiblingIndex)this.nodes[prevSiblingIndex].hasNext=1;this.lastChildInfo[pIndex]=index},addChildNumOfParentsNode:function(index){var pNode,node=this.nodes[index];var folded=0;while(!this.isRoot(node.index)){pNode=this.nodes[node.parentIndex];pNode.childNum++;if(pNode.folded||folded){folded=1}else{pNode.visChildNum++};node=pNode}},setIcon:function(prop,file){this.iconSrc[prop]=this.doc.createElement('img');this.iconSrc[prop].src=top.skin+'/img/menu.tree.03'+file},initiateView:function(){this.rowBack=cco.getCssValue('.usrMenuRow','backgroundColor');this.rowBackSel=cco.getCssValue('.usrMenuRowSel','backgroundColor');this.rowBackOver=cco.getCssValue('.usrMenuRowOver','backgroundColor');this.rowColor=cco.getCssValue('.usrMenuRow','color');this.rowColorSel=cco.getCssValue('.usrMenuRowSel','color');this.rowColorOver=cco.getCssValue('.usrMenuRowOver','color');this.tableCssClass='usrMenuFont usrMenuRow';this.tableCssClassSel='usrMenuFont usrMenuRowSel';this.tableCssClassOver='usrMenuFont usrMenuRowOver';this.setIcon('folded','/tree.fold.gif');this.setIcon('unfolded','/tree.unfold.gif');this.setIcon('notFolder','/tree.item.gif');var node,_row,childContainer,container=this.con;for(var i=0;i<this.orderedIndexes.length;i++){node=this.nodes[this.orderedIndexes[i]];if(!this.editMode&&node.page_type=='trash')break;this.nextInfo[node.depth]=node.hasNext;_row=this.createRow(node.index);if(this.isRoot(node.index)|| !this.editMode&&this.isRoot(node.parentIndex)){_row.firstChild.style.display="none"};container.appendChild(_row);childContainer=this.getChildContainer();if(node.index!=M.homeIndex&&node.folded){childContainer.style.display="none"};container.appendChild(childContainer);if(node.childNum){container=childContainer}else{while(node.index&&!node.hasNext){container=container.parentNode;node=this.nodes[node.parentIndex]}}}},createRow:function(index){var d=this.doc;var node=this.nodes[index];var This=this;var _row=this.doc.createElement("div");var table=El.getTable(this.doc,1,0);var tr=table.firstChild.firstChild;var td,img,subject;_row.appendChild(table);_row.className="treeRowContainer";_row.index=index;this._rows[index]=_row;for(var i=(this.editMode?1:2);i<node.depth;i++){td=tr.appendChild(d.createElement("td"));td.className=this.nextInfo[i]?"treeLineV":"treeLineN";td.appendChild(El.getSpacer(this.doc,M.cellWidth,0))};if(node.depth){td=d.createElement("td");td.className=node.hasNext?"treeLineVH":"treeLineH";td.index=index;td.appendChild(El.getSpacer(this.doc,M.cellWidth,0));img=d.createElement("img");img.index=index;img.width=9;img.height=9;if(!this.editMode)img.style.cursor="hand";if(node.childNum){img.src=node.folded?this.iconSrc.folded.src:this.iconSrc.unfolded.src;img.onmousedown=function(){if(This.isChildFocused(this.index,This.getCurrentIndex())){This.focusCell(this.index)};This.foldSubTree(this.index)}}else{img.style.cursor="default";img.src=this.iconSrc.notFolder.src};td.appendChild(img);img.className="usrMenuButton";tr.appendChild(td)};subject=d.createElement("td");subject.className="usrMenuSubject";if(node._color&&node._color.match(/^\#[0-9a-fA-F]{6}$/)){subject.style.color=node._color};if(node.depth==2){subject.style.fontWeight="bold"};subject.index=index;subject.appendChild(this.doc.createTextNode(node.subject));if(node.depth==1){subject.style.color="#aaaaaa";subject.style.fontWeight="bold"};tr.appendChild(subject);this.setMouseDownEvent(subject);table.setAttribute('index',index);table.className=this.tableCssClass;table.style.height='22px';if(!this.editMode){subject.style.cursor='hand';table.style.width='100%';table.onmouseover=function(){var index=parseInt(this.getAttribute('index'));if(index==This.getCurrentIndex())return;this.style.backgroundColor=This.rowBackOver};table.onmouseout=function(){if(parseInt(this.getAttribute('index'))==This.getCurrentIndex())return;this.style.backgroundColor=This.rowBack}}else{table.style.cursor='default'};return _row},getChildContainer:function(){var div=this.doc.createElement("div");div.style.display="block";return div},isChildFocused:function(clickIndex,childIndex){if(childIndex==0)return false;var parentIndex=this.nodes[childIndex].parentIndex;if(parentIndex==clickIndex)return true;return this.isChildFocused(clickIndex,parentIndex)},setMouseDownEvent:function(cell){var This=this;cell.onmousedown=function(){if(This.win.event.button!=1)return;var node=This.nodes[this.index];if(node.childNum){if(node.folded){This.foldSubTree(this.index)}else if(this.index==This.getCurrentIndex()){This.foldSubTree(this.index)}};This.focusCell(this.index)}},focusCell:function(index,calledOnPageLoaded){var node=this.nodes[index];this.openAllParent(index);if(this.focusedTable){this.focusedTable.style.backgroundColor=this.rowBack;this.focusedTable.style.color=this.rowColor;if(this.focusedCell.getAttribute('fontColor')){this.focusedCell.style.color=this.focusedCell.getAttribute('fontColor')}};var subject=this.getSubjectCell(index);this.focusedCell=subject;this.focusedTable=subject.parentNode.parentNode.parentNode;this.focusedTable.style.backgroundColor=this.rowBackSel;this.focusedTable.style.color=this.rowColorSel;if(subject.style.color){subject.setAttribute('fontColor',subject.style.color);subject.style.color=''};this.setCurrentIndex(index);top.setSiteCookie('currentMenuId',index);if(!calledOnPageLoaded){this.movePage(index)}},openAllParent:function(index){var pIndex=this.nodes[index].parentIndex;if(pIndex==(this.editMode?-1:0))return;if(this.nodes[pIndex].folded){this.foldSubTree(pIndex)};this.openAllParent(pIndex)},foldSubTree:function(index){var btn=this.getButtonCell(index);var node=this.nodes[index];var _row=this._rows[index];var childContainer=_row.nextSibling;if(childContainer.style.display=='none'){childContainer.style.display='block';btn.lastChild.src=this.iconSrc.unfolded.src;node.folded=0}else if(childContainer.style.display=='block'){childContainer.style.display='none';btn.lastChild.src=this.iconSrc.folded.src;node.folded=1};if(this.editMode){this.changeVisChildNum(index);this.arrangeVisibleIndexes()}},movePage:function(index){var node=this.nodes[index];top.setSiteCookie('page',index);switch(node.page_type){case 'telate_page':this.doc.getElementById('user_page_area').src=account_url+'?class=Page&menu_id='+index;break;case 'empty_page':this.doc.getElementById('user_page_area').src=account_url+'?class=Page&request=show_submenus&menu_id='+index;break;case 'custom_page':var src,url=this.nodes[index].url;if(url.match(/^\?/)){src=account_url+url}else if(url.match(/^[a-zA-Z]+\:\/\//)){src=url}else if(url.match(/^\//)){src=account_url+url.substring(1)+'&menu_id='+this.getCurrentIndex()}else{src='http://'+url};if(this.editMode){pageEditor.movePage(index)}else{this.doc.getElementById('user_page_area').src=src};break}},isRoot:function(index){return index===M.rootIndex},getSubjectCell:function(index){return(index&&this._rows[index])?this._rows[index].firstChild.firstChild.firstChild.lastChild:null},getButtonCell:function(index){return this._rows[index].firstChild.firstChild.firstChild.lastChild.previousSibling},getSubject:function(index){return this.nodes[index].subject},drawSubmenus:function(doc,menuId){var submenus=[];for(var i=0,s=this.orderedIndexes.length;i<s;i++){var Id=this.orderedIndexes[i];var node=this.nodes[Id];if(node.parentIndex==menuId){doc.write('<div class="defPageSubmenu"><span><img src="'+this.iconSrc.notFolder.src+'" class="usrMenuButton" style="margin:0px"></span><a href="javascript:top.'+(this.editMode?'mei':'mti')+'.focusCell('+Id+')">'+node.subject+'</a></div>')}}}};cco.initiate();fmo=new F();window.attachEvent("onload",function(){fmo.registerFrame(self);fmo.registerEventHandler({element:"body",type:"onmousedown",handlerId:"removeContextMenu1",clientObject:cmo,clientMethod:cmo.removeContextMenu});fmo.registerEventHandler({element:"body",type:"onkeydown",handlerId:"removeContextMenu2",clientObject:cmo,clientMethod:cmo.removeContextMenu})});