//action: the url of the event
//id : the css id that needs to be redrawn (when null, nothing is displayed)
//display : the rawlet that needs to be displayed in the id tag (default = event rawlet)

//var Table = {};
var RawDev = {};

RawDev.hide = function(a) {
    var n=a.length;
    for(var i=0; i<n; i++) {
	$('#'+a[i]).hide();
    }
}

RawDev.table = function(role, table, onProcess) {
    $('#flash-error').hide();
    return new Table(role, table, onProcess);
}

RawDev.error = function(message) {
    $('#flash-error').html(message).show();
}

RawDev.info = function(message) {
  $('#flash-info').html(message);
}

RawDev.ajax = function (action, id, display) {
  if (!id) {
    jquery.get(action + ';');
  }
  else if (display) {
    jquery.get(action + ';');
    $('#'+id).load(display);
  }
  else {
    $('#'+id).load(action + '&');
  }
}

RawDev.ajaxForm = function(action, id, display) {
    var data = $('#form').formToArray();
  if (!id) {
    jquery.post(action + ';');
  }
  else if (display) {
    jquery.post(action + ';');
    $('#'+id).load(display);
  }
  else {
      $('#'+id).load(action + '&', data);
  }

}

    // this jquery extension allows for binding of an object to an event
   // e.g. $.context(this).callback('process')
    jQuery.extend(
    {
      context: function (context)
      {
        var co = 
        {
          callback: function (method)
          {
            if (typeof method == 'string') method = context[method];
            var cb = function () { method.apply(context, arguments); }
            return cb;
          }
        };
        return co;
      }
    }); 


