	String.prototype.trim = function()
	{
		return this.replace(/(^\s*)|(\s*$)/g, "");
	}


	function login()
	{
		var account = $("account");
		var password = $("password");
		if ( account.value=="" )
		{
			alert("用户名不能为空");
			account.focus();
			return false;
		}
		if ( password.value=="" )
		{
			alert("密码不能为空");
			password.focus();
			return false;
		}

		showHideProgress("show");
		var ajax = new Ajax();
		
		var context = "";
		if ( typeof(hostcontext)!="undefined" && hostcontext.trim()!="" && hostcontext.trim().toLowerCase()!="null" )
		{
			context = hostcontext+"/";
		}

		var _account = encodeURI(account.value);
		
		var url = "/"+context+"memberLoginServlet?account="+_account+"&password="+password.value+"&loginType=ajaxlogin";
		ajax.send(url,logincallback);

		var ajaxMvn = new Ajax();
		var mvnUrl = context+"forum/loginaction.jsp?FromLoginPage=true&md5pw=&url=&MemberName="+account.value+"&MemberMatkhau="+password.value;
		ajaxMvn.send(mvnUrl,mvnlogincallback);

		//var ifr = document.createElement("iframe");
		//ifr.style.width = "600px";
		//ifr.style.height = "600px";
		//document.body.appendChild(ifr);
	//	var url = context+"mvnforum/loginaction.jsp?FromLoginPage=true&md5pw=&url=&MemberName="+account.value+"&MemberMatkhau="+password.value;
	//	ajax.send(url,function(){alert('succss')});
		//ifr.src = "http://192.168.1.11:8080/"+url;
		//alert(ifr.src);
		password.value = "";
		return false;
	}

	function showHideProgress(tag)
	{
		if ( tag=="show" )
		{
			$("loginProgress").style.display = "block";
			$("login").style.display = "none";
			$("loginInfo").style.display = "none";
		}
		else
		{
			$("loginProgress").style.display = "none";
		}
	}

	function mvnlogincallback(info)
	{
	}

	function logincallback(info)
	{
		var a = info.split("|");

		if ( a[0] == "0" )
		{
			//登录成功
			$("login").style.display = "none";
			$("loginInfo").style.display = "block";
			$("login_warning").innerHTML = "";
			$("loginInf_welcome_name").innerHTML = a[2];
			var _account = encodeURI(a[3]);
			//var _account = "<%=java.net.URLEncoder.encode(\""+a[3]+"\",\"GB2312\")%>";
			$("loginInfo_blog").innerHTML = "<a href=\"/blog?account="+_account+"\" target=\"_blank\">个人博客</a>";
		}
		else if ( a[0] == "1" )
		{
			$("login").style.display = "block";
			var account = $("account");
			account.focus();
			account.value = account.value;
			$("loginInfo").style.display = "none";
			$("login_warning").innerHTML = a[1];
		}
		else if ( a[0] == "2" )
		{
			$("login").style.display = "block";
			$("loginInfo").style.display = "none";
			$("login_warning").innerHTML = a[1];
			var password = $("password");
			password.focus();
			password.value = password.value;
		}
		
		showHideProgress("hide");
	}

	function logout()
	{
		var ajax = new Ajax();

		var context = "";
		if ( typeof(hostcontext)!="undefined" && hostcontext.trim()!="" && hostcontext.trim().toLowerCase()!="null" )
		{
			context = hostcontext+"/";
		}
		var url = "/"+context+"memberLoginServlet?loginType=ajaxlogout";
		ajax.send(url,logoutcallback);
	}
	function logoutcallback()
	{
		$("login").style.display = "block";
		$("loginInfo").style.display = "none";
		showHideProgress("hide");
	}