/*
(c) 1995-2011  Healthwise, Incorporated. Healthwise, Healthwise for every health decision,
and the Healthwise logo are trademarks of Healthwise, Incorporated.
Healthwise Resource Package Version: 9.1.200.6 (xml.kb)
*/

(function($hw) {

    org.healthwise.jsRoot = org.healthwise.config.root;

    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.jsRoot + "/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 provided, 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;
    };

    org.healthwise.getfamily = function(doctype) {
        if (typeof (org.healthwise.document.family) != "undefined")
            return org.healthwise.document.family;

        var docTypeLower = doctype.toLowerCase();
        if (docTypeLower == 'aftervisit' ||
        docTypeLower == 'pi-pre-op' ||
        docTypeLower == 'pi-post-op' ||
        docTypeLower == 'pi-pre-test')
            return 'pi';
        else
            return 'kb';

    };

    if (typeof jQuery == 'undefined') {
        $hw.include('control/jquery.library.min.js'); //Compressed for performance
    }

    //<Hw.Includes>
    $hw.include('control/main.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]);
        }
    }

   

})(org.healthwise);

