
function cookiesEnabled() {
 var result=3;  // undefined, if the browser does not know the property
 if (navigator.cookieEnabled!=null) {
  if (navigator.cookieEnabled) result=1;
  else result=2;
 }
 return result;
}

function setCookie(a_name, a_value, a_lifetime) {  // a_lifetime in Tagen
 var now = new Date();
 var expiry = new Date(now.getTime() + a_lifetime*24*60*60*1000);
 if ((a_value != null) && (a_value != ""))
  document.cookie=a_name + "=" + escape(a_value) + "; expires=" + expiry.toGMTString();
 return getCookie(a_name) != null; // Test, ob es geklappt hat
}

function getCookie(a_name) {
 var a_start, an_end;
 if (document.cookie) {
  a_start = document.cookie.indexOf(a_name+"=");
  if (a_start < 0) return null;
  a_start = document.cookie.indexOf("=", a_start) + 1;
  an_end = document.cookie.indexOf(";", a_start);
  if (an_end < 0) an_end = document.cookie.length;
  return unescape(document.cookie.substring(a_start, an_end));
 }
 else return null;
}

function deleteCookie(a_name) {
 var now = new Date();
 var expired = new Date(now.getTime() - 2*24*60*60*1000);  // 2 Tage zurueck
 document.cookie=a_name + "=null; expires=" + expired.toGMTString();
}
