// ***********************************************************************************************************************  
// ±âº»ÀûÀÎ ÆË¾÷																									 *
// ***********************************************************************************************************************  
function PopUp(url, s, w, h)
{	
 var x = (screen.availWidth - w) / 2;
 var y = (screen.availHeight - h) / 2;

	window.open(url,"","left="+x+",top="+y+",toolbar=no,location=no,status=no,menubar=no,scrollbars=" + s + ",width=" + w + ",height=" + h + ",resizable=yes");    
}	

function PopUpOne(url, s, w, h, name)
{	
 var x = (screen.availWidth - w) / 2;
 var y = (screen.availHeight - h) / 2;

	window.open(url,name,"left="+x+",top="+y+",toolbar=no,location=no,status=no,menubar=no,scrollbars=" + s + ",width=" + w + ",height=" + h + ",resizable=yes");    
}	


// ***********************************************************************************************************************  
// ±âº»ÀûÀÎ ÆË¾÷																									 *
// ***********************************************************************************************************************  
function PopUpC(url, s, w, h)
{	
	window.open(url,"","left=" + event.screenX + ",top=" + event.screenY + ",toolbar=no,location=no,status=no,menubar=no,scrollbars=" + s + ",width=" + w + ",height=" + h + ",resizable=yes");    
}	

// ***********************************************************************************************************************  
// ±×¸²ÀÌ Å©´Ù¸é..Àû´çÇÑ..Å©±â·Î																					 *
// ***********************************************************************************************************************  
function PopUpImage(url, s, w, h)
{	
	if (screen.width < w) 
	{	
		w = screen.width - 10; 		
		s = 'yes'; 
	}	 
	if (screen.height < h) 
	{
		h = screen.height - 60;
		s = 'yes'; 
	} 
	PopUp(url, s, w, h);
  return;
  
}	

// ***********************************************************************************************************************  
// * ±×¸² Å©Å° Ã¼Å© ÇÏ°í º¸¿©ÁÖ±â (phpschool.com nux ´Ô ±Û)             											* 
// ***********************************************************************************************************************  
function imgRsize(img, rW, rH)
{
	var iW = img.width;
  var iH = img.height;
  var g = new Array;
  
  if(iW < rW && iH < rH)				// °¡·Î¼¼·Î°¡ Ãà¼ÒÇÒ °ªº¸´Ù ÀÛÀ» °æ¿ì
  { 
    g[0] =  iW; 
    g[1] =  iH; 
  } 
  else 
  {
    if(img.width > img.height)				// ¿øÅ©±â °¡·Î°¡ ¼¼·Îº¸´Ù Å©¸é 
    { 
      g[0] = rW;
      g[1] = Math.ceil(img.height * rW / img.width);
    } 
    else if(img.width < img.height)				//¿øÅ©±âÀÇ ¼¼·Î°¡ °¡·Îº¸´Ù Å©¸é
    { 
      g[0] = Math.ceil(img.width * rH / img.height);
      g[1] = rH;
    } 
    else 
    {
      g[0] = rW;
      g[1] = rH;
    }
    if(g[0] > rW)				// ±¸ÇØÁø °¡·Î°ªÀÌ Ãà¼Ò °¡·Îº¸´Ù Å©¸é
    { 
      g[0] = rW;
      g[1] = Math.ceil(img.height * rW / img.width);
    }
    if(g[1] > rH)				// ±¸ÇØÁø ¼¼·Î°ªÀÌ Ãà¼Ò ¼¼·Î°ª°¡·Îº¸´Ù Å©¸é 
    { 
      g[0] = Math.ceil(img.width * rH / img.height);
      g[1] = rH;
    }
  }
  
  g[2] = img.width; // ¿ø»çÀÌÁî °¡·Î
  g[3] = img.height; // ¿ø»çÀÌÁî ¼¼·Î
  
 	if (screen.width < img.width) 
	{	
		g[2] = screen.width - 10; 		
	}	

 	if (screen.height < img.height) 
	{	
		g[3] = screen.height - 60; 		
	}	
  
  return g;
}

// ***********************************************************************************************************************  
// * ±×¸² Å©Å° Ã¼Å© ÇÏ°í º¸¿©ÁÖ±â (phpschool.com nux ´Ô ±Û + jsguide.net Nextream ´Ô ±Û)              																					 * 
// ***********************************************************************************************************************  
function Rsize(img, ww, hh, aL)
{
  var tt = imgRsize(img, ww, hh);
  if(img.width > ww || img.height > hh)				// °¡·Î³ª ¼¼·ÎÅ©±â°¡ Á¦ÇÑÅ©±âº¸´Ù Å©¸é
  { 
    img.width = tt[0]; // Å©±âÁ¶Á¤
    img.height = tt[1];
    img.alt = 'Å¬¸¯ÇÏ½Ã¸é ¿øº»ÀÌ¹ÌÁö¸¦ º¸½Ç¼öÀÖ½À´Ï´Ù.';
    
    if(aL)				// ÀÚµ¿¸µÅ© on
    { 
      img.onclick = function()
      {
        //wT = Math.ceil((screen.width - tt[2])/2.6); // Å¬¶óÀÌ¾ðÆ® Áß¾Ó¿¡ ÀÌ¹ÌÁöÀ§Ä¡.
        //wL = Math.ceil((screen.height - tt[3])/2.6);
        wT = 0;
        wL = 0;
  
				var wbody = "<head><title>¿ø·¡ Å©±â·Î º¸±â</title>";
				wbody += "</head>";
				wbody += "<body style='margin:0'>";
				wbody += "<a href='javascript:window.close()'><img src='" + img.src + "' border=0></a>";
				wbody += "</body>";
				winResult = window.open("about:blank", 'viewOrig', 'width='+tt[2]+',height='+tt[3]+',top='+wT+',left='+wL+',scrollbars=yes,status=yes,resizable=yes');
				winResult.document.open("text/html", "replace");
				winResult.document.write(wbody);
				winResult.document.close();
      }
      img.style.cursor = "hand";
    }
  } 
  else 
  {
		//img.onclick = function(){ alert("ÇöÀçÀÌ¹ÌÁö°¡ ¿øº» ÀÌ¹ÌÁöÀÔ´Ï´Ù."); }
  }
}

// ***********************************************************************************************************************  
// * ±×¸² Å©Å° Ã¼Å© ÇÏ°í º¸¿©ÁÖ±â              																					 * 
// ***********************************************************************************************************************  
function UploadImage(form, imageFile, imageWidth, imageHeight)
{
	var imageValue = eval('form.fleFileName' + imageFile + '.value');

  if (CheckImage(imageValue))
	{
		document.images["PreviewImage"].width = imageWidth;
		document.images["PreviewImage"].height = imageHeight;

		document.images["PreviewImage"].src = imageValue;
		document.images["PreviewImage"].style.display = "";
		
	}
	else
	{
		alert("ÀÌ¹ÌÁö ÆÄÀÏ¸¸ ¿Ã·ÁÁÖ¼¼¿ä");
	}
}

// ***********************************************************************************************************************  
// * Ã¼Å©¹Ú½º ¼±ÅÃ : ON, OFF																      							 * 
// ***********************************************************************************************************************  
function CheckAll()
{	
	for (var i = 0; i < document.forms[0].elements.length; i++)
	{
		if (document.forms[0].elements[i].type == "checkbox")
		{
			if (document.forms[0].elements[i].name != 'chkAllBox')
			{
				document.forms[0].elements[i].checked = document.forms[0].chkAllBox.checked;
			}
		}
	}
}

// ***********************************************************************************************************************  
// ±×¸² ¹Ì¸® º¸±â																												 *
// ***********************************************************************************************************************  
function PreviewImage(form)
{
	window.open(form.fleFileName.value,"PreviewImage","width=800,height=600,scrollbars=no");
}

// ***********************************************************************************************************************  
// ±×¸² ÆÄÀÏÀÎÁö Ã¼Å©ÇÑ´Ù.																												 *
// ***********************************************************************************************************************  
function CheckImage(filename) 
{
	if (filename.match(/\.(gif|jpg|jpeg|png|bmp)$/i)) 
	{
		return true;
	} 
	else 
	{
		return false;
	}
}

// ***********************************************************************************************************************  
// µ¿¿µ»óÀÎÁö Ã¼Å©ÇÏ´Â ·çÆ¾	 																								 *
// ***********************************************************************************************************************  
function CheckMovie(filename) 
{
	if (filename.match(/\.(asf|wmv|avi|mpg|mpeg|mp3)$/i)) 
	{
		return true;
	} 
	else 
	{
		return false;
	}
}

// ***********************************************************************************************************************  
// ¹®ÀÚ¿­¿¡ °ø¹éÀÌ ÀÖ´ÂÁö °Ë»ç																									 *
// ***********************************************************************************************************************  
function CheckEmpty(strText)
{
	if (strText.match(/^[ ]*$/))
	{
		return true;
	}
	else
	{
		return false;
	}
}

// ***********************************************************************************************************************  
// ¹®ÀÚ¿­¿¡ ¾ËÆÄºª°ú _ - À¸·Î ±¸¼ºµÇ¾î ÀÖ´ÂÁö °Ë»ç	 																								 *
// ***********************************************************************************************************************  
function CheckAlphabet(strText)
{
	if (strText.match(/^[a-zA-Z0-9_-]+$/))
	{
		return true;
	}
	else
	{
		return true;
	}
}

// ***********************************************************************************************************************  
// ¹®ÀÚ¿­¿¡ ÇÑ±ÛÀÌ ÇÑÀÚ¶óµµ ÀÖ´ÂÁö °Ë»ç	 																								 *
// ***********************************************************************************************************************  
function CheckHangul(strText)
{
	if (strText.match(/[°¡-È÷]+/))
	{ 
		return true; 
	}
	else
	{
		return false;
	}
}

// ***********************************************************************************************************************  
// ¹®ÀÚ¿­ÀÌ ¼ýÀÚ¸¸ Á¸ÀçÇÏ´ÂÁö °Ë»ç																									 *
// ***********************************************************************************************************************  
function CheckNumber(strText)
{
	if (strText.match(/^[-]{0,1}[0-9]+$/))
	{
		return true;
	}
	else
	{
		return false;
	}
}

// ***********************************************************************************************************************  
// ÀÌ¸ÞÀÏ Ã¼Å©ÇÏ´Â ·çÆ¾	 																								 *
// ***********************************************************************************************************************  
function CheckEmail(strText)
{
	if (strText.match(/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+.[a-zA-Z.]+$/))
	{
		return true;
	}
	else
	{
		return false;
	}
}

// ***********************************************************************************************************************  
// »ç¿ëÀÚ ID Ã¼Å©ÇÏ´Â ·çÆ¾	 																								 *
// ***********************************************************************************************************************  
function CheckUserId(strText)
{

	if (strText.match(/^[a-zA-Z0-9_-]{1}[a-zA-Z0-9_-]{3,30}$/))
	{
		return true;
	}
	else
	{
		return false;
	}
}

// ***********************************************************************************************************************  
// * ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å© ºÎºÐ              							         * 
// ***********************************************************************************************************************  
function CheckJumin(it) 
{
	var IDtot = 0;
	var IDAdd = "234567892345";

	for (i = 0 ; i < 12 ; i++) 
	{
		IDtot = IDtot + parseInt(it.substring(i, i + 1)) * parseInt(IDAdd.substring(i, i + 1));
	}
	IDtot = 11 - (IDtot % 11);
	if (IDtot == 10) 
  {
		IDtot = 0;
	} 
	else if (IDtot == 11)
	{
		IDtot = 1;
	}
	if (parseInt(it.substring(12,13)) != IDtot)
	{ 
		return true;
	}
}

// ***********************************************************************************************************************  
// * »ç¾÷ÀÚµî·Ï¹øÈ£ Ã¼Å© ºÎºÐ              							         * 
// ***********************************************************************************************************************  
function CheckWorkNo(text)
{
	var sumMod = 0;
	sumMod += parseInt(text.substring(0,1));
	sumMod += parseInt(text.substring(1,2)) * 3 % 10;
	sumMod += parseInt(text.substring(2,3)) * 7 % 10;
	sumMod += parseInt(text.substring(3,4)) * 1 % 10;
	sumMod += parseInt(text.substring(4,5)) * 3 % 10;
	sumMod += parseInt(text.substring(5,6)) * 7 % 10;
	sumMod += parseInt(text.substring(6,7)) * 1 % 10;
	sumMod += parseInt(text.substring(7,8)) * 3 % 10;
	sumMod += Math.floor(parseInt(text.substring(8,9)) * 5 / 10);
	sumMod += parseInt(text.substring(8,9)) * 5 % 10;
	sumMod += parseInt(text.substring(9,10));

	if (text % 10 != 0)
	{
		alert("»ç¾÷ÀÚµî·Ï¹øÈ£°¡ Àß¸øµÇ¾ú½À´Ï´Ù.");
		return false;
	}
	return true;
}

// ***********************************************************************************************************************  
// Á¦Ç°Æò¿¡¼­ »ç¿ë														*
// ***********************************************************************************************************************  
var selMenu = "";
function ToggleMenu(currMenu) 
{
  var currMenu = document.all ? document.all[currMenu] : document.getElementById ? document.getElementById(currMenu) : null; 
	
	if (currMenu) 
	{
		thisMenu = currMenu.style;
		
		if (thisMenu != selMenu)
		{
			if (selMenu != "")
			{
				selMenu.display = "none";
			}
			thisMenu.display = "block";
			selMenu = thisMenu;			
		}
		else
		{
			thisMenu.display = "none";
			selMenu = "";
		}	

		return false;
	}
	else 
	{
		return true;
	}
}

// ***********************************************************************************************************************  
// * title ±¸ÇöÇÏ±â                                    						 * 
// ***********************************************************************************************************************  
document.write( '<div id="TextOnMouse" style="font-size:9pt; border:1 solid #AFADFF; height:20; position:absolute; visibility:hidden; z-Index:1; padding:5; background-color:#F7F8CA;"></div>' );
function GetTitleOver(text, out, e) 
{
	if (out == 1) 
	{
		document.getElementById("TextOnMouse").opened = false;
		document.getElementById("TextOnMouse").style.visibility = 'hidden';
		return false;
	}
	
	document.getElementById("TextOnMouse").opened = true;	

	if (navigator.userAgent.toLowerCase().indexOf("msie") != -1) 
	{
		document.getElementById("TextOnMouse").style.top = (event.clientY + document.body.scrollTop) + "px";
		document.getElementById("TextOnMouse").style.left = (event.clientX + document.body.scrollLeft  + 10) + "px";
		document.getElementById("TextOnMouse").innerHTML = text;
	}
	else
	{
		document.getElementById("TextOnMouse").style.top = (e.clientY + window.pageYOffset ) + "px";
		document.getElementById("TextOnMouse").style.left = (e.clientX + window.pageXOffset  + 10) + "px";
		document.getElementById('TextOnMouse').innerHTML = "";
		document.getElementById('TextOnMouse').appendChild(document.createTextNode(text));
	}
	document.getElementById("TextOnMouse").style.visibility = 'visible';
}

// ***********************************************************************************************************************  
// URL ÀÌµ¿																									 *
// ***********************************************************************************************************************  
function LocationHref(url)
{
	if (url != "")
	{
		location.href = url;
	}
}

// ***********************************************************************************************************************  
// URL ÀÌµ¿																									 *
// ***********************************************************************************************************************  
function ParentHref(url)
{
	parent.location.href = url;
}

// ***********************************************************************************************************************  
// ¹°¾îº¸±¸ URL ÀÌµ¿																									 *
// ***********************************************************************************************************************  
function ConfirmHref(text, url)
{
	var ConfirmPost = confirm(text);
	
	if (ConfirmPost == true) 
	{
		location.href = url;
	}
}


// ***********************************************************************************************************************  
// ¹°¾îº¸±¸ ÇÔ¼ö½ÇÇà																						 *
// ***********************************************************************************************************************  
function ConfirmFunc(text)
{

    if(confirm(text)){
        return true;
    }else{
        return false;
    }


}

// ***********************************************************************************************************************  
// * ±ÛÀÚ ¹ÙÀÌÆ® Ã¼Å© ºÎºÐ                                    						 * 
// ***********************************************************************************************************************  
function CheckByte(text) 
{
	var temp = "";
	var cnt = 0;

	for (var i = 0; i < text.length; i++)  
	{
		temp = text.charAt(i);
		
		if (escape(temp).length > 4)
		{
			cnt += 2;
		}
		else
		{
		  cnt++;
		}
	}      
	return cnt;
}

// ***********************************************************************************************************************  
// * textarea ºÎºÐ¿¡ ÅÇÅ° »ç¿ëÇÏ´Â ºÎºÐ(À¥¿¡µðÅÍ·Î ÀÎÇÏ¿© »ç¿ë¾ÈÇÔ)                                    						 * 
// ***********************************************************************************************************************  
function UseTabKey(text)
{
	if(event.keyCode == 9)
	{
		(text.selection = document.selection.createRange()).text = "\t";
		event.returnValue=false;
	}
}

// ***********************************************************************************************************************  
// * Å¬¸³º¸µå·Î º¹»ç                                    						 * 
// ***********************************************************************************************************************  
function CopyClipBoard(objId)
{
	var strVal = document.getElementById(objId).innerHTML;

	if (window.clipboardData)
	{ 
		window.clipboardData.setData("Text", strVal);
	}
	else if (window.netscape)
	{
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;

		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;

		trans.addDataFlavor('text/unicode');

		var str = new Object();
		var len = new Object();

		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);

		var copytext=strVal;

		str.data=copytext;

		trans.setTransferData("text/unicode",str,copytext.length*2);

		var clipid=Components.interfaces.nsIClipboard;

		if (!clip) return false;

		clip.setData(trans,null,clipid.kGlobalClipboard);

	}
	
	alert("Æ®·¢¹é ÁÖ¼Ò°¡ º¹»çµÇ¾ú½À´Ï´Ù.");
	return false;
}










