
  //--------------------------------------------------------------------
  //- Class: wharffEvent: The base description for a single Event
  //--------------------------------------------------------------------
  function wharffEvent (r, c)
  {
    if (!c)
    {
     var a = String(r).split('.');

     this.r  = Number(a[0]).valueOf();
     this.c  = Number(a[1]).valueOf();
     this.id = r;
     return;
    }

    this.r  = r;
    this.c  = c;
    this.id = r+'.'+c;

  }

  wharffEvent.prototype.r           = 0;
  wharffEvent.prototype.c           = 0;
  wharffEvent.prototype.id          = undefined;
  wharffEvent.prototype.time        = undefined;
  wharffEvent.prototype.room        = undefined;
  wharffEvent.prototype.eventName   = '' ;
  wharffEvent.prototype.description = '' ;
  wharffEvent.prototype.track       = '' ;
  wharffEvent.prototype.presenter   = '' ;
  wharffEvent.prototype.bio         = '' ;
  wharffEvent.prototype.limit       = 0 ;
  wharffEvent.prototype.taken       = 0 ;
  wharffEvent.prototype.style       = '';
  wharffEvent.prototype.script      = '';

  //--------------------------------------------------------------------

  wharffEvent.prototype.isAvailable = function()
  {
    return this.taken < this.limit;
  };

  //--------------------------------------------------------------------

  wharffEvent.prototype.rawTime = function()
  {
    var v = this.date.split(/[: ]/);
    v[0]  = v[2].search(/pm/i) ? v[0]+12 : v[0];

    return new Date(2008,10,2,v[0], v[1], 0);
  };

  //--------------------------------------------------------------------
  //- Class: wharffEventCollection: A group of wharffEvents
  //--------------------------------------------------------------------

  function wharffEventCollection ()
  {
    this.events = [];
  }

  wharffEventCollection.prototype.events = [];
  wharffEventCollection.prototype.script = '';

  //--------------------------------------------------------------------

  wharffEventCollection.prototype.addEvent = function(anEvent)
  {
   if (this.getEventById(anEvent.id))
    return anEvent;

   if (!this.events[anEvent.r])
    this.events[anEvent.r] = [];

   this.events[anEvent.r][anEvent.c] = anEvent;

   return anEvent;
  };

  //--------------------------------------------------------------------

  wharffEventCollection.prototype.getEventAt = function(row, col)
  {
    if (this.events[row])
     return this.events[row][col];

    return false;
  };

  //--------------------------------------------------------------------

  wharffEventCollection.prototype.getRow = function(row)
  {
    return this.events[row];
  }

  //--------------------------------------------------------------------

  wharffEventCollection.prototype.getColumn = function(col)
  {
    var a = [];

    for (i=0; i<this.events.length; i++)
    {
      a.push(this.events[i][col]);
    }

    return a;
  }

  //--------------------------------------------------------------------

  wharffEventCollection.prototype.rows = function()
  {
    return this.events.length;
  }

  //--------------------------------------------------------------------

  wharffEventCollection.prototype.columns = function()
  {
    var x = 0;

    for (i=0; i<this.events.length; i++)
    {
      if (this.events[i])
       x = Math.max(x, this.events[i].length);
    }

    return x;
  }

  //--------------------------------------------------------------------

  wharffEventCollection.prototype.getEventById = function(eventId)
  {
    for (i=0; i<this.events.length; i++)
    {
     if (!this.events[i])
      continue;

     for (j=0; j<this.events[i].length; j++)
     {
      if (this.events[i][j] && this.events[i][j].id == eventId)
       return this.events[i][j];
     }
    }

    return false;
  };

  //--------------------------------------------------------------------

  wharffEventCollection.prototype.getEventByName = function(eventName)
  {
    var re = new RegExp('^'+eventName+'$','i');

    for (i=0; i<this.events.length; i++)
    {
     if (!this.events[i])
      continue;

     for (j=0; j<this.events[i].length; j++)
     {
      if (re.test(this.events[i][j].eventName))
       return this.events[i][j];
     }
    }

    return false;
  };

  //--------------------------------------------------------------------

  wharffEventCollection.prototype.getTracks = function()
  {
    var t  = [];

    for (i=0; i<this.events.length; i++)
    {
     if (!this.events[i])
      continue;

     for (j=0; j<this.events[i].length; j++)
     {
      var m = false;
      var e = this.events[i][j];

      if (!e)
       continue;

      if (!e.track)
       continue;

      e = e.track.toLowerCase();

      for (k=0; k<t.length; k++)
      {
        if (t[k].toLowerCase() == e)
        {
         m = true;
         break;
        }
      }

      if (!m)
       t.push(this.events[i][j].track);
     }
    }

    return t;
  };

  //--------------------------------------------------------------------

  wharffEventCollection.prototype.byId = function(a,b)
  {
   return a.id() - b.id();
  };

  //--------------------------------------------------------------------

  wharffEventCollection.prototype.sorted = function()
  {
    return this.events.sort(this.byId);
  };

  //--------------------------------------------------------------------

//----------------------------------------------------------------------


