// byteMyCode.com
// ©1998-2006  All Rights Reserved.

// Set cookie
function setCookie(strName, strValue, dExpires, strPath, strDomain, bSecure)
{
   	document.cookie = strName + "=" + escape(strValue) +
        ((dExpires) ? "; expires=" + dExpires.toGMTString() : "") +
        ((strPath) ? "; path=" + strPath : "") +
        ((strDomain) ? "; domain=" + strDomain : "") +
        ((bSecure) ? "; secure" : "");
}

// Get cookie
function getCookie(strName)
{
	var strPrefix = strName + "=";
	var nBegin = document.cookie.indexOf("; " + strPrefix);
	if (nBegin == -1)
	{
		nBegin = document.cookie.indexOf(strPrefix);
		if (nBegin != 0)
		{
			return null;
		}
	}
	else
	{
		nBegin += 2;
	}
	var nEnd = document.cookie.indexOf(";", nBegin);
	if (nEnd == -1)
	{
		nEnd = document.cookie.length;
	}

	return unescape(document.cookie.substring(nBegin + strPrefix.length, nEnd));
}

// Delete cookie
function deleteCookie(strName, strPath, strDomain)
{
	if (getCookie(strName))
	{
		document.cookie = strName + "=" + ((strPath) ? "; path=" + strPath : "") + ((strDomain) ? "; domain=" + strDomain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}