﻿function fnTopMenu1_Type1() 
{
 this.menu = new Array();
 this.menuseq = 0;
 this.Start = function() 
 { 
  // 자식개체: this.DivName 밑에 UL 태그 바로 밑에 자식놈들(1댑스 li)을 개체로 잡아라.
  this.MenuBox = document.getElementById(this.DivName).getElementsByTagName("ul")[0].childNodes;
  //테스트 : document.write(this.DivName);  
  // 자식개체 수: 위 그 자식놈들 개체(1댑스 li)의 개수를 파악해라
  this.MenuLength = this.MenuBox.length;
  // 메뉴의 주 메뉴 링크부분에 마우스나 키보드의 반응을 넣는 부분
  for ( var i=0; i<this.MenuLength; i++ ) 
  {
   // 자식개체놈(1댑스 li) 이름이 LI가 아니면 다시 돌려라
   if(this.MenuBox.item(i).tagName != "LI" )
   {continue;}
   // 자식 개체놈(1댑스 li)의 a태그를 this.MenuLink 에 넣는다
   this.MenuLink = this.MenuBox.item(i).getElementsByTagName("a")[0];
   this.MenuLink.i = i;
   // 저 아래서 호출된 fnName을 this.MenuLink.fnName에 넣는다
   this.MenuLink.fnName = this.fnName;
   //마우스오버와 키보드포커스 이벤트에 아래 함수 넣는다.
   this.MenuLink.onmouseover = this.MenuLink.onfocus = function() 
   {
    // 해당 놈 이름값.fnMouseOver 함수 만들기
    // 결과 : TopMenu1.fnMouseOver(0) 부터 해당 개수 -1 까지
    eval(this.fnName+".fnMouseOver("+ this.i + ")")
    // document.write(this.fnName+".fnMouseOver("+ this.i + ")")
   }
   //자식개체놈의 ul태그(2댑스 감싸는 놈)를 this.MenuSubBox 에 넣어라
   this.MenuSubBox = this.MenuBox.item(i).getElementsByTagName("ul")[0];
   // 2댑스를 감싸는 ul > li 인(2댑스메뉴) 놈을 this.MenuSubMenu 에 넣어라
   this.MenuSubMenu = this.MenuSubBox.getElementsByTagName("li");
   // 2댑스의 li 놈들이 몇개인지 넣어라
   this.MenuSubMenuLength = this.MenuSubMenu.length;
   // 메뉴 2뎁스 링크에 마우스나 키보드의 반응 넣는 부분
   for ( var j=0; j<this.MenuSubMenuLength; j++ ) 
   {
    // 2댑스 자식개체놈의 a태그를 this.MenuSubLink 에 넣는다
    this.MenuSubLink = this.MenuSubMenu.item(j).getElementsByTagName("a")[0];
    // 이벤트 고유 위치값을 위한 숫자 넣기
    this.MenuSubLink.i = i;
    this.MenuSubLink.j = j;
    // 해당 놈 이름 값 넣기
    this.MenuSubLink.fnName = this.fnName;
    // 해당 개체에 마우스오버 키보드포커스 이벤트 만들어 넣기
    this.MenuSubLink.onmouseover = this.MenuSubLink.onfocus = function() 
    {
     // 해당 놈 이름값.fnMouseSubOver 함수 만들기
     // 결과 : TopMenu1.fnMouseSubOver(0,1)
     eval(this.fnName + ".fnMouseSubOver(" + this.i + "," + this.j + ")") 
     //document.write(this.fnName + ".fnMouseSubOver(" + this.i + "," + this.j + ")")
    }
    // 해당 개체에 마우스아웃 키보드포커스아웃 이벤트 만들어 넣기
    this.MenuSubLink.onmouseout = this.MenuSubLink.onblur = function() 
    {
     // 해당 놈 이름값.fnMouseSubOut 함수 만들기
     eval(this.fnName +".fnMouseSubOut(" + this.i + "," + this.j + ")") 
    }
   }
   // 2댑스 감싸는 ul 박스 놈들은 일단 감춘다
     this.MenuSubBox.style.display = "none";
   //menuseq에 루프 개수 세기
   // 이벤트 삽입한 놈들 총 수 세는거
   this.menuseq++;
   // menuseq가 i보다 1크다.
   // 고로 this.menu[1] = 0 이 된다.
   this.menu[this.menuseq] = i
  } // 각 a 태그 객체 놈들에 이벤트 삽입 루프 끝
  // DefaultMenu가 0이 아니면 말이지..
  if ( this.DefaultMenu != 0 ) 
  {
   // fnMouseOver 함수 불러라, this.menu[this.DefaultMenu] 값 밑에서 설정한 기본 값
   this.fnMouseOver(this.menu[this.DefaultMenu]);
   //테스트 : document.write(this.menu[this.DefaultMenu]);  
   // DefaultSubMenu가 0이 아니면 말이지..
   if ( this.DefaultSubMenu != 0 ) 
   {
    // fnMouseSubOver 함수 불러라, this.menu[this.DefaultMenu],this.DefaultSubMenu- 1 값 전달해서
    this.fnMouseSubOver(this.menu[this.DefaultMenu],this.DefaultSubMenu- 1);
   }
  } // DefaultMenu가 0이 아닝 경우 끝
 } // this.Start 함수 끝
 // 1댑스의 주 메뉴 링크부분에 마우스나 키보드의 반응에 의해 실행하는 부분
 this.fnMouseOver = function(val) 
 {
  for ( var i=0; i<this.MenuLength; i++ ) 
  {
   if ( this.MenuBox.item(i).tagName != "LI" )
   {continue;}
   // 1댑스 이미지랑, 2댑스 박스 넣놓기
   //this.MenuImg = this.MenuBox.item(i).getElementsByTagName("a")[0].getElementsByTagName("img")[0];
   this.MenuSUl = this.MenuBox.item(i).getElementsByTagName("ul")[0];
   this.MenuA = this.MenuBox.item(i).getElementsByTagName("a")[0]
   this.MenuLi = this.MenuBox.item(i)
   // 마우스나 키보드 접근과 일치 하는 놈들은 다음처럼 해라
   if ( i == val )
   { 
    //this.MenuImg.src = this.MenuImg.src.replace("_off.gif","_on.gif");
    this.MenuSUl.style.display = "block" 
    this.MenuA.style.backgroundImage = "url(../imgs/tm_1d_over_bg.gif)"
    this.MenuLi.style.backgroundImage = "url(../imgs/tm_1d_over_bg.gif)"
    //this.MenuSUlstyle.position = "absolute"
   }else // 일치하지 않는 놈들에 대해선 다음 처럼 해라
   { 
    //this.MenuImg.src = this.MenuImg.src.replace("_on.gif","_off.gif");
    this.MenuA.style.backgroundImage = "none"
    this.MenuLi.style.backgroundImage = "none" 
    this.MenuSUl.style.display = "none" 
   }
  }
 }
 // 2댑스 즉 하위 메뉴 링크부분에 마우스나 키보드의 반응에 의해 실행하는 부분
 this.fnMouseSubOver = function(mnum,snum) 
 {
  //this.SubMenuImg = this.MenuBox.item(mnum).getElementsByTagName("ul")[0].getElementsByTagName("li")[snum].getElementsByTagName("a")[0].getElementsByTagName("img")[0];
  //this.SubMenuImg.src = this.SubMenuImg.src.replace("_off.gif","_on.gif");
    this.SubMenuA = this.MenuBox.item(mnum).getElementsByTagName("ul")[0].getElementsByTagName("li")[snum].getElementsByTagName("a")[0];
    this.SubMenuLi = this.MenuBox.item(mnum).getElementsByTagName("ul")[0].getElementsByTagName("li")[snum]
    this.SubMenuA.style.fontWeight = "bold"
    this.SubMenuLi.style.backgroundImage = "url(../imgs/tm_2d_over_icon.png)"
 }
 this.fnMouseSubOut = function(mnum,snum) 
 {
  //this.SubMenuImg = this.MenuBox.item(mnum).getElementsByTagName("ul")[0].getElementsByTagName("li")[snum].getElementsByTagName("a")[0].getElementsByTagName("img")[0];
  //this.SubMenuImg.src = this.SubMenuImg.src.replace("_on.gif","_off.gif");
    this.SubMenuA = this.MenuBox.item(mnum).getElementsByTagName("ul")[0].getElementsByTagName("li")[snum].getElementsByTagName("a")[0];
    this.SubMenuLi = this.MenuBox.item(mnum).getElementsByTagName("ul")[0].getElementsByTagName("li")[snum]
    this.SubMenuA.style.fontWeight = "normal"
    this.SubMenuLi.style.backgroundImage = "none"
  //this.SubMenuLi.style.backgroundImage = "url(../imgs/tm_2d_nor_icon.png)"
 }
}

// 투명 PNG IE6 적용 용
//function setPng24(obj) {
//    obj.width = obj.height=1;
//    obj.className = obj.className.replace(/\bpng24\b/i,'');
//    obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');"
//    obj.src=''; 
//    return '';
//}

//이미지 확대보기 생성
function imgviewer(obj, imgsrc)
{
  imgviewbox.style.display='block'
  insstr = '<a href="#" id="imgc" title="클릭하거나 엔터치면 닫힙니다." onclick="javascript:imgviewer_c('+obj+');return false;">'
  insstr += '<img src="'+imgsrc+'" alt="이미지 확대 보기용 : 대체텍스트는 본 이미지에 있습니다. 클릭하면 닫힙니다."/>'
  insstr += '</a>'
  imgviewbox.innerHTML=insstr
  imgc.focus();
}

//이미지 확대보기 닫기
function imgviewer_c(obj)
{
  imgviewbox.style.display='none'
  obj.focus();
}
