//Namespace geral do sistema
ProfRose = {};
//Namespace que contem as classes do sistema
ProfRose.classes = {};
//Namespace que contem as variaveis que devem ser persistida entre telas
ProfRose.vars = {};
//Namespace que guarda status do funcionamento do sistema
ProfRose.Regedit = {};
ProfRose.Regedit.debug = true;
//Namespace que armazena o Loader javascript default do sistema
ProfRose.Loader = null;

//Define se as dependencias da pagina foram carregadas.
//Zero significa que todas as dependencias foram carregadas
//Qualquer valor negativo significa que ainda necessitam ser carregadas dependencias
ProfRose.Regedit.dep_ready = 0;




/**
 * Funcao responsavel por carregar modulos do YUI toolkit, assim como modulos externos registrados
 *
 * Exemplo de carregamento de modulo registrado:
 * ProfRose.Loader.require("treeview");
 * ProfRose.Loader.onSuccess = treeInit;
 * ProfRose.Loader.insert();
 *
 * Exemplo de como registrar um modulo para posterior carregamento
 * //Add the module to YUILoader
 * ProfRose.Loader.addModule({
 *     name: "json", //module name; must be unique
 *     type: "js", //can be "js" or "css"
 *     fullpath: "http://www.json.org/json2.js", //can use a path instead, extending base path
 *     varName: "JSON", // a variable that will be available when the script is loaded.  Needed
 *                     // in order to act on the script immediately in Safari 2.x and below.
 *     requires: ['treeview'] //if this module had dependencies, we could define here
 * });
 *
 * //include the new  module
 * ProfRose.Loader.require("json");
 *
 * //set the function that should exectute when the file loads
 * ProfRose.Loader.onSuccess = YAHOO.example.onJsonLoad;
 *
 * //Insert JSON utility on the page
 * ProfRose.Loader.insert();
 */
getDefaultLoader = function(){
    //Registra o YUILoader, configurado para o sistema
    var Loader = new parent.frame_js.parent.frame_js.YAHOO.util.YUILoader({
        // Set where YUI files should be load from
        base:CONF["YUI_2.7.0_URL"]

        ,overrides: {
            treeview: []
        }

    });

    //Registra modulos do sistema para serem carregados via YAHOOLoader
    Loader.addModule({
        name: "Form", //module name; must be unique
        type: "js", //can be "js" or "css"
        fullpath: CONF["JS_URL"]+"Form.class.js", //can use a path instead, extending base path
        varName: "FORM", // a variable that will be available when the script is loaded.  Needed
                    // in order to act on the script immediately in Safari 2.x and below.
        requires: ['dom'] //if this module had dependencies, we could define here
    });

    Loader.addModule({
        name: "Carregando", //module name; must be unique
        type: "js", //can be "js" or "css"
        fullpath: CONF["JS_URL"]+"Carregando.class.js", //can use a path instead, extending base path
        varName: "CARREGANDO", // a variable that will be available when the script is loaded.  Needed
                    // in order to act on the script immediately in Safari 2.x and below.
        requires: ['dom','event'] //if this module had dependencies, we could define here
    });

    Loader.addModule({
      name: "Treeview", //module name; must be unique
      type: "js", //can be "js" or "css"
      fullpath: CONF["JS_URL"]+"Treeview.class.js", //can use a path instead, extending base path
      requires: ['treeview','css_treeview'] //if this module had dependencies, we could define here
   });

    Loader.addModule({
      name: "css_treeview", //module name; must be unique
      type: "css", //can be "js" or "css"
      fullpath: CONF["CSS_URL"]+"especiais/tree.css.php", //can use a path instead, extending base path
      requires: [] //if this module had dependencies, we could define here
   });

    Loader.addModule({
      name: "Util", //module name; must be unique
      type: "js", //can be "js" or "css"
      fullpath: CONF["JS_URL"]+"Util.class.js", //can use a path instead, extending base path
      requires: ['dom'] //if this module had dependencies, we could define here
   });

    Loader.addModule({
      name: "Conn", //module name; must be unique
      type: "js", //can be "js" or "css"
      fullpath: CONF["JS_URL"]+"Conn.class.js", //can use a path instead, extending base path
      requires: ['Util','connection','json'] //if this module had dependencies, we could define here
   });

    Loader.addModule({
      name: "BuscarCep", //module name; must be unique
      type: "js", //can be "js" or "css"
      fullpath: CONF["JS_URL"]+"BuscarCep.class.js", //can use a path instead, extending base path
      requires: ['Util','Conn','Carregando','event','dom'] //if this module had dependencies, we could define here
   });

    Loader.addModule({
      name: "ComponenteIndique", //module name; must be unique
      type: "js", //can be "js" or "css"
      fullpath: CONF["JS_URL"]+"ComponenteIndique.class.js", //can use a path instead, extending base path
      requires: ['containercore','dom'] //if this module had dependencies, we could define here
   });


    
    return Loader;
}
//Registra o Loader padrao do sistema
ProfRose.Loader = getDefaultLoader();
ProfRose.Loader.require("Carregando","Util");
ProfRose.Loader.onSuccess = function(){
    try{
        ProfRose.vars.pagina_carregada = true;
        if(parent.frame_main.src == undefined){
            parent.frame_main.location.href = CONF["VISUALIZACAO_URL"]+"institucional/index.php";
        }
    }
    catch(e){
        setTimeout(ProfRose.Loader.onSuccess,100);
    }
};
ProfRose.Loader.insert();
