function chkSpaces(strValue) //°ø¹é Ã¼Å©
{
	var flag = true;
		
	if(strValue != "")
	{
		for(var i=0; i<strValue.length; i++)
		{
			if(strValue.charAt(i) != " ")
			{
				flag = false;
				break;
			}
		}
	}
	
	return flag;
}

function chkNumeric(strValue) //¼ýÀÚ Ã¼Å©
{
	var flag = true;
	
	if(strValue == "")
	{
		flag = false;
	}
	else
	{
		for(var i=0; i<strValue.length; i++)
		{
			if(strValue.charAt(i) < "0" || strValue.charAt(i) > "9") 
			{
				flag = false;
				break;
			}
		}
	}
	
	return flag;
}

function chkAlphabet(strValue) //¾ËÆÄºª Ã¼Å©
{
	var flag = true;	

	if(chkSpaces(strValue))
	{
		flag = false;
	}
	else
	{
		for(var i=0; i<strValue.length; i++) 
		{
			if((strValue.charAt(i) < "A" || strValue.charAt(i) > "z") && (strValue.charAt(i) < "0" || strValue.charAt(i) > "9"))
			{
				flag = false;
				break;
			}
		}
	}
	
	return flag;
}

function chkEmail(strValue) //ÀÌ¸ÞÀÏ Ã¼Å© 
{
	var flag = true;

	if(strValue.length > 4 && strValue.indexOf("@") > 0 && strValue.indexOf("@.") == -1 && strValue.indexOf(".@") == -1 && strValue.indexOf(",", strValue.indexOf("@")) == -1 && strValue.indexOf(".", strValue.indexOf("@")) != -1) 
	{
		flag = false;
	}
	
	return flag;
}

function chkPwd(strPwd, strPwd2) //ºñ¹Ð¹øÈ£ Ã¼Å©
{
	if(strPwd.length < 5) 
	{
		return 1; //5ÀÚ ¹Ì¸¸ÀÏ¶§ Çã¿ëÇÏÁö ¾ÊÀ½
	}
	else
	{
		var blnValue = false;
		var preChar = strPwd.charAt(0);
		
		for(var i=1; i<strPwd.length; i++)
		{
			if(preChar != strPwd.charAt(i)) 
			{
				blnValue = true;
				break;
			}
		}
		
		if(blnValue)
		{
			blnValue = false;
			preChar = strPwd.charAt(0);
			
			for(i=1; i<strPwd.length; i++)
			{
				var curChar = strPwd.charAt(i);
				
				if(parseInt(preChar)+1 == parseInt(curChar))
				{
					preChar = curChar;
				}
				else
				{
					blnValue = true;
					break;
				}
			}
		}

		if(blnValue) 
		{
			if(strPwd != strPwd2) return 3; //ºñ¹Ð¹øÈ£°¡ ¼­·Î ÀÏÄ¡ÇÏÁö ¾ÊÀ½
			else return 0; //¼º°ø
		}
		else return 2; //¿¬¼ÓµÈ ¹®ÀÚ³ª °°Àº ¹®ÀÚÀÇ ³ª¿­Àº Çã¿ëÇÏÁö ¾ÊÀ½
	}
}

function chkString(s, spc) //¹®ÀÚ Ã¼Å©
{
	var flag = true;

	for(var i=0; i<s.length; i++)
	{
		if(spc.indexOf(s.substring(i,i+1)) < 0)
		{
			flag = false;
			break;
		}
	}
	
	return flag;
}

function chkLen(strValue, strMaxLen) //¹ÙÀÌÆ®(Byte) Ã¼Å©
{
	var flag = false;
	var msgLen = 0;
	
	if(strValue == "")
	{
		flag = true;
	}
	else
	{  
		for(var i=0; i<strValue.length; i++)
		{
			if(escape(strValue.charAt(i)).length > 4)
				msgLen += 2;
			else
				msgLen++;
    
			if(msgLen > strMaxLen)
			{
				flag = true;
				break;
			}  
		}
	}
	
	return flag;
}

/*
function chkHangle(strValue) //ÇÑ±ÛÀÔ·Â¹æÁö Ã¼Å©
{
	var flag = false;

	if(strValue == "")
	{
		flag = true;
	}
	else
	{  
		for(var i=0; i<strValue.length; i++)
		{
			var ch = escape(strValue.charAt(i)).length;
			
			if(ch > 4)
			{
				flag = true;
				break;
			}
		}  
	}
	
	return flag;
}
*/

function chkHangle(strValue) //ÇÑ±ÛÀÔ·Â¹æÁö Ã¼Å©
{
	var flag = false;	
	var ch = "";

	if(strValue == "")
	{
		flag = true;
	}
	else
	{  
		for(var i=0; i<strValue.length; i++)
		{ 
			ch = strValue.charCodeAt(i); 
			
			if(ch > 127)
			{
				flag = true;
				break;
			}
		}
	}
	
	return flag;
}

function chkRadioAndCheckBox(strValue) //¶óµð¿À¹öÆ°, Ã¼Å©¹Ú½º Ã¼Å©
{
	var flag = false;
	var cnt = 0;

	if(strValue.length)
	{
		cnt = strValue.length;
	}
	else
	{
		cnt = 1;
	}

	for(var i=0; i<cnt; i++)
	{
		if(cnt > 1)
		{
			var chkValue = strValue[i].checked;
		}
		else
		{
			var chkValue = strValue.checked;
		}
  
		if(chkValue == true)
		{
			flag = false;
			break;
		}	  
		else
		{
			flag = true;
		}
	}
	
	return flag;
}

function chkSpecialChar(strValue) //ÀÏºÎ Æ¯¼ö¹®ÀÚ Ã¼Å©
{
	var flag = false;

	if(strValue.indexOf('&') >= 0 || strValue.indexOf('"') >= 0 || strValue.indexOf("'") >= 0 || strValue.indexOf(';') >= 0 || strValue.indexOf('%') >= 0 || strValue.indexOf('`') >= 0)
	{
		flag = false;
	}
	else
	{
		flag = true;
	}
	
	return flag;
}

function chkJumin(strJumin1, strJumin2) //ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å©
{
	var flag = false;
    var total = 0;
    var temp = new Array(13);

    for(var i=1; i<=6; i++)
        temp[i] = strJumin1.charAt(i-1);
    
	for(i=7; i<=13; i++)
        temp[i] = strJumin2.charAt(i-7);
    
    for(i=1; i<=12; i++)
	{
        var k = i + 1;

        if(k >= 10)
            k = k % 10 + 2;
        
		total = total + temp[i] * k;
    }
    
	var mm = temp[3] + temp[4];
    var dd = temp[5] + temp[6];
	var totalMod = total % 11;
    var chd = 11 - totalMod;
    
	if(chd%10 == temp[13] && mm < 13 && dd < 32 && (temp[7]==1 || temp[7]==2))
        flag = true;
    
	return flag;
}

/*
function chkAge(strJumin, strAge) //ÁÖ¹Îµî·Ï¹øÈ£¿¡¼­ ³ªÀÌ Ã¼Å©
{
	var flag = true;
	var now = new Date();
    var nYear = now.getYear();
	var strYear = strJumin.substring(0,2);

	if(strYear >= 0 && strYear < 20)
		strYear = "20" + strYear;
	else
		strYear = "19" + strYear;
	
	if(nYear-strYear > strAge)
	{
		flag = false;
	}
	
	return flag;
}
*/

function chkJuminAge(strJumin1, strJumin2, strAge) //ÁÖ¹Îµî·Ï¹øÈ£¿¡¼­ ³ªÀÌ Ã¼Å©
{
	var flag = true;
	var now = new Date();
    var nYear = now.getYear();
	var strYear = strJumin1.substring(0,2);
	var strChar = strJumin2.substring(0,1);

	if(strChar >= 3)
      strYear = "20" + strYear;	
	else
	  strYear = "19" + strYear;
	
	if(nYear-strYear > strAge)
	{
		flag = false;
	}
	
	return flag;
}

function allCheckBox(obj, strValue)
{
	if(obj.id == "chkAll")
	{
		obj.id = "chkNotAll";
  
		if(strValue.length)
		{
			for(var i=0; i<strValue.length; i++)
			{
				strValue[i].checked = true;
			}
		}
		else
		{
			strValue.checked = true;
		}
	}
	else
	{
		obj.id = "chkAll";
				
		if(strValue.length)
		{
			for(i=0; i<strValue.length; i++)
			{
				strValue[i].checked = false;
			}
		}
		else
		{
			strValue.checked = false;
		}
	}
}

function onlyNumber() //¼ýÀÚ¸¸À» ±âÀÔ¹Þ°Ô ÇÏ´Â ¹æ¹ý
{   
	if((event.keyCode < 48)||(event.keyCode > 57))
	{
		event.returnValue = false;
		alert("¼ýÀÚ¸¸ ÀÔ·ÂÀÌ °¡´ÉÇÕ´Ï´Ù.");
	}
}

function keyCode(e)
{
	if(window.event)
		var result = window.event.keyCode;
	else if(e)
		result = e.which;
   
	return result;
}

function moveNextFocus(sFormName, sNow, sNext) //ÅØ½ºÆ®¹Ú½º ±æÀÌÃ¼Å©ÈÄ ÀÌµ¿(ÆûÀÌ¸§, Ã¼Å©ÇÒ ÅØ½ºÆ®ÀÌ¸§, ÀÌµ¿ÇÒ ÅØ½ºÆ®ÀÌ¸§) 
{
	var sForm = "document." + sFormName + "."
	var oNow = eval(sForm + sNow);
	
	if(typeof oNow == "object")
	{
		if(oNow.value.length == oNow.maxLength)
		{
			var oNext = eval(sForm + sNext);
	
			if((typeof oNext) == "object")
				oNext.focus();
		}
	}
}

function setCookie(name, value, expire)
{ 
	var todayDate = new Date(); 
	
	todayDate.setHours(todayDate.getHours()+expire); 
    document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
} 

function clearCookie(name) 
{ 
	var todayDate = new Date();

	todayDate.setHours(todayDate.getHours()-1);
	document.cookie = name + "=" + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

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 openPopupMem(div, w, h)
{
	var width = w;
	var height = h;
	var left = (screen.width/2) - (width/2);
	var top = (screen.height/2) - (height/2);
	
	if(div == 1 || div == 3)
	{
		var chang = window.open("/member/chkid.asp?div="+div,"popupChkId","width="+width+",height="+height+",top="+top+",left="+left+",status=no,toolbar=no,menubar=no,location=no,fullscreen=no,scrollbars=no,resizable=no");
	}
	else if(div == 2 || div == 4 || div == 5)
	{
		chang = window.open("/member/chkzipcode.asp?div="+div,"popupChkZip","width="+width+",height="+height+",top="+top+",left="+left+",status=no,toolbar=no,menubar=no,location=no,fullscreen=no,scrollbars=yes,resizable=no");
	}
	else if(div == 6)
    {
		chang = window.open("/member/chkrecommendid.asp?div="+div,"popupChkId","width="+width+",height="+height+",top="+top+",left="+left+",status=no,toolbar=no,menubar=no,location=no,fullscreen=no,scrollbars=no,resizable=no");
	}
	else if(div == 7)
	{
		chang = window.open("/payment/store/chkgiftid.asp?div="+div,"popupChkId","width="+width+",height="+height+",top="+top+",left="+left+",status=no,toolbar=no,menubar=no,location=no,fullscreen=no,scrollbars=no,resizable=no");
	}
	
	chang.focus();
}

function viewFlash(sDiv, sURL, sId, sCid, sWidth, sHeight, sAlign, sWmode, sBgcolor, sOrder)
{
	var codeBase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0";
	var pluginsPage = "application/x-shockwave-flash";
	var embedType = "application/x-shockwave-flash";
	var pluginsPage = "http://www.macromedia.com/go/getflashplayer";
	
	document.write("<OBJECT CLASSID=\""+ sCid +"\" CODEBASE=\""+ codeBase +"\" WIDTH=\""+ sWidth +"\" HEIGHT=\""+ sHeight +"\" ID=\"" + sId + "\" ALIGN=\"" + sAlign + "\">");
	document.write("<PARAM NAME=\"movie\" VALUE=\"" + sURL + "\">");
	document.write("<PARAM NAME=\"quality\" VALUE=\"high\">");
	if(sWmode) document.write("<PARAM NAME=\"wmode\" VALUE=\""+ sWmode + "\">");
	if(sBgcolor) document.write("<PARAM NAME=\"bgcolor\" VALUE=\""+ sBgcolor + "\">");

	if(sOrder)
	{
		var arrayTemp = sOrder.split("|");

		for(var i=0; i<arrayTemp.length; i++)
		{
			if(arrayTemp[i])
			{
				var arrayOne = arrayTemp[i].split("=");

                if(arrayOne.length > 2)
				{
					var arrayValue = "";
					arrayValue += arrayTemp[i].replace(arrayOne[0] + "=","");
				}
				else
				{
					arrayValue = arrayOne[1];
				}
				
				document.write("<PARAM NAME=\""+ arrayOne[0] + "\" VALUE=\""+ arrayValue + "\">");
			}
		}
	}
	
	document.write("<EMBED SRC=\""+ sURL + "\" QUALITY=\"high\" WMODE=\"" + sWmode + "\" BGCOLOR=\"" + sBgcolor + "\"  WIDTH=\""+ sWidth +"\" HEIGHT=\""+ sHeight +"\" NAME=\"" + sId + "\" ALIGN=\"" + sAlign + "\"TYPE=\"" + embedType + "\" PLUGINSPAGE=\"" + pluginsPage + "\" />");
	document.write("</OBJECT>");
}

function viewMediaPlayer(sDiv, sURL, sId, sCid, sWidth, sHeight, sOrder)
{
	var codeBase = "http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112";
	var pluginsPage = "application/x-oleobject";
	var embedType = "application/x-mplayer2";
	var pluginsPage = "http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/";
	var myObjectElement = document.createElement("<OBJECT WIDTH=\""+ sWidth + "\" HEIGHT=\""+ sHeight  + "\" ID=\"" + sId + "\" name=\"" + sId + "\" CLASSID=\"" + sCid + "\" standby=\"Loading Microsoft Windows Media Player components...\" type=\"" + pluginsPage + "\" CODEBASE=\""+ codeBase + "\" VIEWASTEXT></OBJECT>");

	myObjectElement.appendChild(document.createElement("<PARAM NAME=\"filename\" VALUE=\"" + sURL + "\">"));

	if(sOrder)
	{
		var arrayTemp = sOrder.split("|");

		for(var i=0; i<arrayTemp.length; i++)
		{
			if(arrayTemp[i])
			{
				var arrayOne = arrayTemp[i].split("=");
				myObjectElement.appendChild(document.createElement("<PARAM NAME=\""+ arrayOne[0] + "\" VALUE=\""+ arrayOne[1] + "\">"));
			}
		}
	}
	
	document.getElementById(sDiv).appendChild(myObjectElement);
}