$(document).ready(function() {



	//用户名获取焦点时
	$('#email').focus(function() {
		var email = $.trim($(this).val());
		if(email ==  '用户名/邮箱') {
			$(this).val('');
		}
		$(this).attr('class', 'input2');
	});

	//用户名失去焦点时
	$('#email').blur(function() {
		var email = $.trim($(this).val());
		if(email ==  '') {
			$(this).val('用户名/邮箱');
			$(this).attr('class', 'input1');
			$('#email_error').show();
		} else {
			$('#email_error').hide();
		}
	});

	//密码获取焦点时
	$('#password').focus(function() {
		var password = $(this).val();
		if(password ==  '') {
			$(this).val('');
			$(this).attr('class', 'input2');
		}
		
	});

	//密码失去焦点时
	$('#password').blur(function() {
		var password = $(this).val();
		if(password ==  '') {
			
			$(this).attr('class', 'input21');
			$('#password_error').show();
		} else {
			$(this).attr('class', 'input2');
			$('#password_error').hide();
		}
	});


	



});


//提交
function login() {
	var email    = $.trim($('#email').val());
	var password = $.trim($('#password').val());
	var stat = $('#stat').attr('checked');
	if(stat) {
		stat = 1;
	} else {
		stat = -1
	}
	if(!(email == ''|| password=='' || email == '用户名/邮箱'|| password=='密码')) {
		$.post('/ajax/user.php', {'action':'user_login','email':email,'password':password,'stat':stat},function(data) {
			if(data == 1) {
				window.location.href = '/';
			} else {
				alert('对不起，登录失败，请您重试!!');
			}
		});
	}
}

//回车提交
function keyup(event) {

	var key=window.event?event.keyCode:event.which;
	if(key ==13){
		login();
	}
}
