try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}


/* GNB */
function gnbMenu(objNum) {
	var _d = document,
		outEventTime = 3, //time
		objID = _d.getElementById('gnb'),
		objUl = objID.getElementsByTagName('ul'),
		objUlLength = objUl.length,
		objList = [],
		objImage = [],
		currentNum = 0,
		objSetTime;

	var initialize = function() {
		for (var i=0; i<objUlLength; i++) {
			if (i != 0) {
				objList[i] = objUl[i].parentNode;
				objImage[i] = objList[i].getElementsByTagName('img')[0];
				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';
					}
				}
			}

			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].onkeyup = objList[num].onmouseover;

		objID.onmouseout = function(e) {
			var evt = e || window.event;
			var relatedNode = evt.relatedTarget || evt.toElement;

			searchOutNode(relatedNode, this);
		};
	};

	var outEvent = function() {
		if (!objNum) {
//			objImage[currentNum].src = objImage[currentNum].src.replace('_on.gif', '.gif');
			objUl[currentNum].style.display = 'none';
		} else if (objNum && currentNum != objNum) {
			if (objImage[objNum].src.indexOf('_on.gif') == -1)
				//alert(objNum);
//				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';
		}
	};

	var searchOutNode = function (obj1, obj2) { //bubble
		while (obj1 != obj2) {
			if (!obj1) {
				objSetTime = setTimeout(outEvent, (outEventTime * 1000));
				return true;
			}
			obj1 = obj1.parentNode;
		}
		return false;
	};

	initialize();
}



