/*********************
首页login-cookie
**********************/
 function addCookie(objName,objValue,objHours){//添加cookie
 delCookie(objName);
    var str = objName + "=" + escape(objValue);
    if(objHours > 0){//为0时不设定过期时间，浏览器关闭时cookie自动消失
     var date = new Date();
     var ms = objHours*3600*1000;
     date.setTime(date.getTime() + ms);
     str += "; path=/; expires=" + date.toGMTString();
    }
    document.cookie = str;
   }

function getCookieVal(offset)
{
	var endstr = document.cookie.indexOf(";",offset);
	if (endstr == -1)
	{
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset,endstr));
}
function getCookie(name)
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i= 0;
	while (i<clen)
	{
		var j = i+alen;
			if (document.cookie.substring(i,j) == arg)
			{
				return getCookieVal(j);	
			}
		i = i+1;
	}
	return null;
}
function delCookie(name)
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}

var username = getCookie("mlusername");
var userid = getCookie("mluserid");
var sessiontype = getCookie("sessiontype");
if(username != null&&userid!=null&&sessiontype!=null)
{
	document.write("<span class=\"txt\">你好，<strong class=\"txt5\">"+username+"</strong>&nbsp;&nbsp;</span>");
	document.write("<span class=\"txt\"><a href=\"mark.shtml\" class=\"user\">我的收藏夹</a></span>");
	document.write("<span class=\"txt\"><a href=\"http://space.6ka.com/uhome/space.php?uid="+userid+"\" class=\"user\">我的空间</a></span>");
	document.write("<span class=\"txt\"><a href=\"logout.shtml?url="+window.location.href+"\" class=\"user\">[退出]</a></span>");
}
else
{username=(username==null?"":username);
    document.write("<form name=\"form0\" method=\"post\" action=\"login.shtml\"><span>用户名：<input name=\"username\" class=\"txt\" type=\"text\" value=\""+username+"\" />&nbsp;&nbsp;密码：<input name=\"password\" class=\"txt\" type=\"password\" /></span>");
    document.write("<span class=\"btn2\"><input type=\"image\" src=\"images/btn_login.gif\" /> <a href=\"reg.shtml\"><img src=\"images/btn_reg.gif\" width=\"56\" height=\"19\" alt=\"注册\" /></a></span>");
	document.write("<input type=\"hidden\" name=\"enews\" value=\"login\" /><input type=\"hidden\" name=\"lifetime\" value=\"315360000\" /><input type=\"hidden\" name=\"url\" value=\""+window.location.href+"\"></form>");
}

function addBookmark(){
var title=document.title
var url=document.location.href
if (window.sidebar) window.sidebar.addPanel(title, url,"");
else if( window.opera && window.print ){
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();}
else if( document.all ) window.external.AddFavorite( url, title);
}
