/** 
 * x.js compiled from X 4.0 with XC 0.27b. 
 * Distributed by GNU LGPL. For copyrights, license, documentation and more visit Cross-Browser.com 
 * Copyright 2001-2005 Michael Foster (Cross-Browser.com)
 **/
var request_uri= "";
var xOp7Up,xOp6Dn,xIE4Up,xIE4,xIE5,xIE6,xNN4,xUA=navigator.userAgent.toLowerCase();
if(window.opera){
  var i=xUA.indexOf('opera');
  if(i!=-1){
    var v=parseInt(xUA.charAt(i+6));
    xOp7Up=v>=7;
    xOp6Dn=v<7;
  }
}
else if(navigator.vendor!='KDE' && document.all && xUA.indexOf('msie')!=-1){
  xIE4Up=parseFloat(navigator.appVersion)>=4;
  xIE4=xUA.indexOf('msie 4')!=-1;
  xIE5=xUA.indexOf('msie 5')!=-1;
  xIE6=xUA.indexOf('msie 6')!=-1;
}
else if(document.layers){xNN4=true;}
var xMac=xUA.indexOf('mac')!=-1;
var xFF=xUA.indexOf('firefox')!=-1;

// (element, event(without 'on'), event listener(function name)[, caption])
function xAddEventListener(e,eT,eL,cap)
{
  if(!(e=xGetElementById(e))) return;
  eT=eT.toLowerCase();
  if((!xIE4Up && !xOp7Up) && e==window) {
    if(eT=='resize') { window.xPCW=xClientWidth(); window.xPCH=xClientHeight(); window.xREL=eL; xResizeEvent(); return; }
    if(eT=='scroll') { window.xPSL=xScrollLeft(); window.xPST=xScrollTop(); window.xSEL=eL; xScrollEvent(); return; }
  }
  var eh='e.on'+eT+'=eL';
  if(e.addEventListener) e.addEventListener(eT,eL,cap);
  else if(e.attachEvent) e.attachEvent('on'+eT,eL);
  else eval(eh);
}
// called only from the above
function xResizeEvent()
{
  if (window.xREL) setTimeout('xResizeEvent()', 250);
  var cw = xClientWidth(), ch = xClientHeight();
  if (window.xPCW != cw || window.xPCH != ch) { window.xPCW = cw; window.xPCH = ch; if (window.xREL) window.xREL(); }
}

function xScrollEvent()
{
  if (window.xSEL) setTimeout('xScrollEvent()', 250);
  var sl = xScrollLeft(), st = xScrollTop();
  if (window.xPSL != sl || window.xPST != st) { window.xPSL = sl; window.xPST = st; if (window.xSEL) window.xSEL(); }
}

function xAppendChild(oParent, oChild)
{
  if (oParent.appendChild) return oParent.appendChild(oChild);
  else return null;
}

function xClientHeight()
{
  var h=0;
  if(xOp6Dn) h=window.innerHeight;
  else if(document.compatMode == 'CSS1Compat' && !window.opera && document.documentElement && document.documentElement.clientHeight)
    h=document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    h=document.body.clientHeight;
  else if(xDef(window.innerWidth,window.innerHeight,document.width)) {
    h=window.innerHeight;
    if(document.width>window.innerWidth) h-=16;
  }
  return h;
}

function xClientWidth()
{
  var w=0;
  if(xOp6Dn) w=window.innerWidth;
  else if(document.compatMode == 'CSS1Compat' && !window.opera && document.documentElement && document.documentElement.clientWidth)
    w=document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    w=document.body.clientWidth;
  else if(xDef(window.innerWidth,window.innerHeight,document.height)) {
    w=window.innerWidth;
    if(document.height>window.innerHeight) w-=16;
  }
  return w;
}

function xCreateElement(sTag)
{
  if (document.createElement) return document.createElement(sTag);
  else return null;
}

function xDef()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function xDeleteCookie(name, path)
{
  if (xGetCookie(name)) {
    document.cookie = name + "=" +
                    "; path=" + ((!path) ? "/" : path) +
                    "; expires=" + new Date(0).toGMTString();
  }
}

function xDisplay(e,s)
{
  if(!(e=xGetElementById(e))) return null;
  if(e.style && xDef(e.style.display)) {
    if (xStr(s)) e.style.display = s;
    return e.style.display;
  }
  return null;
}

function xEvent(evt) // object prototype
{
  var e = evt || window.event;
  if(!e) return;
  if(e.type) this.type = e.type;
  if(e.target) this.target = e.target;
  else if(e.srcElement) this.target = e.srcElement;

  // Section B
  if (e.relatedTarget) this.relatedTarget = e.relatedTarget;
  else if (e.type == 'mouseover' && e.fromElement) this.relatedTarget = e.fromElement;
  else if (e.type == 'mouseout') this.relatedTarget = e.toElement;
  // End Section B

  if(xOp6Dn) { this.pageX = e.clientX; this.pageY = e.clientY; }
  else if(xDef(e.pageX,e.pageY)) { this.pageX = e.pageX; this.pageY = e.pageY; }
  else if(xDef(e.clientX,e.clientY)) { this.pageX = e.clientX + xScrollLeft(); this.pageY = e.clientY + xScrollTop(); }

  // Section A
  if (xDef(e.offsetX,e.offsetY)) {
    this.offsetX = e.offsetX;
    this.offsetY = e.offsetY;
  }
  else if (xDef(e.layerX,e.layerY)) {
    this.offsetX = e.layerX;
    this.offsetY = e.layerY;
  }
  else {
    this.offsetX = this.pageX - xPageX(this.target);
    this.offsetY = this.pageY - xPageY(this.target);
  }
  // End Section A
  
  if (e.keyCode) { this.keyCode = e.keyCode; } // for moz/fb, if keyCode==0 use which
  else if (xDef(e.which) && e.type.indexOf('key')!=-1) { this.keyCode = e.which; }

  this.shiftKey = e.shiftKey;
  this.ctrlKey = e.ctrlKey;
  this.altKey = e.altKey;
}

function xFirstChild(e, t)
{
  var c = e ? e.firstChild : null;
  if (t) while (c && c.nodeName != t) { c = c.nextSibling; }
  else while (c && c.nodeType != 1) { c = c.nextSibling; }
  return c;
}

function xGetBodyWidth() {
  var cw = xClientWidth();
  var sw = window.document.body.scrollWidth;
  return cw>sw?cw:sw;
}

function xGetBodyHeight() {
  var cw = xClientHeight();
  var sw = window.document.body.scrollHeight;
  return cw>sw?cw:sw;
}

function xGetComputedStyle(oEle, sProp, bInt)
{
  var s, p = 'undefined';
  var dv = document.defaultView;
  if(dv && dv.getComputedStyle){
    s = dv.getComputedStyle(oEle,'');
    if (s) p = s.getPropertyValue(sProp);
  }
  else if(oEle.currentStyle) {
    // convert css property name to object property name for IE
    var a = sProp.split('-');
    sProp = a[0];
    for (var i=1; i<a.length; ++i) {
      c = a[i].charAt(0);
      sProp += a[i].replace(c, c.toUpperCase());
    }   
    p = oEle.currentStyle[sProp];
  }
  else return null;
  return bInt ? (parseInt(p) || 0) : p;
}

function xGetCookie(name)
{
  var value=null, search=name+"=";
  if (document.cookie.length > 0) {
    var offset = document.cookie.indexOf(search);
    if (offset != -1) {
      offset += search.length;
      var end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      value = unescape(document.cookie.substring(offset, end));
    }
  }
  return value;
}

function xGetElementById(e)
{

  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}

function xGetElementsByAttribute(sTag, sAtt, sRE, fn)
{
  var a, list, found = new Array(), re = new RegExp(sRE, 'i');
  list = xGetElementsByTagName(sTag);
  for (var i = 0; i < list.length; ++i) {
    a = list[i].getAttribute(sAtt);
    if (!a) {a = list[i][sAtt];}
    if (typeof(a)=='string' && a.search(re) != -1) {
      found[found.length] = list[i];
      if (fn) fn(list[i]);
    }
  }
  return found;
}

function xGetElementsByClassName(c,p,t,f)
{
  var found = new Array();
  var re = new RegExp('\\b'+c+'\\b', 'i');
  var list = xGetElementsByTagName(t, p);
  for (var i = 0; i < list.length; ++i) {
    if (list[i].className && list[i].className.search(re) != -1) {
      found[found.length] = list[i];
      if (f) f(list[i]);
    }
  }
  return found;
}

function xGetElementsByTagName(t,p)
{
  var list = null;
  t = t || '*';
  p = p || document;
  if (xIE4 || xIE5) {
    if (t == '*') list = p.all;
    else list = p.all.tags(t);
  }
  else if (p.getElementsByTagName) list = p.getElementsByTagName(t);
  return list || new Array();
}

function xGetURLArguments()
{
  var idx = location.href.indexOf('?');
  var params = new Array();
  if (idx != -1) {
    var pairs = location.href.substring(idx+1, location.href.length).split('&');
    for (var i=0; i<pairs.length; i++) {
      nameVal = pairs[i].split('=');
      params[i] = nameVal[1];
      params[nameVal[0]] = nameVal[1];
    }
  }
  return params;
}

function xHeight(e,h)
{
  if(!(e=xGetElementById(e))) return 0;
  if (xNum(h)) {
    if (h<0) h = 0;
    else h=Math.round(h);
  }
  else h=-1;
  var css=xDef(e.style);
  if (e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    h = xClientHeight();
  }
  else if(css && xDef(e.offsetHeight) && xStr(e.style.height)) {
    if(h>=0) {
      var pt=0,pb=0,bt=0,bb=0;
      if (document.compatMode=='CSS1Compat') {
        var gcs = xGetComputedStyle;
        pt=gcs(e,'padding-top',1);
        if (pt !== null) {
          pb=gcs(e,'padding-bottom',1);
          bt=gcs(e,'border-top-width',1);
          bb=gcs(e,'border-bottom-width',1);
        }
        // Should we try this as a last resort?
        // At this point getComputedStyle and currentStyle do not exist.
        else if(xDef(e.offsetHeight,e.style.height)){
          e.style.height=h+'px';
          pt=e.offsetHeight-h;
        }
      }
      h-=(pt+pb+bt+bb);
      if(isNaN(h)||h<0) return null;
      else e.style.height=h+'px';
    }
    h=e.offsetHeight;
  }
  else if(css && xDef(e.style.pixelHeight)) {
    if(h>=0) e.style.pixelHeight=h;
    h=e.style.pixelHeight;
  }
  return h;
}

function xHex(sn, digits, prefix)
{
  var p = '';
  var n = Math.ceil(sn);
  if (prefix) p = prefix;
  n = n.toString(16);
  for (var i=0; i < digits - n.length; ++i) {
    p += '0';
  }
  return p + n;
}

function xHide(e){return xVisibility(e,0);}

function xInnerHtml(e,h)
{
  if(!(e=xGetElementById(e)) || !xStr(e.innerHTML)) return null;
  var s = e.innerHTML;
  if (xStr(h)) {e.innerHTML = h;}
  return s;
}

function xLeft(e, iX)
{
  if(!(e=xGetElementById(e))) return 0;
  var css=xDef(e.style);
  if (css && xStr(e.style.left)) {
    if(xNum(iX)) e.style.left=iX+'px';
    else {
      iX=parseInt(e.style.left);
      if(isNaN(iX)) iX=0;
    }
  }
  else if(css && xDef(e.style.pixelLeft)) {
    if(xNum(iX)) e.style.pixelLeft=iX;
    else iX=e.style.pixelLeft;
  }
  return iX;
}

function xMoveTo(e,x,y)
{
  xLeft(e,x);
  xTop(e,y);
}

function xName(e)
{
  if (!e) return e;
  else if (e.id && e.id != "") return e.id;
  else if (e.name && e.name != "") return e.name;
  else if (e.nodeName && e.nodeName != "") return e.nodeName;
  else if (e.tagName && e.tagName != "") return e.tagName;
  else return e;
}

function xNextSib(e,t)
{
  var s = e ? e.nextSibling : null;
  if (t) while (s && s.nodeName != t) { s = s.nextSibling; }
  else while (s && s.nodeType != 1) { s = s.nextSibling; }
  return s;
}

function xNum()
{
  for(var i=0; i<arguments.length; ++i){if(isNaN(arguments[i]) || typeof(arguments[i])!='number') return false;}
  return true;
}

function xOffsetLeft(e)
{
  if (!(e=xGetElementById(e))) return 0;
  if (xDef(e.offsetLeft)) return e.offsetLeft;
  else return 0;
}

function xOffsetTop(e)
{
  if (!(e=xGetElementById(e))) return 0;
  if (xDef(e.offsetTop)) return e.offsetTop;
  else return 0;
}

function xPad(s,len,c,left)
{
  if(typeof s != 'string') s=s+'';
  if(left) {for(var i=s.length; i<len; ++i) s=c+s;}
  else {for (i=s.length; i<len; ++i) s+=c;}
  return s;
}

function xPageX(e)
{
  if (!(e=xGetElementById(e))) return 0;
  var x = 0;
  while (e) {
    if (xDef(e.offsetLeft)) x += e.offsetLeft;
    e = xDef(e.offsetParent) ? e.offsetParent : null;
  }
  return x;
}

function xPageY(e)
{
  if (!(e=xGetElementById(e))) return 0;
  var y = 0;
  while (e) {
    if (xDef(e.offsetTop)) y += e.offsetTop;
    e = xDef(e.offsetParent) ? e.offsetParent : null;
  }
//  if (xOp7Up) return y - document.body.offsetTop; // v3.14, temporary hack for opera bug 130324 (reported 1nov03)
  return y;
}

function xParent(e, bNode)
{
  if (!(e=xGetElementById(e))) return null;
  var p=null;
  if (!bNode && xDef(e.offsetParent)) p=e.offsetParent;
  else if (xDef(e.parentNode)) p=e.parentNode;
  else if (xDef(e.parentElement)) p=e.parentElement;
  return p;
}

function xPreventDefault(e)
{
  if (e && e.preventDefault) e.preventDefault()
  else if (window.event) window.event.returnValue = false;
}

function xPrevSib(e,t)
{
  var s = e ? e.previousSibling : null;
  if (t) while(s && s.nodeName != t) {s=s.previousSibling;}
  else while(s && s.nodeType != 1) {s=s.previousSibling;}
  return s;
}

function xRemoveEventListener(e,eT,eL,cap)
{
  if(!(e=xGetElementById(e))) return;
  eT=eT.toLowerCase();
  if((!xIE4Up && !xOp7Up) && e==window) {
    if(eT=='resize') { window.xREL=null; return; }
    if(eT=='scroll') { window.xSEL=null; return; }
  }
  var eh='e.on'+eT+'=null';
  if(e.removeEventListener) e.removeEventListener(eT,eL,cap);
  else if(e.detachEvent) e.detachEvent('on'+eT,eL);
  else eval(eh);
}

function xResizeTo(e,w,h)
{
  xWidth(e,w);
  xHeight(e,h);
}

function xScrollLeft(e, bWin)
{
  var offset=0;
  if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    var w = window;
    if (bWin && e) w = e;
    if(w.document.documentElement && w.document.documentElement.scrollLeft) offset=w.document.documentElement.scrollLeft;
    else if(w.document.body && xDef(w.document.body.scrollLeft)) offset=w.document.body.scrollLeft;
  }
  else {
    e = xGetElementById(e);
    if (e && xNum(e.scrollLeft)) offset = e.scrollLeft;
  }
  return offset;
}

function xScrollTop(e, bWin)
{
  var offset=0;
  if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    var w = window;
    if (bWin && e) w = e;
    if(w.document.documentElement && w.document.documentElement.scrollTop) offset=w.document.documentElement.scrollTop;
    else if(w.document.body && xDef(w.document.body.scrollTop)) offset=w.document.body.scrollTop;
  }
  else {
    e = xGetElementById(e);
    if (e && xNum(e.scrollTop)) offset = e.scrollTop;
  }
  return offset;
}

function xSetCookie(name, value, expire, path)
{
  document.cookie = name + "=" + escape(value) +
                    ((!expire) ? "" : ("; expires=" + expire.toGMTString())) +
                    "; path=" + ((!path) ? "/" : path);
}

function xShow(e) {return xVisibility(e,1);}


function xStr(s)
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  return true;
}

function xTop(e, iY)
{
  if(!(e=xGetElementById(e))) return 0;
  var css=xDef(e.style);
  if(css && xStr(e.style.top)) {
    if(xNum(iY)) e.style.top=iY+'px';
    else {
      iY=parseInt(e.style.top);
      if(isNaN(iY)) iY=0;
    }
  }
  else if(css && xDef(e.style.pixelTop)) {
    if(xNum(iY)) e.style.pixelTop=iY;
    else iY=e.style.pixelTop;
  }
  return iY;
}

function xVisibility(e, bShow)
{
  if(!(e=xGetElementById(e))) return null;
  if(e.style && xDef(e.style.visibility)) {
    if (xDef(bShow)) e.style.visibility = bShow ? 'visible' : 'hidden';
    return e.style.visibility;
  }
  return null;
}

function xWidth(e,w)
{
  if(!(e=xGetElementById(e))) return 0;
  if (xNum(w)) {
    if (w<0) w = 0;
    else w=Math.round(w);
  }
  else w=-1;
  var css=xDef(e.style);
  if (e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    w = xClientWidth();
  }
  else if(css && xDef(e.offsetWidth) && xStr(e.style.width)) {
    if(w>=0) {
      var pl=0,pr=0,bl=0,br=0;
      if (document.compatMode=='CSS1Compat') {
        var gcs = xGetComputedStyle;
        pl=gcs(e,'padding-left',1);
        if (pl !== null) {
          pr=gcs(e,'padding-right',1);
          bl=gcs(e,'border-left-width',1);
          br=gcs(e,'border-right-width',1);
        }
        // Should we try this as a last resort?
        // At this point getComputedStyle and currentStyle do not exist.
        else if(xDef(e.offsetWidth,e.style.width)){
          e.style.width=w+'px';
          pl=e.offsetWidth-w;
        }
      }
      w-=(pl+pr+bl+br);
      if(isNaN(w)||w<0) return null;
      else e.style.width=w+'px';
    }
    w=e.offsetWidth;
  }
  else if(css && xDef(e.style.pixelWidth)) {
    if(w>=0) e.style.pixelWidth=w;
    w=e.style.pixelWidth;
  }
  return w;
}

function xZIndex(e,uZ)
{
  if(!(e=xGetElementById(e))) return 0;
  if(e.style && xDef(e.style.zIndex)) {
    if(xNum(uZ)) e.style.zIndex=uZ;
    uZ=parseInt(e.style.zIndex);
  }
  return uZ;
}

function xStopPropagation(evt)
{
  if (evt && evt.stopPropagation) evt.stopPropagation();
  else if (window.event) window.event.cancelBubble = true;
}


/**
 * @file common.js
 * @author zero (zero@nzeo.com)
 * @brief ëª?ê°?ì§? ?????©í?? & ê¸°ë³¸?????¼ë?? ???ì£? ??¬ì?©ë????? ???ë°???¤í?¬ë¦½??? ??¨ì????? ëª¨ì??
 **/

/**
 * @brief location.href?????? ??¹ì?? key??? ê°???? return
 **/
String.prototype.getQuery = function(key) {
    var idx = this.indexOf('?');
    if(idx == -1) return null;
    var query_string = this.substr(idx+1, this.length);
    var args = {}
    query_string.replace(/([^=]+)=([^&]*)(&|$)/g, function() { args[arguments[1]] = arguments[2]; });

    var q = args[key];
    if(typeof(q)=="undefined") q = "";

    return q;
}

/**
 * @brief location.href?????? ??¹ì?? key??? ê°???? return
 **/
String.prototype.setQuery = function(key, val) {
    var idx = this.indexOf('?');
    var uri = this;
    uri = uri.replace(/#$/,'');

    if(idx != -1) {
        uri = this.substr(0, idx);
        var query_string = this.substr(idx+1, this.length);
        var args = new Array();
        query_string.replace(/([^=]+)=([^&]*)(&|$)/g, function() { args[arguments[1]] = arguments[2]; });

        args[key] = val;

        var q_list = new Array();
        for(var i in args) {
        if( !args.hasOwnProperty(i) ) continue;
            var arg = args[i];
            if(!arg.toString().trim()) continue;

            q_list[q_list.length] = i+'='+arg;
        }
        uri = uri+"?"+q_list.join("&");
    } else {
        if(val.toString().trim()) uri = uri+"?"+key+"="+val;
    }

    uri = uri.replace(/^https:\/\//i,'http://');
    if(typeof(ssl_actions)!='undefined' && typeof(ssl_actions.length)!='undefined' && uri.getQuery('act')) {
        var act = uri.getQuery('act');
        for(i=0;i<ssl_actions.length;i++) {
            if(ssl_actions[i]==act) {
                uri = uri.replace(/^http:\/\//i,'https://');
                break;
            }
        }
    }
    return encodeURI(uri);
}

/**
 * @breif replace outerHTML
 **/
function replaceOuterHTML(obj, html) {
    if(obj.outerHTML) {
        obj.outerHTML = html;
    } else {
        var dummy = xCreateElement("div"); 
        xInnerHtml(dummy, html);
        var parent = obj.parentNode;
        while(dummy.firstChild) {
            parent.insertBefore(dummy.firstChild, obj);
        }
        parent.removeChild(obj);
    }
}

/**
 * @breif get outerHTML
 **/
function getOuterHTML(obj) {
    if(obj.outerHTML) return obj.outerHTML;
    var dummy = xCreateElement("div");
    dummy.insertBefore(obj, dummy.lastChild);
    return xInnerHtml(dummy);
}

/**
 * @brief xSleep(micro time) 
 **/
function xSleep(sec) {
    sec = sec / 1000;
    var now = new Date();
    var sleep = new Date();
    while( sleep.getTime() - now.getTime() < sec) {
        sleep = new Date();
    }      
}


/**
 * @brief string prototype??¼ë?? trim ??¨ì?? ì¶?ê°?
 **/
String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

/**
 * @brief ì£¼ì?´ì?? ??¸ì??ê°? ????????¼ë?? defined?????? ???ì§? ?????¼ë©´ false return
 **/
function isDef() {
    for(var i=0; i<arguments.length; ++i) {
        if(typeof(arguments[i])=="undefined") return false;
    }
    return true;
}

/**
 * @brief ????????? ??¤í??
 * ??´ë?¤ì?? ????????°ì?? ê´?ë¦¬ë?? ??µí?? window.focus()??±ì?? FF????????? ë¹???·í??ê²? êµ¬í?????
 **/
var winopen_list = new Array();
function winopen(url, target, attribute) {
    try {
        if(target != "_blank" && winopen_list[target]) {
            winopen_list[target].close();
            winopen_list[target] = null;
        }
    } catch(e) {
    }

    if(typeof(target)=='undefined') target = '_blank';
    if(typeof(attribute)=='undefined') attribute = '';
    var win = window.open(url, target, attribute);
    win.focus();
    if(target != "_blank") winopen_list[target] = win;
}

/**
 * @brief ????????¼ë??ë§? ?????°ê¸° 
 * common/tpl/popup_layout.html??? ???ì²??????? ???ë¡?ë³´ë?? XE??´ì?? ????????? ê²½ì?°ì?? ??¬ì??
 **/
function popopen(url, target) {
    if(typeof(target)=="undefined") target = "_blank";
    winopen(url, target, "left=10,top=10,width=10,height=10,scrollbars=no,resizable=yes,toolbars=no");
}

/**
 * @brief ë©???? ë³´ë?´ê¸°???
 **/
function sendMailTo(to) {
    location.href="mailto:"+to;
}

/**
 * @brief url??´ë?? (open_window ê°???? N ê°? ??????ë©? ???ì°½ì?¼ë?? ??????)
 **/
function move_url(url, open_wnidow) {
    if(!url) return false;
    if(typeof(open_wnidow)=='undefined') open_wnidow = 'N';
    if(open_wnidow=='N') open_wnidow = false;
    else open_wnidow = true;

    if(/^\./.test(url)) url = request_uri+url;

    if(open_wnidow) {
        winopen(url);
    } else {
        location.href=url;
    }
    return false;
}

/**
 * @brief ??¹ì?? Element??? display ??µì?? ???ê¸?
 **/
function toggleDisplay(obj, display_type) {
    var obj = xGetElementById(obj);
    if(!obj) return;
    if(!obj.style.display || obj.style.display != 'none') {
        obj.style.display = 'none';
    } else {
        if(display_type) obj.style.display = display_type;
        else obj.style.display = '';
    }
}

/**
 * @brief ë©???°ë?¸ë????? ì¶???¥ì?? (IE?????? ?????????/????????? ì£¼ë????? ?????? ???ê¹? ë°©ì?????)
 **/
function displayMultimedia(src, width, height, auto_start, flashvars) {
    if(src.indexOf('files')==0) src = request_uri+src;
    if(auto_start) auto_start = "true";
    else auto_start = "false";

    var clsid = "";
    var codebase = "";
    var html = "";

    if(typeof(flashvars)=="undefined") flashvars = "";

    if(/\.swf/i.test(src)) {
        clsid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; 
        codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0";
        html = ""+
            "<object classid=\""+clsid+"\" codebase=\""+codebase+"\" width=\""+width+"\" height=\""+height+"\" flashvars=\""+flashvars+"\">"+
            "<param name=\"wmode\" value=\"transparent\" />"+
            "<param name=\"allowScriptAccess\" value=\"sameDomain\" />"+
            "<param name=\"movie\" value=\""+src+"\" />"+
            "<param name=\"quality\" value=\"high\" />"+
            "<param name=\"flashvars\" value=\""+flashvars+"\" />"+
            "<embed src=\""+src+"\" autostart=\""+auto_start+"\"  width=\""+width+"\" height=\""+height+"\" flashvars=\""+flashvars+"\" wmode=\"transparent\"></embed>"+
            "<\/object>";
    } else if(/\.flv/i.test(src)) {
        html = "<embed src=\""+request_uri+"common/tpl/images/flvplayer.swf\" allowfullscreen=\"true\" autostart=\""+auto_start+"\" width=\""+width+"\" height=\""+height+"\" flashvars=\"&file="+src+"&width="+width+"&height="+height+"&autostart="+auto_start+"\" />";
    } else {
        html = "<embed src=\""+src+"\" autostart=\""+auto_start+"\" width=\""+width+"\" height=\""+height+"\"></embed>";
    }
    document.writeln(html);
}

/**
 * @brief ????????°ì????? ??¬ì?©ë????? ??´ì?? ??¬ë?«ë?? ì½???? (ê³????, zbxe???)
 **/
function zbxe_folder_open(id) {
    var open_text_obj = xGetElementById("folder_open_"+id);
    var close_text_obj = xGetElementById("folder_close_"+id);
    var folder_obj = xGetElementById("folder_"+id);
    open_text_obj.style.display = "none";
    close_text_obj.style.display = "block";
    folder_obj.style.display = "block";
}

function zbxe_folder_close(id) {
    var open_text_obj = xGetElementById("folder_open_"+id);
    var close_text_obj = xGetElementById("folder_close_"+id);
    var folder_obj = xGetElementById("folder_"+id);
    open_text_obj.style.display = "block";
    close_text_obj.style.display = "none";
    folder_obj.style.display = "none";
}


/**
 * @brief ????????°ì????? ??¬ì?©í????? ??´ì?? ??¬ë?«ë?? ì½???? (zb5beta beta ??¸í????©ì?¼ë?? ??¨ê²¨ ??????)
 **/
function svc_folder_open(id) {
    var open_text_obj = xGetElementById("_folder_open_"+id);
    var close_text_obj = xGetElementById("_folder_close_"+id);
    var folder_obj = xGetElementById("_folder_"+id);
    open_text_obj.style.display = "none";
    close_text_obj.style.display = "block";
    folder_obj.style.display = "block";
}

function svc_folder_close(id) {
    var open_text_obj = xGetElementById("_folder_open_"+id);
    var close_text_obj = xGetElementById("_folder_close_"+id);
    var folder_obj = xGetElementById("_folder_"+id);
    open_text_obj.style.display = "block";
    close_text_obj.style.display = "none";
    folder_obj.style.display = "none";
}

/**
 * @brief ????????? ê²½ì?? ??´ì?©ì?? ë§?ì¶? ??? ????????°ì?? ??¬ê¸°ë¥? ì¡°ì????´ì?? 
 * ????????? ??´ì?©ì?? ë§?ê²? ??¬ê¸°ë¥? ???ë¦¬ë?? ê²????... ??½ê?? ???ì§???? ??????.. ???.???
 * popup_layout ?????? window.onload ??? ?????? ???ì²????.
 **/
function setFixedPopupSize() {

    if(xGetElementById('popBody')) {
        if(xHeight('popBody')>500) {
            xGetElementById('popBody').style.overflowY = 'scroll';
            xGetElementById('popBody').style.overflowX = 'hidden';
            xHeight('popBody', 500);
        }
    }

    var w = xWidth("popup_content");
    var h = xHeight("popup_content");

    var obj_list = xGetElementsByTagName('div');
    for(i=0;i<obj_list.length;i++) {
        var ww = xWidth(obj_list[i]);
        var id = obj_list[i].id;
        if(id == 'waitingforserverresponse' || id == 'fororiginalimagearea' || id == 'fororiginalimageareabg') continue;
        if(ww>w) w = ww;
    }

    // ????????°ì???????? ë¸???¼ì?°ì?? ???ê´??????? ê°?ë¡? ??½ì????? ì¡°ê?? ??? ?????´ë????? ??????.
    if(xUA.indexOf('windows')>0) {
        if(xOp7Up) w += 10;
        else if(xIE4Up) w += 10;
        else w += 6;
    }
    window.resizeTo(w,h);
   
    var h1 = xHeight(window.document.body);
    window.resizeBy(0,h-h1);

    window.scrollTo(0,0);
}

/**
 * @brief ??´ë??, ê²????ê¸???±ì?? ??´ë¦­????????? ê²½ì?? ?????? ë©???´ë?? ë³´ì?¬ì£¼??? ??¨ì??
 **/
//xAddEventListener(window, 'load', createPopupMenu);
//xAddEventListener(document, 'click', chkPopupMenu);

var loaded_popup_menus = new Array();

/* ë©¤ë?? ?????? ë©???? ?????´ì?´ë?? ?????±í????? ??¨ì?? (ë¬¸ì?? ì¶???¥ì?? ???ë£????????????? ??????) */
function createPopupMenu(evt) {
    var area = xGetElementById("popup_menu_area");
    if(area) return;
    area = xCreateElement("div");
    area.id = "popup_menu_area";
    area.style.visibility = 'hidden';
    document.body.appendChild(area);
}

/* ??´ë¦­ ??´ë²¤??? ë°??????? ??´ë²¤??¸ê?? ??¼ì?´ë?? ????????? ê²???¬í????? ????????? ê·?ì¹???? ë§???¼ë©´ ì²?ë¦? */
function chkPopupMenu(evt) {
    // ??´ì????? ??¸ì???????????ì§? ëª¨ë¥´??? ??????ë©???? ??¨ê??
    var area = xGetElementById("popup_menu_area");
    if(!area) return;

    if(area.style.visibility!="hidden") area.style.visibility="hidden";

    // ??´ë²¤??? ????????? ?????¼ë©´ ë¬´ì??
    var e = new xEvent(evt);
    if(!e) return;

    // ????????? ê°?ì²? êµ¬í??
    var obj = e.target;
    if(!obj) return;

    // obj??? nodeName??? div??? span??? ??????ë©? ?????¬ë??ê¹?ì§? ??????ë¥? ì°¾ì??
    if(obj && obj.nodeName != 'DIV' && obj.nodeName != 'SPAN') obj = obj.parentNode;
    if(!obj || (obj.nodeName != 'DIV' && obj.nodeName != 'SPAN')) return;

    // ê°?ì²´ì?? classNameê°???? êµ¬í??
    var class_name = obj.className;
    if(!class_name) return;

    // className??? ë¶?ë¦?
    var class_name_list = class_name.split(' ');
    var menu_id = '';
    var menu_id_regx = /^([a-zA-Z]+)_([0-9]+)$/ig;
    for(var i in class_name_list) {
        if(menu_id_regx.test(class_name_list[i])) {
            menu_id = class_name_list[i];
            break;
        }
    }
    if(!menu_id) return;

    // moduleëª?ê³? ?????? ë²???¸ê?? ?????¼ë©´ return
    var tmp_arr = menu_id.split('_');
    var module_name = tmp_arr[0];
    var target_srl = tmp_arr[1];
    if(!module_name || !target_srl || target_srl < 1) return;

    // action??´ë????? ê·?ì¹???? ë§?ê²? ??????
    var action_name = "get" + module_name.substr(0,1).toUpperCase() + module_name.substr(1,module_name.length-1) + "Menu";

    // ???ë²???? ë©???´ë?? ???ì²?
    var params = new Array();
    params["target_srl"] = target_srl;
    params["cur_mid"] = current_mid;
    params["cur_act"] = current_url.getQuery('act');
    params["menu_id"] = menu_id;
    params["page_x"] = e.pageX;
    params["page_y"] = e.pageY;

    var response_tags = new Array("error","message","menus");

    if(loaded_popup_menus[menu_id]) {
        displayPopupMenu(params, response_tags, params);
        return;
    }

    show_waiting_message = false;
    exec_xml(module_name, action_name, params, displayPopupMenu, response_tags, params);
    show_waiting_message = true;
}

function displayPopupMenu(ret_obj, response_tags, params) {
    var target_srl = params["target_srl"];
    var menu_id = params["menu_id"];
    var menus = ret_obj['menus'];
    var html = "";

    if(loaded_popup_menus[menu_id]) {
        html = loaded_popup_menus[menu_id];
    } else {
        if(menus) {
            var item = menus['item'];
            if(item.length<1) item = new Array(item);
            if(item.length) {
                for(var i=0;i<item.length;i++) {
                    var url = item[i].url;
                    var str = item[i].str;
                    var icon = item[i].icon;
                    var target = item[i].target;

                    var styleText = "";

                    if(icon) styleText = " style=\"background:url('"+icon+"') no-repeat left center; padding-left:18px; \"";
                    switch(target) {
                        case "popup" :
                                click_str = " onclick=\"popopen('"+url+"','"+target+"')\"; return false;";
                            break;
                        case "self" :
                                click_str = " onclick=\"location.href='"+url+"'\"; return false;";
                            break;
                        case "javascript" :
                                click_str = " onclick=\""+url+"\"; return false;";
                            break;
                        default :
                                click_str = " onclick=\"window.open('"+url+"')\"; return false;";
                            break;
                    }

                    html += '<div class="item" onmouseover="this.className=\'item_on\'" onmouseout="this.className=\'item\'"'+styleText+click_str+'>'+str+'</div> ';
                }
            }
        }
        loaded_popup_menus[menu_id] =  html;
    }

    // ?????´ì?? ì¶????
    if(html) {
        var area = xGetElementById("popup_menu_area");
        xInnerHtml(area, "<div class=\"box\">"+html+"</div>");
        xLeft(area, params["page_x"]);
        xTop(area, params["page_y"]);
        if(xWidth(area)+xLeft(area)>xClientWidth()+xScrollLeft()) xLeft(area, xClientWidth()-xWidth(area)+xScrollLeft());
        if(xHeight(area)+xTop(area)>xClientHeight()+xScrollTop()) xTop(area, xClientHeight()-xHeight(area)+xScrollTop());
        area.style.visibility = "visible";
    }
}

/**
 * @brief ì¶?ì²?/ë¹?ì¶?ì²?,??¤í?¬ë??,???ê³?ê¸°ë?¥ë?? ??¹ì?? srl??? ?????? ??¹ì?? module/action??? ??¸ì???????? ??¨ì??
 **/
function doCallModuleAction(module, action, target_srl) {
    var params = new Array();
    params['target_srl'] = target_srl;
    params['cur_mid'] = current_mid;
    exec_xml(module, action, params, completeCallModuleAction);
}

function completeCallModuleAction(ret_obj, response_tags) {
    if(ret_obj['message']!='success') alert(ret_obj['message']);
    location.reload();
}

/**
 * @brief ???ì§? ?????? (??¬ë?? ??´ê¸°) 
 **/
function open_calendar(fo_id, day_str, callback_func) {
    if(typeof(day_str)=="undefined") day_str = "";

    var url = "./common/tpl/calendar.php?";
    if(fo_id) url+="fo_id="+fo_id;
    if(day_str) url+="&day_str="+day_str;
    if(callback_func) url+="&callback_func="+callback_func;

    popopen(url, 'Calendar');
}

/* ??¸ì?´ì????? (lang_type) ì¿???¤ê?? ë³?ê²? */
function doChangeLangType(obj) {
    if(typeof(obj)=="string") {
        setLangType(obj);
    } else {
        var val = obj.options[obj.selectedIndex].value;
        setLangType(val);
    }
    location.reload();
}
function setLangType(lang_type) {
    var expire = new Date();
    expire.setTime(expire.getTime()+ (7000 * 24 * 3600000));
    xSetCookie('lang_type', lang_type, expire);
}

/* ë¯¸ë¦¬ë³´ê¸° */
function doDocumentPreview(obj) {
    var fo_obj = obj;
    while(fo_obj.nodeName != "FORM") {
        fo_obj = fo_obj.parentNode;
    }
    if(fo_obj.nodeName != "FORM") return;
    var editor_sequence = fo_obj.getAttribute('editor_sequence');

    var content = editorGetContent(editor_sequence);

    var win = window.open("","previewDocument","toolbars=no,width=700px;height=800px,scrollbars=yes,resizable=yes");

    var dummy_obj = xGetElementById("previewDocument");

    if(!dummy_obj) {
        var fo_code = '<form id="previewDocument" target="previewDocument" method="post" action="'+request_uri+'">'+
                      '<input type="hidden" name="module" value="document" />'+
                      '<input type="hidden" name="act" value="dispDocumentPreview" />'+
                      '<input type="hidden" name="content" />'+
                      '</form>';
        var dummy = xCreateElement("DIV");
        xInnerHtml(dummy, fo_code);
        window.document.body.insertBefore(dummy,window.document.body.lastChild);
        dummy_obj = xGetElementById("previewDocument");
    }

    if(dummy_obj) {
        dummy_obj.content.value = content;
        dummy_obj.submit();
    }
}

/* ê²????ê¸? ?????? */
function doDocumentSave(obj) {
    var editor_sequence = obj.form.getAttribute('editor_sequence');
    var prev_content = editorRelKeys[editor_sequence]['content'].value;
    if(typeof(editor_sequence)!='undefined' && editor_sequence && typeof(editorRelKeys)!='undefined' && typeof(editorGetContent)=='function') {
        var content = editorGetContent(editor_sequence);
        editorRelKeys[editor_sequence]['content'].value = content;
    }

    var oFilter = new XmlJsFilter(obj.form, "member", "procMemberSaveDocument", completeDocumentSave);
    oFilter.addResponseItem("error");
    oFilter.addResponseItem("message");
    oFilter.addResponseItem("document_srl");
    oFilter.proc();

    editorRelKeys[editor_sequence]['content'].value = prev_content;
    return false;
}

function completeDocumentSave(ret_obj) {
    xGetElementsByAttribute('input', 'name', 'document_srl')[0].value = ret_obj['document_srl'];
    alert(ret_obj['message']);
}

/* ?????¥ë?? ê²????ê¸? ë¶???¬ì?¤ê¸° */
var objForSavedDoc = null;
function doDocumentLoad(obj) {
    // ?????¥ë?? ê²????ê¸? ëª©ë?? ë¶???¬ì?¤ê¸°
    objForSavedDoc = obj.form;
    popopen(request_uri.setQuery('module','member').setQuery('act','dispSavedDocumentList'));
}

/* ?????¥ë?? ê²????ê¸???? ?????? */
function doDocumentSelect(document_srl) {
    if(!opener || !opener.objForSavedDoc) {
        window.close();
        return;
    }

    // ê²????ê¸???? ê°???¸ì????? ??±ë?????ê¸?
    opener.location.href = opener.current_url.setQuery('document_srl', document_srl).setQuery('act', 'dispBoardWrite');
    window.close();
}


/* ??¤í?? ???ë³? */
function viewSkinInfo(module, skin) {
    popopen("./?module=module&act=dispModuleSkinInfo&selected_module="+module+"&skin="+skin, 'SkinInfo');
}

/* ì²´í?¬ë????? ?????? */
function checkboxSelectAll(form, name, option){ 
    var value;
    var fo_obj = xGetElementById(form);
    for ( var i = 0 ; i < fo_obj.length ; i++ ){
        if(typeof(option) == "undefined") {
            var select_mode = fo_obj[i].checked;
            if ( select_mode == 0 ){
                value = true;
                select_mode = 1;
            }else{
                value = false;
                select_mode = 0;
            }
        }
        else if(option == true) value = true
        else if(option == false) value = false

        if(fo_obj[i].name == name) fo_obj[i].checked = value;
    }
}

/* ì²´í?¬ë????¤ë?? ??¤í?? */
function clickCheckBoxAll(form, name) {
    var fo_obj = xGetElementById(form);
    for ( var i = 0 ; i < fo_obj.length ; i++ ){
        if(fo_obj[i].name == name) fo_obj[i].click();
    }
}

/* ê´?ë¦¬ì??ê°? ë¬¸ì??ë¥? ê´?ë¦¬í??ê¸? ?????´ì?? ????????? ??¸ì????? ??£ì?? */
var addedDocument = new Array();
function doAddDocumentCart(obj) {
    var srl = obj.value;
    addedDocument[addedDocument.length] = srl;
    setTimeout(function() { callAddDocumentCart(addedDocument.length); }, 100);
}

function callAddDocumentCart(document_length) {
    if(addedDocument.length<1 || document_length != addedDocument.length) return;
    var params = new Array();
    params["srls"] = addedDocument.join(",");
    exec_xml("document","procDocumentAdminAddCart", params, null);
    addedDocument = new Array();
}

/* ff??? rgb(a,b,c)ë¥? #... ë¡? ë³?ê²? */
function transRGB2Hex(value) {
    if(!value) return value;
    if(value.indexOf('#') > -1) return value.replace(/^#/, '');

    if(value.toLowerCase().indexOf('rgb') < 0) return value;
    value = value.replace(/^rgb\(/i, '').replace(/\)$/, '');
    value_list = value.split(',');

    var hex = '';
    for(var i = 0; i < value_list.length; i++) {
        var color = parseInt(value_list[i], 10).toString(16);
        if(color.length == 1) color = '0'+color;
        hex += color;
    }
    return hex;
}

/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/

var Base64 = {

    // private property
    _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

    // public method for encoding
    encode : function (input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;

        input = Base64._utf8_encode(input);

        while (i < input.length) {

            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);

            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;

            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }

            output = output +
            this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
            this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

        }

        return output;
    },

    // public method for decoding
    decode : function (input) {
        var output = "";
        var chr1, chr2, chr3;
        var enc1, enc2, enc3, enc4;
        var i = 0;

        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

        while (i < input.length) {

            enc1 = this._keyStr.indexOf(input.charAt(i++));
            enc2 = this._keyStr.indexOf(input.charAt(i++));
            enc3 = this._keyStr.indexOf(input.charAt(i++));
            enc4 = this._keyStr.indexOf(input.charAt(i++));

            chr1 = (enc1 << 2) | (enc2 >> 4);
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
            chr3 = ((enc3 & 3) << 6) | enc4;

            output = output + String.fromCharCode(chr1);

            if (enc3 != 64) {
                output = output + String.fromCharCode(chr2);
            }
            if (enc4 != 64) {
                output = output + String.fromCharCode(chr3);
            }

        }

        output = Base64._utf8_decode(output);

        return output;

    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}

/* select - option??? disabled=disabled ?????±ì?? IE????????? ì²´í?¬í??ê¸? ?????? ??¨ì?? */
if(xIE4Up) {
    xAddEventListener(window, 'load', activateOptionDisabled);

    function activateOptionDisabled(evt) {
        var sels = xGetElementsByTagName('select');
        for(var i=0; i < sels.length; i++){
            var disabled_exists = false;
            for(var j=0; j < sels[i].options.length; j++) {
                if(sels[i].options[j].disabled) {
                    sels[i].options[j].style.color = '#CCCCCC';
                    disabled_exists = true;
                }
            }

            if(!disabled_exists) continue;
            
            sels[i].oldonchange = sels[i].onchange;
            sels[i].onchange = function() {  
                if(this.options[this.selectedIndex].disabled) {
                    if(this.options.length<=1) this.selectedIndex = -1;
                    else if(this.selectedIndex < this.options.length - 1) this.selectedIndex++;
                    else this.selectedIndex--;
                } else {
                    if(this.oldonchange) this.oldonchange();
                }
            }

            if(sels[i].selectedIndex >= 0 && sels[i].options[ sels[i].selectedIndex ].disabled) sels[i].onchange();

        }
    }
}


/* ë³´ì?? ë¡?ê·¸ì?? ëª¨ë??ë¡? ?????? */
function toggleSecuritySignIn() {
    var href = location.href;
    if(/https:\/\//i.test(href)) location.href = href.replace(/^https/i,'http');
    else location.href = href.replace(/^http/i,'https');
}   

/* ????????¸í????? ë¬¸ì?? */
if(typeof(resizeImageContents) == 'undefined')
{
    function resizeImageContents() {}
}

/**
 * @file   common/js/xml_handler.js
 * @author zero <zero@nzeo.com>
 * @brief  zbxe??´ì????? ajaxê¸°ë?¥ì?? ??´ì?©í?¨ì?? ?????? module, actë¥? ??? ??¬ì?©í??ê¸? ?????? ???ë°???¤í?¬ë¦½???
 **/

// xml handler??? ??´ì?©í????? user function
var show_waiting_message = true;
function exec_xml(module, act, params, callback_func, response_tags, callback_func_arg, fo_obj) {
    var oXml = new xml_handler();
    oXml.reset();
    for(var key in params) {
	if(!params.hasOwnProperty(key)) continue;
        var val = params[key];
        oXml.addParam(key, val);
    }
    oXml.addParam("module", module);
    oXml.addParam("act", act);

    if(typeof(response_tags)=="undefined" || response_tags.length<1) response_tags = new Array('error','message');

    oXml.request(xml_response_filter, oXml, callback_func, response_tags, callback_func_arg, fo_obj);
}

// ê²°ê³¼ ì²?ë¦? ??? callback_func??? ???ê²¨ì??
function xml_response_filter(oXml, callback_func, response_tags, callback_func_arg, fo_obj) {
    var xmlDoc = oXml.getResponseXml();
    if(!xmlDoc) return null;

    var waiting_obj = xGetElementById("waitingforserverresponse");
    if(waiting_obj) waiting_obj.style.visibility = "hidden";

    var ret_obj = oXml.toZMsgObject(xmlDoc, response_tags);
    if(ret_obj["error"]!=0) {
        alert(ret_obj["message"]);
        return null;
    }

    if(ret_obj["redirect_url"]) {
        location.href=ret_obj["redirect_url"];
        return null;
    }

    if(!callback_func) return null;

    callback_func(ret_obj, response_tags, callback_func_arg, fo_obj);

    return null;
}

// xml handler
function xml_handler() {
    this.objXmlHttp = null;
    this.method_name = null;
    this.xml_path = request_uri+"index.php";

    this.params = new Array();

    this.reset = xml_handlerReset;
    this.getXmlHttp = zGetXmlHttp;
    this.request = xml_handlerRequest;
    this.setPath = xml_handlerSetPath;
    this.addParam = xml_handlerAddParam;
    this.getResponseXml = xml_handlerGetResponseXML;
    this.toZMsgObject = xml_handlerToZMsgObject;
    this.parseXMLDoc = xml_parseXmlDoc;

    this.objXmlHttp = this.getXmlHttp();
}

function zGetXmlHttp() {
    if (window.XMLHttpRequest) return new XMLHttpRequest();
    else if (window.ActiveXObject) {
        try {
            return new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
    }       
    return null;
}

function xml_handlerRequest(callBackFunc, xmlObj, callBackFunc2, response_tags, callback_func_arg, fo_obj) {
    var rd = "";
    rd += "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
    +  "<methodCall>\n"
    +  "<params>\n"

    for (var key in this.params) {
        if(!this.params.hasOwnProperty(key)) continue;
        var val = this.params[key];
        rd += "<"+key+"><![CDATA["+val+"]]></"+key+">\n";
    }

    rd += "</params>\n"
    +  "</methodCall>\n";

    // ssl action
    if(typeof(ssl_actions)!='undefined' && typeof(ssl_actions.length)!='undefined' && typeof(this.params['act'])!='undefined' && /^https:\/\//i.test(location.href) ) {
        var action = this.params['act'];
        for(i=0;i<ssl_actions.length;i++) {
            if(ssl_actions[i]==action) {
                this.xml_path = this.xml_path.replace(/^http:\/\//i,'https://');
                break;
            }
        }
    }

    if(this.objXmlHttp.readyState!=0) {
        this.objXmlHttp.abort();
        this.objXmlHttp = this.getXmlHttp();
    }
    this.objXmlHttp.onreadystatechange = function () {callBackFunc(xmlObj, callBackFunc2, response_tags, callback_func_arg, fo_obj)};

    // ëª¨ë?? xml??°ì?´í?°ë?? POSTë°©ì????¼ë?? ??????. try-cachtë¬¸ì?¼ë?? ??¤ë?? ë°??????? ???ì²?
    try {

		// ?????? ë§???? kkh -080909
        this.objXmlHttp.open("POST", this.xml_path, true);

    } catch(e) {
        alert(e);
        return;
    }

    // ajax ??µì??ì¤? ???ê¸? ë©???¸ì?? ì¶???? (show_waiting_messageê°???? falseë¡? ??¸í????? ë³´ì?´ì?? ??????)
    var waiting_obj = xGetElementById("waitingforserverresponse");
    if(show_waiting_message && waiting_obj) {
        xInnerHtml(waiting_obj, waiting_message);

        xTop(waiting_obj, xScrollTop()+20);
        xLeft(waiting_obj, xScrollLeft()+20);
        waiting_obj.style.visibility = "visible";
    }

    this.objXmlHttp.send(rd);
}

function xml_handlerSetPath(path) {
    this.xml_path = "./"+path;
}


function xml_handlerReset() {
    this.objXmlHttp = this.getXmlHttp();
    this.params = new Array();
}

function xml_handlerAddParam(key, val) {
    this.params[key] = val;
}

function xml_handlerGetResponseXML() {
    if(this.objXmlHttp && this.objXmlHttp.readyState == 4 && isDef(this.objXmlHttp.responseXML)) {
        var xmlDoc = this.objXmlHttp.responseXML;
        this.reset();
        return xmlDoc;
    }
    return null;
}

function xml_parseXmlDoc(dom) {
    if(!dom) return;

    var ret_obj = new Array();

    var obj = dom.firstChild;
    if(!obj) return;

    while(obj) {
        if(obj.nodeType == 1) {

            var name = obj.nodeName;
            var value = null;

            if(obj.childNodes.length==1 && obj.firstChild.nodeType != 1) {
                value = obj.firstChild.nodeValue;
            } else {
                value = this.parseXMLDoc(obj);
            }

            if(typeof(ret_obj[name])=='undefined') {
                ret_obj[name] = value;
            } else {
                if(ret_obj[name].length>0) {
                    ret_obj[name][ret_obj[name].length] = value;
                } else {
                    var tmp_value = ret_obj[name];
                    ret_obj[name] = new Array();
                    ret_obj[name][ret_obj[name].length] = tmp_value;
                    ret_obj[name][ret_obj[name].length] = value;
                }
            }

        }
        obj = obj.nextSibling;
    }
    return ret_obj;
}

function xml_handlerToZMsgObject(xmlDoc, tags) {
    if(!xmlDoc) return null;
    if(!tags) tags = new Array("error","message");
    tags[tags.length] = "redirect_url";
    tags[tags.length] = "act";

    var parsed_array = this.parseXMLDoc(xmlDoc.getElementsByTagName('response')[0]);

    var obj_ret = new Array();
    for(var i=0; i<tags.length; i++) {
        var key = tags[i];
        if(parsed_array[key]) obj_ret[key] = parsed_array[key];
        else obj_ret[key] = null;
    }
    return obj_ret;
}

/**
 * @file   common/js/xml_js_filter.js
 * @author zero (zero@nzeo.com)
 * @brief  xml filter?????? ??¬ì?©ë?? js
 *
 * zbxe ?????? form??? ????????? ???????????? ??¬ë????±ì?? ???ì²?ë¦¬í??ê³? xml_handler.js??? exec_xml()??? ??µí?´ì??
 * ??¹ì?? ëª¨ë??ê³¼ì?? ajax ??µì????? ??µí?? processë¥? ì§??????????
 **/

var alertMsg = new Array();
var target_type_list = new Array();
var notnull_list = new Array();
var extra_vars = new Array();

/**
 * @function filterAlertMessage
 * @brief ajaxë¡? ???ë²???? ???ì²???? ê²°ê³¼ë¥? ì²?ë¦¬í?? callback_function??? ì§???????ì§? ????????? ??? ??¸ì???????? ê¸°ë³¸ ??¨ì??
 **/
function filterAlertMessage(ret_obj) {
    var error = ret_obj["error"];
    var message = ret_obj["message"];
    var act = ret_obj["act"];
    var redirect_url = ret_obj["redirect_url"];
    var url = location.href;

    if(typeof(message)!="undefined"&&message&&message!="success") alert(message);

    if(typeof(act)!="undefined" && act) url = current_url.setQuery("act", act);
    else if(typeof(redirect_url)!="undefined" && redirect_url) url = redirect_url;

    if(url == location.href) url = url.replace(/#(.+)$/,'');

    location.href = url;
}

/**
 * @class XmlJsFilter
 * @authro zero (zero@nzeo.com)
 * @brief form elements, module/act, callback_user_func??? ??´ì?©í????? ???ë²???? ajaxë¡? form ??°ì?´í?°ë?? ???ê¸°ê?? ê²°ê³¼ë¥? ë°??????¤ë?? js class
 **/
function XmlJsFilter(form_object, module, act, callback_user_func) {
    this.field = new Array();
    this.parameter = new Array();
    this.response = new Array();

    this.fo_obj = form_object;
    this.module = module;
    this.act = act;
    this.user_func = callback_user_func;
    this.setFocus = XmlJsFilterSetFocus;
    this.addFieldItem = XmlJsFilterAddFieldItem;
    this.addParameterItem = XmlJsFilterAddParameterItem;
    this.addResponseItem = XmlJsFilterAddResponseItem;
    this.getValue = XmlJsFilterGetValue;
    this.executeFilter = XmlJsFilterExecuteFilter;
    this.checkFieldItem = XmlJsFilterCheckFieldItem;
    this.getParameterParam = XmlJsFilterGetParameterParam;
    this.alertMsg = XmlJsFilterAlertMsg;
    this.proc = XmlJsFilterProc;
}

function XmlJsFilterSetFocus(target_name) {
    var obj = this.fo_obj[target_name];
    if(typeof(obj)=='undefined' || !obj) return;
    
    var length = obj.length;
    try {
        if(typeof(length)!='undefined') {
            obj[0].focus();
        } else {
            obj.focus();
        }
    } catch(e) {
    }
}

function XmlJsFilterAddFieldItem(target, required, minlength, maxlength, equalto, filter) {
    var obj = new Array(target, required, minlength, maxlength, equalto, filter);
    this.field[this.field.length] = obj;
}

function XmlJsFilterAddParameterItem(param, target) {
    var obj = new Array(param, target);
    this.parameter[this.parameter.length] = obj;
}

function XmlJsFilterAddResponseItem(name) {
    this.response[this.response.length] = name;
}

function XmlJsFilterGetValue(target_name) {
    var obj = this.fo_obj[target_name];
    if(typeof(obj)=='undefined' || !obj) return '';
    var value = '';
    var length = obj.length;
    var type = obj.type;
    if((typeof(type)=='undefined'||!type) && typeof(length)!='undefined' && typeof(obj[0])!='undefined' && length>0) type = obj[0].type;
    else length = 0;

    switch(type) {
        case 'checkbox' :
                if(length>0) {
                    var value_list = new Array();
                    for(var i=0;i<length;i++) {
                        if(obj[i].checked) value_list[value_list.length] = obj[i].value;
                    }
                    value = value_list.join('|@|');
                } else {
                    if(obj.checked) value = obj.value;
                    else value = '';
                }
            break;
        case 'radio' :
                if(length>0) {
                    for(var i=0;i<length;i++) {
                        if(obj[i].checked) value = obj[i].value;
                    }
                } else {
                    if(obj.checked) value = obj.value;
                    else value = '';
                }
            break;
        case 'select' :
        case 'select-one' :
                if(obj.selectedIndex>=0) value = obj.options[obj.selectedIndex].value;
            break;
        default :
                if(length>0 && target_type_list[target_name]) {
                    switch(target_type_list[target_name]) {
                        case 'kr_zip' :
                                var val1 = obj[0].value;
                                var val2 = obj[1].value;
                                if(val1&&val2) {
                                    value = val1+'|@|'+val2;
                                }
                            break;
                        case 'tel' :
                                var val1 = obj[0].value;
                                var val2 = obj[1].value;
                                var val3 = obj[2].value;
                                if(val1&&val2&&val3) {
                                    value = val1+'|@|'+val2+'|@|'+val3;
                                }
                            break;
                    }

                } else {
                    value = obj.value;
                }
            break;
    }

    if(typeof(value)=='undefined'||!value) return '';
    return value.trim();
}

function XmlJsFilterExecuteFilter(filter, value) {
    switch(filter) {
        case "email" :
        case "email_address" :
                var regx = /^[_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+)*@[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*$/;
                return regx.test(value);
            break;
        case "userid" :
        case "user_id" :
                var regx = /^[a-zA-Z]+([_0-9a-zA-Z]+)*$/;
                return regx.test(value);
            break;
        case "homepage" :
                var regx = /^(http|https|ftp|mms):\/\/[0-9a-z-]+(\.[_0-9a-z-\/\~]+)+(:[0-9]{2,4})*$/;       
                return regx.test(value);
            break;
        case "korean" :
                var regx = /^[°¡-ÆR?-???]*$/; 
                return regx.test(value);
            break;
        case "korean_number" :
                var regx = /^[°¡-ÆR?-???0-9]*$/; 
                return regx.test(value);
            break;
        case "alpha" :
                var regx = /^[a-zA-Z]*$/; 
                return regx.test(value);
            break;
        case "alpha_number" :
                var regx = /^[a-zA-Z][a-zA-Z0-9\_]*$/; 
                return regx.test(value);
            break;
        case "number" :
            return !isNaN(value);
        break;
    }

    return null;
}

function XmlJsFilterAlertMsg(target, msg_code, minlength, maxlength) {
    var target_msg = "";

    if(alertMsg[target]!='undefined') target_msg = alertMsg[target];
    else target_msg = target;

    var msg = "";
    if(typeof(alertMsg[msg_code])!='undefined') {
        if(alertMsg[msg_code].indexOf('%s')>=0) msg = alertMsg[msg_code].replace('%s',target_msg);
        else msg = target_msg+alertMsg[msg_code];
    } else {
        msg = msg_code;
    }

    if(typeof(minlength)!='undefined' && typeof(maxlength)!='undefined') msg += "("+minlength+"~"+maxlength+")";

    alert(msg);
    this.setFocus(target);

    return false;
}

function XmlJsFilterCheckFieldItem() {
    for(var i=0; i<extra_vars.length;i++) {
        var name = extra_vars[i];
        this.addFieldItem(name, false, 0, 0, "", "");
    }

    for(var i=0; i<this.field.length;i++) {
        var item = this.field[i];
        var target = item[0];
        var required = item[1];
        var minlength = item[2];
        var maxlength = item[3];
        var equalto = item[4];
        var filter = item[5].split(",");

        if(typeof(this.fo_obj[target])=='undefined') continue;

        for(var j=0; j<notnull_list.length; j++) {
            if(notnull_list[j]==target) required = true;
        }

        var value = this.getValue(target);
        if(!required && !value) continue;
        if(required && !value && this.fo_obj[target]) return this.alertMsg(target,'isnull');

        if(minlength>0 && maxlength>0 && (value.length < minlength || value.length > maxlength)) return this.alertMsg(target, 'outofrange', minlength, maxlength);

        if(equalto) {
            var equalto_value = this.getValue(equalto);
            if(equalto_value != value) return this.alertMsg(target, 'equalto');
        }

        if(filter.length && filter[0]) {
            for(var j=0;j<filter.length;j++) {
                var filter_item = filter[j];
                if(!this.executeFilter(filter_item, value)) return this.alertMsg(target, "invalid_"+filter_item);
            }
        }
    }
    return true;
} 

function XmlJsFilterGetParameterParam() {
    if(!this.fo_obj) return new Array();

    var prev_name = '';
    if(this.parameter.length<1) {
        for(var i=0;i<this.fo_obj.length;i++) {
            var name = this.fo_obj[i].name;
            if(typeof(name)=='undefined'||!name||name==prev_name) continue;
            this.addParameterItem(name, name);
            prev_name = name;
        }
    }

    var params = new Array();
    for(var i=0; i<this.parameter.length;i++) {
        var item = this.parameter[i];
        var param = item[0];
        var target = item[1];
        var value = this.getValue(target);
        params[param] = value;
    }
    return params;
}

function XmlJsFilterProc(confirm_msg) {
    var result = this.checkFieldItem();
    if(!result) return false;

    if(typeof(confirm_msg)=='undefined') confirm_msg = '';

    var params = this.getParameterParam();
    var response = this.response;
    if(confirm_msg && !confirm(confirm_msg)) return false;
    if(!this.act) {
        this.user_func(this.fo_obj, params);
        return true;
    }
    exec_xml(this.module, this.act, params, this.user_func, response, params, this.fo_obj);

    return null;
}

// form proc
function procFilter(fo_obj, filter_func) {
    // formë¬? ?????? ???ì§???? ????????°ê?? ??¸í???????? ?????? ê²½ì?? ????????°ì?? ê°?ê³? ì§??????? content fieldë¥? sync
    var editor_sequence = fo_obj.getAttribute('editor_sequence');
    if(typeof(editor_sequence)!='undefined' && editor_sequence && typeof(editorRelKeys)!='undefined') { 
        var content = editorGetContent(editor_sequence);

        var dummy = xCreateElement("div");
        xInnerHtml(dummy, content);

        // IE?????? ì»¨í??ì¸? ???ì²´ë?? P???ê·¸ë?? ê°???¸ë?? ê²½ì?°ê?? ?????´ì?? ??? ???ë¯¸ì????? P???ê·¸ë?? ???ê±?
        if(dummy.firstChild && dummy.firstChild.nodeName == 'P' && dummy.firstChild == dummy.lastChild) {
            var content = xInnerHtml(dummy.firstChild);
            xInnerHtml(dummy,content);
        }

        // img/a ???ê·¸ì?? ????????? ?????? ê²½ë?? ??¬ì?¤ì?? (IEë¸???¼ì?°ì???????? ???ì§???? ????????°ë?´ì?? ê²½ë??ë¥? ?????? ê²½ë??ë¡? ë°?ê¾¸ë?? ë²?ê·¸ë??ë¬¸ã??)
        var imgTags = xGetElementsByTagName('IMG', dummy);
        for(var i=0;i<imgTags.length;i++) {
            if(imgTags[i].src.indexOf(request_uri)!=-1) {
                imgTags[i].src = imgTags[i].src.replace(/(.*)files\/(.*)/i,'files/$2');
            }
        }
        var aTags = xGetElementsByTagName('A', dummy);
        for(var i=0;i<aTags.length;i++) {
            if(aTags[i].href.indexOf(request_uri)!=-1) {
                aTags[i].href = aTags[i].href.replace(/(.*)\?module=file&(.*)/i,'./?module=file&$2');
            }
        }
        var content = xInnerHtml(dummy);
        editorRelKeys[editor_sequence]['content'].value = content;
    }

    filter_func(fo_obj);
    return false;
}

/**
 * @brief ì¹´ì?´í?? ???ë³? ???ì§? javascript
 * window.onload ??´ë²¤??? ?????? counter ëª¨ë????? ??¸ì????????.
 **/

// ??´ë²¤??? ??±ë??
//kkh ë§????
//xAddEventListener(window,'load',doCallCounter);

// counter ëª¨ë????? ??¸ì???????? ??¨ì??
function doCallCounter() {
    show_waiting_message = false;
    exec_xml('counter','procCounterExecute');
    show_waiting_message = true;
}

var url_regx = /((http|https|ftp|news|telnet|irc):\/\/(([0-9a-z\-._~!$&'\(\)*+,;=:]|(%[0-9a-f]{2}))*\@)?((\[(((([0-9a-f]{1,4}:){6}([0-9a-f]{1,4}:[0-9a-f]{1,4})|(([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])){3}[0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])))|(::([0-9a-f]{1,4}:){5}([0-9a-f]{1,4}:[0-9a-f]{1,4})|(([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])){3}[0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])))|(([0-9a-f]{1,4})?::([0-9a-f]{1,4}:){4}([0-9a-f]{1,4}:[0-9a-f]{1,4})|(([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])){3}[0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])))|((([0-9a-f]{1,4}:)?[0-9a-f]{1,4})?::([0-9a-f]{1,4}:){3}([0-9a-f]{1,4}:[0-9a-f]{1,4})|(([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])){3}[0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])))|((([0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::([0-9a-f]{1,4}:){2}([0-9a-f]{1,4}:[0-9a-f]{1,4})|(([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])){3}[0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])))|((([0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:([0-9a-f]{1,4}:[0-9a-f]{1,4})|(([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])){3}[0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])))|((([0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::([0-9a-f]{1,4}:[0-9a-f]{1,4})|(([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])){3}[0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])))|((([0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4})|((([0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::))|(v[0-9a-f]+.[0-9a-z\-._~!$&'\(\)*+,;=:]+))\])|(([0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5])){3}[0-9]|([1-9][0-9])|(1[0-9][0-9])|(2[0-4][0-9])|(25[0-5]))|(([0-9a-z\-._~!$&'\(\)*+,;=]|(%[0-9a-f]{2}))+))(:[0-9]*)?(\/([0-9a-z\-._~!$&'\(\)*+,;=:@]|(%[0-9a-f]{2}))*)*(\?([0-9a-z\-._~!$&'\(\)*+,;=:@\/\?]|(%[0-9a-f]{2}))*)?(#([0-9a-z\-._~!$&'\(\)*+,;=:@\/\?]|(%[0-9a-f]{2}))*)?)/i;
function replaceHrefLink(target_obj)
{
    var obj_list = new Array();
    var obj = target_obj;
    while(obj) {
        obj_list[obj_list.length] = obj;
        obj = obj.nextSibling;
    }
    
    for(var i=0;i<obj_list.length;i++) {
        var obj = obj_list[i];
        var pObj = obj.parentNode;
        if(!pObj) continue;

        var pN = pObj.nodeName.toLowerCase();
        if(pN == 'a' || pN == 'pre' || pN == 'xml' || pN == 'textarea' || pN == 'input')
            continue;
        
        if(obj.nodeType == 3 && obj.data && url_regx.test(obj.data) ) {
            var html = obj.nodeValue.split('<');
            for(var i=0;i<html.length;i++) {
                var html2 = html[i].split('>');
                for(var j=0;j<html2.length;j++)
                    html2[j] = html2[j].replace(url_regx,"<a href=\"$1\" onclick=\"window.open(this.href); return false;\">$1<\/a>");
                html[i] = html2.join('&gt;');
            }
            var output = html.join('&lt;');
            var dummy = xCreateElement('span');
            xInnerHtml(dummy, output);
            pObj.insertBefore(dummy, obj);
            pObj.removeChild(obj);
        }
        else if(obj.nodeType == 1 && obj.firstChild)
            replaceHrefLink(obj.firstChild);
    }
}

function addUrlLink() {
    var objs = xGetElementsByClassName('xe_content');
    if(objs.length<1) return;
    for(var i=0;i<objs.length;i++) {
        if(url_regx.test(xInnerHtml(objs[i]))) replaceHrefLink(objs[i].firstChild);
    }
}

//xAddEventListener(window,'load', addUrlLink);

/**
 * @brief ???ë©´ë?´ì????? ?????? ??????ë³´ë?? ??´ë?¸ì??ê°? ??¬ë©´ ë¦¬ì?¬ì?´ì??ë¥? ???ê³? ??´ë¦­??? ???ë³¸ì?? ë³´ì?¬ì????? ??????ë¡? ë³?ê²?
 **/
var imageGalleryIndex = new Array();
function resizeImageContents() {
    // ??´ë?¸ì?? ???ê·? ???ê·? ?????????
    var img_regx = new RegExp("<img","im");
    var site_regx = new RegExp("^"+request_uri,"im");
    
    // xe_content ??´ì?? ??´ë?¸ì?? ????????¤ì?? ?????? ì²´í??
    var xe_objs = xGetElementsByClassName("xe_content");
    for(var j=0;j<xe_objs.length;j++) {

        imageGalleryIndex[j] = new Array();

        var html = xInnerHtml(xe_objs[j]);
        if(!img_regx.test(html)) continue;

        // ëª¨ë?? ??´ë?¸ì????? ?????? ì²´í?¬ë?? ??????
        var objs = xGetElementsByTagName("IMG", xe_objs[j]);

        for(var i=0;i<objs.length;i++) {
            var obj = objs[i];

            // zbXE??´ë?? ???ë¡?ê·¸ë?? ?????? ??¤í?¨ì?? ??´ë?¸ì????¼ë©´ ??´ë?¸ì?? ë¦¬ì?¬ì?´ì??ë¥? ???ì§? ??????
            if(!/\/(modules|addons|classes|common|layouts|libs|widgets)\//i.test(obj.src)) {
                var parent = obj.parentNode;
                while(parent) {
                    if(/(document|comment)_([0-9]*)_([0-9]*)/i.test(parent.className) ) break;
                    parent = parent.parentNode;
                }
                if(!parent) continue;

                var dummy = xCreateElement("div");
                dummy.style.visibility = "hidden";
                dummy.style.border = "1px solid red";
                parent.parentNode.insertBefore(dummy, parent);

                var parent_width = xWidth(dummy);
                parent.parentNode.removeChild(dummy);
                dummy = null;

                var obj_width = xWidth(obj);
                var obj_height = xHeight(obj);

                // ë§???? ????????? ??´ë?¸ì????? ê°?ë¡? ??¬ê¸°ê°? ë¶?ëª¨ì?? ê°?ë¡???¬ê¸°ë³´ë?? ??¬ë©´ ë¦¬ì?¬ì?´ì?? (??´ë?? ë¶?ëª¨ì?? ê°?ë¡???¬ê¸° - 2 ??????ë¡? ì§??????´ì??)
                if(obj_width > parent_width - 2) {
                    obj.style.cursor = "pointer";
                    var new_w = parent_width - 2;
                    var new_h = Math.round(obj_height * new_w/obj_width);
                    xWidth(obj, new_w);
                    xHeight(obj, new_h);
                } 

                obj.style.cursor = "pointer";

                // ë§???? ?????? ??´ë?¸ì????? ë§???¬ê?? ??¤ì???????? ???ê±°ë?? onclick ??´ë²¤??¸ê?? ë¶???¬ë????? ?????¼ë©´ ???ë³? ë³´ê¸°ë¥? ???ì§? ??????
                if(obj.parentNode.nodeName.toLowerCase()!='a' && !obj.getAttribute('onclick')) xAddEventListener(obj,"click", showOriginalImage);

                imageGalleryIndex[j][i] = obj.src;
                obj.setAttribute("rel", j+','+i);
            }
        }
    }
}
xAddEventListener(window, "load", resizeImageContents);

/**
 * @brief ë³¸ë¬¸??´ì????? ì»¨í??ì¸? ??????ë³´ë?? ??? ??´ë?¸ì????? ê²½ì?? ???ë³? ??¬ê¸°ë¥? ë³´ì?¬ì??
 **/
function showOriginalImage(evt) {
    var e = new xEvent(evt);
    var obj = e.target;
    var src = obj.src;
    var rel = obj.getAttribute('rel');
    displayOriginalImage(src, rel);
}

function displayOriginalImage(src, rel) {
    // ??¬ë?? ë°°ê²½??? ì§????
    var bgObj = xGetElementById("forOriginalImageBGArea");
    if(!bgObj) {
        bgObj = xCreateElement("div");
        bgObj.id = "forOriginalImageBGArea";
        bgObj.style.visibility = "hidden";
        bgObj.style.backgroundColor = "#000000";
        bgObj.style.zIndex = 500;
        bgObj.style.position = "absolute";
        document.body.appendChild(bgObj);
    }
    xWidth(bgObj, xClientWidth());
    xHeight(bgObj, xClientHeight());
    xLeft(bgObj, xScrollLeft());
    xTop(bgObj, xScrollTop());
    bgObj.style.opacity = .5;
    bgObj.style.filter = "alpha(opacity=50);";
    bgObj.style.visibility = "visible";

    // ???ë³? ??´ë?¸ì?? ??¸ì????? ?????? ì¤?ë¹?
    var foreObj = xGetElementById("forOriginalImageArea");
    if(!foreObj) {
        foreObj = xCreateElement("div");
        foreObj.id = "forOriginalImageArea";
        foreObj.style.visibility = "hidden";
        foreObj.style.overflow = "hidden";
        foreObj.style.position = "absolute";
        foreObj.style.zIndex = 510;
        document.body.appendChild(foreObj);
    }
    xWidth(foreObj, xClientWidth());
    xHeight(foreObj, xClientHeight());
    xLeft(foreObj, xScrollLeft());
    xTop(foreObj, xScrollTop());
    foreObj.style.visibility = "visible";

    var foreWidth = xWidth(foreObj);
    var foreHeight = xHeight(foreObj);

    // ë²????
    var iconClose = xGetElementById("forOriginalImageIconClose");
    if(!iconClose) {
        iconClose = xCreateElement("img");
        iconClose.id = "forOriginalImageIconClose";
        iconClose.style.position = "absolute";
        iconClose.src = request_uri+"addons/resize_image/iconClose.png";
        iconClose.style.width = iconClose.style.height = "60px";
        iconClose.className = 'iePngFix';
        iconClose.style.zIndex = 530;
        iconClose.style.cursor = "pointer";
        foreObj.appendChild(iconClose);
    }
    iconClose.style.visibility = 'visible';
    xLeft(iconClose, (foreWidth-60)/2);
    xTop(iconClose, 10);

    var iconLeft = xGetElementById("forOriginalImageIconLeft");
    if(!iconLeft) {
        iconLeft = xCreateElement("img");
        iconLeft.id = "forOriginalImageIconLeft";
        iconLeft.style.position = "absolute";
        iconLeft.src = request_uri+"addons/resize_image/iconLeft.png";
        iconLeft.style.width = iconLeft.style.height = "60px";
        iconLeft.style.zIndex = 530;
        iconLeft.className = 'iePngFix';
        iconLeft.style.cursor = "pointer";
        foreObj.appendChild(iconLeft);
    }
    iconLeft.onclick = null;
    xLeft(iconLeft, 10);
    xTop(iconLeft, (foreHeight-60)/2);
    iconLeft.style.visibility = 'hidden';

    var iconRight = xGetElementById("forOriginalImageIconRight");
    if(!iconRight) {
        iconRight = xCreateElement("img");
        iconRight.id = "forOriginalImageIconRight";
        iconRight.style.position = "absolute";
        iconRight.src = request_uri+"addons/resize_image/iconRight.png";
        iconRight.style.width = iconRight.style.height = "60px";
        iconRight.className = 'iePngFix';
        iconRight.style.zIndex = 530;
        iconRight.style.cursor = "pointer";
        foreObj.appendChild(iconRight);
    }
    iconRight.onclick = null;
    xLeft(iconRight, foreWidth - 10 - 60);
    xTop(iconRight, (foreHeight-60)/2);
    iconRight.style.visibility = 'hidden';


    if(rel) {
        var tmp = rel.split(',');
        var j = parseInt(tmp[0],10);
        var i = parseInt(tmp[1],10);
        var length = imageGalleryIndex[j].length;

        if(length>1) {

            var prev = i-1;
            var next = i+1;
            if(prev>=0) {
                iconLeft.style.visibility = 'visible';
                iconLeft.onclick = function() { displayOriginalImage(imageGalleryIndex[j][prev], j+','+prev); }
            } else {
                iconLeft.style.visibility = 'hidden';
            }

            if(next<length) {
                iconRight.style.visibility = 'visible';
                iconRight.onclick = function() { displayOriginalImage(imageGalleryIndex[j][next], j+','+next); }
            } else {
                iconRight.style.visibility = 'hidden';
            }

        }

    }

    // ???ë³? ??´ë?¸ì??ë¥? ì¶?ê°?
    var origObj = xGetElementById("forOriginalImage");
    if(origObj) foreObj.removeChild(origObj);

    origObj = null;
    origObj = xCreateElement("img");
    origObj.id = "forOriginalImage";
    origObj.style.border = "7px solid #ffffff";
    origObj.style.visibility = "hidden";
    origObj.style.cursor = "move";
    origObj.style.zIndex = 520;
    foreObj.appendChild(origObj);

    origObj.style.position = "relative";
    origObj.src = src;

    var objWidth = xWidth(origObj);
    var objHeight = xHeight(origObj);

    var posX = 0;
    var posY = 0;

    if(objWidth < foreWidth) posX = parseInt( (foreWidth - objWidth) / 2, 10);
    if(objHeight < foreHeight) posY = parseInt( (foreHeight - objHeight) / 2, 10);

    xLeft(origObj, posX);
    xTop(origObj, posY);

    origObj.style.visibility = "visible";

    var sel_list = xGetElementsByTagName("select");
    for (var i = 0; i < sel_list.length; ++i) sel_list[i].style.visibility = "hidden";

    xAddEventListener(origObj, "mousedown", origImageDragEnable);
    xAddEventListener(origObj, "dblclick", closeOriginalImage);
    xAddEventListener(iconClose, "mousedown", closeOriginalImage);
    xAddEventListener(window, "scroll", closeOriginalImage);
    xAddEventListener(window, "resize", closeOriginalImage);
    xAddEventListener(document, 'keydown',closeOriginalImage);
}

/**
 * @brief ???ë³? ??´ë?¸ì?? ë³´ì?¬ì?? ??? ??«ë?? ??¨ì??
 **/
function closeOriginalImage(evt) {
    var bgObj = xGetElementById("forOriginalImageBGArea");
    var foreObj = xGetElementById("forOriginalImageArea");
    var origObj = xGetElementById("forOriginalImage");
    var iconClose = xGetElementById("forOriginalImageIconClose");
    var iconLeft = xGetElementById("forOriginalImageIconLeft");
    var iconRight = xGetElementById("forOriginalImageIconRight");

    var sel_list = xGetElementsByTagName("select");
    for (var i = 0; i < sel_list.length; ++i) sel_list[i].style.visibility = "visible";

    xRemoveEventListener(origObj, "mousedown", origImageDragEnable);
    xRemoveEventListener(origObj, "dblclick", closeOriginalImage);
    xRemoveEventListener(iconClose, "mousedown", closeOriginalImage);
    xRemoveEventListener(window, "scroll", closeOriginalImage);
    xRemoveEventListener(window, "resize", closeOriginalImage);
    xRemoveEventListener(document, 'keydown',closeOriginalImage);

    bgObj.style.visibility = "hidden";
    foreObj.style.visibility = "hidden";
    origObj.style.visibility = "hidden";
    iconClose.style.visibility = 'hidden';
    iconLeft.style.visibility = 'hidden';
    iconRight.style.visibility = 'hidden';
}

/**
 * @brief ???ë³? ??´ë?¸ì?? ??????ê·?
 **/
var origDragManager = {obj:null, isDrag:false}
function origImageDragEnable(evt) {
    var e = new xEvent(evt);
    var obj = e.target;
    if(obj.id != "forOriginalImage") return;

    obj.draggable = true;
    obj.startX = e.pageX;
    obj.startY = e.pageY;

    if(!origDragManager.isDrag) {
        origDragManager.isDrag = true;
        xAddEventListener(document, "mousemove", origImageDragMouseMove, false);
    }

    xAddEventListener(document, "mousedown", origImageDragMouseDown, false);
}

function origImageDrag(obj, px, py) {
    var x = px - obj.startX;
    var y = py - obj.startY;

    var origObj = xGetElementById("forOriginalImage");
    xLeft(origObj, xLeft(origObj)+x);
    xTop(origObj, xTop(origObj)+y);

    obj.startX = px;
    obj.startY = py;
}

function origImageDragMouseDown(evt) {
    var e = new xEvent(evt);
    var obj = e.target;
    if(obj.id != "forOriginalImage" || !obj.draggable) return;

    if(obj) {
        xPreventDefault(evt);
        obj.startX = e.pageX;
        obj.startY = e.pageY;
        origDragManager.obj = obj;
        xAddEventListener(document, 'mouseup', origImageDragMouseUp, false);
        origImageDrag(obj, e.pageX, e.pageY);
    }
}

function origImageDragMouseUp(evt) {
    if(origDragManager.obj) {
        xPreventDefault(evt);
        xRemoveEventListener(document, 'mouseup', origImageDragMouseUp, false);
        xRemoveEventListener(document, 'mousemove', origImageDragMouseMove, false);
        xRemoveEventListener(document, 'mousemdown', origImageDragMouseDown, false);
        origDragManager.obj.draggable  = false;
        origDragManager.obj = null;
        origDragManager.isDrag = false;
    }
}

function origImageDragMouseMove(evt) {
    var e = new xEvent(evt);
    var obj = e.target;
    if(!obj) return;
    if(obj.id != "forOriginalImage") {
        xPreventDefault(evt);
        xRemoveEventListener(document, 'mouseup', origImageDragMouseUp, false);
        xRemoveEventListener(document, 'mousemove', origImageDragMouseMove, false);
        xRemoveEventListener(document, 'mousemdown', origImageDragMouseDown, false);
        origDragManager.obj.draggable  = false;
        origDragManager.obj = null;
        origDragManager.isDrag = false;
        return;
    }

    xPreventDefault(evt);
    origDragManager.obj = obj;
    xAddEventListener(document, 'mouseup', origImageDragMouseUp, false);
    origImageDrag(obj, e.pageX, e.pageY);
}


/**
 * @file   modules/board/js/board.js
 * @author zero (zero@nzeo.com)
 * @brief  board ëª¨ë????? javascript
 **/

/* ê¸???°ê¸° ?????±í?? */
function completeDocumentInserted(ret_obj) {
    var error = ret_obj['error'];
    var message = ret_obj['message'];
    var mid = ret_obj['mid'];
    var document_srl = ret_obj['document_srl'];
    var category_srl = ret_obj['category_srl'];

    //alert(message);

    var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
    if(category_srl) url = url.setQuery('category',category_srl);
    location.href = url;
}

/* ê¸? ?????? */
function completeDeleteDocument(ret_obj) {
    var error = ret_obj['error'];
    var message = ret_obj['message'];
    var mid = ret_obj['mid'];
    var page = ret_obj['page'];

    var url = current_url.setQuery('mid',mid).setQuery('act','').setQuery('document_srl','');
    if(page) url = url.setQuery('page',page);

    //alert(message);

    location.href = url;
}

/* ê²???? ??¤í?? */
function completeSearch(fo_obj, params) {
    fo_obj.submit();
}

function completeVote(ret_obj) {
    var error = ret_obj['error'];
    var message = ret_obj['message'];
    alert(message);
    location.href = location.href;
}

// ?????? ?????´ì?? reload
function completeReload(ret_obj) {
    var error = ret_obj['error'];
    var message = ret_obj['message'];

    location.href = location.href;
}

/* ???ê¸? ê¸???°ê¸° ?????±í?? */
function completeInsertComment(ret_obj) {
    var error = ret_obj['error'];
    var message = ret_obj['message'];
    var mid = ret_obj['mid'];
    var document_srl = ret_obj['document_srl'];
    var comment_srl = ret_obj['comment_srl'];

    var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
    if(comment_srl) url = url.setQuery('rnd',comment_srl)+"#comment_"+comment_srl;

    //alert(message);

    location.href = url;
}

/* ???ê¸? ?????? */
function completeDeleteComment(ret_obj) {
    var error = ret_obj['error'];
    var message = ret_obj['message'];
    var mid = ret_obj['mid'];
    var document_srl = ret_obj['document_srl'];
    var page = ret_obj['page'];

    var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
    if(page) url = url.setQuery('page',page);

    //alert(message);

    location.href = url;
}

/* ??¸ë??ë°? ?????? */
function completeDeleteTrackback(ret_obj) {
    var error = ret_obj['error'];
    var message = ret_obj['message'];
    var mid = ret_obj['mid'];
    var document_srl = ret_obj['document_srl'];
    var page = ret_obj['page'];

    var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
    if(page) url = url.setQuery('page',page);

    //alert(message);

    location.href = url;
}

/* ì¹´í??ê³?ë¦? ??´ë?? */
function doChangeCategory() {
    var sel_obj = xGetElementById("board_category");
    var sel_idx = sel_obj.selectedIndex;
    var category_srl = sel_obj.options[sel_idx].value;
    location.href = current_url.setQuery('category',category_srl);
}

/* ??¤í?¬ë?? */
function doScrap(document_srl) {
    var params = new Array();
    params["document_srl"] = document_srl;
    exec_xml("member","procMemberScrapDocument", params, null);
}

function search(fo_obj) {
	var oFilter = new XmlJsFilter(fo_obj, "board", "", completeSearch);
	oFilter.addFieldItem("search_target",true,0,0,"","");
	oFilter.addFieldItem("search_keyword",true,0,40,"","");
	oFilter.addParameterItem("mid","mid");
	oFilter.addParameterItem("search_target","search_target");
	oFilter.addParameterItem("search_keyword","search_keyword");
	oFilter.addResponseItem("error");
	oFilter.addResponseItem("message");
	return oFilter.proc();
}
alertMsg["search_target"] = "ê²??????????";
alertMsg["search_keyword"] = "ê²???????";
alertMsg["mid"] = "ëª¨ë????´ë??";
target_type_list["search_target"] = "";
target_type_list["search_keyword"] = "";
alertMsg["isnull"] = "%s??? ê°???? ?????¥í?´ì£¼??¸ì??";
alertMsg["outofrange"] = "%s??? ê¸???? ê¸¸ì?´ë?? ë§?ì¶???? ì£¼ì?¸ì??.";
alertMsg["equalto"] = "%s??? ê°???? ???ëª? ????????µë?????.";
alertMsg["invalid_email"] = "%s??? ????????? ???ëª»ë???????µë?????. (???: zbxe@zeroboard.com)";
alertMsg["invalid_userid"] = "%s??? ????????? ???ëª»ë???????µë?????.\n???ë¬?,??«ì????? _ë¡? ë§??????? ??? ?????¼ë©° ?????? ?????? ???ë¬¸ì?´ì?´ì?? ??©ë?????";
alertMsg["invalid_user_id"] = "%s??? ????????? ???ëª»ë???????µë?????.\n???ë¬?,??«ì????? _ë¡? ë§??????? ??? ?????¼ë©° ?????? ?????? ???ë¬¸ì?´ì?´ì?? ??©ë?????";
alertMsg["invalid_homepage"] = "%s??? ????????? ???ëª»ë???????µë?????. (???: http://www.zeroboard.com)";
alertMsg["invalid_korean"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ê¸?ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_korean_number"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ê¸?ê³? ??«ì??ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_alpha"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ë¬¸ì?¼ë??ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_alpha_number"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ë¬¸ê³¼ ??«ì??ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_number"] = "%s??? ????????? ???ëª»ë???????µë?????. ??«ì??ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";

function insert_comment(fo_obj) {
	var oFilter = new XmlJsFilter(fo_obj, "board", "procBoardInsertComment", completeInsertComment);
	oFilter.addFieldItem("document_srl",true,0,0,"","");
	oFilter.addFieldItem("nick_name",true,0,0,"","");
	oFilter.addFieldItem("password",true,0,0,"","");
	oFilter.addFieldItem("email_address",false,0,250,"","");
	oFilter.addFieldItem("homepage",false,0,250,"","");
	oFilter.addFieldItem("content",true,1,0,"","");
	oFilter.addParameterItem("mid","mid");
	oFilter.addParameterItem("document_srl","document_srl");
	oFilter.addParameterItem("comment_srl","comment_srl");
	oFilter.addParameterItem("parent_srl","parent_srl");
	oFilter.addParameterItem("nick_name","nick_name");
	oFilter.addParameterItem("password","password");
	oFilter.addParameterItem("email_address","email_address");
	oFilter.addParameterItem("homepage","homepage");
	oFilter.addParameterItem("content","content");
	oFilter.addParameterItem("is_secret","is_secret");
	oFilter.addParameterItem("notify_message","notify_message");
	oFilter.addResponseItem("error");
	oFilter.addResponseItem("message");
	oFilter.addResponseItem("mid");
	oFilter.addResponseItem("document_srl");
	oFilter.addResponseItem("comment_srl");
	return oFilter.proc("??±ë????????ê²???µë??ê¹??");
}
alertMsg["document_srl"] = "ë¬¸ì??ë²????";
alertMsg["nick_name"] = "?????¤ì??";
alertMsg["password"] = "ë¹?ë°?ë²????";
alertMsg["email_address"] = "??´ë????? ì£¼ì??";
alertMsg["homepage"] = "????????´ì??";
alertMsg["content"] = "??´ì??";
alertMsg["mid"] = "ëª¨ë????´ë??";
alertMsg["comment_srl"] = "comment_srl";
alertMsg["parent_srl"] = "parent_srl";
alertMsg["is_secret"] = "is_secret";
alertMsg["notify_message"] = "notify_message";
target_type_list["document_srl"] = "";
target_type_list["nick_name"] = "";
target_type_list["password"] = "";
target_type_list["email_address"] = "";
target_type_list["homepage"] = "";
target_type_list["content"] = "";
alertMsg["isnull"] = "%s??? ê°???? ?????¥í?´ì£¼??¸ì??";
alertMsg["outofrange"] = "%s??? ê¸???? ê¸¸ì?´ë?? ë§?ì¶???? ì£¼ì?¸ì??.";
alertMsg["equalto"] = "%s??? ê°???? ???ëª? ????????µë?????.";
alertMsg["invalid_email"] = "%s??? ????????? ???ëª»ë???????µë?????. (???: zbxe@zeroboard.com)";
alertMsg["invalid_userid"] = "%s??? ????????? ???ëª»ë???????µë?????.\n???ë¬?,??«ì????? _ë¡? ë§??????? ??? ?????¼ë©° ?????? ?????? ???ë¬¸ì?´ì?´ì?? ??©ë?????";
alertMsg["invalid_user_id"] = "%s??? ????????? ???ëª»ë???????µë?????.\n???ë¬?,??«ì????? _ë¡? ë§??????? ??? ?????¼ë©° ?????? ?????? ???ë¬¸ì?´ì?´ì?? ??©ë?????";
alertMsg["invalid_homepage"] = "%s??? ????????? ???ëª»ë???????µë?????. (???: http://www.zeroboard.com)";
alertMsg["invalid_korean"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ê¸?ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_korean_number"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ê¸?ê³? ??«ì??ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_alpha"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ë¬¸ì?¼ë??ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_alpha_number"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ë¬¸ê³¼ ??«ì??ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_number"] = "%s??? ????????? ???ëª»ë???????µë?????. ??«ì??ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";

/**
 * ????????°ì????? ??¬ì?©í??ê¸? ?????? ë³????
 **/
var editorMode = new Array(); ///<< ????????°ì?? html??¸ì?? ëª¨ë?? flag ??¸í?? ë³???? (html or null)
var editorAutoSaveObj = {fo_obj:null, editor_sequence:0, title:'', content:'', locked:false} ///< ???????????¥ì?? ?????? ???ë³´ë?? ê°?ì§? object
var editorRelKeys = new Array(); ///< ????????°ì?? ê°? ëª¨ë??ê³¼ì?? ??°ë????? ?????? key ê°???? ë³´ê???????? ë³????
var editorDragObj = {isDrag:false, y:0, obj:null, id:'', det:0, source_height:0}

/**
 * ????????? ??¬ì?©ì?? ??¬ì?©ë????? ??´ë²¤??? ??°ê²° ??¨ì?? ??¸ì??
 **/
xAddEventListener(document, 'mouseup', editorEventCheck);
xAddEventListener(document, 'mousedown', editorDragStart);
xAddEventListener(document, 'mouseup', editorDragStop);



function editorGetContent(editor_sequence) {
    // ?????¥ë?? ??´ì?©ì?? ë°???????
    var content = editorRelKeys[editor_sequence]["func"](editor_sequence);

    // ì²¨ë???????? ë§???¬ì?? url??? ë³?ê²?
    var reg_pattern = new RegExp( request_uri.replace(/\//g,'\\/')+"(files|common|modules|layouts|widgets)", 'ig' );
    return content.replace(reg_pattern, "$1");
}

// ????????°ì?? ??¬ì»¤??¤ë?? ì¤?
function editorFocus(editor_sequence) {
    var iframe_obj = editorGetIFrame(editor_sequence);
    iframe_obj.contentWindow.focus();
}

/**
 * ?????? ?????? ê¸°ë??
 **/
// ?????? ?????? ?????±í?? ?????¤ë?? ??¨ì?? (10ì´?ë§???? ????????????)
function editorEnableAutoSave(fo_obj, editor_sequence) {
    var title = fo_obj.title.value;
    var content = editorRelKeys[editor_sequence]['content'].value;
    editorAutoSaveObj = {"fo_obj":fo_obj, "editor_sequence":editor_sequence, "title":title, "content":content, locked:false};
    setTimeout(_editorAutoSave, 10000);
}

// ajaxë¥? ??´ì?©í????? editor.procEditorSaveDoc ??¸ì???????? ?????? ?????¥ì?????
function _editorAutoSave() {
    var fo_obj = editorAutoSaveObj.fo_obj;
    var editor_sequence = editorAutoSaveObj.editor_sequence;

    // ?????? ???????????¥ì????´ë©´ ì¤?ì§?
    if(editorAutoSaveObj.locked == true) return;

    // ????????? ?????¼ë©´ ???????????? ?????¤ë?? ê¸°ë?? ???ì²´ë?? ì¤?ì§?
    if(!fo_obj || typeof(fo_obj.title)=='undefined' || !editor_sequence) return;

    // ???????????¥ì?? ?????? ì¤?ë¹?
    var title = fo_obj.title.value;
    var content = editorGetContent(editor_sequence);

    // ??´ì?©ì?? ??´ì????? ?????¥í???????? ê²?ê³? ??¤ë¥´ë©? ?????? ?????¥ì?? ???
    if(title != editorAutoSaveObj.title || content != editorAutoSaveObj.content ) {
        var params = new Array();

        params["title"] = title;
        params["content"] = content;
        params["document_srl"] = editorRelKeys[editor_sequence]['primary'].value;

        editorAutoSaveObj.title = title;
        editorAutoSaveObj.content = content;

        var obj = xGetElementById("editor_autosaved_message_"+editor_sequence);
        obj.style.display = 'block';
        var oDate = new Date();
        html = oDate.getHours()+':'+oDate.getMinutes()+' '+auto_saved_msg;
        xInnerHtml(obj, html);
        obj.style.display = "block";

        // ?????? ???????????¥ì???????? ??¤ì??
        editorAutoSaveObj.locked = true;

        // ???ë²? ??¸ì?? (???ë²???? êµ????ì¤???´ë?¼ë?? ë©???¸ì??ë¥? ë³´ì?´ì?? ??????ë¡? ???)
        show_waiting_message = false;
        exec_xml("editor","procEditorSaveDoc", params, function() { editorAutoSaveObj.locked = false; } );
        show_waiting_message = true;
    }

    // 10ì´?ë§???? ???ê¸°í??ë¥? ??????
    setTimeout(_editorAutoSave, 10000);
}

// ???????????¥ë?? ëª¨ë?? ë©???¸ì??ë¥? ???????????? ë£¨í??
function editorRemoveSavedDoc() {
    exec_xml("editor","procEditorRemoveSavedDoc");
}

/**
 * ????????°ì?? ????????? ê°?ì²´ë?? êµ¬í??ê¸? ?????? ??¨ì??
 **/

// editor_sequenceê°???? ??´ë?¹í????? iframe??? objectë¥? return
function editorGetIFrame(editor_sequence) {
    if(editorRelKeys != undefined && editorRelKeys[editor_sequence] != undefined && editorRelKeys[editor_sequence]['editor'] != undefined)
	return editorRelKeys[editor_sequence]['editor'].getFrame();
    return xGetElementById( 'editor_iframe_'+ editor_sequence );
}

/**
 * iframe ??¸ë?? ??¬ê¸° ì¡°ì?? ??????ê·? ê´????
 **/
function editorDragStart(evt) {
    var e = new xEvent(evt);
    var obj = e.target;
    if(typeof(obj.id)=='undefined'||!obj.id) return;

    var id = obj.id;
    if(id.indexOf('editor_drag_bar_')!=0) return;

    editorDragObj.isDrag = true;
    editorDragObj.y = e.pageY;
    editorDragObj.obj = e.target;
    editorDragObj.id = id.substr('editor_drag_bar_'.length);

    var iframe_obj = editorGetIFrame(editorDragObj.id);

    editorDragObj.source_height = xHeight(iframe_obj);

    xAddEventListener(document, 'mousemove', editorDragMove, false);
    xAddEventListener(editorDragObj.obj, 'mousemove', editorDragMove, false);
}

function editorDragMove(evt) {
    if(!editorDragObj.isDrag) return;

    var e = new xEvent(evt);
    var h = e.pageY - editorDragObj.y;

    editorDragObj.isDrag = true;
    editorDragObj.y = e.pageY;
    editorDragObj.obj = e.target;

    var iframe_obj = editorGetIFrame(editorDragObj.id);
    xHeight(iframe_obj, xHeight(iframe_obj)+h);
    xHeight(iframe_obj.parentNode, xHeight(iframe_obj)+10);
}

function editorDragStop(evt) {
    if(!editorDragObj.isDrag) return;

    xRemoveEventListener(document, 'mousemove', editorDragMove, false);
    xRemoveEventListener(editorDragObj.obj, 'mousemove', editorDragMove, false);

    var iframe_obj = editorGetIFrame(editorDragObj.id);
    if(typeof(fixAdminLayoutFooter)=='function') fixAdminLayoutFooter(xHeight(iframe_obj)-editorDragObj.source_height);

    editorDragObj.isDrag = false;
    editorDragObj.y = 0;
    editorDragObj.obj = null;
    editorDragObj.id = '';
}

// Editor Option Button 
function eOptionOver(obj) {
    obj.style.marginTop='-21px';	
    obj.style.zIndex='99';	
}
function eOptionOut(obj) {
    obj.style.marginTop='0';	
    obj.style.zIndex='1';	
}
function eOptionClick(obj) {
    obj.style.marginTop='-42px';	
    obj.style.zIndex='99';
}

/**
 * ????????? ì»´í?¬ë????? êµ¬í?? ë¶?ë¶?
 **/

// ????????? ?????¨ì?? ì»´í?¬ë????? ë²???? ??´ë¦­??? action ì²?ë¦? (ë§???°ì?¤ë?¤ì?? ??´ë²¤??? ë°???????ë§???? ???ì²???? ???)
var editorPrevSrl = null;
function editorEventCheck(evt) {
    editorPrevNode = null;

    // ??´ë²¤??¸ê?? ë°??????? object??? IDë¥? êµ¬í?? 
    var e = new xEvent(evt);
    var target_id = e.target.id;
    if(!target_id) return;

    // editor_sequence??? component name??? êµ¬í?? (idê°? ??¬ë§·ê³? ??¤ë¥´ë©? return)
    var info = target_id.split('_');
    if(info[0]!="component") return;
    var editor_sequence = info[1];
    var component_name = target_id.replace(/^component_([0-9]+)_/,'');
    if(!editor_sequence || !component_name) return;

    if(editorMode[editor_sequence]=='html') return;

    switch(component_name) {

        // ê¸°ë³¸ ê¸°ë?¥ì?? ?????? ?????? (ë°?ë¡? ??¤í??) 
        case 'Bold' :
        case 'Italic' :
        case 'Underline' :
        case 'StrikeThrough' :
        case 'undo' :
        case 'redo' :
        case 'JustifyLeft' :
        case 'JustifyCenter' :
        case 'JustifyRight' :
        case 'JustifyFull' :
        case 'Indent' :
        case 'Outdent' :
        case 'InsertOrderedList' :
        case 'InsertUnorderedList' :
        case 'SaveAs' :
        case 'Print' :
        case 'Copy' :
        case 'Cut' :
        case 'Paste' :
        case 'RemoveFormat' :
        case 'Subscript' :
        case 'Superscript' :
                editorDo(component_name, '', editor_sequence);
            break;

        // ì¶?ê°? ì»´í?¬ë????¸ì?? ê²½ì?? ???ë²???? ???ì²???? ??????
        default :
                openComponent(component_name, editor_sequence);
            break;
    }

    return;
}

// ì»´í?¬ë????? ?????? ??´ê¸°
function openComponent(component_name, editor_sequence, manual_url) {
    editorPrevSrl = editor_sequence;
    if(editorMode[editor_sequence]=='html') return;

    var popup_url = request_uri+"?module=editor&act=dispEditorPopup&editor_sequence="+editor_sequence+"&component="+component_name;
    if(typeof(manual_url)!="undefined" && manual_url) popup_url += "&manual_url="+escape(manual_url);

    popopen(popup_url, 'editorComponent');
}

// ???ë¸???´ë¦­ ??´ë²¤??? ë°?????????? ë³¸ë¬¸??´ì?? ??¬í?¨ë?? ì»´í?¬ë????¸ë?? ì°¾ë?? ??¨ì??
var editorPrevNode = null;
function editorSearchComponent(evt) {
    var e = new xEvent(evt);

    editorPrevNode = null;
    var obj = e.target;
    
    // ????????¸ì?? ??¼ë?? ì²´í??
    if(obj.getAttribute("widget")) {
        // editor_sequence??? ì°¾ì??
        var tobj = obj;
        while(tobj && tobj.nodeName != "BODY") {
            tobj = xParent(tobj);
        }
        if(!tobj || tobj.nodeName != "BODY" || !tobj.getAttribute("editor_sequence")) {
            editorPrevNode = null;
            return;
        }
        var editor_sequence = tobj.getAttribute("editor_sequence");
        var widget = obj.getAttribute("widget");
        editorPrevNode = obj;

        if(editorMode[editor_sequence]=='html') return;
        popopen(request_uri+"?module=widget&act=dispWidgetGenerateCodeInPage&selected_widget="+widget+"&module_srl="+editor_sequence,'GenerateCodeInPage');
        return;
    }

    // ???????????´ì?? objectë¶???? ?????¨ì?¼ë?? ??´ë?????ë©´ì?? editor_component attributeê°? ??????ì§? ê²????
    if(!obj.getAttribute("editor_component")) {
        while(obj && !obj.getAttribute("editor_component")) {
            if(obj.parentElement) obj = obj.parentElement;
            else obj = xParent(obj);
        }
    }

    if(!obj) obj = e.target;

    var editor_component = obj.getAttribute("editor_component");

    // editor_componentë¥? ì°¾ì?? ëª»í????? ê²½ì?°ì?? ??´ë?¸ì??/?????¤í??/ë§???¬ì?? ê²½ì?? ê¸°ë³¸ ì»´í?¬ë????¸ì?? ??°ê²°
    if(!editor_component) {
        // ??´ë?¸ì????? ê²½ì??
        if(obj.nodeName == "IMG") {
            editor_component = "image_link";
            editorPrevNode = obj;

        // ?????´ë????? td??? ê²½ì??
        } else if(obj.nodeName == "TD") {
            editor_component = "table_maker";
            editorPrevNode = obj;
            
        // ë§???¬ê±°??? ?????¤í?¸ì?? ê²½ì??
        } else if(obj.nodeName == "A" || obj.nodeName == "BODY" || obj.nodeName.indexOf("H")==0 || obj.nodeName == "LI" || obj.nodeName == "P") {
            editor_component = "url_link";
            editorPrevNode = obj;
        }
    } else {
        editorPrevNode = obj;
    }

    // ???ë¬´ë?? editor_componentê°? ?????¤ë©´ return
    if(!editor_component) {
        editorPrevNode = null;
        return;
    }

    // editor_sequence??? ì°¾ì??
    var tobj = obj;
    while(tobj && tobj.nodeName != "BODY") {
        tobj = xParent(tobj);
    }
    if(!tobj || tobj.nodeName != "BODY" || !tobj.getAttribute("editor_sequence")) {
        editorPrevNode = null;
        return;
    }
    var editor_sequence = tobj.getAttribute("editor_sequence");

    // ??´ë?? ì»´í?¬ë????¸ë?? ì°¾ì????? ??¤í??
    openComponent(editor_component, editor_sequence);
}

// ????????? ??´ì?? ????????? ë¶?ë¶???? htmlì½????ë¥? ë³?ê²?
function editorReplaceHTML(iframe_obj, html) {
    // ????????°ê?? ?????±í?? ?????? ??????ì§? ?????? ??? ë¹??????±í????? ?????±í??
    var editor_sequence = iframe_obj.contentWindow.document.body.getAttribute("editor_sequence");

    // iframe ????????°ì?? ??¬ì»¤??¤ë?? ???
    iframe_obj.contentWindow.focus();

    if(xIE4Up) {
        var range = iframe_obj.contentWindow.document.selection.createRange();
		try{
			if(range.pasteHTML) {
				
				range.pasteHTML(html);
			} else if(editorPrevNode) {
				
				editorPrevNode.outerHTML = html;
			}
		}catch(e) {
			alert('range.pasteHTML error');
		}
    } else {

        try {
            if(iframe_obj.contentWindow.getSelection().focusNode.tagName == "HTML") {
				
                var range = iframe_obj.contentDocument.createRange();
                //range.setStart(iframe_obj.contentDocument.body, 0);
                //range.setEnd(iframe_obj.contentDocument.body, 0);
                range.insertNode(range.createContextualFragment(html));
            } else {
				
                var range = iframe_obj.contentWindow.getSelection().getRangeAt(0);
                range.deleteContents();
                range.insertNode(range.createContextualFragment(html));
            }
        } catch(e) {
            xInnerHtml(iframe_obj.contentWindow.document.body, xInnerHtml(iframe_obj.contentWindow.document.body) + html);
        }

    }
}

// IE ????????? ??¬ì»¤??¤ê?? ???ë²? ???ê°?ë²?ë¦¬ë©´ selection ???ë³´ê?? ??¬ë?¼ì?? ë²?ë¦¬ë??ë¡? Editor ?????? ë§???°ì?? ??´ë¦­???
// ???ë³´ë?? globalRange ??? ?????¥í?? ????????¤ê??. ê·? ???ë³´ë?? ??¬ì?©í????? ??°ì?´í?°ì??ì¹?ë¥? ??¡ê?? ??£ë?????.
function editorDirectReplaceHTML(iframe_obj, html) {
    // ????????°ê?? ?????±í?? ?????? ??????ì§? ?????? ??? ë¹??????±í????? ?????±í??
    var editor_sequence = iframe_obj.contentWindow.document.body.getAttribute("editor_sequence");

    // iframe ????????°ì?? ??¬ì»¤??¤ë?? ???
    iframe_obj.contentWindow.focus();

    if(xIE4Up) {
        var range = globalRange;
		try{
			if(range.pasteHTML) {

				range.pasteHTML(html);
			} else if(editorPrevNode) {
				
				editorPrevNode.outerHTML = html;
			}
		}catch(e) {
			alert('range.pasteHTML error');
		}
    } else {

        try {
            if(iframe_obj.contentWindow.getSelection().focusNode.tagName == "HTML") {
				
                var range = globalRange;
                //range.setStart(iframe_obj.contentDocument.body, 0);
                //range.setEnd(iframe_obj.contentDocument.body, 0);
                range.insertNode(range.createContextualFragment(html));
            } else {
				
                var range = globalRange;
                range.deleteContents();
                range.insertNode(range.createContextualFragment(html));
            }
        } catch(e) {
            xInnerHtml(iframe_obj.contentWindow.document.body, xInnerHtml(iframe_obj.contentWindow.document.body) + html);
        }
iframe_obj.contentWindow.focus();
    }





}


// ????????? ??´ì?? ????????? ë¶?ë¶???? html ì½????ë¥? return
function editorGetSelectedHtml(editor_sequence) {
    var iframe_obj = editorGetIFrame(editor_sequence);
    if(xIE4Up) {
        var range = iframe_obj.contentWindow.document.selection.createRange();
        var html = range.htmlText;
        return html;
    } else {
        var range = iframe_obj.contentWindow.getSelection().getRangeAt(0);
        var dummy = xCreateElement('div');
        dummy.appendChild(range.cloneContents());
        var html = xInnerHtml(dummy);
        return html;
    }
}

// ????????? ??´ì?? ????????? ë¶?ë¶????  ???ì¹?ë¥? return


/**
 * @author zero (zero@nzeo.com)
 * @version 0.1
 * @brief ????????? ê´???? ??¤í?¬ë¦½???
 */

/**
 * ????????? ??¬ì?©ì?? ??¬ì?©ë????? ??´ë²¤??? ??°ê²° ??¨ì?? ??¸ì??
 **/

/**
 * ????????°ì?? ????????? ê°?ì²´ë?? êµ¬í??ê¸? ?????? ??¨ì??
 **/

// editor_sequenceê°???? ??´ë?¹í????? textarea objectë¥? return
function editorGetTextArea(editor_sequence) {
    return xGetElementById( 'editor_textarea_' + editor_sequence );
}

// editor_sequence??? ??´ë?¹í????? formë¬? êµ¬í??
function editorGetForm(editor_sequence) {
    var iframe_obj = editorGetIFrame(editor_sequence);
    if(!iframe_obj) return;

    var fo_obj = iframe_obj.parentNode;
    while(fo_obj.nodeName != 'FORM') { fo_obj = fo_obj.parentNode; }
    if(fo_obj.nodeName == 'FORM') return fo_obj;
    return;
}

// ????????°ì?? ???ì²? ??´ì?? return
function editorGetContent_xe(editor_sequence) {
    var html = "";
    if(editorMode[editor_sequence]=='html') {
        var textarea_obj = editorGetTextArea(editor_sequence);
        if(!textarea_obj) return "";
        html = textarea_obj.value;
    } else {
        var iframe_obj = editorGetIFrame(editor_sequence);
        if(!iframe_obj) return "";
        html = xInnerHtml(iframe_obj.contentWindow.document.body).replace(/^<br([^>]*)>$/i,'');
    }
    return html;
}

// ????????°ì?? ???ì²? ??´ì?? textë§? return
function editorGetContentText(editor_sequence) {
    var html = "";

        var iframe_obj = editorGetIFrame(editor_sequence);
		var pattern = /[<][^>]*[>]/gi;
        if(!iframe_obj) return "";
        html = xInnerHtml(iframe_obj.contentWindow.document.body).replace(pattern,'');

    return html;
}


// ????????? ??´ì?? ????????? ë¶?ë¶???? NODEë¥? return
function editorGetSelectedNode(editor_sequence) {
    var iframe_obj = editorGetIFrame(editor_sequence);
    if(xIE4Up) {
        var range = iframe_obj.contentWindow.document.selection.createRange();
        var div = xCreateElement('div');
        xInnerHtml(div, range.htmlText);
        var node = div.firstChild;
        return node;
    } else {
        var range = iframe_obj.contentWindow.getSelection().getRangeAt(0);
        var node = xCreateElement('div');
        node.appendChild(range.cloneContents());
        return node.firstChild;
    }
}

/**
 * editor ?????? (editor_sequenceë¡? iframeê°?ì²´ë?? ??»ì?´ì?? ??°ê¸° ëª¨ë??ë¡? ??????)
 **/
function editorStart(editor_sequence, primary_key, content_key, editor_height, font_color) {
    if(typeof(font_color)=='undefined') font_color = '#000000';

    // iframe objë¥? ì°¾ì??
    var iframe_obj = editorGetIFrame(editor_sequence);
    if(!iframe_obj) return;
    xWidth(iframe_obj.parentNode, '100%');
    iframe_obj.style.width = '100%';

    // ??? ????????°ë?? ê°???¸ê?? ?????? formë¬¸ì?? ì°¾ì??
    var fo_obj = editorGetForm(editor_sequence);
    if(!fo_obj) return;

    // fo_obj??? editor_sequence ê°? ì§????
    fo_obj.setAttribute('editor_sequence', editor_sequence);

    // ëª¨ë?? ??°ê?? ??? ê°???? ??¸í??
    editorRelKeys[editor_sequence] = new Array();
    editorRelKeys[editor_sequence]["primary"] = fo_obj[primary_key];
    editorRelKeys[editor_sequence]["content"] = fo_obj[content_key];
    editorRelKeys[editor_sequence]["func"] = editorGetContent_xe;

    // saved document(???????????? ë¬¸ì??)??? ?????? ??????
    if(typeof(fo_obj._saved_doc_title)!="undefined" ) { ///<< _saved_doc_title fieldê°? ?????¼ë©´ ???????????? ???ì§? ??????

        var saved_title = fo_obj._saved_doc_title.value;
        var saved_content = fo_obj._saved_doc_content.value;

        if(saved_title || saved_content) {
            // ???????????¥ë?? ë¬¸ì?? ?????©ì?¬ë??ë¥? ë¬¼ì?? ??? ??¬ì?©í??ì§? ????????¤ë©´ ???????????¥ë?? ë¬¸ì?? ??????
            if(confirm(fo_obj._saved_doc_message.value)) {
                if(typeof(fo_obj.title)!='undefined') fo_obj.title.value = saved_title;
                editorRelKeys[editor_sequence]['content'].value = saved_content;
            } else {
                editorRemoveSavedDoc();
            }
        }
    }

    // ?????? form??? content element?????? ??°ì?´í?°ë?? êµ¬í??
    var content = editorRelKeys[editor_sequence]['content'].value;

    // IEê°? ??????ê³? ??´ì?©ì?? ?????¼ë©´ <br /> ì¶?ê°? (FF??±ì????? iframe ????????? focusë¥? ì£¼ê¸° ?????? ê½????)
    //if(!content && !xIE4Up) content = "<br />";

    // IE??? ê²½ì?? ctrl-Enter ?????? ë¬¸êµ¬ë¥? ??¸ì??
    var ieHelpObj = xGetElementById("for_ie_help_"+editor_sequence);
    if(xIE4Up && ieHelpObj) {
        ieHelpObj.style.display = "block";
    }

    // content ??????
    editor_path = editor_path.replace(/^\.\//ig, '');
    var contentHtml = ''+
        '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'+
        '<html lang="ko" xmlns="http://www.w3.org/1999/xhtml><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/>'+
        '<style type="text/css">'+
        'body {font-size:9pt;height:'+editor_height+'px; padding:0; margin:0; background-color:transparent; color:'+font_color+';}'+
        '</style>'+
        '</head><body editor_sequence="'+editor_sequence+'">'+
        content+
        '</body></html>'+
        '';
    iframe_obj.contentWindow.document.open("text/html","replace");
    iframe_obj.contentWindow.document.write(contentHtml);
    iframe_obj.contentWindow.document.close();

    // editorModeë¥? ê¸°ë³¸??¼ë?? ??¤ì??
    editorMode[editor_sequence] = null;

    // ????????°ë?? ?????? ?????? 
    try { 
        iframe_obj.contentWindow.document.designMode = 'On';
    } catch(e) {
    }

    try {
        iframe_obj.contentWindow.document.execCommand("undo", false, null);
        iframe_obj.contentWindow.document.execCommand("useCSS", false, true);

    }  catch (e) {
    }

    /**
     * ???ë¸???´ë¦­??´ë?? ??¤ë??ë¦¼ë?±ì?? ê°?ì¢? ??´ë²¤??¸ì?? ?????? listener ì¶?ê°?
     * ?????±ì?? ????????? ??´ë²¤??? ì²´í??
     * ??? ??´ë²¤??¸ì?? ê²½ì?? ????????? sp1 (NT or xp sp1) ?????? iframe_obj.contentWindow.document??? ?????? ê¶??????? ???ê¸°ì?? try ë¬¸ì?¼ë?? ê°???¸ì?? 
     * ?????¬ë?? ë¬´ì????????ë¡? ??´ì?? ???.
     **/

    // ?????? ê°????ë¥? ?????? ???ë¸???´ë¦­ ??´ë²¤??? ê±¸ê¸° 
	/*
    try {
        xAddEventListener(iframe_obj.contentWindow.document,'dblclick',editorSearchComponent);
    } catch(e) {
    }
	*/

    // ????????°ì????? ??¤ê?? ?????¬ì?????ë§???? ??´ë²¤??¸ë?? ì²´í?¬í?? (enter??¤ì?? ì²?ë¦¬ë?? FF?????? alt-s??±ì?? ì²?ë¦?)
    try {

		
        if(xIE4Up) xAddEventListener(iframe_obj.contentWindow.document, 'keydown',editorKeyPress);
        else xAddEventListener(iframe_obj.contentWindow.document, 'keypress',editorKeyPress);
	


		xAddEventListener(iframe_obj.contentWindow.document, 'keyup',decodeKeyEvent);
		xAddEventListener(iframe_obj.contentWindow.document, 'change',decodeKeyEvent);
		xAddEventListener(iframe_obj.contentWindow.document, 'mousedown', editorMouseDown);
		xAddEventListener(iframe_obj.contentWindow.document, 'mouseup', makeGlobalRange);

//xAddEventListener(document, 'mousedown', decodeKeyEvent);



    } catch(e) {

    }

    // ???????????? ??????ê°? ?????¤ë©´ ?????? ?????? ê¸°ë?? ?????±í??
    //if(typeof(fo_obj._saved_doc_title)!="undefined" ) editorEnableAutoSave(fo_obj, editor_sequence);
}


/**
 * ????????°ì?? ??¸ë?? ??¤ì??ê³? ??°ì?´í?? ??¸ë?¤ë????? ????????? ??¨ì?????
 **/

var clickFlag = false;
function editorMouseDown(){
//alert('frame documet pressed!!');
clickFlag = true;




		
}

var globalRange = null;
function makeGlobalRange(){

    // iframe ????????°ì?? ??¬ì»¤??¤ë?? ???
	var iframe_obj = editorGetIFrame("1");
    iframe_obj.contentWindow.focus();

    if(xIE4Up) {
		try{
        globalRange = iframe_obj.contentWindow.document.selection.createRange();
		}catch(e){
		alert('range ê°?ì²? ?????? ì¤? ?????¬ë?????1');

		}
		
    } else {

        try {
            if(iframe_obj.contentWindow.getSelection().focusNode.tagName == "HTML") {
				
                globalRange = iframe_obj.contentDocument.createRange();

            } else {
				
                globalRange = iframe_obj.contentWindow.getSelection().getRangeAt(0);

            }
        } catch(e) {
           alert('range ê°?ì²? ?????? ì¤? ?????¬ë?????2');
        }

    }


}

/**
 * ??? ?????? ë§???°ì?? ??´ë²¤??? ??¸ë?¤ë?? ?????? ??¨ì??
 **/

// ?????? ??¤ì?? ?????? ??´ë²¤??? ì²´í??
function editorKeyPress(evt) {
    var e = new xEvent(evt);

    // ????????? êµ¬í??
    var obj = e.target;
    var body_obj = null;
    if(obj.nodeName == "BODY") body_obj = obj;
    else body_obj = obj.firstChild.nextSibling;
    if(!body_obj) return;

    // editor_sequence??? ????????°ì?? body??? attributeë¡? ???????????? ??????
    var editor_sequence = body_obj.getAttribute("editor_sequence");
    if(!editor_sequence) return;

    // IE?????? enter??¤ë?? ???????????? P ???ê·? ?????? BR ???ê·? ??????
    if (xIE4Up && !e.ctrlKey && !e.shiftKey && e.keyCode == 13 && editorMode[editor_sequence]!='html') {
        var iframe_obj = editorGetIFrame(editor_sequence);
        if(!iframe_obj) return;

        var contentDocument = iframe_obj.contentWindow.document;

        var obj = contentDocument.selection.createRange();

        var pTag = obj.parentElement().tagName.toLowerCase();

        switch(pTag) {
            case 'li' :
                    return;
                break; 
            default :
                    obj.pasteHTML("<br />");
                break;
        }
        obj.select();
        evt.cancelBubble = true;
        evt.returnValue = false;
        return;
    }

	
/*
    // ctrl-S, alt-S ??´ë¦­??? submit???ê¸?
    if( e.keyCode == 115 && (e.altKey || e.ctrlKey) ) {
        // iframe ????????°ë?? ì°¾ì??
        var iframe_obj = editorGetIFrame(editor_sequence);
        if(!iframe_obj) return;

        // ?????? form??? ì°¾ì??
        var fo_obj = editorGetForm(editor_sequence);
        if(!fo_obj) return;

        // ??°ì?´í?? ???ê¸°í??
        editorRelKeys[editor_sequence]['content'].value = editorGetContent(editor_sequence);

        // formë¬? ??????
        if(fo_obj.onsubmit) fo_obj.onsubmit();

        // ??´ë²¤??? ì¤????
        evt.cancelBubble = true;
        evt.returnValue = false;
        xPreventDefault(evt);
        xStopPropagation(evt);
        return;
    }


    // ctrl-b, i, u, s ??¤ì?? ?????? ì²?ë¦? (?????´ì?´í????¤ì???????? ????????? ???????????? ??¨ì????? ??°ë??ë¡?)
    if (e.ctrlKey) {
        // iframe ????????°ë?? ì°¾ì??
        var iframe_obj = editorGetIFrame(editor_sequence);
        if(!iframe_obj) return;

        // html ????????? ëª¨ë????? ê²½ì?? ??´ë²¤??? ì·¨ì?? ??????
        if(editorMode[editor_sequence]=='html') {
            evt.cancelBubble = true;
            evt.returnValue = false;
            xPreventDefault(evt);
            xStopPropagation(evt);
            return;
        }

        switch(e.keyCode) {
            // ctrl+1~6
            case 49 :
            case 50 :
            case 51 :
            case 52 :
            case 53 :
            case 54 :
                    editorDo('formatblock',"<H"+(e.keyCode-48)+">",e.target);
                    xPreventDefault(evt);
                    xStopPropagation(evt);
                break;
            // ctrl+7
            case 55 :
                    editorDo('formatblock',"<P>",e.target);
                    xPreventDefault(evt);
                    xStopPropagation(evt);
                break;
            // ie?????? ctrlKey + enter??? ê²½ì?? P ???ê·? ??????
            case 13 :
                    if(xIE4Up) {
                        if(e.target.parentElement.document.designMode!="On") return;
                        var obj = e.target.parentElement.document.selection.createRange();
                        obj.pasteHTML('<P>');
                        obj.select();
                        evt.cancelBubble = true;
                        evt.returnValue = false;
                        return;
                    }
            // bold
            case 98 :
                    editorDo('Bold',null,e.target);
                    xPreventDefault(evt);
                    xStopPropagation(evt);
                break;
            // italic
            case 105 :
                    editorDo('Italic',null,e.target);
                    xPreventDefault(evt);
                    xStopPropagation(evt);
                break;
            // underline
            case 117 : 
                    editorDo('Underline',null,e.target);
                    xPreventDefault(evt);
                    xStopPropagation(evt);
                break;
            // strike
*/
            /*
            case 83 :
            case 115 :
                    editorDo('StrikeThrough',null,e.target);
                    xPreventDefault(evt);
                    xStopPropagation(evt);
                break;
            */
//        }
//    }
	
}

// ??¸ì?? ê¸°ë?? ??¤í??
function editorDo(command, value, target) {

    var doc = null;

    // target??? object??¸ì?? editor_sequence??¸ì????? ??°ë?? documentë¥? êµ¬í??
    if(typeof(target)=="object") {
        if(xIE4Up) doc = target.parentElement.document;
        else doc = target.parentNode;
    } else {
        var iframe_obj = editorGetIFrame(target);
        doc = iframe_obj.contentWindow.document;
    }

    var editor_sequence = doc.body.getAttribute('editor_sequence');
    if(editorMode[editor_sequence]=='html') return;

    // ??¬ì»¤???
    if(typeof(target)=="object") target.focus();
    else editorFocus(target);

    // ??¤í??
    doc.execCommand(command, false, value);

    // ??¬ì»¤???
    if(typeof(target)=="object") target.focus();
    else editorFocus(target);
}

// ??°í?¸ë?? ë³?ê²?
function editorChangeFontName(obj,srl) {
    var value = obj.options[obj.selectedIndex].value;
    if(!value) return;
    editorDo('FontName',value,srl);
    obj.selectedIndex = 0;
}

function editorChangeFontSize(obj,srl) {
    var value = obj.options[obj.selectedIndex].value;
    if(!value) return;
    editorDo('FontSize',value,srl);
    obj.selectedIndex = 0;
}

function editorChangeHeader(obj,srl) {
    var value = obj.options[obj.selectedIndex].value;
    if(!value) return;
    value = "<"+value+">";
    editorDo('formatblock',value,srl);
    obj.selectedIndex = 0;
}

/**
 * HTML ??¸ì?? ê¸°ë?? ??????/ë¹???????
 **/
function editorChangeMode(obj, editor_sequence) {
    var iframe_obj = editorGetIFrame(editor_sequence);
    if(!iframe_obj) return;

    var textarea_obj = editorGetTextArea(editor_sequence);
    xWidth(textarea_obj, xWidth(iframe_obj.parentNode));
    xHeight(textarea_obj, xHeight(iframe_obj.parentNode));

    var contentDocument = iframe_obj.contentWindow.document;

    // html ??¸ì?? ??¬ì?©ì??
    if(obj.checked) {
        var html = contentDocument.body.innerHTML;
        html = html.replace(/<br>/ig,"<br />\n");
        html = html.replace(/<br \/>\n\n/ig,"<br />\n");

        textarea_obj.value = html;

        iframe_obj.parentNode.style.display = "none";
        textarea_obj.style.display = "block";
        xGetElementById('xeEditorOption_'+editor_sequence).style.display = "none";

        editorMode[editor_sequence] = 'html';

    // ???ì§???? ëª¨ë?? ??¬ì?©ì??
    } else {
        var html = textarea_obj.value;
        contentDocument.body.innerHTML = html;
        iframe_obj.parentNode.style.display = "block";
        textarea_obj.style.display = "none";
        xGetElementById('xeEditorOption_'+editor_sequence).style.display = "block";
        editorMode[editor_sequence] = null;
    }

}

// Editor Info Close
function closeEditorInfo(editor_sequence) {
    xGetElementById('editorInfo_'+editor_sequence).style.display='none';	
    var expire = new Date();
    expire.setTime(expire.getTime()+ (7000 * 24 * 3600000));
    xSetCookie('EditorInfo', '1', expire);
}

/**
 * @author zero (zero@nzeo.com)
 * @version 0.1
 * @brief ?????? ???ë¡???? ê´????
 *
 *****************************************************************************************************************************
 * ???ë¡?ë³´ë??XE??? ê²????ë¬? ?????¼ì??ë¡???? ì»´í?¬ë????¸ë?? "mmSWFUpload 1.0: Flash upload dialog - http://swfupload.mammon.se/" ë¥? ??¬ì?©í?©ë?????.
 * - SWFUpload is (c) 2006 Lars Huring and Mammon Media and is released under the MIT License:http://www.opensource.org/licenses/mit-license.php
 *****************************************************************************************************************************

 * ê°???¬í?©ë?????.
 **/
var uploading_file = false;
var uploaded_files = new Array();

/**
 * ???ë¡????ë¥? ???ê¸? ?????? ì¤?ë¹? ??????
 * ??? ??¨ì????? editor.html ?????? ?????? ???ë¡???? ê°???¥í?? ê²½ì?? ??¸ì?????
 **/
// window.load ??´ë²¤??¸ì?? ê²½ì?? && ë¬¸ì?? ë²???¸ê?? ê°??????? ë²???¸ê?? ??????ë©? ê¸°ì¡´??? ?????¥ë????? ??????ì§???? ëª¨ë¥´??? ?????? ëª©ë????? ê°???¸ì??
function editor_upload_init(editor_sequence, el, inserted_files_count) {
    xAddEventListener(window,'load',function() { editor_upload_start(editor_sequence, el, inserted_files_count);} );
}

function editor_upload_get_target_srl(editor_sequence) {
    return editorRelKeys[editor_sequence]["primary"].value;
}

function editor_upload_get_uploader_name(editor_sequence) {
    return "swf_uploader_"+editor_sequence;

}

// ?????? ???ë¡????ë¥? ?????? ê¸°ë³¸ ì¤?ë¹?ë¥? ??? 
function editor_upload_start(editor_sequence, fo_obj, inserted_files_count) {
    if(typeof(inserted_files_count)=='undefined' || !inserted_files_count) inserted_files_count = 0;
    else inserted_files_count = parseInt(inserted_files_count, 10);

    // ìº???? ??????
    try { document.execCommand('BackgroundImageCache',false,true); } catch(e) { }

    // ?????? iframe??? ?????? (ê³µí?µì?¼ë?? ??¬ì??)
    if(!xGetElementById('tmp_upload_iframe')) {
        if(xIE4Up) {
            window.document.body.insertAdjacentHTML("afterEnd", "<iframe id='tmp_upload_iframe' name='tmp_upload_iframe' style='display:none;width:1px;height:1px;position:absolute;top:-10px;left:-10px'></iframe>");
        } else {
            var obj_iframe = xCreateElement('IFRAME');
            obj_iframe.name = obj_iframe.id = 'tmp_upload_iframe';
            obj_iframe.style.display = 'none';
            obj_iframe.style.width = '1px';
            obj_iframe.style.height = '1px';
            obj_iframe.style.position = 'absolute';
            obj_iframe.style.top = '-10px';
            obj_iframe.style.left = '-10px';
            window.document.body.appendChild(obj_iframe);
        }
    }

    // ì²¨ë???????? ëª©ë????? ì¶???¥í????? select element êµ¬í??
    var field_obj = xGetElementById("uploaded_file_list_"+editor_sequence);
    if(!field_obj) return;

    // ????????°ë?? ê°???¸ë?? form??? êµ¬í?? submit target??? ?????? iframe??¼ë?? ë³?ê²?
    if(!fo_obj) fo_obj = editorGetForm(editor_sequence);
    fo_obj.target = 'tmp_upload_iframe';

    // SWF uploader ??????
    var uploader_name = editor_upload_get_uploader_name(editor_sequence);
    var embed_html = "";

    // ???ë¡??????? ê´???¨ë?? ë³???? ??¤ì?? (??? ë³??????¤ì?? ê·¸ë??ë¡? zbxe??? ?????¬ë??)
    var flashVars = ''+
        'uploadProgressCallback=editor_upload_progress'+
        '&uploadFileErrorCallback=editor_upload_error_handle'+
        '&allowedFiletypesDescription='+uploader_setting["allowed_filetypes_description"]+
        '&autoUpload=true&allowedFiletypes='+uploader_setting["allowed_filetypes"]+
        '&maximumFilesize='+uploader_setting["allowed_filesize"]+
        '&uploadQueueCompleteCallback=editor_display_uploaded_file'+
        '&uploadScript='+escape( request_uri+'?mid='+current_url.getQuery('mid')+
        '&act=procFileUpload'+
        '&editor_sequence='+editor_sequence+
        '&PHPSESSID='+xGetCookie(zbxe_session_name)
        );

    // ê°?ì²? ?????? ì½????
    if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length) {
        embed_html = '<embed type="application/x-shockwave-flash" src="'+request_uri+'/modules/editor/tpl/images/SWFUpload.swf" width="1" height="1" id="'+uploader_name+'" name="'+uploader_name+'" quality="high" wmode="transparent" menu="false" flashvars="'+flashVars+'" />';
    } else {
        embed_html = '<object id="'+uploader_name+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1" height="1"><param name="movie" value="'+request_uri+'./modules/editor/tpl/images/SWFUpload.swf" /><param name="bgcolor" value="#000000" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="menu" value="false" /><param name="flashvars" value="'+flashVars+'" /></object>';
    }

    // div dummy ê°?ì²´ë?? ë§???¤ê?? SWFUploader ì½????ë¥? ì¶?ê°??????? ê°?ì²? ??????
    var dummy = xCreateElement("div");
    dummy.style.width = "1px";
    dummy.style.height = "1px";
    dummy.style.position="absolute";
    dummy.style.top="0px";
    dummy.style.left="0px";
    window.document.body.appendChild(dummy);
    xInnerHtml(dummy, embed_html);

    /**
     * upload_target_srlê°???? ??¤ì?? ë¬¸ì?? ë²???¸ì?? ê²½ì?? ??´ë?? ??±ë????? ??????ì§???? ëª¨ë¥´??? ì²¨ë???????? ëª©ë????? ë¡???? 
     * procDeleteFile??? file_srl??? ë³´ë?´ì£¼ì§? ?????¼ë©´ ??????????????? ?????? ëª©ë??ë§? ê°±ì????? ??? ??????
     **/
    if(inserted_files_count>0) editor_display_uploaded_file(editor_sequence);
}

// ?????? ???ë¡???? ?????? ??¸ë?¤ë??
function editor_upload_error_handle(errcode,file,msg) {
    switch(errcode) {
        case -10 : 
                alert("- Error Code: HTTP Error\n- File name: "+file.name+"\n- Message: "+msg);
            break;
        case -20 : 
                alert("- Error Code: No upload script\n- File name: "+file.name+"\n- Message: "+msg);
            break;
        case -30 :
                alert("- Error Code: IO Error\n- File name: "+file.name+"\n- Message: "+msg);
            break;
        case -40 : 
                alert("- Error Code: Security Error\n- File name: "+file.name+"\n- Message: "+msg);
            break;
        case -50 : 
                alert("- Error Code: Filesize exceeds limit\n- File name: "+file.name+"\n- File size: "+file.size+"\n- Message: "+msg);
            break;
    }
}

/**
 * ?????? ???ë¡???? ê´???? ??¨ì?????
 **/

// ?????? ???ë¡????
var _prev_editor_sequence; ///< ì§???? ??????ë¥? ?????????ê¸? ?????? ë°?ë¡? ??´ì????? ????????? sequenceê°???? ê°?ì§?ê³? ??????
function editor_upload_file(editor_sequence) {
    // ???ë¡???? ê°?ì²´ë?? êµ¬í??
    var uploader_name = editor_upload_get_uploader_name(editor_sequence);
    var swf_uploader = xGetElementById(uploader_name);

    try {
        swf_uploader.browse();
        _prev_editor_sequence = editor_sequence;
    } catch(e) {
    }

}

// ???ë¡???? ì§?????????? ??????
var _progress_start = false;
function editor_upload_progress(file, bytesLoaded) {
    var obj = xGetElementById('uploaded_file_list_'+_prev_editor_sequence);
    if(!_progress_start) {
        while(obj.options.length) {
            obj.remove(0);
        }
        _progress_start = true;
    }

    var percent = Math.ceil((bytesLoaded / file.size) * 100);
    var filename = file.name;
    if(filename.length>20) filename = filename.substr(0,20)+'...';

    var text = filename + ' ('+percent+'%)';
    if(!obj.options.length || obj.options[obj.options.length-1].value != file.id) {
        var opt_obj = new Option(text, file.id, true, true);
        obj.options[obj.options.length] = opt_obj;
    } else {
        obj.options[obj.options.length-1].text = text;
    }
}

// upload_target_srl ??? ??±ë????? ?????? ??????
function editor_display_uploaded_file(editor_sequence) {
    if(typeof(editor_sequence)=='undefined'||!editor_sequence) editor_sequence = _prev_editor_sequence;
    if(!editor_sequence) return;

    // ??´ë?? ??±ë????? ???ì²? ?????? ëª©ë????? êµ¬í?´ì??
    var url = request_uri + "?act=procFileDelete&editor_sequence="+editor_sequence+"&mid="+current_url.getQuery('mid');

    // iframe??? url??? ë³´ë?´ë??ë¦?
    var iframe_obj = xGetElementById('tmp_upload_iframe');
    if(!iframe_obj) return;
    iframe_obj.contentWindow.document.location.href=url;
}


// ???ë¡??????? ?????? ëª©ë?? ë¹???? (??¨ì????? select ê°?ì²´ì?? ??´ì?©ì?? ì§???°ê?? ë¯¸ë¦¬ë³´ê¸°ë¥? ???ê±°í??)
function editor_upload_clear_list(editor_sequence, upload_target_srl) {
    if(!upload_target_srl || upload_target_srl<1) return;
    editorRelKeys[editor_sequence]["primary"].value = upload_target_srl;
    
    var obj = xGetElementById('uploaded_file_list_'+editor_sequence);
    while(obj.options.length) {
        obj.remove(0);
    }
    var preview_obj = xGetElementById('preview_uploaded_'+editor_sequence);
    xInnerHtml(preview_obj,'')
}

// ???ë¡??????? ?????? ???ë³´ë?? select ëª©ë????? ì¶?ê°?
function editor_insert_uploaded_file(editor_sequence, file_srl, filename, file_size, disp_file_size, uploaded_filename, sid) {
    var obj = xGetElementById('uploaded_file_list_'+editor_sequence);
    var text = disp_file_size+' - '+filename;
    var opt_obj = new Option(text, file_srl, true, true);
    obj.options[obj.options.length] = opt_obj;

    var file_obj = {file_srl:file_srl, filename:filename, file_size:file_size, uploaded_filename:uploaded_filename, sid:sid}
    uploaded_files[file_srl] = file_obj;

    editor_preview(obj, editor_sequence);
    _progress_start = false;
}

// ?????? ëª©ë??ì°½ì????? ??´ë¦­ ????????? ê²½ì?? ë¯¸ë¦¬ ë³´ê¸°
function editor_preview(sel_obj, editor_sequence) {
    var preview_obj = xGetElementById('preview_uploaded_'+editor_sequence);
    if(!sel_obj.options.length) {
        xInnerHtml(preview_obj, '');
        return;
    }

    var file_srl = sel_obj.options[sel_obj.selectedIndex].value;
    var obj = uploaded_files[file_srl];
    if(typeof(obj)=='undefined'||!obj) return;
    var uploaded_filename = obj.uploaded_filename;

    if(!uploaded_filename) {
        xInnerHtml(preview_obj, '');
        return;
    }

    var html = "";

    // ????????? ???????????? ê²½ì??
    if(/\.flv$/i.test(uploaded_filename)) {
        html = "<EMBED src=\"./common/tpl/images/flvplayer.swf?autoStart=false&file="+uploaded_filename+"\" width=\"110\" height=\"110\" type=\"application/x-shockwave-flash\"></EMBED>";

    // ????????? ?????¼ì?? ê²½ì??
    } else if(/\.swf$/i.test(uploaded_filename)) {
        html = "<EMBED src=\""+uploaded_filename+"\" width=\"110\" height=\"110\" type=\"application/x-shockwave-flash\"></EMBED>";

    // wmv, avi, mpg, mpeg??±ì?? ????????? ?????¼ì?? ê²½ì??
    } else if(/\.(wmv|avi|mpg|mpeg|asx|asf|mp3)$/i.test(uploaded_filename)) {
        html = "<EMBED src=\""+uploaded_filename+"\" width=\"110\" height=\"110\" autostart=\"true\" Showcontrols=\"0\"></EMBED>";

    // ??´ë?¸ì?? ?????¼ì?? ê²½ì??
    } else if(/\.(jpg|jpeg|png|gif)$/i.test(uploaded_filename)) {
        html = "<img src=\""+uploaded_filename+"\" border=\"0\" width=\"110\" height=\"110\" />";

    }
    xInnerHtml(preview_obj, html);
}

// ???ë¡??????? ?????? ??????
function editor_remove_file(editor_sequence) {
    var obj = xGetElementById('uploaded_file_list_'+editor_sequence);
    if(obj.options.length<1) return;

    // ???????????¤ë?? ?????¼ì?? ???ë³´ë?? ì±?ê¹?;;
    var fo_obj = obj;
    while(fo_obj.nodeName != 'FORM') { fo_obj = fo_obj.parentNode; }
    var mid = fo_obj.mid.value;

    // ë¹? iframe êµ¬í??
    var iframe_obj = xGetElementById('tmp_upload_iframe');
    if(!iframe_obj) return;

    // upload_target_srl??? ê°???? ë²???¸ì?? ê²½ì?? ???ë¬? ?????? ???ì§? ??????
    var upload_target_srl = editorRelKeys[editor_sequence]["primary"].value;
    if(upload_target_srl<1) return;

    for(var i=0;i<obj.options.length;i++) {
        var sel_obj = obj.options[i];
        if(!sel_obj.selected) continue;

        var file_srl = sel_obj.value;
        if(!file_srl) continue;

        var url = request_uri+"/?act=procFileDelete&editor_sequence="+editor_sequence+"&upload_target_srl="+upload_target_srl+"&file_srl="+file_srl+"&mid="+current_url.getQuery('mid');

        iframe_obj.contentWindow.document.location.href=url;

        xSleep(100);
    }

    var preview_obj = xGetElementById('preview_uploaded_'+editor_sequence);
    xInnerHtml(preview_obj, "");
}

// ???ë¡???? ëª©ë????? ????????? ?????¼ì?? ??´ì?©ì?? ì¶?ê°?
function editor_insert_file(editor_sequence) {
    if(editorMode[editor_sequence]=='html') return;
    var obj = xGetElementById('uploaded_file_list_'+editor_sequence);
    if(obj.options.length<1) return;

    var iframe_obj = editorGetIFrame(editor_sequence);
    editorFocus(editor_sequence);

    var fo_obj = obj;
    while(fo_obj.nodeName != 'FORM') { fo_obj = fo_obj.parentNode; }

    // ??¤ì?? ????????? ê²½ì?°ë?? ?????? loop
    for(var i=0;i<obj.options.length;i++) {
        var sel_obj = obj.options[i];
        if(!sel_obj.selected) continue;

        var file_srl = sel_obj.value;
        if(!file_srl) continue;

        var file_obj = uploaded_files[file_srl];
        var filename = file_obj.filename;
        var sid = file_obj.sid;
        var url = file_obj.uploaded_filename.replace(/(.*)files\/(.*)/i,'files/$2');

        // ë°?ë¡? ë§???? ê°???¥í?? ?????¼ì?? ê²½ì?? (??´ë?¸ì??, ?????????, ????????? ???..)
        if(url.indexOf("binaries")==-1) {
            // ??´ë?¸ì?? ?????¼ì?? ê²½ì?? image_link ì»´í?¬ë????? ??´ê²°
            if(/\.(jpg|jpeg|png|gif)$/i.test(url)) {
                var text = "<img editor_component=\"image_link\" src=\""+url+"\" alt=\""+file_obj.filename+"\" />";
                editorReplaceHTML(iframe_obj, text);
            // ??´ë?¸ì????¸ì?? ê²½ì?°ë?? multimedia_link ì»´í?¬ë????? ??°ê²°
            } else {
                var text = "<img src=\"./common/tpl/images/blank.gif\" editor_component=\"multimedia_link\" multimedia_src=\""+url+"\" width=\"400\" height=\"320\" style=\"display:block;width:400px;height:320px;border:2px dotted #4371B9;background:url(./modules/editor/components/multimedia_link/tpl/multimedia_link_component.gif) no-repeat center;\" auto_start=\"false\" alt=\"\" />";
                editorReplaceHTML(iframe_obj, text);
            }

            // binary?????¼ì?? ê²½ì?? url_link ì»´í?¬ë????? ??°ê²° 
        } else {
            var mid = fo_obj.mid.value;
            var url = "./?module=file&amp;act=procFileDownload&amp;file_srl="+file_srl+"&amp;sid="+sid;
            var text = "<a href=\""+url+"\">"+filename+"</a>\n";
            editorReplaceHTML(iframe_obj, text);
        } 
    }
}

// Hide And Show Toggle
var cc=0
function hideShow(id) {
    if (cc==0) {
        cc=1
        document.getElementById(id).style.display="none";
    } else {
        cc=0
        document.getElementById(id).style.display="block";
    }
}

// Show And Hide Toggle
var cc=0
function showHide(id) {
    if (cc==0) {
        cc=1
        document.getElementById(id).style.display="block";
    } else {
        cc=0
        document.getElementById(id).style.display="none";
    }
}

// Local Navigation Toggle
function lnbToggle(id) {
	for(num=1; num<=3; num++) document.getElementById('D3MG'+num).style.display='none'; //D4MG1~D4MG3 ê¹?ì§? ??¨ê¸´ ??¤ì??
	document.getElementById(id).style.display='block'; //??´ë?? IDë§? ë³´ì??
}

// IS
function chkIsKind(key, value) {
    showHide('selectOrder');
    xGetElementById('search_target'+key).checked = true;
    xInnerHtml('search_target_label', value);
}

function widget_login(fo_obj) {
	var oFilter = new XmlJsFilter(fo_obj, "member", "procMemberLogin", completeLogin);
	oFilter.addFieldItem("user_id",true,0,0,"","user_id");
	oFilter.addFieldItem("password",true,0,0,"","");
	oFilter.addResponseItem("error");
	oFilter.addResponseItem("message");
	return oFilter.proc();
}
alertMsg["user_id"] = "?????´ë??";
alertMsg["password"] = "ë¹?ë°?ë²????";
target_type_list["user_id"] = "user_id";
target_type_list["password"] = "";
alertMsg["isnull"] = "%s??? ê°???? ?????¥í?´ì£¼??¸ì??";
alertMsg["outofrange"] = "%s??? ê¸???? ê¸¸ì?´ë?? ë§?ì¶???? ì£¼ì?¸ì??.";
alertMsg["equalto"] = "%s??? ê°???? ???ëª? ????????µë?????.";
alertMsg["invalid_email"] = "%s??? ????????? ???ëª»ë???????µë?????. (???: zbxe@zeroboard.com)";
alertMsg["invalid_userid"] = "%s??? ????????? ???ëª»ë???????µë?????.\n???ë¬?,??«ì????? _ë¡? ë§??????? ??? ?????¼ë©° ?????? ?????? ???ë¬¸ì?´ì?´ì?? ??©ë?????";
alertMsg["invalid_user_id"] = "%s??? ????????? ???ëª»ë???????µë?????.\n???ë¬?,??«ì????? _ë¡? ë§??????? ??? ?????¼ë©° ?????? ?????? ???ë¬¸ì?´ì?´ì?? ??©ë?????";
alertMsg["invalid_homepage"] = "%s??? ????????? ???ëª»ë???????µë?????. (???: http://www.zeroboard.com)";
alertMsg["invalid_korean"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ê¸?ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_korean_number"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ê¸?ê³? ??«ì??ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_alpha"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ë¬¸ì?¼ë??ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_alpha_number"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ë¬¸ê³¼ ??«ì??ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_number"] = "%s??? ????????? ???ëª»ë???????µë?????. ??«ì??ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";

function openid_login(fo_obj) {
	var oFilter = new XmlJsFilter(fo_obj, "member", "procMemberOpenIDLogin", completeOpenIDLogin);
	oFilter.addFieldItem("user_id",true,0,0,"","");
	oFilter.addResponseItem("error");
	oFilter.addResponseItem("message");
	return oFilter.proc();
}
alertMsg["user_id"] = "?????´ë??";
target_type_list["user_id"] = "";
alertMsg["isnull"] = "%s??? ê°???? ?????¥í?´ì£¼??¸ì??";
alertMsg["outofrange"] = "%s??? ê¸???? ê¸¸ì?´ë?? ë§?ì¶???? ì£¼ì?¸ì??.";
alertMsg["equalto"] = "%s??? ê°???? ???ëª? ????????µë?????.";
alertMsg["invalid_email"] = "%s??? ????????? ???ëª»ë???????µë?????. (???: zbxe@zeroboard.com)";
alertMsg["invalid_userid"] = "%s??? ????????? ???ëª»ë???????µë?????.\n???ë¬?,??«ì????? _ë¡? ë§??????? ??? ?????¼ë©° ?????? ?????? ???ë¬¸ì?´ì?´ì?? ??©ë?????";
alertMsg["invalid_user_id"] = "%s??? ????????? ???ëª»ë???????µë?????.\n???ë¬?,??«ì????? _ë¡? ë§??????? ??? ?????¼ë©° ?????? ?????? ???ë¬¸ì?´ì?´ì?? ??©ë?????";
alertMsg["invalid_homepage"] = "%s??? ????????? ???ëª»ë???????µë?????. (???: http://www.zeroboard.com)";
alertMsg["invalid_korean"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ê¸?ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_korean_number"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ê¸?ê³? ??«ì??ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_alpha"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ë¬¸ì?¼ë??ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_alpha_number"] = "%s??? ????????? ???ëª»ë???????µë?????. ???ë¬¸ê³¼ ??«ì??ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";
alertMsg["invalid_number"] = "%s??? ????????? ???ëª»ë???????µë?????. ??«ì??ë¡?ë§? ?????¥í?´ì£¼?????? ??©ë?????";

/* ë¡?ê·¸ì?? ????????? ??¬ì»¤??? */
function doFocusUserId(fo_id) {
    if(xScrollTop()) return;
    var fo_obj = xGetElementById(fo_id);
    if(fo_obj.user_id) {
        try{
            fo_obj.user_id.focus();
        } catch(e) {};
    }
}

/* ë¡?ê·¸ì?? ??? */
function completeLogin(ret_obj, response_tags, params, fo_obj) {
    var url =  current_url.setQuery('act','');
    location.href = url;
}

/* ??¤í???????´ë?? ë¡?ê·¸ì?? ??? */
function completeOpenIDLogin(ret_obj, response_tags) {
    var redirect_url =  ret_obj['redirect_url'];
    location.href = redirect_url;
}

/* ??¤í?? ?????´ë?? ??? ë³???? */
function toggleLoginForm(obj) {
    if(xGetElementById('login').style.display != "none") {
        xGetElementById('login').style.display = "none";
        xGetElementById('openid_login').style.display = "block";
        xGetElementById('use_open_id_2').checked = true;
    } else {
        xGetElementById('openid_login').style.display = "none";
        xGetElementById('login').style.display = "block";
        xGetElementById('use_open_id').checked = false;
        xGetElementById('use_open_id_2').checked = false;
    }
}
