

function fnSetCookie(name, value)
{
	var curCookie = name + "=" + escape(value);
	document.cookie = curCookie;

}
function fnKillCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	}
	 else
		begin += 2;
		var end = document.cookie.indexOf(";", begin);
		if (end == -1)
		end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}
function fnDelCookie (NameOfCookie) 
{

// The function simply checks to see if the cookie is set.
// If so, the expiration date is set to Jan. 1st 1970.

if (fnGetCookie(NameOfCookie)) {
document.cookie = NameOfCookie + "=" +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}

function fnGetCookie(NameOfCookie)
{

// First we check to see if there is a cookie stored.
// Otherwise the length of document.cookie would be zero.

if (document.cookie.length > 0) 
{ 

// Second we check to see if the cookie's name is stored in the
// "document.cookie" object for the page.

// Since more than one cookie can be set on a
// single page it is possible that our cookie
// is not present, even though the "document.cookie" object
// is not just an empty text.
// If our cookie name is not present the value -1 is stored
// in the variable called "begin".

begin = document.cookie.indexOf(NameOfCookie+"="); 
if (begin != -1) 
{ 

// Our cookie was set. 
// The value stored in the cookie is returned from the function.

begin += NameOfCookie.length+1; 
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end)); } 
}
return null; 

// Our cookie was not set. 
// The value "null" is returned from the function.

}
//remove an item from a comma delimited list cookie

function fnAddCSItem(sCookieName,sSectionID)
{	
	var csString;
	csString=fnGetCookie(sCookieName);
	if(csString==null)
	{
			fnSetCookie(sCookieName,sSectionID);
	}
	else
	{
		if (csString.indexOf(sSectionID) == -1)
		{
			csString = csString + ',' + sSectionID;
			fnSetCookie(sCookieName,csString);
			
		}
	}
		
}
//remove an item from a comma delimited list cookie
function fnRemoveCSItem(sCookieName,sSectionID)
{
	
	var csString;
	csString=fnGetCookie(sCookieName);
	var arValues = csString.split(',');
	var arNewValues = new Array(0);
	var x=0;
	
	for (i=0;i<arValues.length;i++)
		if (arValues[i] != sSectionID)
		{
			arNewValues[x] = arValues[i];
			x++;
		}	
	
	fnSetCookie(sCookieName,arNewValues.join(','));
}

	