


// gnb
function gnbMenu(objNum) {
	var _d = document,
		outEventTime = 3, //본 레이어로 돌아가는 시간
		objID = _d.getElementById('navG'),
		objUl = objID.getElementsByTagName('ul'),
		objUlLength = objUl.length,
		objList = [],
		objImage = [],
		currentNum = 0,
		objSetTime;

	var initialize = function() {
		
		//objUl[0].style.display = 'none';
		objUl[1].style.display = 'none';
		objUl[2].style.display = 'none';
		objUl[3].style.display = 'none';
		objUl[4].style.display = 'none';
		objUl[5].style.display = 'none';
		objUl[6].style.display = 'none';

		for (var i=0; i<objUlLength; i++) {
			//if (objNum == 'null') objID.style.backgroundImage = 'url(/open_content/images/main/bg_topmenu.gif)';
			if (i != 0) {
				objList[i] = objUl[i].parentNode;

				objImage[i] = objList[i].getElementsByTagName('img')[0];
				//objID.style.backgroundImage = 'url(/open_content/images/main/bg_topmenu.gif)';
				objEvent(i);
			}
		}

		
		if (objNum >= 0) {
			objNum = objNum + 1;
			objImage[objNum].src = objImage[objNum].src.replace('.gif', '_on.gif');
			objUl[objNum].style.display = 'block';
			
		}
		
	};

	var objEvent = function(num) {
		objList[num].onmouseover = function() {
			currentNum = num;
			clearTimeout(objSetTime);
			for (var i=0; i<objUlLength; i++) {
				if (i != 0) {
					if (i == num) {
						//Do nothing
					} else {
						objImage[i].src = objImage[i].src.replace('_on.gif', '.gif');
						objUl[i].style.display = 'none';
						//objID.style.backgroundImage = 'url(/open_content/images/main/bg_topmenu_on.gif)';
					}
				}
			}

			if (objImage[num].src.indexOf('_on.gif') == -1)
				objImage[num].src = objImage[num].src.replace('.gif', '_on.gif');

				
			objUl[num].style.display = 'block';

		};

//		objList[num].onmouseout = function() {				
//			objUl[num].style.display = 'none';
//		};

		objList[num].onkeyup = objList[num].onmouseover;

		objID.onmouseout = function(e) {
			var evt = e || window.event;
			var relatedNode = evt.relatedTarget || evt.toElement;

			//objID.style.backgroundImage = 'url(/open_content/images/main/bg_topmenu.gif)';

			if (currentNum !=6)
			{
				objUl[num].style.display = 'none';
			}

			searchOutNode(relatedNode, this);

		};
	};

	var outEvent = function() {

		if (currentNum !=0)
		{
			if (!objNum) {
				objImage[currentNum].src = objImage[currentNum].src.replace('_on.gif', '.gif');
				objUl[currentNum].style.display = 'none';

				//objID.style.backgroundImage = 'url(/open_content/images/main/bg_topmenu_on.gif)';
			} else if (objNum && currentNum != objNum) {
				if (objImage[objNum].src.indexOf('_on.gif') == -1)
					objImage[objNum].src = objImage[objNum].src.replace('.gif', '_on.gif');
					objUl[objNum].style.display = 'block';
				

				objImage[currentNum].src = objImage[currentNum].src.replace('_on.gif', '.gif');
				objUl[currentNum].style.display = 'none';
				//objID.style.backgroundImage = 'url(/open_content/images/main/bg_topmenu_on.gif)';
			}
		}
	};

	var searchOutNode = function (obj1, obj2) { //이벤트 버블링현상 제거
		while (obj1 != obj2) {
			if (!obj1) {
				objSetTime = setTimeout(outEvent, (outEventTime * 10));
				return true;
			}
			obj1 = obj1.parentNode;
		}
		return false;
	};

	initialize();
}


//전체메뉴보기

function wholemenu_Show() {
	var obj = document.getElementById("menuOpen");
	if ( !obj.style.display || obj.style.display == "none" ) {
		document.getElementById("all_menu").title = "전체메뉴닫기"
		obj.style.display = "block";
	} else {
		document.getElementById("all_menu").title = "전체메뉴열기"
		obj.style.display = "none";
	}
}

//index 인터뷰, 협력캘린더
function viewList(a){
 for(var i=1;i<3;i++){
 obj = document.getElementById("hlist"+i);
 obj2 = document.getElementById("tab"+i);
	if (i>1)
	{
		 obj3 = document.getElementById("tab"+(i-1));
	}
 if(a==i){
 obj.style.display = "block";
 obj2.setAttribute("src","images/index/h_tab"+i+"_on.gif");
 }else{
 obj.style.display = "none";
 obj2.setAttribute("src","images/index/h_tab"+i+".gif");
 }
 }
}
