var Ajax = new Object();

Ajax.DataPoster = function(dataType, sync)
{
  var _that = this;
  this.Success = null;
  this.Error = null;

  this.PostForm = function(form, sender)
  {
    _that.Post(form.action, $(form).serialize(), sender);
  }
    
  this.Post = function(url, data, sender)
  {
    if(url.indexOf(".aspx") == -1)
      url += ".aspx?rnd=" + Math.random(10000);

    if(dataType == "")
      dataType = "text";

    if(sync == null || sync == true)
    {
      $.ajax({
        context: sender,
        url: url,
        data: data,
        dataType: dataType,
        type: 'post',
        success: successCallbackHandler,
        error: errorCallbackHandler,
        mode: 'queue'
      });
    }
    else
    {
      return $.ajax({
        url: url,
        data: data,
        type: 'post',
        dataType: dataType,
        async: false
      });
    }
      
  }
    
  var successCallbackHandler = function(data)
  {
    if(_that.Success != null)
    {
        _that.Success(this, data);
    }
  }
    
  var errorCallbackHandler = function(httpObject, textStatus)
  {
    if(_that.Error != null)
    {
        _that.Error(this, textStatus);
    }
  }
}
