
	//******************************//
	//** THIS IS THE MODULE START **//	
	function CookieModule() {
		//** Define the module interface
		this.getValueByCookieAndKey = fncGetValueByCookieAndKey;
		this.getStringByCookieAndKey = fncGetStringByCookieAndKey;
		this.setValueByCookieAndKeyAndValue = fncSetValueByCookieAndKeyAndValue;
	}
	//** THIS IS THE MODULE STOP  **//	
	//******************************//

	//**************************//
	//** MODULE METHODS START **//	
	function fncSetValueByCookieAndKeyAndValue(){
		var strCookie = arguments[0];
		var strKey = arguments[1];
		var strValue = escape(arguments[2]);
		var strOut = new String;
		var arrCookie = document.cookie.split("; ");
		//alert (document.cookie);
		//** LOOP THROUGH ALL COOKIES
		for (var t=0;t<arrCookie.length;t++)
		{
			//** IF THE COOKIE IS THE ONE WE WANT
			strTmp = arrCookie[t].split("=")[0].toLowerCase();
			if(strTmp == strCookie.toLowerCase())
			{
				//** REMOVE COOKIE NAME
				strCookieCntnt = arrCookie[t].substring(strCookie.length+1,arrCookie[t].length);
				
				//** THEN LOOP THROUGH ALL KEY AND VALUE PAIRS 
				arrKeyAndValue = strCookieCntnt.split("&");
				for (var u=0;u<arrKeyAndValue.length;u++)
				{
					//** IF THE KEY IS NOT THE ONE WE WANT
					strTmp = arrKeyAndValue[u].split("=")[0].toLowerCase();
					if(strTmp != strKey.toLowerCase())
					{
						//** COLLECT/RESTORE THE EXISTING VALUE
						strOut = strOut + "&" + arrKeyAndValue[u]
					}
				}
			}
		}
		//** FINISH BY ADDING THE NEW KEY/VALUE SET
		strOut = strOut + '&' + strKey + '=' + strValue;
		
		//** TRIM EVENTUAL LEADING '&' CHARACTER
		if (strOut.charAt(0) == '&'){
			strOut = strOut.substring(1,strOut.length); 
		}
		
		//** WRITE THE COOKIE
		document.cookie = strCookie +'='+ strOut;
	}
	
	function fncGetValueByCookieAndKey(){

		var strCookie = arguments[0].toLowerCase();
		var strKey = arguments[1].toLowerCase();
		var arrCookie = document.cookie.split("; ");
		
		//** LOOP THROUGH ALL COOKIES
		for (var t=0;t<arrCookie.length;t++)
		{
			//** IF THE COOKIE IS THE ONE WE WANT
			strTmp = arrCookie[t].split("=")[0].toLowerCase();
			if(strTmp == strCookie)
			{
				//** REMOVE COOKIE NAME
				strCookieCntnt = arrCookie[t].substring(strCookie.length+1,arrCookie[t].length);

				//** THEN LOOP THROUGH ALL KEY AND VALUE PAIRS 
				arrKeyAndValue = strCookieCntnt.split("&");
				for (var u=0;u<arrKeyAndValue.length;u++)
				{
					//** IF THE KEY IS THE ONE WE WANT
					strTmp = arrKeyAndValue[u].split("=")[0].toLowerCase();
					if(strTmp == strKey)
					{
						//** RETURN THE VALUE
						return (unescape(arrKeyAndValue[u].split("=")[1]));
					
					}
				}				
			}
		}
		//** ELSE RETURN EMPTY STRING
		return '';
	}
	
	function fncGetStringByCookieAndKey(){
		var strCookie = arguments[0].toLowerCase();
		var strKey = arguments[1].toLowerCase();
		return fncGetValueByCookieAndKey(strCookie, strKey).replace(/\+/,' ');
		//return fncGetValueByCookieAndKey(strCookie, strKey).replace(/\+/gi,' '); // Changed because of MAC IE 5.1 
	}
	
	//** MODULE METHODS STOP  **//	
	//**************************//


