function getlength(item)
  {
          var onchar
          var ochar
          var tcount=0
          onechar1=eval("newuser."+item+".value");
          leng=onechar1.length;
          onechar="";

          for(i=0 ; i< leng ;i++){
            if (onechar1.charAt(i)!=' '){
              onechar=onechar+onechar1.charAt(i);
            }
          }
          leng=onechar.length;

          for(i=0 ; i< leng ;i++){
                  ochar=onechar.charAt(i)
                  //alert(ochar);
                  if(escape(ochar).length > 4)
                  {
                          tcount+=2;
                  }else if (ochar!='\r') {
                          tcount++;
                  }

          }
          return tcount
  }


function openpop(val)
{
        var sgname,strleng,val ;

        if(val==1)
		{
                sgname=document.newuser.uid.value;
                if (sgname.length > 0 ){
                        strleng        = getlength("uid");
                }
				else
				{
                        strleng        = 0;
                }

                if (!checkhan("uid"))
				{
                        window.alert("ID will be a combination of numbers and small letters in 10 bites.");
                        document.newuser.uid.focus();
                        return
                }

                if (!check_id(sgname))
				{
                        window.alert("not an available ID.");
                        document.newuser.uid.focus();
                        return
                }

                if ( (strleng > 0) && (strleng < 4 || strleng >10) )
				{
                        window.alert("ID is a combination of letters and numbers 4 - 10 characters.");
                        document.newuser.uid.focus();
                        return
                }

				if ( strleng > 0 )
				{
                        idcheck = window.open("./pop_id_check.asp?div="+val+"&sgname="+sgname,"idcheck","width=320,height=300, toolbar= no,menubar=no,resizable=no,scrollbars=no");
                }

				return;

        }
		else
		{
                semail=document.newuser.uemail.value;
			
                if (semail.length > 0 ){
                        strleng        = getlength("uemail");
                }
				else
				{
                        strleng        = 0;
                }

               if ( strleng > 0 )
				{
                idcheck = window.open("./pop_id_check.asp?div="+val+"&sgname="+semail,"idcheck","width=320,height=300, toolbar= no,menubar=no,resizable=no,scrollbars=no");
                }

				return;
        }
}


 function checkhan(item){

    var checkOK = "abcdefghijklmnopqrstuvwxyz0123456789";
    var checkStr = eval("newuser."+item+".value");
    var allValid = true;
    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)
      {
        allValid = false;
        break;
      }
    }
    return(allValid);
  }


  function check_id(val){
          var id = val.substring(0,3);
          if (id =="oro")        {
                  return false;
          }
          var id = val.substring(1,5)
          if ( id =="cyberoro" )        {
                  return false;
          }
          return true;
  }





  function checkdata()
  {
    theForm=document.newuser;

   
	
   

    if (theForm.uid.value == "")
    {
      window.alert("Put your ID.");
      document.newuser.uid.focus();
      return;
    }


    var checkOK = "abcdefghijklmnopqrstuvwxyz0123456789_";
    var checkStr = theForm.uid.value;
    var allValid = true;
    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)
      {
        allValid = false;
        break;
      }
    }

    if (!check_id(theForm.uid.value))
    {
      window.alert("Put your ID in.");
      document.newuser.uid.focus();
      return;
    }


    if (!allValid)
    {
      window.alert("ID will be a combination of numbers and small letters in 10 bites.");

      theForm.uid.value = "";
      theForm.uid.focus();
      return ;
    }

	
	if (theForm.uglvl.value == "")
    {
      window.alert("Please Select Baduk level.");
      document.newuser.uglvl.focus();
      return ;
    }

	if(theForm.uemail.value=="")
    {
      window.alert("Put your email in.");
      document.newuser.uemail.focus();
      return ;
    }


	if (theForm.g_National_Code_no.value == "")
    {
      window.alert("Please Select your Nationality.");
      document.newuser.g_National_Code_no.focus();
      return ;
    }



    if (theForm.uname.value == "")
    {
      window.alert("Put your Name.");
      document.newuser.uname.focus();
      return ;
    }else {
      var leng
          leng = getlength("uname");
          if ( leng > 20 ){
             window.alert("Name is combination of letters and numbers 4 - 20 characters. ");
             document.newuser.uname.focus();
             return ;
          }
         
    }

	if (theForm.uYear.value == "")
    {
      window.alert("Put your birth year in.");
      document.newuser.uYear.focus();
      return ;
    }

	if (theForm.uMonth.value == "")
    {
      window.alert("Put your birth Month in.");
      document.newuser.uMonth.focus();
      return ;
    }

	if (theForm.uDay.value == "")
    {
      window.alert("Put your birth Day in.");
      document.newuser.uDay.focus();
      return ;
    }

   
   
    if (theForm.addr.value == "")
    {
      window.alert("Put your Address in.");
      document.newuser.addr.focus();
      return ;
    }

	if (theForm.utel.value == "")
    {
      window.alert("Put your Telephone in.");
      document.newuser.utel.focus();
      return ;
    }

	

	var count = 0;
    var num=theForm.agree.length

    for(i=0; i<num; i++)
    {
     if(theForm.agree[i].checked == true)
     {
     count +=1;
     }
    }
     if(count< 2)
     {
     alert("Do you agree?");
     return;
     }  


   

          document.newuser.submit();

  }



function checkmod()
  {
    theForm=document.newuser;



  

   




    if (theForm.uname.value == "")
    {
      window.alert("Put your Player Name.");
      document.newuser.uname.focus();
      return ;
    }else {
      var leng
          leng = getlength("uname");
          if ( leng > 20 ){
             window.alert("Name is combination of letters and numbers 4 - 20 characters. ");
             document.newuser.uname.focus();
             return ;
          }
         
    }

	if (theForm.uYear.value == "")
    {
      window.alert("Put your birth year in.");
      document.newuser.uYear.focus();
      return ;
    }

	if (theForm.uMonth.value == "")
    {
      window.alert("Put your birth Month in.");
      document.newuser.uMonth.focus();
      return ;
    }

	if (theForm.uDay.value == "")
    {
      window.alert("Put your birth Day in.");
      document.newuser.uDay.focus();
      return ;
    }

   
   
    if (theForm.addr.value == "")
    {
      window.alert("Put your Address in.");
      document.newuser.addr.focus();
      return ;
    }

	if (theForm.utel.value == "")
    {
      window.alert("Put your Telephone in.");
      document.newuser.utel.focus();
      return ;
    }


          document.newuser.submit();

  }

