// PotoSIG -- SIG extensions for Rails. Written by Javier Goizueta
// IvyGIS --- Mapserver and PostGIS on Rails.  Written by Robert S. Thau.
// Copyright 2006, Japan Spatial Information Technology, Inc.
//
// Distributed without warranty under the terms of the GNU General Public
// License, version 2.  

var Notifier = Class.create();

Notifier.prototype = {

  initialize: function () { this.initialize_as_notifier(); },

  initialize_as_notifier: function () { this.listeners = []; },

  add_listener: function (listener) {
    this.listeners.push (listener);
  },

  broadcast: function (event_name, arg) {
    var handler_name = 'on_' + event_name;
    for (var i = 0; i < this.listeners.length; ++i)
      if (this.listeners[i][handler_name] != null)
        this.listeners[i][handler_name] (arg)
  }

};

var PageEvents = new Notifier();

PageEvents.set_privs = function (privs) {
  document.body.className = privs;
};
