

function checkName(name) {
	if (name == '') {

		document.getElementById('alertUserName').style.display = 'block';

	} else {
		document.getElementById('alertUserName').style.display = 'none';

	}

}

function checkPass(password) {

	if (password == "") {

		document.getElementById('alertPassWord').style.display = 'block';

	} else {
		document.getElementById('alertPassWord').style.display = 'none';

	}
}


$("body").keydown(function(e) {
	var ee = e || window.event;   
	if(ee.keyCode == 13){   
        login();
    }
});

function login() {
	var userName = $('#username').val();
	var password = $('#password').val();
	$.post('login', {
		userName : userName,
		password : password
	}, function(data) {
	
		if (data.success) {
			$('#loginMsg').hide();
			window.location.replace("homepage.jsp");

		}

		else {
			information(data.failedMessage);
		}
	},"json");
}
function adminLogin() {

	var userName = $('#username').val();
	var password = $('#password').val();
	$.post('adminLogin', {
		userName : userName,
		password : password
	}, function(data) {
		if (data.success) {
			$('#loginMsg').hide();
			window.location.replace("agentManage.jsp");

		}

		else {
			information(data.failedMessage);
		}
	});
}
function register() {
	var userName = $('#username').val();
	var password = $('#password').val();
	var rePassword = $("#re_password").val();
	if (rePassword != password) {
		$('#username').val("");
		$('#password').val("");
		information("password is wrong! retype again");
	}

	$.post('register', {
		userName : userName,
		password : password,
		rePassword:rePassword
	}, function(data) {
		if (data.success) {
			$('#registerMsg').hide();
			window.location.replace("registerSuccess.jsp");

		}

		else {
			information(data.failedMessage);
			// $('#registerMsg').html($.i18n.prop('msgRegister'));
			$('#registerMsg').show();
		}
	}, "json");
}

$("#img").mouseover(function(){document.getElementById("img").setAttribute("src", "img/githubsignon1.jpg");});

$("#img").mouseout(function(){document.getElementById("img").setAttribute("src", "img/githubsignon.jpg");});
