//XSS º¸¾È °ü·Ã - 20071029
function checkScript(content){	
	idx = content.value.toLowerCase().indexOf("script");
	idx2 = content.value.toLowerCase().indexOf("alert");
	if(idx>0 || idx2>0){
		alert("¿Ã¹Ù¸£Áö ¾ÊÀº ¹®ÀÚ°¡ µé¾îÀÖ½À´Ï´Ù.");
		return false;
	}
	return true;
}

//XSS º¸¾È °ü·Ã - 20071029
function checkFileLastName(filename){
	var FileName = filename.value
	FileName = FileName.toLowerCase();
	idx = FileName.lastIndexOf(".");
	if(idx>0){
		if(FileName.substring(idx)==".gif"||FileName.substring(idx)==".jpg"
		||FileName.substring(idx)==".hwp"||FileName.substring(idx)==".doc"
		||FileName.substring(idx)==".pdf"||FileName.substring(idx)==".xls"
		||FileName.substring(idx)==".txt"||FileName.substring(idx)==".zip"
		||FileName.substring(idx)==".alz"){
		}else{
			alert("Ã·ºÎ ºÒ°¡´ÉÇÑ È®ÀåÀÚ ÀÔ´Ï´Ù.");
			filename.focus();
			return false;
		}
	}
		return true;
}
	
// ÆÄÀÏÀÌ¸§¿¡ °ø¹éÀÌ ÀÖ´ÂÁö¸¦ Ã¼Å© 		added by jylee 2006.05.02
function checkFileName(filePath)
{
	while (filePath.indexOf("\\") != -1)
	{
		filePath = filePath.slice(filePath.indexOf("\\") + 1);
		//alert(filePath);
	}// end while
		
	for (var i = 0; i < filePath.length; i++) 
	{
		if(filePath.charAt(i) == ' ')
		{ 
			alert("ÆÄÀÏÀÌ¸§¿¡ °ø¹éÀ» ³ÖÀ» ¼ö ¾ø½À´Ï´Ù. ´Ù½Ã ÆÄÀÏÀ» ¼±ÅÃÇÏ½Ê½Ã¿À.");
			return false;
		}
	}// end for
	
	return true;
}

// ÆÄÀÏÀÇ È®ÀåÀÚ°¡ ÀÌ¹ÌÁöÀÎÁö¸¦ Ã¼Å©  added by jylee 2006.05.02
function LimitAttach(filePath)
{
	var arrFileFilter = new Array(".gif", ".jpg", ".png", ".bmp");		
	
	while (filePath.indexOf("\\") != -1)
	{
		filePath = filePath.slice(filePath.indexOf("\\") + 1);
		//alert(filePath);
	}// end while
		
	ext = filePath.slice(filePath.indexOf(".")).toLowerCase();
		
	for (var i = 0; i < arrFileFilter.length; i++) 
	{
		if (arrFileFilter[i] == ext) 
		{ 
			return true;
		}
	}// end for
	
	alert("¾÷¸£µå ÇÒ ¼ö ÀÖ´Â ÆÄÀÏÀº" 
	+ (arrFileFilter.join("  ")) + "\n  ÀÌ¹ÌÁö È®ÀåÀÚÀÔ´Ï´Ù."
	+ "´Ù½Ã ÆÄÀÏÀ» ¼±ÅÃÇÏ½Ê½Ã¿À.");
	
	return false;
}

/**
 * ÀÔ·Â°ªÀÌ Æ¯Á¤ ¹®ÀÚ(chars)¸¸À¸·Î µÇ¾îÀÖ´ÂÁö Ã¼Å©
 * Æ¯Á¤ ¹®ÀÚ¸¸ Çã¿ëÇÏ·Á ÇÒ ¶§ »ç¿ë
 * ex) if (!containsCharsOnly(form.blood, "ABO")) {
 *         alert("Ç÷¾×Çü ÇÊµå¿¡´Â A, B, O ¹®ÀÚ¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.");
 *     }
 */
function containsCharsOnly(input, chars) {
    for (var inx = 0; inx < input.value.length; inx++) {
       if (chars.indexOf(input.value.charAt(inx)) == -1)
           return false;
    }
    return true;
}

/**
 * ÀÔ·Â°ªÀÌ ¼ýÀÚ, ´ë½Ã(-)·Î µÇ¾îÀÖ´ÂÁö Ã¼Å©
 */
function isNumDash(input) {
    var chars = "-0123456789";
    return containsCharsOnly(input, chars);
}

/**
 * ÀÔ·Â°ªÀÌ »ç¿ëÀÚ°¡ Á¤ÀÇÇÑ Æ÷¸Ë Çü½ÄÀÎÁö Ã¼Å©  added by jylee 2006.05.09
 * ÀÚ¼¼ÇÑ format Çü½ÄÀº ÀÚ¹Ù½ºÅ©¸³Æ®ÀÇ 'regular expression'À» ÂüÁ¶
 */
function isValidFormat(input, format) {
    if (input.value.search(format) != -1) {
        return true; //¿Ã¹Ù¸¥ Æ÷¸Ë Çü½Ä
    }
    return false;
}

/**
 * ÀÔ·Â°ªÀÌ ÀÌ¸ÞÀÏ Çü½ÄÀÎÁö Ã¼Å©	 added by jylee 2006.05.09
 */
function isValidEmail(input) {
//    var format = /^(\S+)@(\S+)\.([A-Za-z]+)$/;
    var format = /^((\w|[\-\.])+)@((\w|[\-\.])+)\.([A-Za-z]+)$/;
    return isValidFormat(input, format);
}

/**
 * ÀÔ·Â°ªÀÌ ÀüÈ­¹øÈ£ Çü½Ä(¼ýÀÚ-¼ýÀÚ-¼ýÀÚ)ÀÎÁö Ã¼Å©	 added by jylee 2006.05.09
 */
function isValidPhone(input) {
    var format = /^(\d+)-(\d+)-(\d+)$/;
    return isValidFormat(input, format);
}

/*-------------------------------------------
   ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å© 
  --------------------------------------------*/
function isValidSsn(name1,  name2) {
    var weight = 0;
    var check;

    weight += (name1.charAt(0) - '0') * 2;         
    weight += (name1.charAt(1) - '0') * 3;         
    weight += (name1.charAt(2) - '0') * 4;       
    weight += (name1.charAt(3) - '0') * 5;      
    weight += (name1.charAt(4) - '0') * 6;     
    weight += (name1.charAt(5) - '0') * 7;    
    weight += (name2.charAt(0) - '0') * 8;   
    weight += (name2.charAt(1) - '0') * 9;  
    weight += (name2.charAt(2) - '0') * 2; 
    weight += (name2.charAt(3) - '0') * 3;
    weight += (name2.charAt(4) - '0') * 4; 
    weight += (name2.charAt(5) - '0') * 5;
    
    check = (11 - weight % 11) % 10;

    return ((name2.charAt(6) - '0') == check ? 1 : 0);
}

function goViewPage(strPg, strQString)
{
	location.href = strPg + "?" + strQString;
}

/** ÇÑ±ÛÀ» 2±ÛÀÚ·Î °è»êÇÏ¿© ¼ø¼öÇÑ ±æÀÌ¸¦ °è»êÇÑ´Ù */
String.prototype.strLen = function() {
	var temp;
	var set = 0;
	var mycount = 0;

	for( k = 0 ; k < this.length ; k++ ){
		temp = this.charAt(k);

		if( escape(temp).length > 4 ) {
			mycount += 2
		}
		else mycount++;
	}

	return mycount;
}

/** ÅØ½ºÆ® ÇÊµå¿¡ °ø¹é Ã¼Å© **/
function isEmpty(toString)	{
	var str_tmp;

	str_tmp = toString.replace(/ /g,'');

	if(str_tmp.length == 0 ){
		return true;
	}
	return false;
}

/** ¾Õ °ø¹é Á¦°Å */
String.prototype.ltrim = function() {
	var i, j = 0;
	var objstr

	for ( i = 0; i < this.length ; i++){
		if(this.charAt(i) == ' ' ){
			j = j + 1;
		}
		else{
			break;
		}
	}
	return this.substr(j, this.length - j+1)  
}

/** µÚ °ø¹é Á¦°Å */
String.prototype.rtrim = function() {
	var i, j = 0;

	for ( i = this.length - 1; i >= 0 ; i--){
		if(this.charAt(i) == ' ' ){
			j = j + 1
		}
		else{
			break;
		}
	}
	return 	this.substr(0, this.length - j);
}

/** ¾Õ/µÚ °ø¹é Á¦°Å */
String.prototype.trim = function() {
	return this.replace(/\s/g, "");
}

/** Focus ¸ÂÃã */
function _cmdfocus(formobj){
	formobj.select();
	formobj.focus();
}

function ChkForm(formField, checkName, message, minlength, maxlength) {
	
	var formValue = formField.value.ltrim().rtrim();

	if(formField == null) return false;
	if(formValue == '/' && minlength > 0) { alert(message+" ÇÊ¼öÀÔ·Â Ç×¸ñÀÔ´Ï´Ù."); _cmdfocus(formField); return false; }
	if(formValue.strLen() < minlength) { alert(message+" ÃÖ¼Ò "+minlength+" ÀÚÀÌ»ó ÀÔ·ÂÇÏ¼¼¿ä."); _cmdfocus(formField); return false; } 

	if(formValue.strLen() > maxlength) { 
		alert(message+" ÃÖ´ë ¿µ¾î "+maxlength*2+"ÀÚ, ÇÑ±Û "+maxlength+"ÀÚ±îÁö ÀÔ·Â °¡´ÉÇÕ´Ï´Ù."); 
		_cmdfocus(formField); 
		return false; 
	} else {
		return true;
	}
	
}

//¹®ÀÚ¿­ÀÇ ¾çÂÊ(¿ÞÂÊ, ¿À¸¥ÂÊ) °ø¹éÀ» Á¦°Å ÇÔ¼ö
function emate_trim(src)
{
    var search = 0

    while ( src.charAt(search) == " ")
    {
        search = search + 1
    }

    src = src.substring(search, (src.length))

    search = src.length - 1

    while (src.charAt(search) ==" ")
    {
        search = search - 1
    }

    return src.substring(0, search + 1)
}
function getTemp()
{
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds();
	return stemp = hours+minutes+seconds;
}


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 IsAlpha(checkStr)
{
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	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 IsAlphaNum(str)
{
	var ch, ch2=1;

	for ( k = 0; k < str.length; k++ )
	{
		ch = str.charAt(k);
		if ( !(('0' <= ch && '9' >= ch ) ||
			('A' <= ch && 'Z' >= ch ) ||
			('a' <= ch && 'z' >= ch ) || ( ch == '_' )) )
	    {
			if ( ch == ' ' )
				alert("°ø¹éÀ» »ç¿ëÇÒ¼ö ¾ø½À´Ï´Ù..");
			else
			{
				alert("¿µ¹®ÀÚ, ¼ýÀÚ, '_' ¿ÜÀÇ ¹®ÀÚ´Â »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù..");
			}
			return (false);
		}
	}
	return (true);
}

function LowAlphaNum(str)
{
	var ch, ch2=1;

	for ( k = 0; k < str.length; k++ )
	{
		ch = str.charAt(k);
		if ( !(('0' <= ch && '9' >= ch ) ||
			('a' <= ch && 'z' >= ch ) || ( ch == '_' )) )
	    {
			if ( ch == ' ' )
				alert("°ø¹éÀ» »ç¿ëÇÒ¼ö ¾ø½À´Ï´Ù..");
			else
			{
				alert("¿µ¹® ¼Ò¹®ÀÚ, ¼ýÀÚ, '_' ¿ÜÀÇ ¹®ÀÚ´Â »ç¿ëÇÏ½Ç ¼ö ¾ø½À´Ï´Ù..");
			}
			return (false);
		}
	}
	return (true);
}

function IsNumeric(value)
{
	var ch, ch2=1;

	for ( k = 0; k < value.length; k++ )
	{
		ch = value.charAt(k);
		if ( ch < '0' || ch > '9' )
	    {
			return (false);
		}
	}
	return (true);
}


function IsValidString(string)
{
	var ch;

	for ( k = 0; k < string.length; k++ )
	{
		ch = string.charAt(k);
		if ( ch == ' ' )
		{
			alert("°ø¹éÀ» »ç¿ëÇÒ¼ö ¾ø½À´Ï´Ù..");
			return (false);
		}
	}
	return (true);
}


// ÀÔ·ÂµÈ ³¯Â¥°¡ À¯È¿ÇÑ °ªÀÎÁö °Ë»çÇÑ´Ù.
function IsValidDate(year, month, day) 
{
	
	var er = 0; // ¿¡·¯ º¯¼ö
	var days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	
	if (year%1000 != 0 && year%4 == 0) days[1] = 29; // À±³â
	
	if (day > days[month-1] || day < 1) er = 1; // ³¯Â¥ Ã¼Å©
	
	if (month < 1 || month > 12) er = 1; // ¿ù Ã¼Å©
	
	if (month%1 != 0 || year%1 != 0 || day%1 != 0) er = 1; // Á¤¼ö Ã¼Å©
	
	if (er == 1) 
		return false;
	else 
		return true;
}

function GetLength(string)
{
	var ch;
	var length = 0;

    if( string == "") return 0;

	browserName = navigator.appName;
	browserVer = navigator.appVersion.indexOf("5.");
	if (browserName == "Netscape")
		return string.length;
	else
	{
		for ( k = 0; k < string.length; k++ )
		{
			ch = string.charAt(k);
			if ( ch >= '¤¡' && ch <= 'ÆR' )
			{
				length += 2;
			}
			else if ( ch > 128)
			{
				length += 2;
			}
			else
				length++;
		}
		return length;
	}
}


function common_PopupMessage(url, popupname)
{
	window.open(url,popupname,"toolbar=no,width=290,height=170,directories=no,status=no,scrollbars=no,resize=no,menubar=no");
}

//ÆË¾÷Ã¢À» ¶ç¿î´Ù.
// url : url
// popupname : ÆË¾÷ À©µµ¿ì¸í
// x : width
// y : height
// scroll : È­¸é scroll¿©ºÎ( yes,no )
//by jupiter
function emate_popup(url, popupname,x,y,scroll)
{
	window.open(url,popupname,"toolbar=no,width="+x+",height="+y+",directories=no,status=no,scrollbars="+scroll+",resize=no,menubar=no");
}

//³¯Â¥Çü½ÄÀÌ ¸Â´ÂÁö¸¦ Ã¼Å©ÇÑ´Ù. Çü½Ä : YYYY.MM.DD
//ÆÄ¶ó¹ÌÅÍ(strDate)´Â ¸ÕÀú emate_trim(strDate)À» »ç¿ëÇÑ´Ù.
//»ç¿ë¿¹ :
//	 if( !is_dateformat( emate_trim(kWord) ) ){
//	 	   alert(ERROR_MSG_DATE);
//	 	   document.searchForm.p_schword.focus();
//	 	   return(false);
//	 }
//by jupiter
function is_dateformat(strDate)
{
      var strMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

      if ( strDate.length != 10 )
      	  return false;

      var YYYY  = eval(strDate.substr(0,4));
      var MM    = eval(strDate.substr(5,2));
      var DD    = eval(strDate.substr(8,2));

      if ( !IsNumeric(YYYY) || !IsNumeric(MM) || !IsNumeric(DD) )
           return false;
		if ( strDate.charAt(4) != '.' || strDate.charAt(7) != '.' )
			  return false

      var MonthDays = (YYYY != 2) ? strMonth[MM-1] : (( YYYY%4==0 && YYYY%100 !=0 || YYYY%400 ==0 ) ? 29:28 );

      if( ( MM <13 && MM >0 && DD >0 && DD <= MonthDays) == false )
      	 return false;

      return true;
}

//¹®ÀÚ¿­À» º¯È¯ÇÑ´Ù.
//by jupiter
function emate_replace(str, from, to)
{
    var index;
    var pstr;
    var str1;
    var str2;
    if((index = str.indexOf(from)) >= 0) {
   	str1 = str.substr(0, index);
   	str2 = str.substr(index+(from.length), str.length);
   	pstr = str1;
   	pstr += to;
		if(str2 && str2.length >= from.length) {
	   pstr += emate_replace(str2, from, to);
	 	}
	 	return pstr;
    }else{
    	return str;
    }
}


// Ã·ºÎÆÄÀÏ¿¡¼­ ÆÄÀÏ¸í¸¸ »Ì¾Æ¿Â´Ù.
 function chkFile(str)
{
	var filename 	= str;
	var svi 		= 100;
	var extname 	= "";
	var firstname	= "";
	var han			= 0;
	var orgname		= "";

	if (filename.length > 0 )
	{
		for (i = 0; i < filename.length; i++)
		{
			if (filename.charAt(i) == "\\")
				han= i;

			if (filename.charAt(i) == ".")
				svi= i;

			if (i > svi)
                 extname += filename.charAt(i);
       }

        for (j = han+1 ; j < svi; j++)
        {
        	orgname += filename.charAt(j);
        }

        return orgname;
    }
    else
    {
        return true;
    }
}

// Ã·ºÎÆÄÀÏ¿¡¼­ ÆÄÀÏÁ¤º¸¸¦ »Ì¾Æ¿Â´Ù.
 function chkFileName(str)
{
	var filename 	= str;
	var svi 		= 100;
	var extname 	= "";
	var firstname	= "";
	var han			= 0;
	var orgname		= "";

	if (filename.length > 0 )
	{
		for (i = 0; i < filename.length; i++)
		{
			if (filename.charAt(i) == "\\")
				han= i;

			if (filename.charAt(i) == ".")
				svi= i;

			if (i > svi)
                 extname += filename.charAt(i);
       }

        for (j = han+1 ; j < svi; j++)
        {
        	orgname += filename.charAt(j);
        }

        return orgname+"."+extname;
    }
    else
    {
        return true;
    }
}


function chke()
{
	alert("Á¦Ç° À¯ÇüÀ» ¼±ÅÃÇÏ¼¼¿ä.");	
}
function mem_login()
{
	window.open("/join/login.jsp","login","toolbar=no,width=430,height=410,directories=no,status=no,scrollbars=no,resize=no,menubar=no");
}

//½ºÅ©·Ñ ÇÖ¸µÅ© ±âÁØÁÂÇ¥ ¼³Á¤
function WindScroll()
{

	LayerFloatingBn.style.top = document.body.scrollTop;
	
	

	if(document.body.scrollTop <= document.body.clientTop)
	{
		LayerFloatingBn.style.top = document.body.clientTop + 250;
	}
	else
	{
		LayerFloatingBn.style.top = document.body.scrollTop + 250;
	}

	LayerFloatingBn.style.visibility = "visible";
}

//½ºÅ©·Ñ ÇÖ¸µÅ© ±âÁØÁÂÇ¥ »çÀÌÁî º¯°æ
function WindReset()
{

	LayerFloatingBn.style.left = 972;
	LayerFloatingBn.style.top = document.body.clientTop + 250;
}

//¸Þ´º ½ºÅ©·Ñ
function movepics()
{

	menu_sub_load.SetVariable("VRscrollTop",document.body.scrollTop)
	menu_sub_load.SetVariable("VRclientTop",document.body.clientTop)
	menu_sub_load.SetVariable("VRscrollHeight",document.body.scrollHeight)
	menu_sub_load.SetVariable("VRclientHeight",document.body.clientHeight)
}


var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
function menu_sub_load_DoFSCommand(command, args) {
	var menu_sub_load = isInternetExplorer ? document.all.menu_sub_load : document.menu_sub_load;
	movepics();
}

if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub menu_sub_load_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call menu_sub_load_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}



