function IdCheck()
{
	with(document.join)
	{
			WO=window.open("idcheck.php","","width=404,height=155,align=left,left=50,top=150");
			WO.window.focus();
	}
}

function OpenZipCode()
{

		WO=window.open("find_zipcode.php","","width=604,height=185,align=left,left=50,top=150");
		WO.window.focus();

}

function OpenSsnCheck()
{
	with(document.ssn)
	{
			WO=window.open("ssncheck.php","","width=404,height=148,align=left,left=85,top=140");
			WO.window.focus();
	}
}


function SetPasswordQuestion()
{
	with(document.join)
	{
		m_passwd_question.value=m_passwd_question_list.value;
		if(m_passwd_question_list.value=="")
		{
			m_passwd_question.focus();
		}
	}
}

function ClearBox(target)
{
	target.value="";
	return true;
}

function JoinCheck()
{
	with(document.join)
	{	
		if(m_id.value=="")
		{
			alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
			WO=window.open("idcheck.php","","width=404,height=155,align=left,left=50,top=150");
			WO.window.focus();
			return false;
		}
		
		if(!PasswordCheck())return false;
		
		/*
		if(!m_passwd_question.value)
		{
			alert("º»ÀÎÈ®ÀÎ Áú¹®À» ÀÔ·ÂÇÏ¼¼¿ä.");
			m_passwd_question.focus();
			return false;
		}

		if(!m_passwd_answer.value)
		{
			alert("º»ÀÎÈ®ÀÎ ´äÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
			m_passwd_answer.focus();
			return false;
		}
		*/
		
		if(!m_name.value)
		{
			alert("ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä.");
			m_name.focus();
			return false;
		}

		
	  	if(!email.value.match("([_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+)*)@([_0-9a-zA-Z-]+\.([_0-9a-zA-Z-]+)*)"))
		{
			alert("Á¤È®ÇÑ EmailÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
			email.value="";
			email.focus();		
			return false;
		}

		if(!SsnCheck())return false;
		
		/* ÁÖ¼®Ã³¸® 2003.10.22
		if(!PhoneCheck(tel1.value,tel2.value,tel3.value))
		{
			alert('ÀüÈ­¹øÈ£´Â \" \"°ø¹é¾øÀÌ ¼ýÀÚ·Î¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.');
			tel2.value="";tel3.value="";
			tel1.focus();
			return false;
		}
		
		if(!PhoneCheck(mobile1.value,mobile2.value,mobile3.value))
		{
			alert('ÇÚµåÆù ¹øÈ£´Â \" \"°ø¹é¾øÀÌ ¼ýÀÚ·Î¸¸ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.');
			mobile2.value="";mobile3.value="";
			mobile1.focus();
			return false;
		}
		
		if(!zipcode1.value || !zipcode2.value || !addr1.value || !addr2.value)
		{
			OpenZipCode();
			return false;
		}
		*/
		
		return true;
	}
}

function ModifyCheck()
{
	with(document.join)
	{	
		if(!m_passwd_question.value)
		{
			alert("º»ÀÎÈ®ÀÎ Áú¹®À» ÀÔ·ÂÇÏ¼¼¿ä.");
			m_passwd_question.focus();
			return false;
		}

		if(!m_passwd_answer.value)
		{
			alert("º»ÀÎÈ®ÀÎ ´äÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
			m_passwd_answer.focus();
			return false;
		}
		
		if(!m_name.value)
		{
			alert("ÀÌ¸§À» ÀÔ·ÂÇÏ¼¼¿ä.");
			m_name.focus();
			return false;
		}

		if(!m_number.value)
		{
			alert("Çã°¡¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
			m_number.focus();
			return false;
		}
		
		return true;
	}
}


function PasswordCheck()
{
	with(document.join)
	{
		if(!m_passwd.value)
		{
			alert("ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
			m_passwd.focus();
			return false;
		}
		
	//	checkamt(document.join.m_passwd,1);

		if(m_passwd.value.length<4)
		{
			m_passwd.value="";
			m_passwd2.value="";
			alert("ºñ¹Ð¹øÈ£´Â 4ÀÚ¸® ÀÌ»ó ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À..");
			m_passwd.focus();
			return false;		
		}
		
		if(m_passwd.value!=m_passwd2.value)
		{
			m_passwd.value="";
			m_passwd2.value="";
			alert("ºñ¹Ð¹øÈ£°¡ ¼­·Î °°Áö ¾Ê½À´Ï´Ù.");
			m_passwd.focus();
			return false;		
		}
		
		if(m_passwd.value==m_id.value)
		{
			m_passwd.value="";
			m_passwd2.value="";
			alert("ºñ¹Ð¹øÈ£¿Í ID´Â µ¿ÀÏÇÏ°Ô »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù..");
			m_passwd.focus();
			return false;		
		}
				
		return true;
	}
}

//==================================================================
	function checkamt(fm,type) {
		flag = 1;			// true
		tmp1= document.join.m_passwd1.value;
		
		validatenum(fm);
		
		if(fm.className != ""){ 
		    fm.value="" ;
		    alert("ºñ¹Ð¹øÈ£´Â ¿µ¹®ÀÚ¿Í ¼ýÀÚÀÇ È¥ÇÕÀÌ¾î¾ß ÇÕ´Ï´Ù.");
			fm.focus() ;
			return false ;
		}			
				
		for (i = 0; i < tmp1.length; i++) {			
			if (tmp1.charAt(i) < '0' || tmp1.charAt(i) > '9') {				
				flag = 0;	// false
			}
		}
		
		if (flag == 1 && document.join.m_passwd1.value != "") {
			alert("ºñ¹Ð ¹øÈ£´Â ¼ýÀÚ·Î¸¸ ±¸¼ºµÉ¼ö ¾ø½À´Ï´Ù.");
			document.join.m_passwd1.value = "";
			document.join.m_passwd2.value = "";
			
			if ( type == 1 ) 
				document.join.m_passwd1.focus();			
			else 
				document.join.m_passwd2.focus();
			return false;
		}		
	}
	
	
	function validatenum(e1) {
	
		var num="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
		e1.returnValue = true;

		for (var i=0;i<e1.value.length;i++) {
			if (-1 == num.indexOf(e1.value.charAt(i)))
				e1.returnValue = false;
	
			if (!e1.returnValue)
				e1.className="badvalue";
			else
				e1.className="";
		}
	}

/*
	function checkLength(fl) {
		if (fl.value.replace(/ /g, "") =="") return false;

		if (fl.name=="m_name") {
			if (fl.value.length<2) {
				alert("ÀÌ¸§Àº 2ÀÚ ÀÌ»óÀÌ¾î¾ß ÇÕ´Ï´Ù.") ;
				fl.focus() ;
				return false ;
			}
		}
		else if (fl.value.length<6) {
			alert("ºñ¹Ð¹øÈ£´Â ¿µ/¼ýÀÚ Á¶ÇÕÀ¸·Î \n6ÀÚ ÀÌ»óÀÌ¾î¾ß ÇÕ´Ï´Ù.") ;
			fl.value = "";
			fl.focus() ;
			return false ;
		}	
	}
*/	
	
	function checkpw(fm) {
		if (document.join.m_passwd1.value != document.join.m_passwd2.value && document.join.m_passwd2.value.length > 0) {
			alert("ÀÔ·ÂÇÏ½Å µÎ°³ÀÇ ºñ¹Ð¹øÈ£°¡  ÀÏÄ¡ÇÏÁö ¾Ê½À´Ï´Ù.");
			document.join.m_passwd1.value = "";
			document.join.m_passwd2.value = "";
			document.join.m_passwd1.focus();
			return false;		
		}
	}
//====================================================================================================
function PhoneCheck(no1, no2, no3)
{
	str1 = no1;
	str2 = no2;
	str3 = no3;
	str = str1 + str2 + str3;
	
	if(!str1 || !str2 || !str3)return false;
	
	str = str.toUpperCase();
	
	for(i=0; i<str.length; i++)
	{

		if(str.charAt(i)==" ")
		{
			continue;
		}
		else if ((str.charAt(i) < "0") || (str.charAt(i) > "9"))
		{
			return false;
		}
	}
	return true;
}

function SsnCheck()
{
	with(document.join)
	{
	    if (ssn1.value.length == 6 && ssn2.value.length  == 7)
    	{
	        var chk = 0;
	        for(var i=0; i < 6 ;i++)
	        {
	            chk = chk + ((i%8+2) * parseInt(ssn1.value.substring(i,i+1)));
    	    }
    	    for(var i=6; i < 12 ;i++)
    	    {
    	        chk = chk + ((i%8+2) * parseInt(ssn2.value.substring(i-6,i-5)));
    	    }

    	    chk = 11 - (chk%11);
        	chk = chk % 10;
        	if(chk != ssn2.value.substring(6,7))
        	{
        	    alert("Á¤È®ÇÑ ÁÖ¹Îµî·Ï ¹øÈ£¸¦ Àû¾îÁÖ¼¼¿ä");
				ssn1.value="";ssn2.value="";
        	    ssn1.focus();
        	    return false;
        	}
			return true;
    	}
    	else
    	{
    	    alert('Á¤È®ÇÑ ÁÖ¹Îµî·Ï ¹øÈ£¸¦ Àû¾îÁÖ¼¼¿ä');
			ssn1.value="";ssn2.value="";
    	    ssn1.focus();
    	    return false;
    	}
	}
}

function JoinAgree()
{
	with(document.ssn)
	{
		if(!agree[0].checked)
		{
			alert('È¸¿ø°¡ÀÔÀ» ÇÏ½Ã·Á¸é ¾à°ü¿¡ µ¿ÀÇ ÇÏ¼Å¾ß ÇÕ´Ï´Ù.');
			agree[0].focus();
			return false;
		}
		return true;
	}
}

function SetZipCode()
{
	with(document.setzip)
	{
		if(!addr2.value)
		{
			alert('»ó¼¼ ÁÖ¼Ò¸¦ ÀÔ·ÂÇÏ¼¼¿ä');
			addr2.focus();
			return false;
		}
	}
	return true;
}

function LoginCheck()
{
	with(document.login)
	{
		if(!m_id.value)
		{
			alert('¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä.');
			m_id.focus();
			return false;		
		}
		
		if(!m_passwd.value)
		{
			alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.');
			m_passwd.focus();
			return false;		
		}
	}
	return true;
}


