function register()
{
       if($("username").value==""&& $("password").value==""&& $("conpassword").value==""&& $("salt").value==""){
	       alert("Username, password, re-enter password, and identification code cannot be empty!");
    	   return false;
       }
        if($("password").value==""&& $("conpassword").value==""&& $("salt").value==""){
       alert("Password, re-enter password, and identification code cannot be empty!");
       return false;
       }
       
       if(!$("username").value.match(/^[a-zA-Z0-9_]{6,16}$/))
       {
	     alert("Enter a username with 6-16 digits.");
	     return;
       }
       ///^[\w!@#$%\^&\*\(\)]+[\w!@#$%\^&\*\(\)]*$/)
       if(!$("password").value.match(/^[A-Za-z0-9_-]{6,16}$/))
       {
         alert("Enter a password with 6-16 digits.");
         return;
       }  
       if($("password").value!=$("conpassword").value)
       {
         alert("Password do not match!");
         return false;
       } 
       
       if($("salt").value.length==0)
       {
         alert("Enter Verification code");
         return false;
       }
		var user={
			username:$("username").value,
			password:$("password").value
		};
		showLoading();
		var salt=$("salt").value;
		
		UserAction.register(user,salt,{callback:function(){
			hideLoading();
			window.location="/choose.jsp";
		},errorHandler:function(msg){
			hideLoading();
			alert(msg);			
			if(msg=="This username already exists"){
			$('error1').style.display='block';}
		}});
		return false;
}

function submitRegister(){
	if($('acceptCheckbox').checked){
		register();
	}else{
		alert('You shall sign up when you accept the Aimail Registration Agreement and Privacy Agreement!');
		return false;
	}
}