function getScriptName()
{
	var path = location.pathname;
	
	//  don't get leading "/" and anything after gateway.dll
	path = path.substring(1, path.indexOf('.') + 4);  
//	return path;
	return "";
}

function getCookie(cookie_name)
{
	var cookie = document.cookie;
	
	var script_cookie_name = /* getScriptName() + "/" + */ cookie_name;
	var index = cookie.indexOf(script_cookie_name + "=");
	if(-1 == index)
	{
		return "";
	}

	index = cookie.indexOf("=", index);
	if(-1 == index)
	{
		return "";
	}

	var endstr = cookie.indexOf(";", index);
	if(-1 == endstr)
	{
		endstr = cookie.length;
	}

	var cookie_value = unescape(cookie.substring(index + 1, endstr));
	if(cookie_value == null || cookie_value == "null" || cookie_value == "" || cookie_value.indexOf("undefined") >= 0 || cookie_value.lastIndexOf("=") == cookie_value.length - 1)
	{
		cookie_value = "";
	}
	return cookie_value;
}

function setCookie(cookie, value, expires, path, domain, nSecure)
{
	// This function sets the desired cookie based on passed in data
	var cv, ev, pv, dv, sv;

	// Set the cookie parameters if valid data given
	// =============================================
	if(cookie != null && cookie != "" && value != null)
	{
		cv = "" + /*getScriptName() + "/" + */ cookie + "=" + escape(value) + "; ";	
	}
	else
	{
	  return 1; // Fatal
	}

	//if(expires != null && expires != "")
	//{ ev = "expires=" + expires + "; "; }
	//else
	//{ ev = ""; }
	var lastyear = new Date();
	lastyear.setFullYear(lastyear.getFullYear() - 1);
	ev = "expires=" + lastyear.toUTCString() + "; ";
ev="";
	if(path != null && path != "")
	{ pv = "path=" + path + "; "; }
	else
	{ pv = "path=/;"; } // Default to path of root

	if(domain != null && domain != "")
	{ dv = "domain=" + domain + "; "; }
	else
	{ dv = ""; }

	if(nSecure)
	{ sv = "secure"; }
	else
	{ sv = ""; }

	// Set the desired cookie
	str = "" + cv + ev + pv + dv + sv;
	document.cookie = str;
	return;
}

