var today = new Date();
var cookieExpiration = new Date( today.getYear() + 1, today.getMonth(), today.getDate() );

function getCookie(lookup)
{
	var offset = 0;
	var limit = document.cookie.length;
	var currentName = "";
	var currentValue = "";

	if ( limit == 0 || limit <= lookup.length ) return null;

	do
	{
		limit = document.cookie.indexOf( "=", offset );
		currentName = document.cookie.substring( offset, limit );
		offset = limit + 1;
		limit = document.cookie.indexOf( ";", offset );
		if ( limit < 0 ) limit = document.cookie.length;
		currentValue = document.cookie.substring( offset, limit );
		if ( currentName == lookup ) return unescape(currentValue);
		else offset = limit + 2;
	}
	while( offset > 0 && offset < document.cookie.length )

	return null;
}

function setCookie(fieldName, fieldValue)
{
	document.cookie = fieldName + "=" + escape(fieldValue) + "; expires=" + cookieExpiration.toGMTString() + ";";
}

function clearCookie(fieldName)
{
	document.cookie = fieldName + "=; expires=" + (new Date(today.getYear() - 1, today.getMonth(), today.getDate())).toGMTString();
}
