/* À©µµ¿ì À§Ä¡ Àç¼³Á¤ */
function winResize(win_width, win_height) {
	if(win_width < 1 || win_height < 1){
		win_width	= 100;
		win_height	= 100;
	}
	win_left	= (window.screen.width-win_width) / 2;
	win_right	= (window.screen.height-win_height) / 2;
	window.moveTo(win_left, win_right);
	window.resizeTo(win_width, win_height);
}

/* ¿øÇÏ´Â »çÀÌÁî·Î ÆË¾÷¿­±â */
function winOpen(w, h, url, winName) {
	var x = (screen.width - w) / 2 - 10;
	var y = (screen.height - h) / 2 - 10;
	var exp = "width=" + w + ", height=" + h + ", top=" + y + ",left=" + x +
		  ", status=yes, resizable=no, toolbar=no, scrollbars=no ";
	return window.open(url, winName, exp);
}


/* °ø¹é°Ë»ç */
function wordVoidCheck(strValue) {
	if (changeWord(strValue, " ", "") == 0 || changeWord(strValue, "&nbsp;", "") == 0) {
		return false;
	} else {
		return true;
	}
}

/* °ø¹é °Ë»ç */
function isSpace(s) { 
	if(s.replace(/(^\s*)|(\s*$)/g, "") && s != null) {
		return false; 
	} else {
		return true; 
	}
}

/* °ø¹é¹× ±æÀÌ À¯È¿¼º°Ë»ç */
function wordVoidLenCheck(strValue, minNumber, maxNumber) {
	if (changeWord(strValue, " ", "") == 0 || changeWord(strValue, "&nbsp;", "") == 0) {
		return false;
	}

	if(strValue.length < minNumber || strValue.length > maxNumber) {
		return false;
	}
	return true;
}


/* ÁÖ·Î °ø¹é ½ºÆäÀÌ½º¸¦ ¹Ù²Ù¾îÁØ´Ù */
function changeWord(strOriginal, strFind, strChange){ 
    var position, strOri_Length; 
    position = strOriginal.indexOf(strFind);  
    while (position != -1){ 
      strOriginal	= strOriginal.replace(strFind, strChange); 
      position		= strOriginal.indexOf(strFind); 
    } 
    strOri_Length	= strOriginal.length; 
    return strOri_Length; 
}

/* ¼ýÀÚ¿Í ¾ËÆÄºªÀÌ¸é true */
function IsAlphaNumeric(checkStr) {
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	for (i = 0; i < checkStr.length; i++ ) {
		ch = checkStr.charAt(i);
		for (j = 0; j < checkOK.length; j++)
			if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length) {
			return false;
			break;
		}
	}
	return true;
}
/* ¾çÂÊ °ø¹éÁ¦°Å */
function trim(value){
    if (value.length == 0) return value;
    
    var start = 0, end = value.length;
    var i;
    
    for (i = start; i < end; i++) {
        if (value.charAt(i) != ' ') {
            start = i;
            break;
        }
	}
    if (i!=end) {
        for (i = end-1; i >= start; i--) {
            if (value.charAt(i) != ' ') {
                end = i+1;
                break;
            }
		}
    } else {
        start = 0;
        end = 0;
    }
    return value.substring(start, end);
}

/*	¼ýÀÚÀÎÁö¸¦ °Ë»çÇÏ´Â */
function checkDigit(tocheck) {
	var isnum = true;
	if (( tocheck ==null ) || ( tocheck == "" )) {
		isnum = false;
        return isnum;
	}
	for (var j= 0 ; j< tocheck.length; j++ ) {
		 if ( ( tocheck.substring(j,j+1) != "0" ) &&
			( tocheck.substring(j,j+1) != "1" ) &&
			( tocheck.substring(j,j+1) != "2" ) &&
			( tocheck.substring(j,j+1) != "3" ) &&
			( tocheck.substring(j,j+1) != "4" ) &&
			( tocheck.substring(j,j+1) != "5" ) &&
			( tocheck.substring(j,j+1) != "6" ) &&
			( tocheck.substring(j,j+1) != "7" ) &&
			( tocheck.substring(j,j+1) != "8" ) &&
			( tocheck.substring(j,j+1) != "9" ) ) {
			isnum = false;
		}
	}

	return isnum;
}

/* ·Î±×ÀÎ Ã¼Å© */
function loginCheck(frm) {
	if(!wordVoidCheck(frm.login_id.value)) {
		alert("¾ÆÀÌµð³ª ºñ¹Ð¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù!!");
		frm.login_id.focus();
		return false;
	}
	if(!wordVoidCheck(frm.login_pwd.value)) {
		alert("¾ÆÀÌµð³ª ºñ¹Ð¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù!!");
		frm.login_pwd.focus();
		return false;
	}
	return true;
}

/* ·Î±×¾Æ¿ô */
function logout() {
	document.location.href = "/commons/logoutPro.asp";
}

/* ÀÎ³ÊÇÁ·¹ÀÓ ³ôÀÌ»çÀÌÁî¸¦ ±¸ÇØ¿Í ºÎ¸ðÇÁ·¹ÀÓÀ» Å©±âÁ¶Á¤ */
function innerReSize(innerName) { 
	document.body.scrollIntoView(false);
	var pValue		= eval("parent.document.all." + innerName);
	pValue.height	= document.body.scrollHeight;
}

/* ÇÑ±ÛÀÎÁö Ã¼Å© */
function hanCheck(value){ 
    var pattern = new RegExp('[^°¡-ÆR\x20]', 'i'); 
    if (pattern.exec(value) != null) { 
        return false; 
    } else { 
        return true; 
    } 
} 

/* ÇØ´ç±ÛÀÚ¼ö¸¦ ¸¸Á·ÇÏ¸é ´ÙÀ½Æ÷Ä¿½º·Î ³Ñ±ä´Ù */
function focusMove(maxLength, fromName, toFormNext){
	var valueLength = fromName.value.length;
	if(valueLength == maxLength) {
		toFormNext.focus();
	}
}

/* ÇØ´çurl·Î °£´Ù */
function goUrl(url) {
	self.top.location.href=url;	
}

/* ¾ÆÀÌµð³ª ÆÐ½º¿öµå ¹éÀÌ¹ÌÁö¸¦ ¾ø¾Ø´Ù */
function hiddenSearch(formStr) {
	document.all[formStr].style.backgroundImage	= "";
}

/* ---------------------------------------------------------------------- 
¼ýÀÚÆ÷¸Ë[°ª, ´ÜÀ§, Ç¥½Ã] - ex) number_format("1000000","4","-") => Ãâ·Â: 100-0000  */
function number_format(input, input2, input3) { 
  var i, val=''; 
  var len = input.length; // ¿ø·¡ °ªÀÇ ±æÀÌ 
  var top = (len % input2);    // ÄÄ¸¶ÂïÈú ÀÌÀüÀÇ ±æÀÌ 
  if(top==0) top=input2; 

  var topnum = input.substring(0,top); // ÄÄ¸¶ÂïÈú ÀÌÀüÀÇ °ª 
  var midnum = input.substring(top);   // ÄÄ¸¶°¡ ½ÃÀÛµÉ ÀÌÈÄÀÇ °ª 

  for(i=0;i<midnum.length;i++) { 
    if(i % input2 == 0) val = val + input3; 
    val = val + midnum.charAt(i); 
  } 
  return (topnum + val); 
} 


/**
*	¿¬°ü¹è¿­ »ç¿ë½Ã Å°¼ÒÆ® ±â´É
*	µé¾îÀÖ´Â °ª¸¸Å­ ¹è¿­À» length¸¦ ¹Þ¾Æ¾ßÇÒ °æ¿ìµµ »ç¿ë °á°úÀûÀ¸·Î µé¾î°£ °ª¸¸Å­ length¸¦ ³ªÅ¸³¿
*	
*/
function sortHashKeys(arr){
	var keys = new Array;
	for(key in arr){	
		keys[keys.length] = key;
	}
	//keys.sort();
	//keys.reverse(); // ¿ª¼øÀ» ¿øÇÏ½Ã¸é ÀÌ °÷ÀÇ ÁÖ¼®À» ÇØÁ¦, À§ÀÇ keys.sort()´Â Áö¿ì¸é ¾ÈµÊ.
	return keys;
}
/*
ex)
var cat = new Array();
cat['c'] = '¿©¼º';
cat['b'] = '°í¾çÀÌ';
cat['a'] = '»ý¼±';

var keys = sortHashKeys(cat); // Á¤·ÄµÈ Å°°ªÀ» ¹è¿­·Î µ¹·ÁÁÝ´Ï´Ù.
for( var i=0; i< keys.length; i++){ // ·çÇÁ¹®À» »ç¿ëÇÏ¸é Á¤·ÄµÈ Å°°ª ¼øÀ¸·Î º¸½Ç ¼ö ÀÖÀ¾´Ï´Ù.
	document.write(keys[i] ,'-', cat[keys[i]],'<br />');
}
*/


/**
*	xp¼­ºñ½ºÆÑ2ÀÎ°¡¸¦ È®ÀÎÇÏ´Â ÇÔ¼ö
*	
*/
function isXpSp2(){
	try {
		var info = window.clientInformation;
		var reg1 = /[^A-Z0-9]MSIE[ ]+6.0[^A-Z0-9]/i;
		var reg2 = /[^A-Z0-9]WINDOWS[ ]+NT[ ]+5.1[^A-Z0-9]/i;

		if ((info.appMinorVersion.replace(/\s/g,"").toUpperCase().indexOf(";SP2;") >= 0) &&
			(reg1.test(info.userAgent) == true) && (reg2.test(info.userAgent) == true)) {
			return true;
		}
	} catch(e) {
		return false;
	}
	return false;
}


/* ¿Ã¹Ù¸¥ ÀÌ¸ÞÀÏ ÀÎÁö °Ë»ç */
function isEmail(emailValue) {
	var emailValue = trim(emailValue);

    if (!wordVoidCheck(emailValue)) {
        alert("ÀÌ¸ÞÀÏÁÖ¼Ò¸¦ ÀÔ·ÂÇØ ÁÖ½Ã±â ¹Ù¶ø´Ï´Ù");
        return false;
    }
    var i;
    for (i = 0; i < emailValue.length; i++) {
        if ( ((emailValue.charAt(i) >= '0') && (emailValue.charAt(i) <= '9'))
             || ((emailValue.charAt(i) >= 'a') && (emailValue.charAt(i) <= 'z'))
             || ((emailValue.charAt(i) >= 'A') && (emailValue.charAt(i) <= 'Z'))
             || (emailValue.charAt(i) == '@')
             || (emailValue.charAt(i) == '.')
             || (emailValue.charAt(i) == '-')
             || (emailValue.charAt(i) == '_')
             || (emailValue.charAt(i) == '%') )
            ;
        else {
            alert("ÀÌ¸ÞÀÏÁÖ¼Ò°¡ Á¤È®ÇÏÁö ¾Ê½À´Ï´Ù");
            return false;
        }
    }
    if ((emailValue.indexOf("@") == -1)
        || (emailValue.indexOf("@") == 0)
        || (emailValue.indexOf("@") == (emailValue.length - 1)) ) {
            alert("ÀÌ¸ÞÀÏÁÖ¼Ò°¡ Á¤È®ÇÏÁö ¾Ê½À´Ï´Ù");
            return false;
    }
	if ((emailValue.indexOf(".") == -1)
        || (emailValue.indexOf(".") == 0)
        || (emailValue.indexOf(".") == (emailValue.length - 1)) ) {
            alert("ÀÌ¸ÞÀÏÁÖ¼Ò°¡ Á¤È®ÇÏÁö ¾Ê½À´Ï´Ù");
            return false;
    }
	
	/*	
	var x, txt;
		x = emailValue.indexOf("@");
		txt = emailValue.toLowerCase(); //¼Ò¹®ÀÚ º¯È¯
		
		if ( (txt.substring(x+1, x+9) == "daum.net")
		   || (txt.substring(x+1, x+12) == "hanmail.net") ) {
	            alert("ÁË¼ÛÇÕ´Ï´Ù. ÇÑ¸ÞÀÏÀÌ ¾Æ´Ñ ´Ù¸¥ ÀÌ¸ÞÀÏ ÁÖ¼Ò·Î ÀÔ·ÂÇØ ÁÖ¼¼¿ä!");
				EMail.focus();
	            return 1;
	    }	
	*/		   
	return true;
}

function enterNoneAction() {
	if(event.keyCode == 13) {  
		event.returnValue	= false; 
        event.cancelBubble	= true; 
	} 
}

function faq(obj)
{
	if (eval("faq" + obj + ".style.display == 'inline'"))
	{
		for(i=1;i<7;i++){
				eval("faq" + i + ".style.display='none';");
		}
	}
	else if (eval("faq" + obj + ".style.display == 'none'"))
	{
		for(i=1;i<7;i++){
			if(obj == i){
				eval("faq" + obj + ".style.display='inline';");
			}else{
				eval("faq" + i + ".style.display='none';");
			}
		}
	}
}

function setCookie( name, value, expiredays) {
	var today = new Date();
	today.setDate( today.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";";
}
    
function closePop(name) {
	setCookie( name , "checked" ,1);
	self.close();
}

function getCookie( name ) {
	var nameOfCookie = name + "=";
	var 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 openPop() {
	var winState = "left=0,top=0,width=600,height=470,status=yes,resizable=no,toolbar=no,scrollbars=no";
	try {
		if(getCookie("mainPop20060801") != "checked"){
			var mainPop = window.open("/popup/20060801/","_pop20060801", winState).focus();
		} else {
			return;
		}
	} catch (e) {
		return;
	}
}

