var class_generic = function(){
    this._fdata = "";
    this._finit = "";
    this._fcancel = "";
    this._ffinish = "";
    
}

class_generic.prototype.setData = function(param){
    this._fdata = param;
}

class_generic.prototype.onInit = function(func){
    this._finit = func;
}

class_generic.prototype.onFinish = function(func){
    
    this._ffinish = func;
    
}

class_generic.prototype.onCancel = function(func){
    this._fcancel = func;
}

class_generic.prototype.cancel = function(data){
    if (typeof this._fcancel=='function')
        this._fcancel(data);
}
class_generic.prototype.finish = function(data){
    if (typeof this._ffinish=='function')
        this._ffinish(data);
}

class_generic.prototype.init = function(data){
    if (typeof this._finit=='function')
        this._finit(data);
}

class_generic.prototype.copy = function(){
    function F() {}
    F.prototype = this;
    return new F();
}
var generic = new class_generic;

function load_mod(mod, content, params){
    $.ajax({
        url : _url_sitio + "core/modules/rmod.php?init=1&mod="+mod,
        data : params,
        type: "post",
        success: function(rtn){
            $(content).html(rtn);
        }
    });
}


//load local app: 
//mod : carpeta app, 
//containter : selector jquery del contenedor
//params : variables POST que se pasaran al inicio del modulo.
//callback : funcion de retorno,
//cancel : funcion de cancel
function load_app(mod, containter, params, finit, ffinish, fcancel, js_extra){
    $.ajax({
        url : _url_sitio + mod + "/x_init_mod",
        data : {
            params : params,
            modulo : mod
        },
        type: "post",
        success: function(rtn){
           // var finit, ffinish, fcancel = "";
            if (typeof finit=='undefined'){
                finit = "_"+mod+".init(param)";
            }
            if (typeof ffinish=='undefined'){
                ffinish = "_"+mod+".finish(param)";
            }
            if (typeof fcancel=='undefined'){
                fcancel = "_"+mod+".cancel(param)";
            }
            generic.onInit(finit)
            generic.onFinish(ffinish)
            generic.onCancel(fcancel)
            generic.containter = containter;
            if (typeof js_extra!='undefined')
                generic.extras = js_extra;
            
            
            $(containter).html(rtn);
            generic.init();
            

        }
    });
}

function stopBubble(e) {
    if (e){
     e.stopPropagation();
   }
    else{
     window.event.cancelBubble = true;
  }
}



