// COOKIE FUNCTIONALITY ============================================================================
	// Sets the JScript cookie's data ----------------------------------------------------
	function setCookie(param){
		// Declarations (Break down the JSON)
		name 		= (param.name);
		value 		= (escape(param.value));														// Handle special chars
		expiration	= (param.expiration)	? param.expiration	: null;								// Allow for instant expiry
		path		= (param.path)	 		? ';path=' 			+ param.path		: ';path=/';	// Ensure the cookie's on root
		domain		= (param.domain) 		? ';domain=' 		+ param.domain		: ''; 			// Only applicable to subdomains
		secure		= (param.secure) 		? ';secure' 							: ''; 			// Only used for trans-SSL
	
		// Set up the cookie's expiration
		if(expiration != null){
			var today 			= new Date();										// Define base expiry date as today
			today.setTime(today.getTime());											// Define base expiry time as "right now"
			expiration 			= (expiration) ? expiration * 3600000 : 3600000; 	// Calculate expiry in hours (default: 1 hour)
			expiration 			= new Date(today.getTime() + (expiration));			// Add calculated expiry to "right now"
			expiration			= expiration.toGMTString();							// Convert the expiry to GMT timestamp
			expiration			= ';expiration=' + expiration;
		}
		// Construct the cookie itself
		document.cookie 	= name + "=" + value +									// Set VALUE to NAME (myCookie = 'myValue')
							  expiration +											// Expiry time (defaults to 1 hour)
							  path		 +											// The path of the cookie (defaults to the root)
							  domain 	 +											// The cookie's domain (defaults to self)
							  secure;												// Whether it's tamper-proof (defaults to false)
	} // EO: setCookie -------------------------------------------------------------------
	
	// Adds a value to the existing cookie, separated by ||| -----------------------------
	function appendCookie(param){
		var currentCookieVal = readCookie(param.name);
		var newCookieVal 	 = (currentCookieVal == null) ? param.value : currentCookieVal + '|||' + param.value;
		setCookie({name:param.name, value:newCookieVal, expiration:param.expiration, path:param.path, domain:param.domain, secure:param.secure});
		return newCookieVal;
	} // EO: appendCookie ----------------------------------------------------------------
	
	function cookieValueExists(cookieName, soughtValue){
		var cookieString = readCookie(cookieName);
		if(!cookieString)  return false;
		var retVal 		 = ((cookieString.indexOf(soughtValue) != -1) || (cookieString.indexOf(('|||' + soughtValue)) != -1) || (cookieString.indexOf((soughtValue + '|||') != -1)));
		return (retVal  != -1);
	}
	
	// Reads the cookie's data -----------------------------------------------------------
	// Note: document.cookie only returns ALL of the name=value pairs, not just the one specified
	function readCookie(cookieName){
		// Declarations
		var RC_allCookies 		= document.cookie.split(';');					// Collect and explode all cookies
		var RC_currentCookie 	= '';											// The loop's current cookie
		var RC_currentName 		= '';											// The loop's current cookie name
		var RC_currentValue 	= '';											// The loop's current cookie value

		for(i=0; i<RC_allCookies.length; i++){									// Loop through the exploded cookies
			RC_currentCookie = RC_allCookies[i].split('=');						// Split each into a name/value pair
			RC_currentName   = RC_currentCookie[0].replace(/^\s+|\s+$/g, '');	// Obtain the current cookie's name & trim
			if(RC_currentName.toUpperCase() == cookieName.toUpperCase()){		// See if this is the sought cookie
				if(RC_currentCookie.length > 1)									// If there IS a value...
					RC_currentValue = RC_currentCookie[1]; 							// Grab it
				return unescape(RC_currentValue.replace(/^\s+|\s+$/g, ''))			// And return it after cleaning it up
				break;																// Bail out of the function
			}																	// Otherwise...
			RC_currentCookie 	= null;												// Reset the cookie,
			RC_currentName 		= '';												// Reset its name,
		}																			// And try again
			return null;
	} // EO: readCookie ------------------------------------------------------------------
	
	// Deletes the cookie entirely -------------------------------------------------------
	//	Ex. 	deleteCookie({name:'r2b', path:'/'});
	function deleteCookie(param) {
		if(readCookie(param.name)) 
			document.cookie = param.name + "=" +
			((param.path) ? ";path=" + param.path : "") +
			((param.domain) ? ";domain=" + param.domain : "") +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	} // EO: deleteCookie ----------------------------------------------------------------
// =================================================================================================
