// JavaScript Document

function AjaxHandler()
{
    this.URL = '';
    this.Params = {};
    this.Cache = false;
    this.Async = false;
    
    AjaxHandler.prototype.URL;
    AjaxHandler.prototype.Params;
    AjaxHandler.prototype.Cache;
    AjaxHandler.prototype.Async;
   
   
   
    AjaxHandler.prototype.SetParam = function(param, value)
    {
        value = this.HTMLDecode(value);
        this.Params[param.toLowerCase()] = value;
    }
    
    
    
    AjaxHandler.prototype.GetParam = function(paramName)
    {
        return this.Params[paramName.toLowerCase()];
    }
    
    
    
    AjaxHandler.prototype.Run = function(onCompleteFunction, onErrorFunction)
    {
        if(onErrorFunction == undefined)
        {
            onErrorFunction = function(a, b, c)
                {
                    alert('Er is een fout opgetreden.');
                }
        }
        
        jQuery.ajax({
          type: 'POST',
          url: this.URL,
          cache: this.Cache,
          async: this.Async,
          data: this.Params,
          success: onCompleteFunction,
          error: onErrorFunction,
          dataType: 'html'
        });        
    }
    
    
    AjaxHandler.prototype.HTMLDecode = function(strText)
    {
       return jQuery('<unknownNode />').text(strText).html();
    }
}
