/**
* @author moufer<moufer@163.com>
* @copyright www.modoer.com
*/

function login_read() {
	var activationauth = get_cookie('activationauth');
	var hash = get_cookie('hash');
	var myauth = get_cookie('myauth');

	if(!activationauth && !hash && !myauth) {
		$('#login_0').show();
		$('#login_1').hide();
		$('#login_2').hide();
		return;
	}

	$.post(getUrl('member')+'login.php', { act:"checklogin", in_ajax:1 }, 
	function(result) {
		if(result.match(/\{\s+caption:".*",message:".*".*\s*\}/)) {
			myAlert(result);
		} else if(result.match(/\{\s+type:".*",username:".*".*\s*\}/)) {
			var login = eval('('+result+')'); //JSON转换
			if(login.type == 'activationauth') {
				$('#login_activation').html(login.username);
				var href = $('#login_activation_a').attr('href');
				href = href.replace('_activationauth_', get_cookie('activationauth'));
				$('#login_activation_a').attr('href', href);
				$('#login_0').hide();
				$('#login_1').hide();
				$('#login_2').show();
			} else {
				$('#login_name').html(login.username);
				$('#login_0').hide();
				$('#login_1').show();
				$('#login_2').hide();
			}
		}
	});
}

$(function() {
   login_read();
});