// Copyright (c) 2000,2006 Semaphor// appendCookie: Append a name/value pair to a CookieVal string// cCookieVal - The CookieVal string to which the name/value pair should be appended.// cName - The name of the name/value pair. Duplicate name checking not performed.// cValue - The value of the name/value pair.// returns - new CookieValvar cookieReturnName = 'Semaphor_Return';var cookieNameName = 'Semaphor_Name';var cookieEmailName = 'Semaphor_Email';var cookieChatActive = 'Semaphor_Chat_Active';var cookieDomain = '';var cookiePath = '/';function appendCookie(cCookieVal, cName, cValue) {   // We concatenate a new name/value pair to the Cookie value.   // This is stored in string format   return cCookieVal + "&" + cName + ":" + escape(cValue);}// extractCookie: Given the name, extract a value from a CookieVal string// cCookieVal - The CookieVal string from which the value should be extracted.// cName - The name of the name/value pair. // returns - value or empty string if not found.function extractCookie(cCookieVal, cName) {   // We look for the specified name and return its value   // The CookieVal is stored in string format   var cReturn;   // The return value   if ("" == cCookieVal) return "";   // No values      // Now find the specific cStoreName cookie in the string   var nStart = cCookieVal.indexOf("&" + cName + ":");   if (-1 == nStart) return "";  // cName not found   nStart += cName.length + 2;   // Point at first data char   var nEnd = cCookieVal.indexOf("&", nStart); // Find the end   if (-1 == nEnd) {      nEnd = cCookieVal.length; // Point at last char   }   cReturn = cCookieVal.substring(nStart, nEnd); // Extract the Cookie   return cReturn;  // and return it}// saveCookie: Save a CookieVal - Save to Web browser. It may have several name/value pairs// doc - The document object that should be used for the save.// cStoreName - The actual cookie name that will be known by the browser.// cCookieVal - The CookieVal string to save.// nSeconds - (optional) (integer) The duration that the cookie should live, in seconds.// cDomain - (optional) The domain name.// cPath - (optional) The path associated with the cookie.// bSecure - (optional) (boolean) The secure option// returns - voidfunction saveCookie(doc, cStoreName, cCookieVal, nSeconds, cDomain, cPath, bSecure ) {   var cCooking;  // Used to store intermediate strings   var dtExpires; // Date this cookie expires   cCooking = cStoreName + "=" + cCookieVal // The name=value   if (nSeconds) {      // Calculate expiration date      dtExpires = new Date((new Date()).getTime() + 1000 * nSeconds);	  cCooking += "; expires=" + dtExpires.toGMTString();   }   if (cDomain) { // If the domain was supplied      cCooking += "; domain=" + cDomain;   }   if (cPath) {   // If the path was supplied      cCooking += "; path=" + cPath;   }   if (bSecure) { // If the secure parameter was supplied      cCooking += "; secure";   }   // Done cooking, now assign the cookie   doc.cookie = cCooking;}// loadCookie: Load a CookieVal - It may contain several name/value pairs.// doc - The document object that should be used for the load// cStoreName - The actual cookie name that will be known by the browser.// returns - The CookieVal string or empty string if not found.function loadCookie(doc, cStoreName) {   var cCooking;  // Used to store intermediate strings   var cReturn;   // The return value   cCooking = doc.cookie; // Get all the Cookie name/values   if ("" == cCooking) return "";   // No values      // Now find the specific cStoreName cookie in the string   var nStart = cCooking.indexOf(cStoreName + "=");   if (-1 == nStart) return "";  // cStoreName not found   nStart += cStoreName.length + 1; // Point at first data char   var nEnd = cCooking.indexOf(";", nStart); // Find the end   if (-1 == nEnd) {      nEnd = cCooking.length; // Point at last char   }   cReturn = cCooking.substring(nStart, nEnd); // Extract the CookieVal   return cReturn;  // and return it}// Remember return URL when submitting formsfunction setReturnURL(url) {    var expSeconds = 60;    saveCookie(document, cookieReturnName, url, expSeconds, cookieDomain, cookiePath);}// Remember users name when submitting forms eg. in discussionfunction setName(name) {    var expSeconds = 60*60*24*365*2;    saveCookie(document, cookieNameName, escape(name), expSeconds, cookieDomain, cookiePath);}// Remember users email when submitting forms eg. in tipfunction setEmail(email) {    var expSeconds = 60*60*24*365*2;    saveCookie(document, cookieEmailName, email, expSeconds, cookieDomain, cookiePath);}// Remember that user wants to chatfunction setChatActive() {    var expSeconds = 60*60*24;    saveCookie(document, cookieChatActive, 1, expSeconds, cookieDomain, cookiePath);}function CookieHandler() {	this.setCookie = setCookie;	this.getCookie = getCookie;	function setCookie( name, value, path, expires ) {		document.cookie = name + '=' + value+'; path=' + path+'; expires=' + expires.toGMTString() ;	}	function getCookie( name) {		var index = -1;		if(document.cookie) {			index = document.cookie.indexOf( name);		}		if (index != -1) {			var key = name + '=';			var countbegin = (document.cookie.indexOf( key, index) + key.length);			var countend = document.cookie.indexOf(';', index);			if (countend == -1) {				countend = document.cookie.length;			}			return document.cookie.substring(countbegin, countend);		}		return '';	}}