




/* ¸ÞÀÎ ¸Þ´º ¼û±è */

function hidepoptext() {

  if(parent.lf && parent.lf != this){
    if (typeof(parent.lf.slidingFrame) == "undefined") {
      alert("¾÷¹«¸Þ´º¸¦ ·ÎµùÁßÀÔ´Ï´Ù. Àá½Ã ÈÄ ´Ù½Ã Å¬¸¯ÇØ ÁÖ½Ê½Ã¿À.");
      return;
    }
    parent.lf.slidingFrame();
    return;
  }

  if(typeof(layer1) == "undefined") {
    alert("ÀüÃ¼È­¸é¸ðµå¿¡¼­´Â ¾÷¹«¸Þ´º¸¦ »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
    return;
  }

  var str = layer1.style.visibility;
  if (str == "visible") {
    layer1.style.visibility = "hidden";
    showElementAll('SELECT', document.all.layer1);
  } else {
    layer1.style.visibility = "visible";
    hideElementAll('SELECT', document.all.layer1);
  }

  try {
    if (mainObject && mainObject.hideSelectbox) {
      mainObject.hideSelectbox(str);
    }
  } catch (e) {}

}

/* Folder Object constructor */
function Folder(folderDescription, hreference) {
  // constant data
  this.folderDescription = folderDescription;
  this.arrange = folderDescription;
  this.hreference = hreference;
  this.id = -1;
  this.navObj = 0;
  this.iconImg = 0;
  this.nodeImg = 0;
  this.isLastNode = 0;

  /* dynamic data */
  this.isOpen = true;
  this.iconSrc = "/mis/images/common/tree_menu/ftv2folderopen.gif";
  this.rootIconSrc = "/mis/images/common/tree_menu/icon_top.gif";
  this.children = new Array;
  this.nChildren = 0;

  // methods
  this.initialize = initializeFolder;
  this.setStateFolder = setStateFolder;
  this.addChild = addChild;
  this.createEntryIndex = createEntryIndex;
  this.hide = hideFolder;
  this.display = display;
  this.drawFolder = drawFolder;
  this.totalHeight = totalHeight;
  this.folderSubEntries = folderSubEntries;
  this.outputFolderLink = outputFolderLink;
}

function setStateFolder(isOpen) {
  var folderSubEntries;
  var totalHeight;
  var fIt = 0;
  var i=0;

  if (isOpen == this.isOpen) return;

  if (browserVersion == 2) {
    totalHeight = 0;
    for (i = 0; i < this.nChildren; i++)
      totalHeight = totalHeight + this.children[i].navObj.clip.height;
      folderSubEntries = this.folderSubEntries();

    if (this.isOpen) totalHeight = 0 - totalHeight;

    for (fIt = this.id + folderSubEntries + 1; fIt < nEntries; fIt++)
      indexOfEntries[fIt].navObj.moveBy(0, totalHeight);
  }
  this.isOpen = isOpen;
  propagateChangesInState(this);
}

function propagateChangesInState(folder) {
  var i = 0;

  if (folder.isOpen) {
    if (folder.nodeImg) {
      if (folder.isLastNode) folder.nodeImg.src = "/mis/images/common/tree_menu/ftv2mlastnode.gif";
      else folder.nodeImg.src = "/mis/images/common/tree_menu/ftv2mnode.gif";
    }

    if(folder.isRoot)
    {
       folder.iconImg.src = "/mis/images/common/tree_menu/icon_top.gif";
    } else {
       folder.iconImg.src = "/mis/images/common/tree_menu/ftv2folderopen.gif";
    }
    for (i = 0; i < folder .nChildren; i++)
      folder.children[i].display();
  } else {
    if (folder.nodeImg) {
      if (folder.isLastNode) folder.nodeImg.src = "/mis/images/common/tree_menu/ftv2plastnode.gif";
      else folder.nodeImg.src = "/mis/images/common/tree_menu/ftv2pnode.gif";
    }

    folder.iconImg.src = "/mis/images/common/tree_menu/ftv2folderclosed.gif";
    for (i = 0; i < folder.nChildren; i++) folder.children[i].hide();
  }
}

function hideFolder() {
  if (browserVersion == 1) {
    if (this.navObj.style.display == "none") return;
    this.navObj.style.display = "none";
  } else {
    if (this.navObj.visibility == "hiden") return;
    this.navObj.visibility = "hiden";
  }

  this.setStateFolder(0);
}

function initializeFolder(level, lastNode, leftSide) {
  var j = 0;
  var i = 0;
  var numberOfFolders;
  var numberOfDocs;
  var nc;

  nc = this.nChildren;

  this.createEntryIndex();

  var auxEv = "";

  this.arrange  = changeType(this.arrange);

  if (browserVersion > 0) auxEv = "<a href='javascript:clickOnNode(" + this.id + ")' >";
  else auxEv = "<a>";

  if (level > 0) {
    if (lastNode) { //the last 'brother' in the children array
      this.drawFolder(leftSide + auxEv + "<img name='nodeIcon" +
          this.id + "' src='/mis/images/common/tree_menu/ftv2mlastnode.gif' width=16 height=22 border=0 id='"+this.arrange+"'></a>");
      leftSide = leftSide + "<img src='/mis/images/common/tree_menu/ftv2blank.gif' width=16 height=22>";
      this.isLastNode = 1;
    } else {
      this.drawFolder(leftSide + auxEv + "<img name='nodeIcon" +
          this.id + "' src='/mis/images/common/tree_menu/ftv2mnode.gif' width=16 height=22 border=0 id='"+this.arrange+"'></a>");
      leftSide = leftSide + "<img src='/mis/images/common/tree_menu/ftv2vertline.gif' width=16 height=22>";
      this.isLastNode = 0;
    }
  } else {
    this.drawFolder("");
  }

  if (nc > 0) {
    level = level + 1;
    for (i = 0 ; i < this.nChildren; i++) {
      if (i == this.nChildren-1) this.children[i].initialize(level, 1, leftSide);
      else this.children[i].initialize(level, 0, leftSide);
    }
  }
}

function drawFolder(leftSide) {

  if (browserVersion == 2) {
    if (!doc.yPos) doc.yPos = 8;
    doc.write("<layer id='folder" + this.id + "' top=" + doc.yPos + " left=10 visibility=hiden >");
  }

  doc.write("<table ");
  if (browserVersion == 1) {
    doc.write(" id='folder" + this.id + "' style='position:block;' ");
  }
  doc.write(" border=0 cellspacing=0 cellpadding=0>");

  doc.write("<tr><td>");
  doc.write(leftSide);
  doc.write("<IMG name='folderIcon" + this.id + "' ");
  if(leftSide =="") {
     doc.write("src='" + this.rootIconSrc + "' border=0></a>");
  }
  else {
     doc.write("src='" + this.iconSrc + "' border=0></a>");
  }

  doc.write("</td><td valign=middle nowrap >");
  if (USETEXTLINKS) {
    this.outputFolderLink();
    doc.write(this.folderDescription + "</a>");
  } else {
    doc.write(this.folderDescription);
  }
  doc.write("</td>");
  doc.write("</table>");

  if (browserVersion == 2) {
    doc.write("</layer>");
  }

  if (browserVersion == 1) {
    this.navObj = doc.all["folder" + this.id];
    this.iconImg = doc.all["folderIcon" + this.id];
    this.nodeImg = doc.all["nodeIcon" + this.id];
  } else if (browserVersion == 2) {
    this.navObj = doc.layers["folder" + this.id];
    this.iconImg = this.navObj.document.images["folderIcon" + this.id];
    this.nodeImg = this.navObj.document.images["nodeIcon" + this.id];
    doc.yPos = doc.yPos + this.navObj.clip.height;
  }
}

function outputFolderLink() {
  if (this.hreference) {
    // alert(this.hreference);
    doc.write("<a href='" + this.hreference + "' target=\"inbar\" ");
    if (browserVersion > 0) {
      doc.write("onClick='javascript:clickOnFolder(" + this.id + ")'");
    }
    doc.write(">");
  } else {
    // alert(this.hreference);
    doc.write("<a>");
  }
//  doc.write("<a href='javascript:clickOnFolder("+this.id+")'>")
}

function addChild(childNode) {
  this.children[this.nChildren] = childNode;
  this.nChildren++;
  return childNode;
}

function folderSubEntries() {
  var i = 0;
  var se = this.nChildren;

  for (i = 0; i < this.nChildren; i++) {
    if (this.children[i].children) // is a folder
      se = se + this.children[i].folderSubEntries();
  }

  return se;
}

/* Definition of class Item (a document or link inside a Folder) */
function Item(itemDescription, itemLink) {
  // constant data
  this.itemDescription = itemDescription;
  this.link = itemLink;
  this.id = -1;     // initialized in initalize()
  this.navObj = 0;  // initialized in render()
  this.iconImg = 0; // initialized in render()
  this.iconSrc = "/mis/images/common/tree_menu/ftv2doc.gif";

//  methods
  this.initialize = initializeItem;
  this.createEntryIndex = createEntryIndex;
  this.hide = hideItem;
  this.display = display;
  this.drawItem = drawItem;
  this.totalHeight = totalHeight;
}

function hideItem() {
  if (browserVersion == 1) {
    if (this.navObj.style.display == "none") return;
    this.navObj.style.display = "none";
  } else {
    if (this.navObj.visibility == "hiden") return;
    this.navObj.visibility = "hiden";
  }
}

function initializeItem(level, lastNode, leftSide) {
  this.createEntryIndex();

  if (level > 0) {
    if (lastNode) { // the last 'brother' in the children array
      this.drawItem(leftSide + "<img src='/mis/images/common/tree_menu/ftv2lastnode.gif' width=16 height=22>");
      leftSide = leftSide + "<img src='/mis/images/common/tree_menu/ftv2blank.gif' width=16 height=22>";
    } else {
      this.drawItem(leftSide + "<img src='/mis/images/common/tree_menu/ftv2node.gif' width=16 height=22>");
      leftSide = leftSide + "<img src='/mis/images/common/tree_menu/ftv2vertline.gif' width=16 height=22>";
    }
  } else {
    this.drawItem("");
  }
}

function drawItem(leftSide) {
  if (browserVersion == 2)
    doc.write("<layer id='item" + this.id + "' top=" + doc.yPos + " visibility='hiden' >");

  doc.write("<table width='100%'");
  if (browserVersion == 1)
    doc.write(" id='item" + this.id + "' style='position:block;' ");
  doc.write(" border=0 cellspacing=0 cellpadding=0>");
  doc.write("<tr width='100%'><td>");
  doc.write(leftSide);

  doc.write("<img id='itemIcon" + this.id + "' ");
  doc.write("src='" + this.iconSrc + "' border=0>");

  doc.write("</td><td valign=middle nowrap width='100%'>");
  //alert(this.itemDescription);
  if (USETEXTLINKS) {
    //alert (this.itemDescription);
    //doc.write("<a href=" + this.link + ">" + this.itemDescription + "</a>");
    doc.write("<a id='link" + this.id + "' onactivate='setMark(this);' href=\"javascript:clickLink(" + this.link + ");\">" + this.itemDescription + "</a>");
  } else doc.write(this.itemDescription);
  doc.write("</table>");

  if (browserVersion == 2) doc.write("</layer>");

  if (browserVersion == 1) {
    this.navObj = doc.all["item" + this.id];
    this.iconImg = doc.all["itemIcon" + this.id];
  } else if (browserVersion == 2) {
    this.navObj = doc.layers["item" + this.id];
    this.iconImg = this.navObj.document.images["itemIcon" + this.id];
    doc.yPos = doc.yPos+this.navObj.clip.height;
  }
}
function clickLink(link) {

  var p = link.indexOf("popup/");
  if ( p > 0 ) {
     openWin = window.open(link.substring(0, p)+link.substring(p + 6),  null,
        "menubar = no, resizable = yes, scrollbar = no"
        + ", left = 0, top = 0, width = 1010, height = 720");
  } else {
    if (document.all.fullCheck.checked == true) {
        openWin = window.open(link,  null,
        "menubar=no, resizable=yes, scrollbar=yes"
        + ", left=0, top=0, width="
        + screen.availWidth
        + ", height="
        + screen.availHeight);
      } else {
        window.document.location.href=link;
      }
  }
}


/* Methods common to both objects (pseudo-inheritance) */
function display() {
  if (browserVersion == 1) this.navObj.style.display = "block";
  else this.navObj.visibility = "show";
}

function createEntryIndex() {
  this.id = nEntries;
  indexOfEntries[nEntries] = this;
  nEntries++;
}

/* total height of subEntries open */
function totalHeight() { // used with browserVersion == 2
  var h = this.navObj.clip.height;
  var i = 0;

  if (this.isOpen) { // is a folder and _is_ open
    for (i = 0 ; i < this.nChildren; i++)
      h = h + this.children[i].totalHeight();
  }
  return h;
}


/* Events */
function clickOnFolder(folderId) {
  var clicked = indexOfEntries[folderId];

  if (!clicked.isOpen)
    clickOnNode(folderId);

  return;

  if (clicked.isSelected) return;
}

function clickOnNode(folderId) {
  var clickedFolder = 0;
  var state = 0;

  clickedFolder = indexOfEntries[folderId];
  state = clickedFolder.isOpen;

  clickedFolder.setStateFolder(!state); // open<->close
}

function initializeDocument() {
  if (doc.all) browserVersion = 1;   // IE4
  else {
    if (doc.layers)
      browserVersion = 2; // NS4
    else
      browserVersion = 0; // other
  }
  foldersTree.initialize(0, 1, "");
  foldersTree.isRoot = true; // mark as root
  foldersTree.display();

  if (browserVersion > 0) {
    doc.write("<layer top=" + indexOfEntries[nEntries-1].navObj.top + ">&nbsp;</layer>");
    // clickOnNode(0) ÇÔ¼ö µÎ°³ ´Ù ÁÖ¼®Ã³¸® ÇÏ¸é ¸ðµç ¸Þ´º¸¦ ÆîÃÄ¼­ º¸¿©ÁÖ°í ÁÖ¼®À» ¸ðµÎ Ç®¸é ´ÝÈù ¸Þ´º°¡ ³ªÅ¸³²
    // close the whole tree
    //clickOnNode(0);
    // open the root folder
    //clickOnNode(0);
  }
}

/* Auxiliary Functions for Folder-Treee backward compatibility */
function gFld(description, hreference) {
  folder = new Folder(description, hreference);
  return folder;
}

function gLnk(target, description, linkData) {
  // fullLink = "";

  if (target == "") {
    fullLink = "'" + linkData + ";jsessionid=F93A9F844B81BE1A442DA48298296279" + "'";
  } else {
    fullLink = "'" + linkData + ";jsessionid=F93A9F844B81BE1A442DA48298296279" + "' target=\"" + target + "\"";
  }

  linkItem = new Item(description, fullLink);
  return linkItem;
}

function submitData(data, description, targetObject){
  //alert(targetObject);
  fullLink = "\"javascript:opener.document.all." + targetObject + ".value='" + data + "';self.close();\"";
  //alert (fullLink);
  linkItem = new Item(description, fullLink);
  return linkItem;
}

function insFld(parentFolder, childFolder) {
  return parentFolder.addChild(childFolder);
}

function insDoc(parentFolder, document) {
  parentFolder.addChild(document);
}
function setMark(linker){
  if( linkObject != linker ){
    linker.className='linkClass';
    if(linkObject){
      linkObject.className='';
    }
    linkObject  = linker;
  }
}
function setMarkEx(linker){
  linker  = getCheckObject(linker);
  if( linkObject != linker ){
    linker.className='linkClass';
    if(linkObject){
      linkObject.className='';
    }
    linkObject  = linker;
  }
}
function getCheckObject(input){
  var td = input.parentNode;
  while((td.nodeName).toLowerCase()!="table"){
    td  = td.parentNode;
  }
  return td;
}
function changeType(kor){
  if(!kor) return '';
  if(kor == 'ÀÎ»ç')      return 'HR';
  if(kor == 'ÃÑ¹«')      return 'GA';
  if(kor == '±³À°')      return 'ED';
  if(kor == 'ºñ»ó º¸¾È') return 'SC';
  if(kor == 'È¸°è')      return 'FI';
  if(kor == '¿ÜÀÚ')      return 'FP';
  if(kor == '³»ÀÚ')      return 'DP';
  if(kor == 'ÀÚ»ê')      return 'AS';
  if(kor == 'Àåºñ')      return 'RE';
  if(kor == '½Ã¼³')      return 'FC';
  if(kor == '¿ø°¡')      return 'PC';
  if(kor == '¿¹»ê')      return 'BG';
  return '';
}
USETEXTLINKS    = 1;
indexOfEntries  = new Array;
nEntries        = 0;
doc             = document;
browserVersion  = 0;
selectedFolder  = 0;
linkObject      = '';


/* ÇØ´ç ÇÁ·¹ÀÓ¿¡¼­ ¸Þ´º ·¹ÀÌ¾î¿¡ °É¸®´Â select box¸¦ ¸ðµÎ ¼û±ä´Ù */
function hideElementAll(element, layer) {
  hideElement(document.all, element, layer);

  if (typeof(sect_master_contents) != "undefined") {
    hideElement(sect_master_contents.document.all, element, layer);
  }
  if (typeof(sect_query_cond) != "undefined") {
    hideElement(sect_query_cond.document.all, element, layer);
  }
  if (typeof(sect_detail) != "undefined") {
    hideElement(sect_detail.document.all, element, layer);
  }

/*
  for (var i = 0; i < document.all.tags("iframe").length; i++) {
    hideElement(document.all.tags("iframe")[i].document.all, element, layer);
    alert(document.all.tags("iframe")[i].document.all);
    alert(document.all.tags("iframe")[i].id);
  }
*/
}

/* ÇØ´ç ÇÁ·¹ÀÓ¿¡¼­ ¸Þ´º ·¹ÀÌ¾î¿¡ °É·Á¼­ ¼û°ÜÁ³´ø select box¸¦ ¸ðµÎ º¸¿©ÁØ´Ù */
function showElementAll(element, layer) {
  showElement(document.all, element, layer);

  if (typeof(sect_master_contents) != "undefined") {
    showElement(sect_master_contents.document.all, element, layer);
  }
  if (typeof(sect_query_cond) != "undefined") {
    showElement(sect_query_cond.document.all, element, layer);
  }
  if (typeof(sect_detail) != "undefined") {
    showElement(sect_detail.document.all, element, layer);
  }
/*
  for (var i = 0; i < document.all.tags("iframe").length; i++) {
    showElement(document.all.tags("iframe")[i].document.all, element);
    alert(document.all.tags("iframe")[i].id);
  }
*/
}

/* ÇØ´ç ÇÁ·¹ÀÓ¿¡¼­ ¸Þ´º ·¹ÀÌ¾î¿¡ °É¸®´Â select box¸¦ ¸ðµÎ ¼û±ä´Ù */
function hideElement(frame, elmID, overDiv) {
  var ie = frame;

  if (ie) {
    for (i = 0; i < ie.tags(elmID).length; i++) {
      obj = ie.tags(elmID)[i];

      if (!obj || !obj.offsetParent) {
        continue;
      }

      // Find the element's offsetTop and offsetLeft relative to the BODY tag.
      objLeft = obj.offsetLeft;
      objTop = obj.offsetTop;
      objParent = obj.offsetParent;

      while (objParent.tagName.toUpperCase() != "BODY") {
        objLeft += objParent.offsetLeft;
        objTop += objParent.offsetTop;
        objParent = objParent.offsetParent;
      }
  
      objHeight = obj.offsetHeight;
      objWidth = obj.offsetWidth;

      var str = "layer left = " + overDiv.offsetLeft + "\n"
              + "layer Width = " + overDiv.offsetWidth + "\n"
              + "layer top = " + overDiv.offsetTop + "\n"
              + "layer Height = " + overDiv.offsetHeight;

      if ((overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft);
      //else if ((overDiv.offsetTop + overDiv.offsetHeight ) <= objTop);
      //else if (overDiv.offsetTop >= ( objTop + objHeight));
      else if (overDiv.offsetLeft >= ( objLeft + objWidth));
      else {
        obj.style.visibility = "hidden";
      }
    }
  }
}

/* ÇØ´ç ÇÁ·¹ÀÓ¿¡¼­ ¸Þ´º ·¹ÀÌ¾î¿¡ °É·Á¼­ ¼û°ÜÁ³´ø select box¸¦ ¸ðµÎ º¸¿©ÁØ´Ù */
function showElement(frame, elmID, overDiv) {
  var ie = frame;

  if (ie) {
    for (i = 0; i < ie.tags(elmID).length; i++) {
      obj = ie.tags(elmID)[i];

      if (!obj || !obj.offsetParent) {
        continue;
      }

      // Find the element's offsetTop and offsetLeft relative to the BODY tag.
      objLeft = obj.offsetLeft;
      objTop = obj.offsetTop;
      objParent = obj.offsetParent;

      while (objParent.tagName.toUpperCase() != "BODY") {
        objLeft += objParent.offsetLeft;
        objTop += objParent.offsetTop;
        objParent = objParent.offsetParent;
      }
  
      objHeight = obj.offsetHeight;
      objWidth = obj.offsetWidth;

      var str = "layer left = " + overDiv.offsetLeft + "\n"
              + "layer Width = " + overDiv.offsetWidth + "\n"
              + "layer top = " + overDiv.offsetTop + "\n"
              + "layer Height = " + overDiv.offsetHeight;

      if ((overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft);
      else if ((overDiv.offsetTop + overDiv.offsetHeight ) <= objTop);
      //else if (overDiv.offsetTop >= ( objTop + objHeight));
      //else if (overDiv.offsetLeft >= ( objLeft + objWidth));
      else {
        obj.style.visibility = "";
      }
    }
  }
}

/*
* unhides <select> and <applet> objects (for IE only)
*/
/*
function showElement(frame, elmID) {
  var ie = frame;
  if (ie) {
    for (i = 0; i < ie.tags(elmID).length; i++) {
      obj = ie.tags( elmID )[i];
      
      if (!obj || !obj.offsetParent) {
        continue;
      }
    
      obj.style.visibility = "";
    }
  }
}
*/

/* hidepoptext() Overriding */
//function hidepoptext() {
//
//}
