var jieqiUserId = 0;
var jieqiUserName = '';
var jieqiUserHonor = '';
var jieqiUserPassword = '';
var jieqiUserGroup = 0;
var jieqiNewMessage = 0;

if(document.cookie.indexOf('jieqiUserInfo') >= 0){
	
	var jieqiUserInfo = get_cookie_value('jieqiUserInfo');
	
	start = 0;
	offset = jieqiUserInfo.indexOf(',', start); 
	while(offset > 0){
		tmpval = jieqiUserInfo.substring(start, offset);
		tmpidx = tmpval.indexOf('=');
		if(tmpidx > 0){
           tmpname = tmpval.substring(0, tmpidx);
		   tmpval = tmpval.substring(tmpidx+1, tmpval.length);
		   if(tmpname == 'jieqiUserId') jieqiUserId = tmpval;
		   else if(tmpname == 'jieqiUserName_un') jieqiUserName = tmpval;
		   else if(tmpname == 'jieqiUserHonor_un') jieqiUserHonor = tmpval;
		   else if(tmpname == 'jieqiUserPassword') jieqiUserPassword = tmpval;
		   else if(tmpname == 'jieqiUserGroup') jieqiUserGroup = tmpval;
		   else if(tmpname == 'jieqiNewMessage') jieqiNewMessage = tmpval;
		}
		start = offset+1;
		if(offset < jieqiUserInfo.length){
		  offset = jieqiUserInfo.indexOf(',', start); 
		  if(offset == -1) offset =  jieqiUserInfo.length;
		}else{
          offset = -1;
		}
	}
}
if(jieqiUserId != 0 && jieqiUserName != '' && (document.cookie.indexOf('PHPSESSID') != -1 || jieqiUserPassword != '')){
  document.write('<table width="550"  border="0" cellspacing="0" cellpadding="0">');
  document.write('<tr>');
  document.write('<td class="green_12">&nbsp;欢迎您回来“<font color=#ff0000>'+jieqiUserHonor+'</font>”&nbsp;<b><font color=#ff0000>'+jieqiUserName+'</font></b>');
  	if(jieqiNewMessage>0){
		document.write(' | <a href="/message.php?box=inbox"><font color="#ff0000">您有新消息</font></a>');
		}
	else{
		document.write(' | <a href="/message.php?box=inbox">查看短信</a>');
	}
  document.write(' | <a href="/logout.php" target="_self" class="green_12">[退出登陆]</a>&nbsp;</td>');
  document.write('</tr>');
  document.write('</table>');

}else{
  var jumpurl="";
  if(location.href.indexOf("jumpurl") == -1){
    jumpurl=location.href;
  }
  document.write('<table width="550"  border="0" cellspacing="0" cellpadding="0">');
  document.write('<form name="framelogin" method="post" target="_top" action="/login.php">');
  document.write('<tr>');
  document.write('<td align=left>用户名：');
  document.write('<input name="username" type="text" class="text" onkeypress="javascript: if (event.keyCode==32) return false;" value="" size="8" maxlength="30" />');
  document.write('&nbsp;&nbsp;密码：<input type="password" class="text" size="8" maxlength="30" name="password" />');
  document.write('<input type="hidden" name="action" value="login" />');
  document.write('<input type="hidden" name="jumpurl" value="'+jumpurl+'" />');
  document.write('&nbsp;&nbsp;<input type="checkbox" class="mycheckbox" name="usecookie" value="1" />');
  document.write('&nbsp;记录cookie&nbsp;');
  document.write('<input type="submit"  value=" 登 录 " name="submit" class="mybutton"/>');
  document.write('</td>');
  document.write('</tr>');
  document.write('</form>');
  document.write('</table>');
}


function get_cookie_value(Name) { 
  var search = Name + "=";
　var returnvalue = ""; 
　if (document.cookie.length > 0) { 
　  offset = document.cookie.indexOf(search) 
　　if (offset != -1) { 
　　  offset += search.length 
　　  end = document.cookie.indexOf(";", offset); 
　　  if (end == -1) 
　　  end = document.cookie.length; 
　　  returnvalue=unescape(document.cookie.substring(offset, end));
　　} 
　} 
　return returnvalue; 
}
