// Sets cookie values. Notice the use of escape to encode special characters (semicolons, commas, spaces) in the //value string. This function assumes that cookie names do not have any special characters. Expiration date is optional:function setCookie(name, value, expires) {   document.cookie = name + "=" + escape(value) + "; path=/" +   ((expires == null) ? "" : "; expires=" + expires.toGMTString());}//The following function returns a cookie value, given the name of the cookie:function getCookie(Name) {   var search = Name + "="   if (document.cookie.length > 0) { // if there are any cookies      offset = document.cookie.indexOf(search)       if (offset != -1) { // if cookie exists          offset += search.length          // set index of beginning of value         end = document.cookie.indexOf(";", offset)          // set index of end of cookie value         if (end == -1)             end = document.cookie.length         return unescape(document.cookie.substring(offset, end))      }    }}//The following function fixes cookie names in HTTP headers set by a CGI server and then corrupted by IE which introduces an extra space. The fixed cookie has a session expiry time:function HAfixCookie(Name) {IEname = (Name + " ");x = getCookie(IEname);if (HAcheckvar(x)) {delCookie(IEname);setCookie(Name,x,null);}}// Use this function to delete a cookie.function delCookie(name) {   document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";}//Use this function to trim leading and trailing spaces from a variablefunction HAtrim(x){	if(HAcheckvar(x)){		//trim leading spaces		while (x.charAt(0)==" ") {x=x.substr(1)}		//trim trailing spaces		while (x.charAt(x.length-1)==" ") {x=x.substr(0,x.length-1)}	return x	}	else {return ""}}//Use this function to check for a number or string variablefunction HAcheckvar(x){if(typeof(x) == "string" || typeof(x) == "number"){	return true	}else {return false}}
