function FilterCookie() {
	
}

FilterCookie.prototype.init=function(){
}


FilterCookie.prototype.SetTimeCookie=function(filterName,clickTime){
	var strValue=this.GetCookie('TF');
	if(strValue==null)
		strValue="{}";
	var message={};
	try{
		message = YAHOO.lang.JSON.parse(strValue); 	        
	}catch(x){
		message={};
	}
	message[filterName]=clickTime;
	this.SetCookie("TF",YAHOO.lang.JSON.stringify(message));
}


FilterCookie.prototype.DeleteCookie = function(key)
{
	var exp = new Date();
	var argv = arguments;
	var argc = arguments.length;
	var expires = (argc > 2) ? argv[2] : null;			// seconds
	var path = (argc > 3) ? argv[3] : "/";
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	exp.setTime(exp.getTime() - 10000);
	document.cookie = key + "=" + "" +("; expires="+ exp.toGMTString())
	+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
	+((secure == true) ? "; secure" : "");
}

FilterCookie.prototype.GetValue = function(offset)
{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

FilterCookie.prototype.SetCookie = function(key, value)
{
	var expdate = new Date();
	var argv = arguments;
	var argc = arguments.length;
	var expires = (argc > 2) ? argv[2] : null;			// seconds
	var path = (argc > 3) ? argv[3] : "/";
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	if(expires!=null) 
	{
		expdate.setTime(expdate.getTime() + ( expires * 1000 ));
	}
	else
	{
		expdate.setFullYear(expdate.getFullYear() + 30);	
	}
	document.cookie = key + "=" + escape (value) +("; expires="+ expdate.toGMTString())
	+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
	+((secure == true) ? "; secure" : "");
}
FilterCookie.prototype.GetCookie = function(key)
{
	var arg = key + "=";
	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 this.GetValue(j);
		
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

/////////////////// Save and Get Cookie Value, to JSON //////////////////////
FilterCookie.prototype.GetJSONCookie = function(cookieName){
	var value = this.GetCookie(cookieName);
	var result = null;
	try{
		result = YAHOO.lang.JSON.parse(value); 	        
	}catch(x){
		result = null;
	}
	return result;
}
FilterCookie.prototype.SaveJSONCookie = function(cookieName,cookieValue){
	this.SetCookie(cookieName,YAHOO.lang.JSON.stringify(cookieValue));
}

