var jieqiUserId = 0;
var jieqiUserName = '';
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 == '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('<a class="asign" href="/userdetail.php" target="_top" title="会员面板"><em></em><div>'+jieqiUserName+'</div><label></label></a><a class="abook" href="/modules/article/bookcase.php" title="我的书架" target="_top"><em></em><div>书架</div><label></label></a>');
  if(jieqiNewMessage > 0){
	  document.write('<a class="amsg" href="/message.php?box=inbox" title="查看我的短信息" target="_top"><em></em><div>您有新短信</div><label></label></a>');
  }else{
	  document.write('<a class="amsg" href="/message.php?box=inbox" title="查看我的短信息" target="_top"><em></em><div>查看短信</div><label></label></a>');
  }
  document.write('<a class="aout" href="/logout.php" target="_top"><label></label><span></span></a>');
}else{
  var jumpurl="";
  if(location.href.indexOf("jumpurl") == -1){
    jumpurl=location.href;
  }
  document.write('<form name="framelogin" method="post" action="/login.php">');
  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;密码：<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(' <input type="checkbox" class="checkbox" name="usecookie" value="1" />');
  document.write('<input type="submit" class="dengluCss" value=" " name="submit" />');
  document.write('<input type=\"button\" value=\"\" class=\"zhuceCss\" onClick=\"window.top.location.href=\'\/register.php\';\" \/>');
  document.write('</form>');
}

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; 
}