        function Login(){
            window.location.href='/login';
        };

        $(function (){
            var username = $("input[name='username']");
            var password = $("input[name='password']");
            var confirmpwd = $("input[name='confirmpwd']");
            var status = false;
            var form = $("form");

            username.blur(function(){
                $.get("/check_username","username="+username.val(),function(resText){
                    if(resText.errMsg){
                        $("#firstname-span").text("This username is already registered");
                        status = false;
                    }else{
                        $("#firstname-span").text("");
                        status = true;
                    };
                },'json');
            });

            confirmpwd.blur(function(){
                var span = $("#password-span");
                if(password.val() != confirmpwd.val()){
                    span.text("Passwords does not match");
                    status = false;
                }else{
                    span.text("");
                    status = true;
                };
            });

            form.submit(function(){
                if((status == true) && (password.val() != '') && (confirmpwd.val() != '')){
                    return true;
                }else{
                    alert("Please type your infomation");
                    return false;
                };
            });
        });