/*
  功能：在客户端设置cookie的值

*/
function setcookie(name,value,domain)
{
var argv=setcookie.arguments;
var argc=setcookie.arguments.length;

//清除原来的cookie
var today = new Date();
//var expiration = new Date(today.getTime() + (-365) * 24 * 60 * 60 * 1000);
//document.cookie=name+"=;expires="+expiration.toGMTString()+";path=/";

//创建cookie
var expiration = new Date(today.getTime() + 6 * 60 * 60 * 1000);  // 365 days from today
document.cookie=name+"="+escape(value)+";expires="+expiration.toGMTString()+";path=/";
/*	if (domain='')
	{
		document.cookie=name+"="+escape(value)+";path=/;domain="+domain+";";
	}
	else
	{
		document.cookie=name+"="+escape(value)+";path=/;";
	}
*/
//alert(document.cookie);
}

/*
  功能：在客户端获取cookie的值

*/
function getcookie(Name) {
   var 	WholeCookie=document.cookie;
   var index = WholeCookie.indexOf(Name + "=");
   if (index == -1) return "";
   index=WholeCookie.indexOf("=", index)+1;
   var endstr = WholeCookie.indexOf(";", index);
   if (endstr == -1) endstr = WholeCookie.length;
   var IndividualCookie = unescape(WholeCookie.substring(index, endstr));
   if (IndividualCookie == null || IndividualCookie == "null" ||
       IndividualCookie == "" || IndividualCookie.indexOf("undefined") >= 0 ||
       IndividualCookie.lastIndexOf("=") == IndividualCookie.length - 1) {
      IndividualCookie = ""
   }
   return IndividualCookie
}

/*
function getcookie(name)
{
var arg=name+"=";
var alen=arg.length;
var clen=document.cookie.length;
var j=0;
	while(j<clen)
	{
		var k=j+alen;
		if (document.cookie.substring(j,k)==arg) return getcookieval(k);
		j=document.cookie.indexOf("",j)+1;
		if (j==0) break;
	}
	return null;

}

function getcookieval(offset)
{
var endstr=document.cookie.indexOf(";",offset);
	if (endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset,endstr));
}*/

function deletecookie(name)
{
	var exp= new Date();
	//FixcookieDate(exp);
	exp.setTime(exp.getTime()-1);
	var cval=getcookie(name);
	if (cval!=null)
	document.cookie=name+"="+cval+";expires="+exp.toGMTString();
}