(function() {

  var lang = YAHOO.lang,
      util = YAHOO.util,
      YUILoader = util.YUILoader;

  var IXL = {

    useIXLBase: {},

    info: {

      root: '2.8.0r4/build/',
      base: '/yui2.8.0/', //'http://yui.yahooapis.com/2.8.0r4/build/',
      ixlBase: '/static/math/',

      comboBase: 'http://yui.yahooapis.com/combo?',

      skin: {
          'defaultSkin': 'sam',
          'base': 'assets/skins/',
          'path': 'skin.css',
          'after': ['reset', 'fonts', 'grids', 'base'],
          'rollup': 3
      },

      moduleInfo: {

        /*********************************************************************
         *                        Common modules                             *
         *********************************************************************/

        "helpfile": {
          type: "js",
          fullpath: "/static/help/helpFile.js",
          varName: "getHelpFileByKey"
        },

        "ixlutils": {
          type: "js",
          path: "common/utils.js",
          requires: ["cookie","dom","event","yahoo"],
          varName: "YAHOO.ixl.topic"
        },

        "flowdialog": {
          type: "js",
          path: "common/flowdialog.js",
          requires: ["animation", "button", "connection", "container", "dragdrop", "ixlutils"],
          optional: ["json"]
        },

        "login": {
          type: "js",
          path: "account/login.js",
          requires: ["flowdialog", "ixlutils", "cookie"],
          varName: "redirectByUserType"
        },

        "marketing": {
          type: "js",
          path: "marketing/marketing.js",
          requires: ["flowdialog"],
          varName: "YAHOO.widget.FlowDialog"
        },

        "profile": {
          type: "js",
          path: "account/profile.js",
          requires: ["flowdialog", "ixlutils", "carousel", "json", "cookie"],
          varName: "profileDialog"
        },

        "accordion": {
          type: "js",
          path: "navigation/accordion.js",
          requires: ["ixlutils", "cookie", "flowdialog"]
        },

        "screenshots": {
          type: "js",
          path: "navigation/skillscreenshots.js",
          requires: ["container"],
          varName: "YAHOO.ixl.widget.ScreenshotTooltip"
        },

        /*********************************************************************
         *                        Specific modules                           *
         *********************************************************************/

        "account": {
              type: "js",
              path: "account/account.js",
              requires: ["flowdialog", "utilities", "json"],
              varName: "printReceipt"
            },

        "labadmin": {
          type: "js",
          path: "admin/admin.js",
          requires: ["datasource", "datatable"],
          varName: "YAHOO.widget.DataTable"
        },

        "awardsgame": {
          type: "js",
          path: "awards/game.js",
          requires: ["ixlutils", "datasource", "datatable", "json", "tabview", "history", "flowdialog"],
          varName: "YAHOO.widget.GameBoard"
        },

        "noaccess": {
          type: "js",
          path: "common/noAccess.js",
          requires: ["flowdialog", "ixlutils"],
          varName: "YAHOO.widget.FlowDialog"
        },

        "comingsoon": {
          type: "js",
          path: "marketing/comingsoon.js",
          requires: ["accordion", "button", "connection", "dom", "event"],
          varName: "csLoaded"
        },

        "playtimer": {
          type: "js",
          path: "practice/playtimer.js",
          requires: ["ixlutils"],
          varName: "YAHOO.ixl.PlayTimer"
        },

        "playevents": {
          type: "js",
          path: "practice/playevents.js",
          requires: ["connection", "cookie", "dom", "event", "flowdialog", "ixlutils", "json"],
          varName: "YAHOO.ixl.correctAccolades"
        },

        "qgtest": {
          type: "js",
          path: "practice/qgtest.js",
          requires: ["utilities", "container", "autocomplete"],
          varName: "writetxt"
        },

        "multiplestandards": {
          type: "js",
          path: "standards/multiplestandards.js",
          requires: ["connection", "cookie", "dom", "event"],
          varName: "YAHOO.ixl.multiStds"
        },

        "standards": {
          type: "js",
          path: "standards/standards.js",
          requires: ["event", "container"],
          varName: "YAHOO.widget.FlowDialog"
        },

        "roster": {
          type: "js",
          path: "roster/roster.js",
          requires: ["connection", "dom", "event", "flowdialog"],
          varName: "YAHOO.widget.FlowDialog"
        },

        "masterlist": {
          type: "js",
          path: "roster/ixlmasterlist.js",
          requires: ["autocomplete"],
          varName: "YAHOO.widget.RosterAutoComplete"
        },


        // Subscription JS

        "activation": {
          type: "js",
          path: "subscription/activation.js",
          requires: ["utilities", "ixlutils", "json"],
          varName: "YAHOO.util.Connect"
        },

        "classroom": {
          type: "js",
          path: "subscription/classroom.js",
          requires: ["event", "dom"],
          varName: "YAHOO.util.Event"
        },

        "stepone": {
          type: "js",
          path: "subscription/stepone.js",
          requires: ["container", "event", "dom"],
          varName: "YAHOO.util.Event"
        },

        "steptwo": {
          type: "js",
          path: "subscription/steptwo.js",
          requires: ["container", "event", "dom", "json"],
          varName: "YAHOO.util.Event"
        },

        "removechildren": {
          type: "js",
          path: "subscription/removechildren.js",
          requires: ["flowdialog", "ixlutils"],
          varName: "YAHOO.widget.FlowDialog"
        },

        // Reports
        "reportsettings": {
          type: "js",
          path: "reports/reportsettings.js",
          requires: ["flowdialog", "history", "cookie"],
          varName: "YAHOO.ixl.WaitMask"
        },

        "ixldatatable": {
          type: "js",
          path: "common/ixlDataTable.js",
          requires: ["datasource", "datatable", "json", "cookie"],
          optional: ["screenshots"],
          varName: "YAHOO.ixl.widget.DataTable"
        },

        "prototype": {
          type: "js",
          fullpath: "/script/prototype.js",
          varName: "Prototype"
        },

        "plotr": {
          type: "js",
          path: "common/plotr_uncompressed.js",
          requires: ["prototype"],
          varName: "Plotr"
        },

        "ixlchart": {
          type: "js",
          path: "reports/ixlchart.js",
          requires: ["plotr"],
          varName: "Plotr.IXLLineChart"
        },

        "advreports": {
          type: "js",
          path: "reports/advreports.js",
          requires: ["cookie", "accordion"],
          varName: "YAHOO.widget.AdvancedReport"
        },

        "advreportlanding": {
          type: "js",
          path: "reports/advreportlanding.js",
          requires: ['utilities','accordion','datasource'],
          varName: "setImage"
        },

        "a8": {
          type: "js",
          path: "reports/usage/a8.js",
          requires: ["ixldatatable", "paginator"],
          varName: "YAHOO.ixl.ProblemDetailsDataTable"
        },

        // Old reports

        "completionPieChart": {
          type: "js",
          path: "reports/skills/completionPieChart.js",
          requires: ['connection', 'datasource', 'dom', 'event', 'reportsettings', 'ixlchart'],
          varName: "YAHOO.ixl.CompletionReport"
        },

        "overview": {
          type: "js",
          path: "reports/overview/overview.js",
          requires: ['completionPieChart', 'screenshots', 'flowdialog', 'ixldatatable'],
          varName: "YAHOO.ixl.OverviewReport"
        },

        "problemsBarchart": {
          type: "js",
          path: "reports/problems/problemsBarchart.js",
          requires: ['connection', 'datasource', 'dom', 'event', 'reportsettings', 'ixlchart'],
          varName: "YAHOO.ixl.PracticedBarchart"
        },

        "skillsDataTable": {
          type: "js",
          path: "reports/skills/skillsDataTable.js",
          requires: ['screenshots', 'reportsettings', 'ixldatatable'],
          varName: "YAHOO.ixl.SkillReportDataTable"
        },

        "problemsDataTable": {
          type: "js",
          path: "reports/problems/problemsDataTable.js",
          requires: ['screenshots', 'reportsettings', 'ixldatatable'],
          varName: "YAHOO.ixl.SkillReportDataTable"
        },

        "skillDetailsDataTable": {
          type: "js",
          path: "reports/skillDetails/skillDetailsDataTable.js",
          requires: ['ixldatatable', 'reportsettings'],
          varName: "YAHOO.ixl.SkillReportDataTable"
        },

        "performanceReportGraph": {
          type: "js",
          path: "reports/skillDetails/performanceReportGraph.js",
          requires: ['utilities', 'datasource', 'reportsettings', 'ixlchart'],
          varName: "YAHOO.ixl.PerformanceReport"
        },

        "statestandards": {
          type: "js",
          path: "reports/state/statestandards.js",
          requires: ['screenshots', 'reportsettings', 'ixldatatable'],
          varName: "YAHOO.ixl.StateStandardsReport"
        },

        "studentsSummaryDataTable": {
          type: "js",
          path: "reports/student/studentsSummaryDataTable.js",
          requires: ['reportsettings', 'ixldatatable'],
          varName: "YAHOO.ixl.StudentReportDataTable"
        },

        "problemSummaryDataTable": {
          type: "js",
          path: "reports/summary/problemSummaryDataTable.js",
          requires: ['ixldatatable', 'reportsettings', 'tabview', 'paginator'],
          varName: "YAHOO.ixl.ProblemDetailsDataTable"
        },

        "timeSpentSkillsDataTable": {
          type: "js",
          path: "reports/timespent/timeSpentSkillsDataTable.js",
          requires: ['screenshots', 'ixldatatable', 'reportsettings'],
          varName: "YAHOO.ixl.SkillReportDataTable"
        },

        "loginBarchart": {
          type: "js",
          path: "reports/timespent/loginBarchart.js",
          requires: ['utilities', 'datasource', 'reportsettings', 'ixlchart'],
          varName: "YAHOO.ixl.LoginBarchart"
        },

        "loginSummaryDataTable": {
          type: "js",
          path: "reports/timespent/loginSummaryDataTable.js",
          requires: ['ixldatatable', 'reportsettings'],
          varName: "YAHOO.ixl.LoginSummaryDataTable"
        }

      }
    }
  };

  // Populate the useIXLBase field
  for (var name in IXL.info.moduleInfo) {
    IXL.useIXLBase[IXL.info.moduleInfo[name].path] = true;
  }

  var IXLLoader = function(o) {
    IXLLoader.superclass.constructor.call(this, o);

    this.base = IXL.info.base;
    this.ixlBase = IXL.info.ixlBase;
    this.comboBase = IXL.info.comboBase;
    this.root = IXL.info.root;
    this.moduleInfo = lang.merge(this.moduleInfo, IXL.info.moduleInfo);
    this.skin = lang.merge(this.skin, IXL.info.skin);
  };

  YAHOO.extend(IXLLoader, YUILoader, {
    _url: function(path) {
      var base = this.base || "";
      if (IXL.useIXLBase[path]) base = this.ixlBase;
      return this._filter(base + path);
    }
  });

  util.IXLLoader = IXLLoader;

})();
