function cpiAjaxClass(){

  // cpiWebApps Base URL
  this.appUrl = '';

  this.load = function( url, data, callback ){
    cpiAjax.post(url,data,
      function(response){
        I = /<!-- (cpiJsId[a-f0-9]{13}) -->/.exec(response);
        Error = /<!-- cpiJsError ([^\n]*) -->/.exec(response);
        NoContent = /<!-- No content -->/.exec(response);
        // If identified content
        if( I ){
          I = I[1];
          $('body').append('<div id="'+I+'" style="display:none;" class="cpiWebApps"></div>');
          $('#'+I).html(response);
        
          if(typeof callback == 'function') {
            callback(I);
          }
        }
        // If error message
        else if( Error ){
          alert( 'Server error: ' + Error[1] );
        }
        // If 'identified' no content
        else if( NoContent ){
          if(typeof callback == 'function') {
            callback();
          }
        }
        // If non identified content
        else{
          if(typeof callback == 'function') {
            callback(response);
          }
        }
        
        //alert( response );
        return false;
  
      }
    );
    return false;
  }

  this.sendForm = function ( form, url, callback ){
    data = $(form).serialize();
    cpiAjax.post(url,data,callback);
  }
  
  this.post = function( url, data, callback ){
    url = this.appUrl+url;
    $.post( url, data,
      function( response ){
        callback( response );
      }
    );
  }
  
  this.reload = function(){
    window.location.reload()
  }

}

cpiAjax = new cpiAjaxClass();