


/*---------------------------------------------
	·Î±×ÀÎ°ü·Ã
-------------------------------------------------*/
function fnGetDomain(){
 
 var _strHost	=	location.hostname;
 //alert(_strHost);
  return _strHost;
}

function fnGetAdminDomain(){
  var adminHost;
  var strHost	=	fnGetDomain();
	var hostStartIndex = strHost.indexOf(".");
		adminHost = unescape(strHost.substring(hostStartIndex, strHost.length))
       return preAdminSite + adminHost;
}


function fnReturnLogin(){
   var retURL = "";
   if(parent && parent != this) {
		retURL = location.href;
	} else {
	   retURL = top.location.href;
}
    top.location.href="http:/"+"/" + fnGetDomain() + "/login.asp?returl="+ escape(retURL);
}

function fnLogout(){
      top.location.href="http:/"+"/" + fnGetDomain() + "/library/LogoutProc.asp";
}

function fnAdminSite(){
      var url = "http:/"+"/" + fnGetAdminDomain()+ "/";
	   window.open(url, "_admin");
}

function Win_scroll(theURL,wide,high) {
 var window_left = (screen.width-600)/2;
 var window_top = (screen.height-680)/2;
 window.open(theURL,"Newwin",'width='+wide+',height='+high+',scrollbars=no,resizable=no,top=' + window_top + ',left=' + window_left + '');
}


function getSubCookie(name, subname) {
	var prefix = name + "=";
	var cookieStartIndex = document.cookie.indexOf(prefix);
	if (cookieStartIndex == -1)
		return (null);
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
	if (cookieEndIndex == -1)
		cookieEndIndex = document.cookie.length;
	
	var cookies = unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
	prefix = subname + "=";
	cookieStartIndex = cookies.indexOf(prefix);
	if (cookieStartIndex == -1)
		return (null);
	cookieEndIndex = cookies.indexOf("&", cookieStartIndex + prefix.length);
	if (cookieEndIndex == -1)
		cookieEndIndex = document.cookie.length;
	return (unescape(cookies.substring(cookieStartIndex + prefix.length, cookieEndIndex)));
}



// onOver Script

// Ä«Å×°í¸® ºä¾î ½ºÅ©¸³Æ®
	var old_layer_index = 0;
	var layer_top_start = 0;
	var layer_left_start = 0;
	var layer_interval=0;

	var _pos_top=0;
	var _pos_left=0;


	function showLayer(index,topPosition,left_Index) {
	
		var nowWinWidth = document.body.clientWidth;
	
		var left_margin  = 0;
		if (nowWinWidth > 950) {
			left_margin = (nowWinWidth-950)/2;
		}
		var layer_name = "Layer"+index;
		
		if (old_layer_index != 0 && old_layer_index != index) {
			var old_layer_name = "Layer"+old_layer_index;
			document.all[old_layer_name].style.visibility = "hidden";
			//alert(old_layer_name);
		}
		
		old_layer_index = index;
		hideLayerExclusive(index);	

		 if (left_Index != null){ //top menu
			var defWidth = 160;
			document.all[layer_name].style.top = topPosition;  
			var avaW	= (nowWinWidth - (650 +  (defWidth*2))) / 2  ;
			var aW = (defWidth-defWidth/2) + avaW + 25;
				document.all[layer_name].style.left = aW  + (90 * left_Index) ;
			if (document.body.scrollLeft >0 ) {
			}

		 } else {
			document.all[layer_name].style.top = topPosition;
			document.all[layer_name].style.left = left_margin + layer_left_start + 120;
		}
		document.all[layer_name].style.visibility = "visible";

		//alert(document.all[layer_name].style.visibility + ':' + document.all[layer_name].style.left );
	}


function getPosLoad(){

	window.cancelBubble = true;
	var oBtn = window.event.srcElement;

		// if (oBtn.LinkType == "TKLAYER") 
		// {
			
			var left = 0;
			var top = 0;
			 var tmp = oBtn;
			while (tmp != null) {
			 left += tmp.offsetLeft;
			 top += tmp.offsetTop;
			tmp = tmp.offsetParent;

		}
			//alert(top);
		//}
		//_pos_top=top;
		//alert(left);
		return left;

}

  function hideLayerExclusive(index) {
	if(document.all["layer"]!=null)	{
		for(i=1;i<document.all["layer"].length;i++)
		if (i != index) document.all["layer"][i].style.visibility="hidden";
	}
  }

	
	function hideLayer(index) {
		var layer_name = "Layer"+index;
		document.all[layer_name].style.visibility = "hidden";
		//alert(layer_name);
	
	}


function window_open(N,H,K){
  window.open(N,H,K)
}

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_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_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_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_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_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; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



/*-----------------------------------------------------------
	Cookie
-------------------------------------------------------------*/
function getCookie( name ) { 
var nameOfCookie = name + "=", x = 0;
while ( x <= document.cookie.length ) { 
  var y = (x+nameOfCookie.length); 
  
  if ( document.cookie.substring( x, y ) == nameOfCookie )  { 
	if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 ) endOfCookie = document.cookie.length; 
	return unescape( document.cookie.substring( y, endOfCookie ) ); 
  } 
  
  x = document.cookie.indexOf( " ", x ) + 1; 
  if ( x == 0 ) break; 
	}
return "";
}


function setCookie( name, value, expiredays ) {
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name+"="+escape( value )+"; path=/;expires="+todayDate.toGMTString()+";"
}



function goURL(url,tg) {

  if (url !==''){
	   if (tg =='')  {
		top.location.href = url;
	   } else {
	     window.open(url,tg);
	   }
  }

}




var openWin=null;

/*-------------------------------------------
	ÀÌ¹ÌÁö ¹Ì¸®º¸±â
-------------------------------------------*/
function openImageView(ImagePath) {
	if (ImagePath=="")
	{
	 alert("ÀÌ¹ÌÁö¸¦ °ð ÁØºñÇÏ°Ú½À´Ï´Ù.")
	} else {
	
	if (openWin!=null && !openWin.closed) openWin.close();
	openWin=window.open("/app/popup_image.asp?path="+ImagePath,"pop_img",
	"scrollbars=yes,resizable=yes,width=500,height=400");
	openWin.focus();
   }
}

/*-------------------------------------------
 MS ÀÍ½ºÇÃ·¯ ÄÁÆ®·Ñ Á¦¾î
-------------------------------------------*/
function fnLaunchFlash(width, height, url, vars){
	if (vars !=""){
		url = url + "?" + vars;  
	}
	document.write("<object classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 width=" + width + " height=" + height + ">");
	document.write("<param name=movie value=" + url + ">");
	document.write("<param name=wmode value=transparent>");
	document.write("<param name=quality value=high>");
	document.write("<embed src=" + url + " quality=high pluginspage=http://www.macromedia.com/go/getflashplayer type=application/x-shockwave-flash width=" + width + " height=" + height + "></embed>");
	document.write("</object>");
}


function resizeIframe(fr) {
fr.setExpression('height',ifr.document.body.scrollHeight+300);
//fr.setExpression('width',aaa.document.body.scrollWidth);
}

function vwimgrzmv(obj,imgsrc) {
	var rz = 0;
	var scrl = 0;
	var rzwidth = obj.width + 5;
	var rzheight = obj.height + 25;
	var mvleft = (window.screen.width - obj.width) / 2;
	var mvtop = (window.screen.height - obj.height - 25) / 2;
	var imgwin = null;
	var ie = navigator.appName.indexOf('Microsoft Internet Explorer')>-1 ? true : false;

	if(obj.height>window.screen.height) {
		rz = 0;
		scrl = 1;
		rzwidth = obj.width + 23;
		rzheight = window.screen.height - 30;
		mvtop = 0;
	}

	if(obj.width>window.screen.width) {
		rz = 0;
		scrl = 1;
		rzwidth = window.screen.width;
		mvleft = 0;
	}

	if(!imgsrc) imgsrc = obj.src;

	imgwin = window.open('','_blank','toolbar=0,menubar=0,status=1,scrollbars=' + scrl + ',resizable=' + rz + ',width=0,height=0,left=' + ((window.screen.availWidth-245)/2) + ',top=' + ((window.screen.availHeight-105)/2));
	if(imgwin) {
		imgwin.blur();
		imgwin.moveTo(0,0);
		imgwin.resizeTo(0,0);

		imgwin.document.write(("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><" + "html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"ko\" xml:lang=\"utf-8\"><" + "head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><" + "title>object</" + "title><style type=\"text/css\">body { margin:0; }</style></" + "head>" +
			"<" + "body>" +
			"<img src=\"" + imgsrc.replace('+',' ') + "\" id=\"uploaded_image\" " +
			" onload=\"" +
				"var rz = 0;" +
				"var scrl = 0;" +
				"var rzwidth = this.width + 5;" +
				"var rzheight = this.height + 25 + " + (ie?55:30)  + ";" +
				"var mvleft = (window.screen.width - this.width) / 2;" +
				"var mvtop = (window.screen.height - this.height-25) / 2;" +
				"var imgwin = null;" +
				"if(this.height >= window.screen.height - 10) {" +
					"rzwidth = this.width + 23;" +
					"rzheight = window.screen.height - 30;" +
					"mvtop = 0;" +
				"} " +
				"if(this.width >= window.screen.width - 10) {" +
					"rz = 1;" +
					"scrl = 1;" +
					"rzwidth = window.screen.width;" +
					"mvleft = 0;" +
				"}" +
				"window.resizeTo(rzwidth, rzheight);" +
				"window.moveTo(mvleft, mvtop);" +
				"window.scrollbars = scrl;" +
				"window.resizable = rz;" +
				"\"" +
			" onerror=\"alert('ÀÌ¹ÌÁöÆÄÀÏÀÌ ¾ø°Å³ª ÆÄÀÏÀÌ¸§ÀÌ Àß¸øµÇ¾ú½À´Ï´Ù.\\nÆÄÀÏÀÌ¸§¿¡ ÇÑ±ÛÀÌ Æ÷ÇÔµÇ¾î ÀÖÀ¸¸é ºä¾îÃ¢¿¡ ¿À·ù°¡ ¹ß»ýÇÒ¼öµµ ÀÖ½À´Ï´Ù.');self.close();\"" +
			" onclick=\"window.close();\"" +
			" style=\"cursor:hand;cursor:pointer;\" alt=\"Å¬¸¯ÇÏ½Ã¸é Ã¢ÀÌ ´ÝÈü´Ï´Ù\" />" +
			"<" + "script type=\"text/javascript\">" +
				"function init() {" +
					"var img = document.getElementById('uploaded_image');" +
					"if(img) {" +
						"if(img.width >= window.screen.width -10) {" +
							"img.width = window.screen.width - 10;" +
						"}" +
						"if(img.height >= window.screen.height-50) {" +
							"document.body.scroll='auto';" +
						"}" +
						"document.title = img.width + '*' + img.height;" +
					"}" +
				"}" +
				"window.onLoad = init();" +
			"</" + "script" + ">" +
			"</" + "body></" + "html>"));
		imgwin.status = "Resolution:" + window.screen.width + "x" + window.screen.height;
		imgwin.focus();
	}
}

//**************************************
//E-Ä«´Ù·Î±× ÇØ»óµµ¿¡ µû¶ó °¡¿îµ¥¼­ ¶ç¿ì±â ¼Ò½º
//**************************************

function WinPopupOpen(pUrl, pNm, pStatus, pToolbar, pResize, pScroll, pMenubar, pWidth, pHeight, pTop, pLeft){

 //º¯¼ö ÃÊ±âÈ­
 pNm = (pNm == null) ? '' : pNm;
 pStatus = (pStatus == null) ? 'no' : pStatus;
 pToolbar = (pToolbar == null) ? 'no' : pToolbar;
 pResize = (pResize == null) ? 'no' : pResize;
 pScroll = (pScroll == null) ? 'no' : pScroll;
 pMenubar = (pMenubar == null) ? 'no' : pMenubar;
 pWidth = (pWidth == null) ? 0 : pWidth;//¶ç¿ï »õÃ¢¿¡ Å©±â
 pHeight = (pHeight == null) ? 0 : pHeight;//¶ç¿ï »õÃ¢¿¡ Å©±â

 //ÄíÅ°¿¡¼­ OSÃ¼Å© : var OsVer = document.GNax.GetOsVer(ÃßÈÄ-·Î±×ÀÎÇØ¾ßÇÏ´Â¹®Á¦...???)
 //win2000±âÁØÀ¸·Î ÇÏ½Ã¸é µÉ°Í°°½À´Ï´Ù.
 pHeight = (window.navigator.userAgent.indexOf("SV1") != -1) ? eval(pHeight)+20 : pHeight;

 //ÆË¾÷ÀÌ¸§¿¡µû¶ó ½ºÅ©·Ñ¿©ºÎ ÁöÁ¤
 if (pNm=="notice" || pNm=="help" || pNm=="driver" ){
  pScroll= 'yes';
 }

 var sw = screen.availWidth;//¸ð´ÏÅÍ ÇØ»óµµ(width)  <----------------ÇÙ½É
 var sh = screen.availHeight;//¸ð´ÏÅÍ ÇØ»óµµ(height)   <----------------ÇÙ½É
 var px = pTop//(sw - pWidth)/2;//	<----------------ÇÙ½É ÇØ»óµµ¿¡ µû¸¥ °¡¿îµ¥ »õÃ¢¿­±â width
 var py = pLeft//(sh - pHeight)/2;//	<----------------ÇÙ½É ÇØ»óµµ¿¡ µû¸¥ °¡¿îµ¥ »õÃ¢¿­±â height

 var Option = "";
 // pTop, pLeft µÑ ´Ù °ªÀÌ ¾øÀ» °æ¿ì¿¡¸¸ 0,0 À¸·Î ÃÊ±âÈ­
 if (pTop == null & pLeft == null){
  Option = "status="+pStatus+",toolbar="+pToolbar+",resizable="+pResize+",scrollbars="+pScroll+", menubar="+pMenubar+",width="+sw+",height="+sh;
 }else{
  pTop = (pTop == null) ? 0 : py;
  pLeft = (pLeft == null) ? 0 : px;
  Option = "status="+pStatus+",toolbar="+pToolbar+",resizable="+pResize+",scrollbars="+pScroll+", menubar="+pMenubar+",width="+sw+",height="+sh+",top="+pTop+",left="+pLeft+"";
  //Option = "status="+pStatus+",toolbar="+pToolbar+",resizable="+pResize+",scrollbars="+pScroll+", menubar="+pMenubar+",fullscreen,top="+pTop+",left="+pLeft+"";
 }

 pUrl = pUrl+'&sw='+sw+'&sh='+sh;

 //alert(Option);

 var  ObjWin = window.open(pUrl, pNm, Option);
 ObjWin.focus();
}

var openWin=null;

function openMIPOClub(eth){
openWin=window.open('popup.asp?eth='+eth,'sample','location=no,directories=no,resizable=no,status=no,toolbar=no,menubar=no,width=900,height=635,scrollbars=no')
//()ºÎºÐÀº ÇÑÁÙ·Î ÀÛ¼ºÇØ¾ß ÇÕ´Ï´Ù.;
openWin.focus();
return false;
}


/*È¸¿ø ¾ÆÀÌµðÃ£±â*/
	function fnLoginFindID(){
		openWindows('/board/Library/findMemberID.asp?Action=ID','find_id','350','300','0');
	}

/*È¸¿ø ºñ¹Ð¹øÈ£Ã£±â*/
	function fnLoginFindPW(){
		openWindows('/board/Library/findMemberID.asp?Action=PW','find_id','350','300','0');
	}

/*È¸¿ø Å»Åð½ÅÃ»*/
function fnMemberSecession(){
	openWindows("/board/Library/memberSecession.asp", 'memberSecession', 500, 500, 0);
}

function fnFindPost(str){
	openWindows("/board/Library/findPost.asp?strForm=" + str, 'findPost', 500, 500, 0);
}
function openWindows(filename,p_name,s_width,s_height,s_scrol){
	var x = screen.width;
	var y = screen.height;
	var wid = (x / 2) - (s_width / 2);
	var hei = (y / 2) - (s_height / 2);

	window.open(filename, p_name, "toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrollbars=" + s_scrol + ",width=" + s_width + ",height=" + s_height + ",top=" + hei + ",left=" + wid + ",scrolbar=no"); 
}


var openWin=null;
/*---------------------------------------------
	ÀÎÁõ¼­ º¸±â
-------------------------------------------------*/
function openCertify(tp){
	if (openWin!=null && !openWin.closed) openWin.close();
	openWin=window.open("/library/certify_index.asp?tp="+tp,"certify",
	"fullscreen=no,titlebar=no,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=570,height=720,top=0,left=0");
    openWin.focus();
}

/*---------------------------------------------
	µµ¸éº¸±â / ´Ù¿î·Îµå
-------------------------------------------------*/
function openPaper(tp){
	if (openWin!=null && !openWin.closed) openWin.close();
	openWin=window.open("/library/paper_index.asp?tp="+tp,"certify",
	"fullscreen=no,titlebar=no,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=850,height=800,top=0,left=0");
    openWin.focus();
}


/*---------------------------------------------
	SIMULATION
-------------------------------------------------*/
function openSimulation(tp){

	w=450;
	h= 450;

	if (openWin!=null && !openWin.closed) openWin.close();
	openWin=window.open("/library/simulation.asp?tp="+tp,"simulation",
	"fullscreen=no,titlebar=no,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=450,height=491,top=150,left=150");
    openWin.focus();
}


/*---------------------------------------------
	°ü¸®ÀÚ ·Î±×ÀÎ
-------------------------------------------------*/
function openAdmin(tn){
	w=400;
	h= 350;
	if (openWin!=null && !openWin.closed) openWin.close();
	openWin=window.open("/board/popup_login.asp?tn="+tn,"admin",
	"fullscreen=no,titlebar=no,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=250,top=" + (screen.availWidth - w)/2 + ",left="  + (screen.availHeight - h)/2 +",");
    openWin.focus();
}


/*-------------------------------------------
	ÀÌ¹ÌÁö ¹Ì¸®º¸±â
-------------------------------------------*/
function openImageView(ImagePath) {
	if (ImagePath=="")
	{
	 alert("ÀÌ¹ÌÁö¸¦ °ð ÁØºñÇÏ°Ú½À´Ï´Ù.")
	} else {
	
	if (openWin!=null && !openWin.closed) openWin.close();
	openWin=window.open("/library/popup_image.asp?path="+ImagePath,"pop_img",
	"scrollbars=yes,resizable=yes,width=500,height=400");
	openWin.focus();
   }
}

function openImageView(ImagePath) {
	if (ImagePath=="")
	{
	 alert("ÀÌ¹ÌÁö¸¦ °ð ÁØºñÇÏ°Ú½À´Ï´Ù.")
	} else {
	
	if (openWin!=null && !openWin.closed) openWin.close();
	openWin=window.open("/library/popup_image.asp?path="+ImagePath,"pop_img",
	"scrollbars=yes,resizable=yes,width=500,height=400");
	openWin.focus();
   }
}






function fnEcatalog(url)
{
	if (url ==""){
		url = "/ecatalog/mCatalog.html";
	} 
	if (openWin!=null && !openWin.closed) openWin.close();
	var opt = "directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no, top=0, left=0, width="+screen.width+", height="+screen.height+"";
	openWin=window.open(url,'_mCatalog',opt);
	openWin.focus();
}

function resizeImage(target_img,Width,Height){

    var newX, newY;
    var newHeight, newWidth;
    var newImg;

    var maxWidth = Width;
    var maxHeight = Height;

    newImg = new Image();
    newImg.src = target_img.src;
	
	imgw = newImg.width;
    imgh = newImg.height;

   // if (imgw*1.2 >= imgh) {
   // 	return false;
   // }

    if (imgw > maxWidth || imgh > maxHeight)
    {
        if(imgw > imgh)
        {
            if(imgw > maxWidth)
                newWidth = maxWidth;
            else
                newWidth = imgw;
            newHeight = Math.round((imgh*newWidth)/imgw);
        }
        else
        {
            if(imgh > maxHeight)
                newHeight = maxHeight;
            else
                newHeight = imgh;
            newWidth = Math.round((imgw*newHeight)/imgh);
        }
    }
    else
    {
        newWidth = imgw;
        newHeight = imgh;
    }
    newX = maxWidth/2 - newWidth/2;
    newY = maxHeight/2 - newHeight/2;

	target_img.onload = null;
	target_img.src = newImg.src;
    target_img.width = newWidth;
    target_img.height = newHeight;
}

