// Cookie support.

function CookieStorage (doc)
{
    this._document = (doc)? doc : document;
}

CookieStorage.prototype.getCookieVal= function (offset) {
   var endstr = this._document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = this._document.cookie.length;
   return unescape(this._document.cookie.substring(offset, endstr));
}

CookieStorage.prototype.GetCookie = function(name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = this._document.cookie.length;
        var i = 0;
        while (i < clen) {
                var j = i + alen;
                if (this._document.cookie.substring(i, j) == arg)
                        return this.getCookieVal (j);
                i = this._document.cookie.indexOf(" ", i) + 1;
                        if (i == 0)
                                break;
                }
   return null;
}

CookieStorage.prototype.SetCookie = function (name, value) {
        var argv = this.SetCookie.arguments;
        var argc = this.SetCookie.arguments.length;
        var expires = (argc > 2) ? argv[2] : null;
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;
        var secure = (argc > 5) ? argv[5] : false;
        this._document.cookie = name + "=" + escape (value) +
                ((expires == null) ? "" : ("; expires=" +
expires.toGMTString())) +
                ((path == null) ? "" : ("; path=" + path)) +
                ((domain == null) ? "" : ("; domain=" + domain)) +
                ((secure == true) ? "; secure" : "");
}

function SetStdCookie(name, value)
{
  pathname = location.pathname;
  myDomain = pathname.substring(0,pathname.lastIndexOf('/')) +'/';
  var largeExpDate = new Date ();
  largeExpDate.setTime(largeExpDate.getTime() + (365 * 24 * 3600 * 1000));
  
  SetCookie(name,value,largeExpDate,myDomain);
}

// 08.09.2010 6:33:58