/*-------------------------------------------------
Common Javascript
Version : 1.0
author : park myeong hee
create date : 2007. 08. 07.
last update : 2007. 08. 07.
-------------------------------------------------*/

//FLASH
function onLoadFlash(filename, width, height, title) {
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + width + '"  height="' + height + '" title="' + title + '">');
        document.write('<param name="movie" value="' + filename + '">');
        document.write('<param name="wmode" value="transparent">');
				document.write('<param name="menu" value="false">');
        document.write('<param name="quality" value="high">');
        document.write('<embed src="' + filename + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" wmode="transparent" menu="false"></embed></object>');
}


/* LAYER SHOW/HIDE SCRIPT
-------------------------------------------------*/
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


/* IMG ON/OFF SCRIPT - MOUSEOVER / MOUSEOUT
-------------------------------------------------*/
function menuOver() {
	this.src = this.src.replace(".gif", "_on.gif");
}
function menuOut() {
	this.src = this.src.replace("_on.gif", ".gif");
}

function imageOver(imgEl) {
	imgEl.src = imgEl.src.replace(".gif", "_on.gif");
}
function imageOut(imgEl) {
	imgEl.src = imgEl.src.replace("_on.gif", ".gif");
}



/* Navigation JAVASCRIPT - ¸Þ´º, ÇöÀçÀ§Ä¡
-------------------------------------------------*/

/* Global Navigation JAVASCRIPT - ÀÌ¹ÌÁö on/off
-------------------------------------------------*/
function initGNavigation() {
	// change top menu text to image
	topMenuEl = document.getElementById("gnavigation").getElementsByTagName("li");
	for (i=0; i<topMenuEl.length; i++) {
		var menuAnchor = topMenuEl[i].getElementsByTagName("a")[0];
		menuAnchor.innerHTML = "<img src=\"/eng/img/navigation/global/" + topMenuEl[i].className + ".gif\" alt=\"" + menuAnchor.innerHTML + "\" />";
		menuAnchor.getElementsByTagName("img").item(0).onmouseover = menuOver;
		menuAnchor.getElementsByTagName("img").item(0).onmouseout = menuOut;
	}
}

/* Sub Navigation JAVASCRIPT - ÀÌ¹ÌÁö on/off
-------------------------------------------------*/
function initSNavigation() {
	subMenuEl = document.getElementById("snavigation").getElementsByTagName("li");
	for (i=0; i<subMenuEl.length; i++) {
		var menuAnchor = subMenuEl[i].getElementsByTagName("a")[0];
		menuAnchor.innerHTML = "<img src=\"/eng/img/navigation/sub/" + subMenuEl[i].className + ".gif\" alt=\"" + menuAnchor.innerHTML + "\" />";
		menuAnchor.getElementsByTagName("img").item(0).onmouseover = menuOver;
		menuAnchor.getElementsByTagName("img").item(0).onmouseout = menuOut;
	}
}

/* Top Side Menu JAVASCRIPT - ÀÌ¹ÌÁö on/off
-------------------------------------------------*/
function initTSMenu() {
	subMenuEl = document.getElementById("tsidemenu").getElementsByTagName("li");
	for (i=0; i<subMenuEl.length; i++) {
		var menuAnchor = subMenuEl[i].getElementsByTagName("a")[0];
		menuAnchor.innerHTML = "<img src=\"/eng/img/navigation/tsidemenu/" + subMenuEl[i].className + ".gif\" alt=\"" + menuAnchor.innerHTML + "\" />";
		menuAnchor.getElementsByTagName("img").item(0).onmouseover = menuOver;
		menuAnchor.getElementsByTagName("img").item(0).onmouseout = menuOut;
	}
}



/* Global Navigation Action JAVASCRIPT 
-------------------------------------------------*/
var currentMenu;	// current shown menu (mouse over)
var focusMenu;	// current page menu
var menu = new Array();	// each menu array

function initNavigation(seq) {
	for(i=1; i<5; i++) {
		menu[i] = document.getElementsBySelector("#gnavigation li.menu0" + i)[0];
		menu[i].onmouseover = navigationOver;
		menu[i].onmouseout = navigationOut;

		menu[i].submenu = document.getElementsBySelector("#gnavigation li.menu0" + i +" ul.depth2")[0];
		menu[i].submenu.menu = menu[i];
		menu[i].submenu.onmouseover = subOver;
	}
}
function initFocus() {		// current page menu focusing
	if (focusMenu) {
		currentMenu = focusMenu;
	} else {
		currentMenu = null;
	}
	showSubmenu();
}
function navigationOver() {		// onmouseover
	hideSubmenu();
	if (focusMenu) {
		focusMenu.submenu.style.display = "none";
	}
	currentMenu = this;
	showSubmenu();
}
function navigationOut() {		// onmouseout
	this.isMenuOver = false;
	setTimeout("hideSubmenu()", 500);
}
function showSubmenu() {
	if (currentMenu) {
		currentMenu.submenu.style.display = "block";
		currentMenu.isMenuOver = true;
	}
}
function hideSubmenu() {
	if (currentMenu && !currentMenu.isMenuOver) {
		currentMenu.submenu.style.display = "none";
		currentMenu.isMenuOver = false;
		initFocus();
	}
}
function subOver() {
	this.menu.isMenuOver = true;
}

/* Location Current JAVASCRIPT - ÇöÀçÀ§Ä¡
-------------------------------------------------*/
function initLocation() {
	initNavigation();

	if (document.getElementById("location")) {
		loc = document.getElementById("location").getElementsByTagName("a");
	
		if (document.getElementById("gnavigation") && document.getElementById("gnavigation").getElementsByTagName("li")) {
			topMenuLi = document.getElementById("gnavigation").getElementsByTagName("li");
			for(j=0; j<topMenuLi.length; j++) {
				topMenuText = topMenuLi[j].getElementsByTagName("img").item(0).alt;
				if (loc.item(1) && topMenuText == loc.item(1).innerHTML) {		// top menu depth1					
					focusMenu = menu[topMenuLi[j].className.substr(topMenuLi[j].className.length-1, 1)];
					initFocus();
					if (currentMenu.getElementsByTagName("img").item(0).src.indexOf("_on.gif") == -1) {
						currentMenu.getElementsByTagName("img").item(0).onmouseover();
					}
					currentMenu.getElementsByTagName("img").item(0).onmouseover = null;
					currentMenu.getElementsByTagName("img").item(0).onmouseout = null;
				}
				
				if (loc.item(2) && topMenuText == loc.item(2).innerHTML) {		// top menu depth2

					if(topMenuText != ""){
						topMenuLi[j].getElementsByTagName("img").item(0).onmouseover();
						topMenuLi[j].getElementsByTagName("img").item(0).onmouseover = null;
						topMenuLi[j].getElementsByTagName("img").item(0).onmouseout = null;
					}
				}
			}
		}
	
		if (document.getElementById("snavigation") && document.getElementById("snavigation").getElementsByTagName("li")) {
			subMenuLi = document.getElementById("snavigation").getElementsByTagName("li");
			for(i=0; i<subMenuLi.length; i++) {
				subMenuText = subMenuLi[i].getElementsByTagName("img").item(0).alt;
				if (loc.item(2) && subMenuText == loc.item(2).innerHTML) {		// sub menu depth2
					if (subMenuLi[i].getElementsByTagName("img").item(0).src.indexOf("_on.gif") == -1) {
						subMenuLi[i].getElementsByTagName("img").item(0).onmouseover();
					}
					subMenuLi[i].getElementsByTagName("img").item(0).onmouseover = null;
					subMenuLi[i].getElementsByTagName("img").item(0).onmouseout = null;
					if (subMenuLi[i].getElementsByTagName("ul").item(0)) {
						subMenuLi[i].getElementsByTagName("ul").item(0).style.display = "block";
					}
				}
				if (loc.item(3) && subMenuText == loc.item(3).innerHTML) {		// sub menu depth3
					if (subMenuLi[i].getElementsByTagName("img").item(0).src.indexOf("_on.gif") == -1) {
						subMenuLi[i].getElementsByTagName("img").item(0).onmouseover();
					}
					subMenuLi[i].getElementsByTagName("img").item(0).onmouseover = null;
					subMenuLi[i].getElementsByTagName("img").item(0).onmouseout = null;
				}
			}
		}
	}
}

function getAllChildren(e) {
	// Returns all children of element. Workaround required for IE5/Windows. Ugh.
	return e.all ? e.all : e.getElementsByTagName('*');
}

document.getElementsBySelector = function(selector) {
	// Attempt to fail gracefully in lesser browsers
	if (!document.getElementsByTagName) {
		return new Array();
	}
	// Split selector in to tokens
	var tokens = selector.split(' ');
	var currentContext = new Array(document);
	for (var i = 0; i < tokens.length; i++) {
		token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
		if (token.indexOf('#') > -1) {
			// Token is an ID selector
			var bits = token.split('#');
			var tagName = bits[0];
			var id = bits[1];
			var element = document.getElementById(id);
			if (tagName && element.nodeName.toLowerCase() != tagName) {
				// tag with that ID not found, return false
				return new Array();
			}
			// Set currentContext to contain just this element
			currentContext = new Array(element);
			continue; // Skip to next token
		}
		if (token.indexOf('.') > -1) {
			// Token contains a class selector
			var bits = token.split('.');
			var tagName = bits[0];
			var className = bits[1];
			if (!tagName) {
				tagName = '*';
			}
			// Get elements matching tag, filter them for class selector
			var found = new Array;
			var foundCount = 0;
			for (var h = 0; h < currentContext.length; h++) {
				var elements;
				if (tagName == '*') {
						elements = getAllChildren(currentContext[h]);
				} else {
						elements = currentContext[h].getElementsByTagName(tagName);
				}
				for (var j = 0; j < elements.length; j++) {
					found[foundCount++] = elements[j];
				}
			}
			currentContext = new Array;
			var currentContextIndex = 0;
			for (var k = 0; k < found.length; k++) {
				if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
					currentContext[currentContextIndex++] = found[k];
				}
			}
			continue; // Skip to next token
		}
		// Code to deal with attribute selectors
		if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
			var tagName = RegExp.$1;
			var attrName = RegExp.$2;
			var attrOperator = RegExp.$3;
			var attrValue = RegExp.$4;
			if (!tagName) {
				tagName = '*';
			}
			// Grab all of the tagName elements within current context
			var found = new Array;
			var foundCount = 0;
			for (var h = 0; h < currentContext.length; h++) {
				var elements;
				if (tagName == '*') {
						elements = getAllChildren(currentContext[h]);
				} else {
						elements = currentContext[h].getElementsByTagName(tagName);
				}
				for (var j = 0; j < elements.length; j++) {
					found[foundCount++] = elements[j];
				}
			}
			currentContext = new Array;
			var currentContextIndex = 0;
			var checkFunction; // This function will be used to filter the elements
			switch (attrOperator) {
				case '=': // Equality
					checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
					break;
				case '~': // Match one of space seperated words 
					checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
					break;
				case '|': // Match start with value followed by optional hyphen
					checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
					break;
				case '^': // Match starts with value
					checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
					break;
				case '$': // Match ends with value - fails with "Warning" in Opera 7
					checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
					break;
				case '*': // Match ends with value
					checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
					break;
				default :
					// Just test for existence of attribute
					checkFunction = function(e) { return e.getAttribute(attrName); };
			}
			currentContext = new Array;
			var currentContextIndex = 0;
			for (var k = 0; k < found.length; k++) {
				if (checkFunction(found[k])) {
					currentContext[currentContextIndex++] = found[k];
				}
			}
			// alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
			continue; // Skip to next token
		}
		// If we get here, token is JUST an element (not a class or ID selector)
		tagName = token;
		var found = new Array;
		var foundCount = 0;
		for (var h = 0; h < currentContext.length; h++) {
			var elements = currentContext[h].getElementsByTagName(tagName);
			for (var j = 0; j < elements.length; j++) {
				found[foundCount++] = elements[j];
			}
		}
		currentContext = found;
	}
	return currentContext;
}




/* Onfocus SCRIPT
-------------------------------------------------*/
function allblur() {
  for (i = 0; i < document.links.length; i++)
    document.links[i].onfocus = document.links[i].blur;

  for (i = 0; i < document.images.length; i++)
    document.images[i].onfocus = document.images[i].blur;

}

function load1(form) {
     var url = form.Llist_1.options[form.Llist_1.selectedIndex].value;
     if (url != '') open(url);
     return false;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}