//------------------------------------------------------------------------------
// Class:  CookieManager
//------------------------------------------------------------------------------
// Author:  JY
// Date:  2007/02/26
// Description:  This class defines methods to set and get a cookie.
//------------------------------------------------------------------------------
function CookieManager()
{
	// Methods:
	this.setCookie = setCookie;
	this.getCookie = getCookie;

	//--------------------------------------------------------------------------

	function setCookie(name, value, expires, path, domain, secure)
	{
		document.cookie = name + "=" + escape(value) +
						  (expires ? "; expires="+expires.toGMTString() : "") +
			              (path ? "; path="+path : "") +
			              (domain ? "; domain="+domain : "") +
			              (secure ? "; secure" : "")
						  ;	
	}
	
	//--------------------------------------------------------------------------

	function getCookie(name)
	{
		var strCookie = "" + document.cookie;

		var index1 = strCookie.indexOf(name);
		if (index1 == -1 || name == "") 
		{
			return "";
		}
		
		var index2 = strCookie.indexOf(';', index1);
		if (index2 == -1)
		{
			index2 = strCookie.length;
		}
		
		return unescape(strCookie.substring(index1 + name.length+1, index2));
	}
}
