function GetCookie(tName, DefaultReturn)
{
	if ("undefined" == typeof(DefaultReturn))
		DefaultReturn = "";

	var tArg = tName + "=";
	var nArgLen = tArg.length;
	var nCookieLen = document.cookie.length;
	var nStartPos = 0;

	while (nStartPos < nCookieLen)
		{
		var nEndPos = nStartPos + nArgLen;

		if (document.cookie.substring(nStartPos, nEndPos) == tArg)
			{
			var n2EndPos = document.cookie.indexOf(";", nEndPos);
			if (n2EndPos == -1)
				{
				n2EndPos = document.cookie.length;
				}
			return unescape(document.cookie.substring(nEndPos, n2EndPos));
			}

		nStartPos = document.cookie.indexOf(" ", nStartPos) + 1;
		if (nStartPos == 0)
			break;
		}

	return DefaultReturn;
}

function SetPersistentCookie(szName, szValue)
{
	var dateNow = new Date();
	var dateExpire = new Date();
	dateExpire.setTime(dateNow.getTime() + 1000 * 60 * 60 * 24 * 365);
	mSetCookie(szName, szValue, false, dateExpire);

	return;
}

function FIsVariableInCookie(szName, DefaultValue)
{
	if ("undefined" == typeof(DefaultValue))
		DefaultValue = "";

	return (DefaultValue != GetCookie(szName, DefaultValue));
}

function mSetCookie(tName, vValue)
{
	var aArgs = mSetCookie.arguments;
	var nArgs = mSetCookie.arguments.length;
	var bAppendToCurrentCookie = (nArgs > 2) ? aArgs[2] : false;
	var expires = (nArgs > 3) ? aArgs[3] : null;
	var path = (nArgs > 4) ? aArgs[4] : "/";
	var domain = (nArgs > 5) ? aArgs[5] : null;
	var secure = (nArgs > 6) ? aArgs[6] : false;

	if (bAppendToCurrentCookie && "" != GetCookie(tName))
		vValue = GetCookie(tName) + "," + vValue;

	document.cookie = tName + "=" + vValue +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");

	return;
}

function mGetCookie(tName)
{
	return GetCookie(tName, "na");
}

function mDeleteCookie(tName) {
		var exp = new Date();
		exp.setDate (exp.getDate() -10);
		mSetCookie(tName, "", false, exp);
}

function SzGetArgumentValue(strQueryName)
{
	var iStart;
	var iEnd;
	var strQueryUpper = unescape(location.search.toUpperCase());
	var strQuery = "&" + strQueryName.toUpperCase() + "=";

	iStart = strQueryUpper.indexOf(strQuery);

	if (-1 == iStart)
		{
		strQuery = "?" + strQueryName.toUpperCase() + "=";
		iStart = strQueryUpper.indexOf(strQuery);
		}

	if (-1 == iStart)
		return null;

	iStart += strQuery.length;
	iEnd = strQueryUpper.indexOf("&", iStart);

	if (-1 == iEnd)
		iEnd = strQueryUpper.indexOf("?", iStart);
	if (-1 == iEnd)
		iEnd = strQueryUpper.length;

	return unescape(location.search).substring(iStart, iEnd);
}

