//ÀÏ´Ü »ç¿ëÇÏÁö ¸¶¼¼¿ä~
var strChars = "1234567890";
var deny_pattern = /[!%=\"\'<>|]/;

//Çã¿ëÇÒ ¹®ÀÚ¿­ Ã¼Å©
function containsCharsOnly(input,chars) {
    for (var inx = 0; inx < eval(input).value.length; inx++) {
       if (chars.indexOf(eval(input).value.charAt(inx)) == -1)
           return false;
    }
    return true;
}

function excludeChars(input,chars) {
    for (var inx = 0; inx < eval(input).value.length; inx++) {
       if (chars.indexOf(eval(input).value.charAt(inx)) != -1)
           return true;
    }
    return false;
}

function numericCheck(objField, strDescription, blnBit)
{
	//ÀÔ·Â¿©ºÎ Ã¼Å©
	if (textFieldCheck(objField, strDescription, blnBit) == false) 
		return false;
	//¼ýÀÚÀÎÁö Ã¼Å©
	else if (decimalFieldCheck(objField, strDescription, blnBit) == false) 
		return false;
	else
		return true;
}


function textFieldCheck(objField, strDescription, blnBit)
{
// ÅØ½ºÆ® ÇÊµå¿¡ °ªÀ» ÀÔ·ÂÇß´ÂÁö È®ÀÎ
// ÇØ´ç input °´Ã¼, ÀÔ·ÂÇØ¾ß ÇÏ´Â ÇÊµå ÀÌ¸§, ¹ÞÄ§ À¯¹«¸¦ ÁöÁ¤ÇÑ´Ù.
	if (blnBit == 0) //¸¶Áö¸· ±ÛÀÚ¿¡ ¹ÞÄ§ÀÌ ¾ø´Â °æ¿ì
	{
		if (eval(objField).value.length == 0 || eval(objField).value.split(" ").join("") == "")
		{
			alert(strDescription + "¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
			eval(objField).focus();
			return false;
		}
	}
	else //¸¶Áö¸· ±ÛÀÚ¿¡ ¹ÞÄ§ÀÌ ÀÖ´Â °æ¿ì
	{
		if (eval(objField).value.length == 0 || eval(objField).value.split(" ").join("") == "")
		{
			alert(strDescription + "À» ÀÔ·ÂÇØ ÁÖ¼¼¿ä."); 
			objField.focus();
			return false;
		}
	}
	return true;
}


function decimalFieldCheck(objField, strDescription, blnBit)
{

//ÅØ½ºÆ® ÇÊµå¿¡ ¼ýÀÚ °ªÀ» ÀÔ·ÂÇß´ÂÁö È®ÀÎ
	if (blnBit == 0) //¸¶Áö¸· ±ÛÀÚ¿¡ ¹ÞÄ§ÀÌ ¾ø´Â °æ¿ì
	{
		if (!containsCharsOnly(objField,strChars))
		{
			alert(strDescription + "´Â ¼ýÀÚ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù."); 
			eval(objField).focus(); 
			eval(objField).select(); 
			return false;
		}
	}
	else //¸¶Áö¸· ±ÛÀÚ¿¡ ¹ÞÄ§ÀÌ ÀÖ´Â °æ¿ì
	{
		if (!containsCharsOnly(objField,strChars))
		{
			alert(strDescription + "Àº ¼ýÀÚ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù."); 
			eval(objField).focus(); 
			eval(objField).select(); 
			return false;
		}	
	}
	return true;
}

function initNumericCombo(combobox, startValue, endValue, stepValue)
{
// °ªÀÌ ¼ýÀÚ·Î¸¸ ±¸¼ºµÈ ÄÞº¸¹Ú½º¸¦ ÃÊ±âÈ­ÇØÁÖ´Â ÇÔ¼ö
// ÄÞº¸¹Ú½º °´Ã¼, ½ÃÀÛ°ª, ³¡°ª, °£°ÝÀ» ÁöÁ¤ÇÑ´Ù.
// »ç¿ë¿¹: 0½ÃºÎÅÍ 23½Ã±îÁö Ç¥½ÃµÇ´Â "½Ã(Hour)" ÄÞº¸¹Ú½º´Â numericComboInit(document.frm.myCombo, 0, 23, 1)À» È£ÃâÇÏ¸é
// myCombo¶ó´Â ÄÞº¸¹Ú½ºÀÇ <option>ÀÌ Ã¤¿öÁø´Ù.
	var tempValue;
	var comboLength = parseInt(((endValue - startValue)) / stepValue) + 1;
	
	combobox.length = comboLength;
	
	for (var i = 0; i < comboLength; i++)
	{
		tempValue = startValue + stepValue * i
		combobox.options[i].value = tempValue;
		if (tempValue < 10)
			combobox.options[i].text = "0" + tempValue;
		else
			combobox.options[i].text = tempValue;
	}
}

function selectCombo(combobox, selectValue)
{
// ¿øÇÏ´Â ÄÞº¸¹Ú½º¿¡¼­ ÁöÁ¤ÇÑ °ª¿¡ ÇØ´çÇÏ´Â <option>ÀÌ ¼±ÅÃµÇµµ·Ï ÇÏ´Â ÇÔ¼ö
	var comboLength = combobox.length;
	for (var i = 0; i < comboLength; i++)
	{
		if (combobox.options[i].value == selectValue)
		{
			combobox.options.selectedIndex = i;
			break;
		}
	}
}

function emailCheck(strEmail)
{
// ÀÌ¸ÞÀÏ Æû¿¡ ¸Â´ÂÁö È®ÀÎ
	//regular expressionÀÌ Áö¿øµÇ´ÂÁö È®ÀÎ
	var supported = 0
	if (window.RegExp)
	{
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr))
			supported = 1
	}
	
	if (!supported)
	{// Áö¿øµÇÁö ¾ÊÀ¸¸é
		return (strEmail.indexOf(".") > 2) && (strEmail.indexOf("@") > 0);
	}
	else
	{// Áö¿øµÇ¸é
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
		return (!r1.test(strEmail) && r2.test(strEmail));
	}

	//strEmail.value.search(/(\S+)@(\S+)\.(\S+)/) == -1
}

function searchFieldCheck(objField)
{
	var searchValue = objField.value.split(" ").join("");
	
	if (searchValue == "")
	{
		objField.value = "";
		return true;
	}
	else if (searchValue.length > 0 && searchValue.length < 2)
	{
		alert("°Ë»ö¾î´Â 2±ÛÀÚ ÀÌ»ó¸¸ °¡´ÉÇÕ´Ï´Ù.");
		objField.focus();
		return false;
	}
	else if (excludeChars(objField,"\"('¡±/\;:-+)_<>*&^%$@"))
	{
		alert("Æ¯¼ö¹®ÀÚ´Â °Ë»ö¾î·Î ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù.");
		objField.focus();
		return false;
	}
	else
		return true;
}

function searchFieldCheckEnter(objField)
{
	var searchValue = objField.value.split(" ").join("");

	if (event.keyCode == 13)
	{
		if (searchValue == "")
		{
			objField.value = "";
			return true;
		}
		else if (searchValue.length > 0 && searchValue.length < 2)
		{
			alert("°Ë»ö¾î´Â 2±ÛÀÚ ÀÌ»ó¸¸ °¡´ÉÇÕ´Ï´Ù.");
			objField.focus();
			return false;
		}
		else if (excludeChars(objField,"\"('¡±/\;:-+)_<>*&^%$@"))
		{
			alert("Æ¯¼ö¹®ÀÚ´Â °Ë»ö¾î·Î ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù.");
			objField.focus();
			return false;
		}
		else
			return true;
	}
	else
	{
		return true;
	}
}

function textLengthLimit(objField, theLimit)
{
	if (objField.value.length > theLimit)
	{
		alert("³»¿ëÀº " + theLimit + "ÀÚ±îÁö¸¸ ¾µ ¼ö ÀÖ½À´Ï´Ù.");
		objField.value = objField.value.substring(0, theLimit);
		return false;
	}
	else
		return true;
}

function delConfirm()
{
	if(confirm("Á¤¸» »èÁ¦ ÇÏ½Ã°Ú½À´Ï±î?")) 
		return true; 
	else 
		return false;
}

function AlertConfirm(msg)
{
	if(confirm(msg)) 
		return true; 
	else 
		return false;
}

function onlyNumber() {
	if( ((event.keyCode<48)||(event.keyCode>57)) && (event.keyCode != 13) ) {
		event.returnValue=false;
//		alert("¼ýÀÚ¸¸ ÀÔ·ÂÀÌ °¡´ÉÇÕ´Ï´Ù.");
	}
}
function openPopup(theUrl, winName, bScrollbar, winWidth, winHeight, topPos, leftPos)
{
	//ÆË¾÷Ã¢ ¿©´Â ÇÔ¼ö
	//URL, Ã¢ÀÌ¸§, ½ºÅ©·Ñ¹Ù À¯¹«(yes or no), width, height, top ÁÂÇ¥, left ÁÂÇ¥¸¦ ÀÔ·Â¹Þ´Â´Ù.
	//³ª¸ÓÁö ¼Ó¼ºÀº ¸ðµÎ no
	var objPopup = window.open(theUrl, winName, "toolbar=no,location=no,status=no,manubar=no,resizable=no,scrollbars=" + bScrollbar + ",width="+ winWidth +",height=" + winHeight + ",top=" + topPos +",left=" + leftPos);
	if (objPopup == null)
	{
		if(confirm("ÆË¾÷Ã¢ÀÌ Â÷´ÜµÇ¾ú½À´Ï´Ù. ¾È³»ÆäÀÌÁö·Î ÀÌµ¿ÇÏ½Ã°Ú½À´Ï±î?"))
		{
			location.href = "/Popup/Popsafe.htm";
		}
	}
}


//°¶·¯¸® ÀÌ¹ÌÁöÆË¾÷
function default_size(img){ 
  imageid= new Image(); 
  imageid.src=(img); 
  imageCT(img); 
} 

function imageCT(img){ 
  if((imageid.width!=0)&&(imageid.height!=0)){ 
    NewWinImg(img); 
  } 
  else{ 
    imgCT="imageCT('"+img+"')"; 
    intervalID=setTimeout(imgCT,0); 
  } 
} 

function NewWinImg(img){ 
        H=imageid.height + 4; 
        W=imageid.width + 20;        
        S="width="+W+",height="+H; 
        //imgWin=window.open("","",S); 
        //imgWin.document.write("<html><head><title>Gallery</title></head>");
        //imgWin.document.write("<body topmargin=0 leftmargin=0>");
        //imgWin.document.write("<a href='javascript:self.close()'><img src='"+img+"' border='0'></a></body></html>");
        //imgWin.document.close();
        //imgWin.document.write("<body topmargin=0 leftmargin=0 style='background:url("+img+")'>");
        openPopup("/Common/Script/ImagePopUp.aspx?ImageURL= "+ img + "", "", 1, W, H, 0,0);
   
        
}


//2008.02.16 ¹éÁ¤¿ì Ãß°¡ - layer popup
function SetCookie (name, value, expDays) 
{		 
	var expire = new Date();
	expire.setDate(expire.getDate() + expDays);
	document.cookie = name + "=" + value + "; expires=" + expire.toGMTString() + "; path=/";
} 

function GetCookie(cookieName) 
{ //ÄíÅ° °¡Á®¿À±â

	var allCookies = document.cookie.split('; ');
	for (i=0;i<allCookies.length;i++)
	{
		cookieArray = allCookies[i].split('=');
		if (cookieName == cookieArray[0])
		{ 
			return unescape(cookieArray[1]);
		}
	}
/*
	var start, end;
	var i = 0;

	while(i <= document.cookie.length) 
	{ 
		start = i 
		end = start + name.length 

		if(document.cookie.substring(start, end) == name) 
		{
			return true;
			break;
		}
		i++;
	}
*/
	return false;
}

function GetArrayCookie(cookieName) 
{ //ÄíÅ° °¡Á®¿À±â

	var allCookies = document.cookie.split('; ');
	for (i=0;i<allCookies.length;i++)
	{
		cookieArray = allCookies[i].split('&');
		for (j=0;j<cookieArray.length;j++)
		{
			cookieArray2 = cookieArray[j].split('=');
			if (cookieArray2.length > 1)
			{
				if (cookieName == cookieArray2[0])
				{ 
					return unescape(cookieArray2[1]);
				}
			}
			else
				continue;
		}
	}

	return false;
}

function checkLayerNotice() 
{ 
	var ckValue = GetArrayCookie('LAYERNOTICE'); 
	if (ckValue == false || ckValue == "-" || GetCookie('LAYERNOTICE') == '-1') 
	{ 
		document.all.PopupLayer.style.display = "none"
	}
	else
	{
		document.all.PopupLayer.style.display = "block"
	}
}

function closePopupLayer(name){
 if(document.all[name].style.display=="" || document.all[name].style.display=="block"){
  document.all[name].style.display="none"
 }
}

function closePeroidPopupLayer(name, key, period){
 SetCookie( key, "1" , period);
 closePopupLayer(name);
}

function checkToViewLayerPopup(name, key) {
 if ( getCookie(key) == "checked" ) {
  closePopupLayer(name);
 }
}

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.PopupLayer : document.getElementById("PopupLayer");
  hotDog=isIE ? event.srcElement : e.target;
  while (hotDog.id!="PopupLayer"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }
  if (hotDog.id=="PopupLayer"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}

function dd(e){
  if (!ddEnabled) return;
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx;
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");

// Æ÷Ä¿½º Ã³¸®
function autoblur() 
{
	if(event.srcElement.tagName == "A") document.body.focus();
}
document.onfocusin = autoblur;
