var default_kid = '1454';

function getQueryString(queryStringName)
{
	var returnValue = "";
	var URLString = new String(document.location);
	var serachLocation = -1;
	var queryStringLength = queryStringName.length;
	do
	{
		serachLocation = URLString.indexOf(queryStringName + "\=");
		if (serachLocation != -1)
		{
			if ((URLString.charAt(serachLocation-1) == '?') || (URLString.charAt(serachLocation-1) == '&'))
			{
				URLString = URLString.substr(serachLocation);
				break;
			}
			URLString = URLString.substr(serachLocation + queryStringLength + 1);
		}
		
	}
	
	while (serachLocation != -1)
	if (serachLocation != -1)
	{
		var seperatorLocation = URLString.indexOf("&");
		if (seperatorLocation == -1)
		{
			returnValue = URLString.substr(queryStringLength + 1);
		}
		else
		{
			returnValue = URLString.substring(queryStringLength + 1,seperatorLocation);
		}
	}
	return returnValue;
}

function WriteCookies(cookieName, cookieValue, expires)
{
    if (expires)
    {
        document.cookie =
            WriteCookies_GetCookieName(cookieName) + "=" + escape(cookieValue)
            + "; expires=" + xpires.toGMTString();
    }
    else
    {
        document.cookie = WriteCookies_GetCookieName(cookieName) + "=" + escape(cookieValue);
    }
}

function WriteCookies_GetCookieName(cookieName)
{
    var lowerCookieName = cookieName.toLowerCase();
    var cookieStr = document.cookie;
   
    if (cookieStr == "")
    {
        return cookieName;
    }
   
    var cookieArr = cookieStr.split("; ");
    var pos = -1;
    for (var i=0; i<cookieArr.length; i++)
    {
        pos = cookieArr[i].indexOf("=");
        if (pos > 0)
        {
            if (cookieArr[i].substring(0, pos).toLowerCase() == lowerCookieName)
            {
                return cookieArr[i].substring(0, pos);
            }
        }
    }
   
    return cookieName;
}

function ReadCookies(cookieName, dfltValue)
{
	var lowerCookieName = cookieName.toLowerCase();
	var cookieStr = document.cookie;
	if (cookieStr == "")
	{
		return dfltValue;
	}
	var cookieArr = cookieStr.split("; ");
	var pos = -1;
	for (var i=0; i<cookieArr.length; i++)
	{
		pos = cookieArr[i].indexOf("=");
		if (pos > 0)
		{
			if (cookieArr[i].substring(0, pos).toLowerCase() == lowerCookieName)
			{
				return unescape(cookieArr[i].substring(pos+1, cookieArr[i].length));
			}
		}
	}
	return dfltValue;
}
