﻿var enricofoschi = {}

/* Common methods -- START */
enricofoschi.defineNamespace = function(namespaceString) {
    var splittedNamespace = namespaceString.split(".");
    
    var initialNamespace = "";
    var initialIndex = 0;
    
    while(initialIndex < splittedNamespace.length) {
        if(initialIndex > 0) initialNamespace += ".";
        initialNamespace += splittedNamespace[initialIndex];
        
        eval("if(!"+initialNamespace+") "+initialNamespace+" = {}");
        
        initialIndex++;
    }
    
}
enricofoschi.redirectSite = function(newUrl) {
    top.location.href = newUrl;
}
/* Common methods -- END */

/* Deferred Javascript -- START */
enricofoschi.deferredJavascript = function() {
    this.init();
}
enricofoschi.deferredJavascript.prototype = {
    init : function() {
        deferredScripts = new Array();
        $(document).ready(function() {
            for(var i = 0; i < deferredScripts.length; i++) eval(deferredScripts[i]); 
        });
    },
    addInlineScript : function(scriptTxt) {
        deferredScripts.push(scriptTxt);
    },
    processScripts : function() {
        
    },
    deferredScripts:null
}
deferredJavascriptObj = new enricofoschi.deferredJavascript();
/* Deferred Javascript -- END */

/* Loader Manager -- START */
enricofoschi.commonLoader = function() {
    tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
    imgLoader = new Image();
    imgLoader.src = "Media/loadingAnimation.gif";
}
enricofoschi.loaderManager = function() {
    this.init();
}
enricofoschi.loaderManager.prototype = {
    init : function() {
        this.loaderFunctions = new Array();
        
        this.addMethod(enricofoschi.commonLoader);
        
        $(document).ready(function(){
            for(var i = 0; i < enricofoschi.loaderManagerObj.loaderFunctions.length; i++) {
                enricofoschi.loaderManagerObj.loaderFunctions[i]();
            }
        });
    },
    addMethod : function(method) {
        this.loaderFunctions.push(method);
    },
    loaderFunctions : null
}
enricofoschi.loaderManagerObj = new enricofoschi.loaderManager();
/* Loader Manager -- END */