function Cookie() {
  this.calc_expire_date = function( days, hours, minutes ) {
    result = new Date();
    if ( typeof days    == 'number' &&
         typeof hours   == 'number' &&
         typeof minutes == 'number' ) {
      result.setDate(    result.getDate()    + parseInt( days    ) );
      result.setHours(   result.getHours()   + parseInt( hours   ) );
      result.setMinutes( result.getMinutes() + parseInt( minutes ) );
      return result.toGMTString();
    }
  }

  this.get_value = function( offset ) {
    endstr = document.cookie.indexOf( ';', offset );
    if ( endstr == -1 ) { endstr = document.cookie.length; }
    return unescape( document.cookie.substring( offset, endstr ) );
  }

  this.get = function( name ) {
    arg  = name + '=';
    alen = arg.length;
    clen = document.cookie.length;
    i = 0;
    while ( i < clen ) {
      j = i + alen;
      if ( document.cookie.substring( i, j ) == arg ) { return this.get_value( j ); }
      i = document.cookie.indexOf( ' ', i ) + 1;
      if ( i == 0 ) { break; }
    }
    return '';
  }

  this.set = function( name, value, expires, path, domain, secure ) {
    document.cookie = name + '=' + escape( value ) +
      ( ( expires ) ? '; expires=' + expires : '' ) +
      ( ( path    ) ? '; path='    + path    : '' ) +
      ( ( domain  ) ? '; domain='  + domain  : '' ) +
      ( ( secure  ) ? '; secure'             : '' );
  }

  this.unset = function( name, path, domain ) {
    if ( this.get( name ) ) { this.set( name, '', 'Thu, 01-Jan-70 00:00:01 GMT', path, domain ); }
  }
}

var _COOKIE = new Cookie();
