function checkid(id){
        if(!is_alphanumeric("username")) {
          alert("Enter Username");
          return false;
        }  else
        window.open('checkid.php3?username='+id,'','width=480,height=220,scrollbars=yes,resizable=yes')
}               
function checkemail(addr){
        if(!valid_email("email")) {
          alert("Enter E-mail");
          return false;
        }  else
        window.open('checkid.php3?email='+addr,'','width=480,height=300,scrollbars=yes,resizable=yes')
}
function check(){
	if(document.forms.regForm.username.value == ""){
          alert("You must enter your username!");
          document.forms.regForm.username.focus();
          return false;
	}
	else if(document.forms.regForm.passwd.value == ""){
          alert("You must enter your password!");
	  document.forms.regForm.passwd.focus();
          return false;
	}    
	else if(document.forms.regForm.passwd1.value == ""){
          alert("You must enter your re-type password!");
          document.forms.regForm.passwd1.focus();
	  return false;
        }
	else if(document.forms.regForm.passwd.value != document.forms.regForm.passwd1.value ){
          alert("Your two password do not match!");
	  document.forms.regForm.passwd.focus();
          return false;
        }
        else if(document.forms.regForm.name.value == ""){
          alert("You must enter your name!");
          document.forms.regForm.name.focus();
          return false;
        }
	else if(document.forms.regForm.email.value == ""){
          alert("You must enter your email address!");
          document.forms.regForm.email.focus();
          return false;
        }
	else if( document.forms.regForm.verif_box.value == "" ){
	  alert("You must enter Verification Code!");
	  document.forms.regForm.verif_box.focus();
	  return false;
	}
        else if(document.forms.regForm.email.value != ""){
          var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
          email = document.forms.regForm.email.value;
          db =1;

          for (i=0; i<invalidChars.length; i++) {
             if (email.indexOf(invalidChars.charAt(i),0) > -1) {
                 if (db) alert('email address contains invalid characters');
                 document.forms.regForm.email.focus();
                 return false;
             }
          var atPos = email.indexOf('@',0);
          if (atPos == -1) {
            if (db) alert('email address must contain an @');
          document.forms.regForm.email.focus();
          return false;
          }
          if (atPos == 0) {
            if (db) alert('email address must not start with @');
          document.forms.regForm.email.focus();
          return false;
          }

          if (email.indexOf('@', atPos + 1) > - 1) {
            if (db) alert('email address must contain only one @');
          document.forms.regForm.email.focus();
          return false;
          }

          if (email.indexOf('.', atPos) == -1) {
            if (db) alert('email address must contain a period in the domain name (.)');
          document.forms.regForm.email.focus();
          return false;
          }
	
	  var lastindex = email.substring(email.lastIndexOf('.')+1);
          if(lastindex == ""){
             alert('Your email address is invalid. You must remove the last dot (.) in your email address');
	     document.forms.regForm.email.focus();
	     return false;
	  }

	  var suffix = email.substring(email.lastIndexOf('@')+1);
          if (suffix.length != 2 && suffix == 'hotmail.com.my'){ 
	    if (db) alert('Invalid email address. Your email address should be end by hotmail.com instead of hotmail.com.my');
	    document.forms.regForm.email.focus();	    
            return false;
          } 
	 }
	}else{
	  return true;
	}
} 
