// JavaScript Document

function MM_windowOpen(m_url, m_width, m_height, m_left, m_top ) {
	var winopen = window.open(m_url, "open_v","width="+m_width+", height="+m_height+", left="+m_left+", top="+m_top+" scrollbars=auto");
}
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_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function getCookie(strName) {
	var browser = navigator.appName;
	var strArg = new String(strName + "=");
	var nArgLen, nCookieLen, nEnd;
	var i = 0, j;

	nArgLen = strArg.length;
	nCookieLen = document.cookie.length;

	if(nCookieLen > 0) {
		while(i < nCookieLen) {
			j = i + nArgLen;

			if(document.cookie.substring(i, j) == strArg) {
				nEnd = document.cookie.indexOf (";", j);
				
				if(nEnd == -1) nEnd = document.cookie.length;

				return unescape(document.cookie.substring(j, nEnd));
			}

			i = document.cookie.indexOf(" ", i) + 1;
			if (i == 0) break;
		}
	}
	return("");
}

function setCookie(name, val) {
	var expire = new Date();
	expire.setDate(expire.getDate() + 1);
	document.cookie = name + "=" + escape(val) + "; path=/; expires=" + expire.toGMTString()+ ";";
}

function getCrossCookie(strName) {
	var browser = navigator.appName;
	var strArg = new String(strName + "=");
	var nArgLen, nCookieLen, nEnd;
	var i = 0, j;

	nArgLen = strArg.length;
	nCookieLen = document.cookie.length;

	if(nCookieLen > 0) {
		while(i < nCookieLen) {
			j = i + nArgLen;

			if(document.cookie.substring(i, j) == strArg) {
				nEnd = document.cookie.indexOf (";", j);
				
				if(nEnd == -1) nEnd = document.cookie.length;

				if(navigator.userAgent.indexOf("MSIE") != -1) return document.cookie.substring(j, nEnd);
				else return decodeURIComponent(document.cookie.substring(j, nEnd));
			}

			i = document.cookie.indexOf(" ", i) + 1;
			if (i == 0) break;
		}
	}
	return("");
}

function setCrossCookie(name, val) {
	var expire = new Date();
	expire.setDate(expire.getDate() + 1);

	if(navigator.userAgent.indexOf("MSIE") != -1) document.cookie = name + "=" + val + "; path=/; expires=" + expire.toGMTString()+ ";";
	else document.cookie = name + "=" + encodeURIComponent(val) + "; path=/; expires=" + expire.toGMTString()+ ";";
}


IEx = navigator.appName.indexOf("Microsoft") != -1; 
function init(where) {
    flashObj = IEx ? Fmovie : document.Fmovie; 
    flashObj.SetVariable( "/_root:oldN", where) 
}

function oninit(where) {
	
	if(!where) where = 9;
	
	for(i=1; i<=8; i++){
		if(i == where) {
			MM_swapImage('top_menu_0' + i,'','/images/gnb_0' + i + '_on.gif',1);
		}else{
			MM_swapImage('top_menu_0' + i,'','/images/gnb_0' + i + '.gif',1);
		}
	}
  	
}


function autoBlur(){
  if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG")
  document.body.focus();
}
  document.onfocusin=autoBlur;

function fnChkSelect(){
	var f = document.form1;

	var listcnt = f.elements.length;
	var chkflag = 0;
	
	for (i=0; i < listcnt; i++) {
		var j = f.elements[i].name;
		if (j.substring(0,4) == "chk_" && f.elements[i].type == "checkbox" && f.elements[i].checked == true) {
			chkflag++;
		}
	}
	
	return chkflag;
	
}

function fnSelectAll(flag){
	var f = document.form1;

	var listcnt = f.elements.length;
	var chkflag = 0;
	
	for (i=0; i < listcnt; i++) {
		var j = f.elements[i].name;
		if (j.substring(0,4) == "chk_" && f.elements[i].type == "checkbox") {
			if(flag) {
				f.elements[i].checked = true;
			}else{
				f.elements[i].checked = false;
			}
			chkflag++;
		}
	}
	
}

String.prototype.trim = function(){
  return this.replace(/(^\s*)|(\s*$)/g, ""); 
}

// ´ë¹®ÀÚ º¯È¯ ex) toUpperCase(¹®ÀÚ)
function toUpperCase(str) {
	var ret;
	str != null ? ret = str.toUpperCase() : ret = "";
	return ret;
}	

// Æû¿¡ ÇØ´çÇÏ´Â ÄÁÆ®·ÑµéÀÇ ±âº»°ª ½±°Ô ¼ÂÆÃÇØ ÁÖ±â
function initForm(f)	{
	var nLen;	// form ¿ä¼ÒÀÇ °¹¼ö
	var ival;	// °¢ ¿ä¼ÒÀÇ default value °ª Áï! ÃÊ±âÈ­ÇÏ°íÀÚ ÇÏ´Â°ª
	var fTyp;	// form ¿ä¼ÒÀÇ Å¸ÀÔ(select, radio, checkbox...)

	for (var i = 0; i < f.elements.length; i++) {
		fTyp = toUpperCase(f.elements[i].type);
		ival = f.elements[i].ival;

		if (ival && fTyp == "SELECT-ONE") {
			nLen = f.elements[i].options.length;
			for (var j = 0; j < nLen; j++) {
				if (f.elements[i].options[j].value == ival)
					f.elements[i].options[j].selected = true;
			}
		}
		if (fTyp == "SELECT-MULTIPLE") {
			nLen = f.elements[i].options.length;
			for (var j = 0; j < nLen; j++) {
				if (f.elements[i].options[j].value == f.elements[i].options[j].ival)
					f.elements[i].options[j].selected = true;
			}
		}
		if (ival && (fTyp == "RADIO" || fTyp == "CHECKBOX")) {
			if (f.elements[i].value == ival)
				f.elements[i].checked = true;
		}
	}
	return true;
}

// ¹è¿­ ¿ä¼ÒÀÏ °æ¿ì checked µÈ°ÍÀÌ ÀÖ´ÂÁö È®ÀÎ
function checkChecked(obj) {
	var objnm = obj.name;
	var oElem = eval("document.all."+objnm);
	//var oElem = eval(fname+"."+objnm);
	var ret = false;

	if (typeof(oElem.length) == "undefined") {
		if (oElem.checked) {
			ret = true;
		}
	} else {
		for (var i=0;i<oElem.length;i++) {
			if (oElem[i].checked) {
				ret = true;
			}
		}
	}
	return ret;
}
	
function showFlv(uid, flv, cWith, cHeight){
	var cHtml = "";
	cHtml = '<object type="application/x-shockwave-flash" width="' + cWith + '" height="' + cHeight + '">'; 
	cHtml += '<param name="movie" value="' + flv + '">';
	cHtml += '<param name="quality" value="high">';
	cHtml += '<param name="wmode" value="transparent">';
	cHtml += '<param name="FlashVars" value="&uid=' + uid + '">';
	cHtml += '</object>'; 
	document.write(cHtml);
}

/*
function truebody(){
	return (navigator.appName == "Netscape") ? document.body : document.documentElement;
}
*/
function truebody(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body;
}


function setScreen(flag,tp){
	var sWidth, sHeight;
	
	if(flag){
		sWidth = truebody().scrollWidth;
		sHeight = truebody().scrollHeight;
	}else{
		sWidth = screen.width;
		sHeight = screen.height;
	}
	
	if(tp == "w") return sWidth;
	if(tp == "h") return sHeight;
}


//if(!getCookie("cHeight")){
	setCrossCookie( "cHeight", setScreen('','h'));
//}
	
	
	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 ''; 
}
