$(function(){

	var user = fetchUSER(); // 获取用户信息

	// 判断用户是否有登陆过，登陆直接跳转
	loginInit = function(){ 
		/*if(user.uname!=undefined && user.uname!=null && user.uname!=''){
			if(user.hostId!='0' && user.pwd!=''){
				window.location.href = HTTP_PREFIX+'/protal/index.html';
			}else{
				$("#uname").val(user.uname);
			}
		}*/
		$("#uname").val(user.uname);
	};

	loginInit();

	$("#loginBtn").click(function(){
		var uname = $.trim($("#uname").val());
		var pwd = $.trim($("#pwd").val());
		if(uname==''||pwd==''){
			$.toast('用户名或密码不能为空！');
			return;
		}
		var secpwd=$.md5(pwd);
		var params={    
				uname : uname,    
				pwd : secpwd  
		};
		$.ajax({
			url: HTTP_PREFIX+'/member/loginSubmit.shtml',
			type:"post",
			data:$.toJSON(params),   
			dataType: "json",
			async:true,
			contentType:"application/json",
			success:function(data){
				if(data.code=='01'){
					var mem=data.content;
					localStorage.hostId = mem.hostId; 
					localStorage.utype = mem.utype; 
					localStorage.uname = uname; 
					localStorage.pwd = secpwd; 
					localStorage.nick = mem.nick; 
					localStorage.head = mem.logo; 
					localStorage.province = mem.province; 
					localStorage.city = mem.city; 
					localStorage.strict = mem.strict; 

					window.location.href =  HTTP_PREFIX+'/protal/index.html';
				}else{
					$.toast(data.msg);
				}
			}
		});

	});



	$.init();
});