function checkreg(){
	var firstname = document.getElementById("firstname").value;
	var lastname = document.getElementById("lastname").value;
	var email = document.getElementById("email").value;
	var password = document.getElementById("password").value;
	var repass = document.getElementById("repass").value;
	var sReg = /[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/;
	if(firstname.length == 0){
		document.getElementById("regerror").innerHTML="<font style='font-size: 13px' color='red'>Error: Sorry, first name can't be null !</font>"
		document.getElementById("firstname").focus();
		return false;
	}
	if(lastname.length == 0){
		document.getElementById("regerror").innerHTML="<font style='font-size: 13px' color='red'>Error: Sorry, last name can't be null !</font>"
		document.getElementById("lastname").focus();
		return false;
	}
	if(email.length == 0){
		document.getElementById("regerror").innerHTML="<font style='font-size: 13px' color='red'>Error: Sorry, email can't be null !</font>"
		document.getElementById("email").focus();
		return false;
	}
	if (!sReg.test(email)){		
		document.getElementById("regerror").innerHTML="<font style='font-size: 13px' color='red'>Error: Sorry, there is no match for that email !</font>"
		document.getElementById("email").focus();
		return false;
	}
	
	if(password.length == 0){	
		document.getElementById("regerror").innerHTML="<font style='font-size: 13px' color='red'>Error: Sorry, password can't be null !</font>"
		document.getElementById("password").focus();
		return false;
	}
	if(repass.length == 0){	
		document.getElementById("regerror").innerHTML="<font style='font-size: 13px' color='red'>Error: Sorry, confirm password can't be null !</font>"
		document.getElementById("repass").focus();
		return false;
	}
	if(repass != password){	
		document.getElementById("regerror").innerHTML="<font style='font-size: 13px' color='red'>Error: The Password Confirmation  must match your Password.</font>"
		document.getElementById("repass").focus();
		return false;
	}
	if(document.getElementById("regerror").innerHTML != "" && document.getElementById("regerror").innerHTML != "<regerror></regerror>"){
		document.getElementById("regerror").innerHTML="<font style='font-size: 13px' color='red'>Error: That e-mail has already been registered, please try again.</font>"
		return false;
	}
	
	return true;	
}

function checkemail(email){
	
	var t = email.value;
	send_request('/silkroad/servlet/Checkemail?email='+t+'&dd='+ new Date().getTime());
	
}
	var http_request = false;
	function send_request(url) {
		http_request = false;
		
		if(window.XMLHttpRequest) { //Mozilla 
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {//MiME
				http_request.overrideMimeType("text/xml");
			}
		}
		else if (window.ActiveXObject) {
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		if (!http_request) {
			window.alert("XMLHttpRequest Errors,try again.");
			return false;
		}
		http_request.onreadystatechange = processRequest;
		http_request.open("GET", url, true);
		http_request.send(null);
	}
	
    function processRequest() {
        if (http_request.readyState == 4) { 
       
            if (http_request.status == 200 || http_request.status == 0) { 
   			
         		document.getElementById("regerror").innerHTML = http_request.responseText;        
              
            } else { //页面不正常
                alert("Exception!");
            }
        }
    }