function check() 
{
 if(is_null(document.form1.userid.value) || is_space(document.form1.userid.value))
 {
  alert("Please enter Username.");
  document.form1.userid.focus();
 }
 else if(document.form1.userid.value.length < 4 || document.form1.userid.value.length > 15)
 {
  alert("Username must be between 4 and 15 characters ");
  document.form1.userid.focus();
 }
 else 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, numbers or combination)");
  document.form1.userid.focus();
 }

 else if(is_null(document.form1.userpw.value))
 {
  alert("Please enter password.");
  document.form1.userpw.focus();
 }
  else if(document.form1.userpw.value.length < 4 || document.form1.userpw.value.length > 15)
 {
  alert("password must be between 4 and 15 charcaters.");
  document.form1.userpw.focus();
 }
 else if(is_null(document.form1.userpw2.value))
 {
  alert("Please enter your password again to confirm it.");
  document.form1.userpw2.focus();
 }
 else if(document.form1.userpw.value != document.form1.userpw2.value)
 {
  alert("The password is not matched. Please enter it again.");
  document.form1.userpw.focus();
 }

 else if(is_null(document.form1.company.value) || is_space(document.form1.company.value))
 {
  alert("Please enter company Name.");
  document.form1.company.focus();
 }

 else if(is_null(document.form1.name_first.value) || is_space(document.form1.name_first.value))
 {
  alert("Please enter Applicant's First Name.");
  document.form1.name_first.focus();
 }
 else if(is_null(document.form1.name_last.value) || is_space(document.form1.name_last.value))
 {
  alert("Please enter Applicant Last Name.");
  document.form1.name_last.focus();
 }
  else if(is_null(document.form1.prefix.value) || is_space(document.form1.prefix.value))
 {
  alert("Please select Prefix.");
  document.form1.prefix.focus();
 }

 else if(is_null(document.form1.title.value) || is_space(document.form1.title.value))
 {
  alert("Please enter your Job Title.");
  document.form1.title.focus();
 }
 else if(is_null(document.form1.street1.value) || is_space(document.form1.street1.value))
 {
  alert("Please enter Street Address.");
  document.form1.street1.focus();
 }
 else if(is_null(document.form1.city.value) || is_space(document.form1.city.value))
 {
  alert("Please enter City Name.");
  document.form1.city.focus();
 }
 else if(is_null(document.form1.zipcode.value) || is_space(document.form1.zipcode.value))
 {
  alert("Please enter Zipcode.");
  document.form1.zipcode.focus();
 }
 else if(is_null(document.form1.country.value) || is_space(document.form1.country.value))
 {
  alert("Please select Your Country Name.");
  document.form1.country.focus();
 }
 else if(is_null(document.form1.tel1.value) || is_space(document.form1.tel1.value))
 {
  alert("Please enter Country Code of Phone Number");
  document.form1.tel1.focus();
 }
 else if(is_null(document.form1.tel2.value) || is_space(document.form1.tel2.value))
 {
  alert("Please enter Area Code of Phone Number.");
  document.form1.tel2.focus();
 }
 else if(is_null(document.form1.tel3.value) || is_space(document.form1.tel3.value))
 {
  alert("Please enter Phone Number");
  document.form1.tel3.focus();
 }
/* else if(is_null(document.form1.fax1.value) || is_space(document.form1.fax1.value))
 {
  alert("Please enter Country Code of Fax Number");
  document.form1.fax1.focus();
 }
*/
 else if(is_null(document.form1.email.value) || is_space(document.form1.email.value))
 {
  alert("Please enter E-mail Address");
  document.form1.email.focus();
 }
 else if(!isEmail(document.form1.email))
 {
  alert("Invaild E-mail Address.");
  document.form1.email.focus();
 }
  else if(is_null(document.form1.biz_type.value) || is_space(document.form1.biz_type.value))
 {
  alert("Please select your business type.");
  document.form1.biz_type.focus();
 }
 else if(is_null(document.form1.establish.value) || is_space(document.form1.establish.value))
 {
  alert("Please enter the date of Company Establishment.");
  document.form1.establish.focus();
 }
 else if(is_null(document.form1.employee.value) || is_space(document.form1.employee.value))
 {
  alert("Please enter Number of Employee");
  document.form1.employee.focus();
 }
 else{
  document.form1.submit();
 }
}

function checkEDIT() 
{
if(is_null(document.form1.userpw.value) || is_space(document.form1.userpw.value))
 {
  alert("Please enter password.");
  document.form1.userpw.focus();
 }
  else if(document.form1.userpw.value.length < 4 || document.form1.userpw.value.length > 15)
 {
  alert("password must be between 4 and 15 charcaters.");
  document.form1.userpw.focus();
 }
 else if(is_null(document.form1.userpw2.value) || is_space(document.form1.userpw2.value))
 {
  alert("Please enter your password again to confirm it.");
  document.form1.userpw2.focus();
 }
 else if(document.form1.userpw.value != document.form1.userpw2.value)
 {
  alert("The password is not matched. Please enter it again.");
  document.form1.userpw.focus();
 }

 else if(is_null(document.form1.title.value) || is_space(document.form1.title.value))
 {
  alert("Please enter your Job Title.");
  document.form1.title.focus();
 }
 else if(is_null(document.form1.street1.value) || is_space(document.form1.street1.value))
 {
  alert("Please enter Street Address.");
  document.form1.street1.focus();
 }
 else if(is_null(document.form1.city.value) || is_space(document.form1.city.value))
 {
  alert("Please enter City Name.");
  document.form1.city.focus();
 }
 else if(is_null(document.form1.zipcode.value) || is_space(document.form1.zipcode.value))
 {
  alert("Please enter Zipcode.");
  document.form1.zipcode.focus();
 }
 else if(is_null(document.form1.tel1.value) || is_space(document.form1.tel1.value))
 {
  alert("Please enter Country Code of Phone Number");
  document.form1.tel1.focus();
 }
 else if(is_null(document.form1.tel2.value) || is_space(document.form1.tel2.value))
 {
  alert("Please enter Area Code of Phone Number.");
  document.form1.tel2.focus();
 }
 else if(is_null(document.form1.tel3.value) || is_space(document.form1.tel3.value))
 {
  alert("Please enter Phone Number");
  document.form1.tel3.focus();
 }
 else if(is_null(document.form1.fax1.value) || is_space(document.form1.fax1.value))
 {
  alert("Please enter Country Code of Fax Number");
  document.form1.fax1.focus();
 }
 else if(is_null(document.form1.fax2.value) || is_space(document.form1.fax2.value))
 {
  alert("Please enter Area Code of Fax Number.");
  document.form1.fax2.focus();
 }
 else if(is_null(document.form1.fax3.value) || is_space(document.form1.fax3.value))
 {
  alert("Please enter Fax Number");
  document.form1.fax3.focus();
 }
 else if(is_null(document.form1.email.value) || is_space(document.form1.email.value))
 {
  alert("Please enter E-mail Address");
  document.form1.email.focus();
 }
 else if(!isEmail(document.form1.email))
 {
  alert("Invaild E-mail Address.");
  document.form1.email.focus();
 }
  else if(is_null(document.form1.biz_type.value) || is_space(document.form1.biz_type.value))
 {
  alert("Please select your business type.");
  document.form1.biz_type.focus();
 }
 else if(is_null(document.form1.employee.value) || is_space(document.form1.employee.value))
 {
  alert("Please enter Number of Employee");
  document.form1.employee.focus();
 }
 else{
  document.form1.submit();
 }
}


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 > 10)
 {
  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" + "Lletters and numbers only for user ID");
  document.form1.userid.focus();
 }
 else if(is_null(document.form1.userpw.value) || is_space(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 > 10)
 {
  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(form)
{
 if(form.userid.value=="")
 {
  alert("Enter a desired User ID and check its availability....");
  form.userid.focus();
  return true;
 }
 if(!isID(form.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, numbers or combination)");
  return ;
 }
/* url = "id_check.php?userid=" + form.userid.value;
 self.location=url;
}*/
 url = "id-check.htm?userid=" + document.form1.userid.value;
 MM_openBrWindow(url,'','width=370,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 Key_Press_ad() {
	if(window.event.keyCode ==13)
	checkLOG(this.form);
}
function Key_Press_ssn() {
	if(window.event.keyCode ==13)
	user_bnoCheck(document.form1);
}
