function getUsername()
{
	return getCookie("passport_91_cn_utfname");
}
function getCookie(sName) 
{
	  var aCookie = document.cookie.split("; ");
	  
	  for (var i=0; i < aCookie.length; i++)
	  {
	        var aCrumb = aCookie[i].split("=");
	        
	        if (sName.toLowerCase() == aCrumb[0].toLowerCase()) 
	        {
				if(sName=="passport_91_cn_utfname")
					return unescape(aCrumb[1].replace(/%25/g,'%'));
				else
					return unescape(aCrumb[1]);
	        }
	  }
	  return null;		
}
function userIsLogined()
{
	var auth = getCookie("passport_91_cn_utfname");
	var key  = getCookie("passport_91_cn_code");
	//alert(auth);
	if((null == auth)||(null == key)||(key.length!=32))
		return false;
	return true;
}

function showLoginArea()
{
	if(userIsLogined())//已经登录
	{
		document.writeln("<TABLE cellSpacing=0 cellPadding=0 width=\"100%\" border=0>");
		document.writeln("<FORM action=\"http:\/\/\" method=post target=_blank ID=\"Form1\">");
		document.writeln("<TR><td>");
		document.writeln("<a href=\"http:\/\/\" target=\"_blank\"><strong>通行证<\/strong><\/a>&nbsp;");
		document.writeln("你好," + getUsername().replace(" ","") + " ");
		document.writeln("<a href=\"http:\/\/\" target=\"_blank\" title=\"注销\">注销<\/a>");		
		document.writeln("|");
		document.writeln("<A href=\"http:\/\/\" target=_blank title=\"帮助手册\">帮助手册<\/A>");
		document.writeln("<\/td><\/TR>");
		document.writeln("<\/FORM>");
		document.writeln("<\/table>");
	}
	else//未登录 
	{
document.writeln("<TABLE cellSpacing=0 cellPadding=0 width=\"98%\" border=0>");
document.writeln("<FORM action=http:\/\/laozhongyi.net\/e/enews/index.php method=post target=_blank ID=\"Form1\">");
document.writeln("<TR>");
document.writeln("<td>");
document.writeln("<a href=\"http:\/\/\" target=\"_blank\"><strong>通行证<\/strong><\/a>&nbsp;用户名： ");
document.writeln("<INPUT onmouseover=this.focus() onfocus=this.select() size=12 name=username style=\"height:18px\">&nbsp;");
document.writeln("密码： <INPUT onmouseover=this.focus() onfocus=this.select() type=password size=12 name=password style=\"height:18px\"> ");
document.writeln("<INPUT type=\"submit\" value=\"登陆\" title=\"登录\" border=\"0\" style=\"height:20px; width:40px; cursor:hand\"> ");
document.writeln("<A href=\"http://laozhongyi.net/e/member/register\" target=_blank title=\"注册\">注册<\/A>");
document.writeln("|");
document.writeln("<A href=\"http:\/\/\/\" target=_blank title=\"帮助手册\">帮助手册<\/A>");
document.writeln("<\/td>");
document.writeln("<\/TR>");
document.writeln("<\/FORM>");
document.writeln("<\/table>");
	}
}
showLoginArea();

