// A function that sets cookie values properly
// The cookieName and cookieValue arguments are mandatory
// but all other arguments are optional.
// The expires argument is a Date object.
// The path defines the part of the document tree on the server
// that the cookie is valid for.
// The domain argument allows multiple server hosts to be used.
// The secure value is boolean and only applicable for use
//
// FW/fw fuer eine Debug-Ausgabe am Ende der Funktion folgendes einfuegen: alert("Cookie "+cookieName+" auf "+cookieValue+" gesetzt!");
//
// with HTTPS: connections.function setCookie(cookieName, cookieValue, expires, path, domain, secure)
function setCookie(cookieName, cookieValue, expires, path, domain, secure)
{
document.cookie = escape(cookieName) + '=' + escape(cookieValue)
+ (expires ? '; EXPIRES=' + expires.toGMTString() : '')
+ (path ? '; PATH=' + path : '')
+ (domain ? '; DOMAIN=' + domain : '')
+ (secure ? '; SECURE' : '');
}

// A complementary function to unwrap a cookie.
function getCookie(cookieName)
{
var cookieValue = null;
var posName = document.cookie.indexOf(escape(cookieName) + '=');
if (posName != -1)
{
  var posValue = posName + (escape(cookieName) + '=').length;
  var endPos = document.cookie.indexOf(';', posValue);
  if (endPos != -1)
  {
    cookieValue = unescape(document.cookie.substring(posValue, endPos));
  }
  else
  {
    cookieValue = unescape(document.cookie.substring(posValue));
  }
}
else{
  cookieValue = ''; //'Kein cookie gefunden fuer:'+escape(cookieName);
}
return cookieValue;
}

// Indirection of Javascript - use string as an javascript expression
function CallJS(jsStr){
  return eval(jsStr);
}