$(function(){
document.onkeydown = function(e){
    var ev = document.all ? window.event : e;
    if(ev.keyCode==13) {checklogin();return false;}
}
});   
function checklogin(){
    var usernameobj=$('#username');
    var passwordobj=$('#password');
    var verifyobj=$('#verify');
    var mobileobj=$('#mobile');
    var username=usernameobj.val();
    var password=passwordobj.val();
    var verify=verifyobj.val();
    var mobile=mobileobj.val();
    var load='<img src="'+ROOT_PATH+'Public/images/onLoad.gif" />';
    var error='<img src="'+ROOT_PATH+'Public/images/error.png" />';
    var right='<img src="'+ROOT_PATH+'Public/images/right.png" />';
    $('.Validform_checktip').removeClass('Validform_wrong').html('');
    verifyobj.parent().find('.Validform_checktip').addClass('Validform_loading').html('登录中');
    if(!username){
        verifyobj.parent().find('.Validform_checktip').removeClass('Validform_loading').html('');
        usernameobj.parent().find('.Validform_checktip').addClass('Validform_wrong').html('用户名不能为空');
        return false;
    }
    if(!password){
        verifyobj.parent().find('.Validform_checktip').removeClass('Validform_loading').html('');
        passwordobj.parent().find('.Validform_checktip').addClass('Validform_wrong').html('密码不能为空');
        return false;
    }    
    if(!verify){
        verifyobj.parent().find('.Validform_checktip').removeClass('Validform_loading').addClass('Validform_wrong').html('验证码不能为空');
        return false;
    }
    var query = new Object();
	query.username = username;
	query.password = password;
	query.verify = verify;
	query.mobile = mobile;
    var url=APP+"Login/shop_login.html"
    $.ajax({
		url: url, 
		data: query,
		type:"post",
		dataType: "json",
		success: function(obj){
            if(obj.status){
                $('#'+obj.ob).parent().find('.Validform_checktip').removeClass('Validform_loading').addClass('Validform_right').html(obj.msg);
                location.href=APP+"Index/index.html";return false;
            }else{
                if(obj.resetverify)$('#verify_img').attr('src',APP+"Login/verify.html#"+Math.random());
                verifyobj.parent().find('.Validform_checktip').removeClass('Validform_loading').html('');
                $('#'+obj.ob).parent().find('.Validform_checktip').addClass('Validform_wrong').html(obj.msg);
                return false;
            }
        }
    });    
}