// JavaScript Document

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// image roll
function menuOver() {
	if (this.id != selectedMenuId) {
		this.src = this.src.replace("_off.gif", "_on.gif");
	}

	var lis = this.parentNode.parentNode.parentNode.getElementsByTagName("li");
	for (var i=0, n = lis.length; i<n; i++) {
		if (lis[i].tagName == "LI") {
			document.getElementById(lis[i].childNodes[0].childNodes[0].getAttribute("submenuId")).style.display = "none";
		}
	}
	
	var submenu = document.getElementById(this.getAttribute("submenuId"));
	submenu.style.display = "block";
}
function menuOut() {
	if (this.id != selectedMenuId) {
		this.src = this.src.replace("_on.gif", "_off.gif");
	}
}

function imageOver(imgEl) {
	imgEl.src = imgEl.src.replace("_off.gif", "_on.gif");
}
function imageOut(imgEl) {
	imgEl.src = imgEl.src.replace("_on.gif", "_off.gif");
}


// convert menu text to image
function TopNavigation(selected, pImgPath) {
  var imgPath = "../../_images/";
 
  if (pImgPath != null && pImgPath != "") {
    imgPath = pImgPath;
  }
  
  selectedMenuId = selected;
  
	// change top menu text to image
	topMenuEl = document.getElementById("globalNavi").getElementsByTagName("li");
	for (i=0; i<topMenuEl.length; i++) {
		var menuAnchor = topMenuEl[i].getElementsByTagName("a")[0];
		if (selectedMenuId == topMenuEl[i].className) {
			menuAnchor.innerHTML = "<img src=\"" + imgPath + topMenuEl[i].className + "_on.gif\" alt=\"" + menuAnchor.innerHTML + "\" id=\"" + topMenuEl[i].className + "\"submenuId=\"globalNaviSub0" + (i + 1) + "\"/>";		
		} else {
			menuAnchor.innerHTML = "<img src=\"" + imgPath + topMenuEl[i].className + "_off.gif\" alt=\"" + menuAnchor.innerHTML + "\" id=\"" + topMenuEl[i].className + "\"submenuId=\"globalNaviSub0" + (i + 1) + "\"/>";	
		}
		menuAnchor.getElementsByTagName("img").item(0).onmouseover = menuOver;
		menuAnchor.getElementsByTagName("img").item(0).onmouseout = menuOut;
	}
}
var selectedMenuId;




// image roll
function menuOver() {
	if (this.id != selectedMenuId) {
		this.src = this.src.replace("_off.gif", "_on.gif");
	}

	var lis = this.parentNode.parentNode.parentNode.getElementsByTagName("li");
	try{
		for (var i=0, n = lis.length; i<n; i++) {
			if (lis[i].tagName == "LI") {
				document.getElementById(lis[i].childNodes[0].childNodes[0].getAttribute("submenuId")).style.display = "none";
			}
		}
		
		var submenu = document.getElementById(this.getAttribute("submenuId"));
		submenu.style.display = "block";
	}catch (e){}

}
function menuOut() {
	if (this.id != selectedMenuId) {
		this.src = this.src.replace("_on.gif", "_off.gif");
	}
}

function imageOver(imgEl) {
	imgEl.src = imgEl.src.replace("_off.gif", "_on.gif");
}
function imageOut(imgEl) {
	imgEl.src = imgEl.src.replace("_on.gif", "_off.gif");
}

function tabOver() {
	this.src = this.src.replace("_off.gif", "_on.gif");
}
function tabOut() {
	this.src = this.src.replace("_on.gif", "_off.gif");
}



// convert menu text to image
function MainNavigation(selected, pImgPath) {
  var imgPath = "../_images/";
 
  if (pImgPath != null && pImgPath != "") {
    imgPath = pImgPath;
  }
  
  selectedMenuId = selected;
  
	// change top menu text to image
	topMenuEl = document.getElementById("globalNavi").getElementsByTagName("li");
	for (i=0; i<topMenuEl.length; i++) {
		var menuAnchor = topMenuEl[i].getElementsByTagName("a")[0];
		if (selectedMenuId == topMenuEl[i].className) {
			menuAnchor.innerHTML = "<img src=\"" + imgPath + topMenuEl[i].className + "_on.gif\" alt=\"" + menuAnchor.innerHTML + "\" id=\"" + topMenuEl[i].className + "\"submenuId=\"globalNaviSub0" + (i + 1) + "\"/>";		
		} else {
			menuAnchor.innerHTML = "<img src=\"" + imgPath + topMenuEl[i].className + "_off.gif\" alt=\"" + menuAnchor.innerHTML + "\" id=\"" + topMenuEl[i].className + "\"submenuId=\"globalNaviSub0" + (i + 1) + "\"/>";	
		}
		menuAnchor.getElementsByTagName("img").item(0).onmouseover = menuOver;
		menuAnchor.getElementsByTagName("img").item(0).onmouseout = menuOut;
	}
}
var selectedMenuId;

// QuickMenu

function initMoving(target) {
	if (!target)
		return false;

	var obj = target;
	obj.initTop = 310;
	obj.initLeft = 833;
	obj.bottomLimit = document.documentElement.scrollHeight - 220;
	obj.topLimit = 250;

	obj.style.position = "absolute";
	obj.top = obj.initTop;
	obj.left = obj.initLeft;
	obj.style.top = obj.top + "px";
	obj.style.left = obj.left + "px";

	obj.getTop = function() {
		if (document.documentElement.scrollTop) {
			return document.documentElement.scrollTop;
		} else if (window.pageYOffset) {
			return window.pageYOffset;
		} else {
			return 0;
		}
	}
	obj.getHeight = function() {
		if (self.innerHeight) {
			return self.innerHeight;
		} else if(document.documentElement.clientHeight) {
			return document.documentElement.clientHeight;
		} else {
			return 500;
		}
	}
	obj.move = setInterval(function() {
		pos = obj.getTop() + obj.getHeight() / 2 - 200;

		if (pos > obj.bottomLimit)
			pos = obj.bottomLimit
		if (pos < obj.topLimit)
			pos = obj.topLimit

		interval = obj.top - pos;
		obj.top = obj.top - interval / 3;

		obj.style.top = obj.top + "px";
	}, 50)
}



// Flash publish
function swfprint(furl,fwidth,fheight,transoption)	{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ fwidth +'" height="' + fheight +'" align="middle">');
	document.write('<param name="movie" value="'+ furl +'"/>');
	if (transoption == "t")	{
		document.write('<param name="wmode" value="transparent"/>');
	} else if	(transoption == "o")	{
		document.write('<param name="wmode" value="opaque"/>');
	}
	document.write('<!-- Hixie method -->');
	document.write('<!--[if !IE]> <-->');
	document.write('<object type="application/x-shockwave-flash" data="'+ furl +'" width="'+ fwidth +'" height="' + fheight +'"');
	if (transoption == "t")	{
		document.write(' wmode="transparent"');
	} else if	(transoption == "o")	{
		document.write(' wmode="opaque"');
	}
	document.write('></object>');
	document.write('<!--> <![endif]-->');
	document.write('</object>');
}




// Tabbed menu
function initTabMenu(menuElId) {
	var tabMenu = document.getElementById(menuElId).getElementsByTagName("a");
	if(tabMenu.length > 0){
		for(i=0; i<tabMenu.length; i++) {
			thismenu = tabMenu.item(i);
			thismenu.menuContainer = document.getElementById(menuElId);
			thismenu.targetEl = document.getElementById(tabMenu.item(i).href.split("#")[1]);

				if(thismenu.targetEl) thismenu.targetEl.style.display = "none";
				if(thismenu.getElementsByTagName("img").length>0)	{
					thismenu.getElementsByTagName("img").item(0).onmouseover = tabOver;
					thismenu.getElementsByTagName("img").item(0).onmouseout = tabOut;
				}

			thismenu.onclick = tabMenuClick;		
		}
		
		
		initmenu = tabMenu.item(0);
		initmenu.menuContainer = document.getElementById(menuElId);
		initmenu.targetEl = document.getElementById(initmenu.href.split("#")[1]);

			if(initmenu.targetEl) initmenu.targetEl.style.display = "block";		
			initmenu.className = "activate";
			if(initmenu.getElementsByTagName("img").length>0)	{
				initmenu.getElementsByTagName("img").item(0).onmouseover();
				initmenu.getElementsByTagName("img").item(0).onmouseover = null;
				initmenu.getElementsByTagName("img").item(0).onmouseout = null;
			}

		initmenu.menuContainer.current = initmenu;
	}
}
function tabMenuClick() {
	currentmenu = this.menuContainer.current;
	if (currentmenu != this) {
		if(currentmenu.targetEl) currentmenu.targetEl.style.display = "none";
		currentmenu.className = null;
		if(currentmenu.getElementsByTagName("img").length>0)	{
			currentmenu.getElementsByTagName("img").item(0).onmouseover = tabOver;
			currentmenu.getElementsByTagName("img").item(0).onmouseout = tabOut;
			currentmenu.getElementsByTagName("img").item(0).onmouseout();
		}
		if(this.targetEl) this.targetEl.style.display = "block";
		this.className = "activate";
		if(this.getElementsByTagName("img").length>0)	{
			this.getElementsByTagName("img").item(0).onmouseover = null;
			this.getElementsByTagName("img").item(0).onmouseout = null;
		}
		this.menuContainer.current = this;
	}
	return false;
}



function login() {
  var form = document.loginForm;
  if (form.loginUserId.value == "") {
    alert("ID 를 입력하세요");
    form.loginUserId.focus();
    return false;
  }
  if (form.loginPassword.value == "") {
    alert("Password 를 입력하세요");
    form.loginPassword.focus();
    return false;
  }
  document.loginForm.submit();
}
function logout() {
  location.href = "/logout.html";
}
/*
    window.onload = function() {
		getResize();
	}
*/	
	function getResize()
	{
		var objBodyHeight = parent.document.getElementById('iFrm').contentWindow.document.body.scrollHeight;
		parent.document.getElementById('iFrm').style.height = objBodyHeight + "px";
	}
	
function enterkeyListener(event, executeMethod) {
  var e = window.event || event;
  var keyCode = e.keyCode || e.which;
  
  if (keyCode == 13) {
    if (executeMethod != null) {
      return executeMethod();
    }
  } 
}