//  This routine sets a cookie on the visitor's machine.
// 
//  * name is the name of the cookie
//  * value is the information contained by name
//  * expires sets the number of days of when you want the cookie to expire. 
//    Leave blank to have cookie expire when browser is closed
//  * path specifies which folder on your Web site can access this cookie
//  * domain specifies which servers on your domain can access this cookie
//  * secure specifies whether a secure connection is needed to access this cookie
function setCookie(name,value,expires,path,domain,secure)
{	if (expires)
	{	var exp = new Date()
		exp.setTime(exp.getTime() + (expires * 60 * 60 * 24 * 1000))
		expires = exp.toGMTString()
	}
	
	document.cookie = name + "=" + escape(value) + 
	((expires) ? "; expires=" + expires : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "")
}


//  This routine retrieves a cookie's value
//
//  * if the returned value is "null", then the cookie has not been set or has been cleared
function getCookie(name)
{	var cookie = " " + document.cookie
	var search = " " + name + "="
	var setStr = null
	var offset = 0
	var end = 0
	
	if (cookie.length > 0)
	{	offset = cookie.indexOf(search)
		if (offset != -1)
		{	offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1)
			{	end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	
	//if the first try is null, try again, but this time with UPPERCASE for coldfusion
	if (setStr == null) {
		var cookie = " " + document.cookie
		var search = " " + name.toUpperCase() + "="
		var setStr = null
		var offset = 0
		var end = 0
		
		if (cookie.length > 0)
		{	offset = cookie.indexOf(search)
			if (offset != -1)
			{	offset += search.length;
				end = cookie.indexOf(";", offset)
				if (end == -1)
				{	end = cookie.length;
				}
				setStr = unescape(cookie.substring(offset, end));
			}
		}
	}
	
	return(setStr);
}


// This routine clears the value of a cookie
function clearCookie(variable)
{	setCookie(variable,"","Thu, 01-Jan-1970 00:00:00 GMT")
}