function checkLOG()
{
 if(is_null(document.form1.userid.value) || is_space(document.form1.userid.value))
 {
  alert("Please enter your User ID.");
  document.form1.userid.focus();
 }
 else if(document.form1.userid.value.length < 4 || document.form1.userid.value.length > 15)
 {
  alert("The User ID must be between 4 and 15 characters.");
  document.form1.userid.focus();
 }
 else if(!isID(document.form1.userid))
 {
  alert("User ID must be started with the first letter \n\n" + "Letters and numbers only for user ID");
  document.form1.userid.focus();
 }
 else if(is_null(document.form1.userpw.value))
 {
  alert("Please enter your password.");
  document.form1.userpw.focus();
 }
  else if(document.form1.userpw.value.length < 4 || document.form1.userpw.value.length > 15)
 {
  alert("The password must be between 4 and 15 characters.");
  document.form1.userpw.focus();
 }
 else{
  document.form1.submit();
 }
}

function is_null(string)
{
 if( string == "" )
  return  true;
 return  false;
}
function is_space(string)
{
 for(var i = 0; i < string.length; i++ )
  if( string.charAt( i ) != ' ' )
   return false;
  return true;
}

function user_idCheck()
{
 if(document.form1.userid.value=="")
 {
  alert("Enter a desired User ID and check its availability.");
  document.form1.userid.focus();
  return true;
 }
 if(!isID(document.form1.userid))
 {
  alert("The entered User ID is not vaild...\n\n" + "The User ID must be started with the first letter \n\n and between 4 and 15 characters (letters and numbers only) ");
  return ;
 }
 url = "id-check.htm?userid=" + document.form1.userid.value;
 MM_openBrWindow(url,'','width=430,height=250,top=20, left=200');
}

function isEmail(obj) 
{
 var str = obj.value;
 if(str == "")
  return true;
//  return false;
 var i = str.indexOf("@");
 if(i < 0)
  return false;
 i = str.indexOf(".");
 if(i < 0)
  return false;
 return true;
}

function isID(obj) {
 var str = obj.value;
 if(str.length < 4)
  return false;
 str = str.toUpperCase();
 if(!(('A' <= str.charAt(0) && str.charAt(0) <= 'Z')))
  return false;
 for(var i=1; i < str.length; i++) {
  if(!(('A' <= str.charAt(i) && str.charAt(i) <= 'Z') || ('0' <= str.charAt(i) && str.charAt(i) <= '9') || (str.charAt(i) == '_')))
   return false;
 }
 return true;
}
function isSSN(front, back)
{
 var birthday = front.value;
 var num = back.value;
 if(birthday.length != 6) {
  return false;
 }
 if(num.length != 7) {
  return false;}
 var hap = 0;
 for(var i=0; i < 6; i++) {
  var temp = birthday.charAt(i) * (i+2);
  hap += temp;}
 var n1 = num.charAt(0);
 var n2 = num.charAt(1);
 var n3 = num.charAt(2);
 var n4 = num.charAt(3);
 var n5 = num.charAt(4);
 var n6 = num.charAt(5);
 var n7 = num.charAt(6);
 hap += n1*8+n2*9+n3*2+n4*3+n5*4+n6*5;
 hap %= 11;
 hap = 11 - hap;
 hap %= 10;
 if(hap != n7)
  return false;
 return true;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
 window.open(theURL,winName,features);
}

function  forget_idpw(ObjNum){

   var h = 350;// height size 
   var w = 420;// width size 
   var LeftPosition = (screen.width) ? (screen.width-w)/2:0;
   var TopPosition = (screen.height) ? (screen.height-h)/2:0;  
   var scroll = "no";//ũ 
   var Settings = "height="+ h +",width="+ w +",top="+ TopPosition +",left="+ LeftPosition +",scrollbars="+ scroll +",resizable=no";//    


	if ( ObjNum == 1 ){//̵ ˻
		
		if (!document.findid.findname.value){ alert("Enter the name you used to sign up for your account."); document.findid.findname.focus(); return;}
		if (!document.findid.findemail.value){ alert("Enter the e-mail address you used to sign up for your account."); document.findid.findtel1.focus(); return;}		
		findpop = window.open("","findidpw",Settings);
		document.findid.target = "findidpw";
		document.findid.submit();
		findpop.focus();
	}
	if ( ObjNum == 2 ){//йȣ ˻
		
		if (!document.findpw.findid.value){ alert("Enter your User ID."); document.findpw.findid.focus(); return;}	
		if (!document.findpw.findemail.value){ alert("PEnter the e-mail address you used to sign up for your account."); document.findid.findtel1.focus(); return;}		
		findpop = window.open("","findidpw",Settings);
		document.findpw.target = "findidpw";
		document.findpw.submit();
		findpop.focus();
	}
}

function Key_Press_ad() {
	if(window.event.keyCode ==13)
	checkLOG(this.form);
}
function Key_Press_ssn() {
	if(window.event.keyCode ==13)
	user_bnoCheck(document.form1);
}
