// ? 1995-2009 Healthwise, Incorporated. Healthwise, Healthwise for every health decision, 
// and the Healthwise logo are trademarks of Healthwise, Incorporated.

org.healthwise.include = function(fileName) {
    // If filename starts with letter it is considered relative
    // to the /inc directory, otherwise it is considered a ready path
    if (!fileName.match(/^([^\w]|http\:)/))
		fileName = org.healthwise.config.root + "/inc/" + fileName;
    var script = '<script type="text/javascript" src="' + fileName + '"></script>';
    document.write(script);
};

org.healthwise.includedModules = {};

org.healthwise.includeModule = function(name, fileName) {
    if (fileName) {
        org.healthwise.include(fileName);
        org.healthwise.includedModules[name] = fileName;
    } else {
        // If no fileName is provide, mark module as disabled, preventing 
        // subsequent calls to includeModule from loading the module.
        org.healthwise.includedModules[name] = '[disabled]';
    }
};

org.healthwise.module = function(name, implementation) {
    org.healthwise[name] = implementation;
    org.healthwise.includedModules[name] = true;
};


(function($hw) {

    // jQuery and required stuff
    if (typeof jQuery == 'undefined') {
        $hw.include('control/jquery-1.3.2.min.js'); //Compressed for performance
    }

    var docTypeLower = org.healthwise.document.doctype.toLowerCase();
    if (docTypeLower != 'aftervisit' &&
        docTypeLower != 'pi-pre-op' &&
        docTypeLower != 'pi-post-op' &&
        docTypeLower != 'pi-pre-test') {
        
//<Hw.Includes>
$hw.include('control/hw.kb.js');
//</Hw.Includes>


        

        // load modules specified by app if defined previously
        if (typeof (org.healthwise.modulesToLoad) != 'undefined') {
            for (var module in org.healthwise.modulesToLoad) {
                $hw.includeModule(module, org.healthwise.modulesToLoad[module]);
            }
        }
    }

    // Customizations
    $hw.include('custom/custom.js');

})(org.healthwise);


