var objCookieUtils = new Object();

objCookieUtils.cc = document.cookie;

objCookieUtils.getCookieValue = function (name) 
{
	var iStart = this.cc.indexOf("; " + name + "="); //find start of label
	
	if (iStart == -1) iStart = this.cc.indexOf(name + "="); //check if label is first in cookie
	
	if (iStart<0) return null; //exit if label not found
	
	if (iStart > 0) iStart += 2; //add two to make sure that the starting semicolon is skipped
	
	var iEnd = this.cc.indexOf(";", iStart); //get position of semicolon after cookie value
	
	if (iEnd == -1) iEnd = this.cc.length; //if there is no trailing semicolon, get length of cookie
	
	return this.cc.substring(iStart + name.length + 1, iEnd); //return cookie value

}

objCookieUtils.setEscapedCookie = function (escapedName, escapedValue, expiration, path, domain) 
{
	if (expiration + "" == "undefined") {
		var now = new Date();
		expiration = new Date((now.getFullYear() + 1), now.getMonth(), now.getDate());
		}
	if (path + "" == "undefined") {
		path = "/";
		}
	if (domain + "" == "undefined") {
		domain = ".on24.com";
		}

	document.cookie =
		escapedName + "=" + escapedValue
		+ ";expires=" + expiration.toGMTString()
		+ ";path=" + path
		+ ";domain=" + domain 
		+ ";" ;
}


objCookieUtils.setEscapedSessionCookie = function (escapedName, escapedValue, path, domain) 
{
	if (path + "" == "undefined") {
		path = "/";
		}
	if (domain + "" == "undefined") {
		domain = ".on24.com";
		}

	document.cookie =
		escapedName + "=" + escapedValue
		+ ";path=" + path
		+ ";domain=" + domain 
		+ ";" ;
}


objCookieUtils.deleteEscapedCookie = function (escapedName, path, domain) 
{
	if (path + "" == "undefined") {
		path = "/";
		}
	if (domain + "" == "undefined") {
		domain = ".on24.com";
		}

	var now = new Date();
	var expiration = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);

	document.cookie =
		escapedName + "=" 
		+ ";expires=" + expiration.toGMTString()
		+ ";path=" + path
		+ ";domain=" + domain 
		+ ";" ;
}

