

// ===================================================================================
//  js_cookiefuncs
// ===================================================================================
function geber_lib_CookieClass()
{
    this.defaultPath = "";
}


geber_lib_CookieClass.prototype.setRaw = function(cookieString)
{
    document.cookie = cookieString;
}

geber_lib_CookieClass.prototype.getRaw = function()
{
    return document.cookie.toString();
}



geber_lib_CookieClass.prototype.setValue = function(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path)    ? "; path=" + path : "; path=" + this.getDefaultPath()) +
      ((domain)  ? "; domain=" + domain : "") +
      ((secure)  ? "; secure" : "");

  this.setRaw(curCookie);
}



geber_lib_CookieClass.prototype.getValue = function(name) {

  var dc = this.getRaw();
  if (!dc) return null;

  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = dc.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}



geber_lib_CookieClass.prototype.deleteValue = function(name, path, domain) {
  if (geber_getCookie(name)) {
    this.setRaw(name + "=" +
    ((path)    ? "; path=" + path : (this.defaultPath != "" ? "; path=" : "") + this.defaultPath) +
    ((domain)  ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT");
  }
}

geber_lib_CookieClass.prototype.setDefaultPath = function(path)
{
    if (typeof(path) == 'string' && path.length > 0)
       this.defaultPath = path;
    else
       this.defaultPath = "";
}

geber_lib_CookieClass.prototype.getDefaultPath = function()
{
    if (this.defaultPath && typeof(this.defaultPath) == 'string' && this.defaultPath.length > 0)
        return this.defaultPath;
    else
    {
        var myCookiePath = geber_lib_getBaseURLPath();
        myCookiePath = myCookiePath.replace(new RegExp("/(de|en|fr|it|es|nl)/?$", "i"), "");
        return myCookiePath;
    }
}

function geber_cookie_addCookieToBrowserObject()
{
  try {
    var browser = geber_getBrowser();
    if (browser)
        browser.cookie = new geber_lib_CookieClass();
      }
   catch (e){}
}
geber_cookie_addCookieToBrowserObject();
