dojo.provide("parus.balanceIndexConsComparationPrint");

dojo.require("parus.parus8");
dojo.require("parus.database");

dojo.require("parus.balanceIndexConsComparation");

dojo.mixin(parus, {

  balanceIndexConsComparationPrint: {

    print: function() {

      var query;
      var html;
      var handler;

      dojo.xhrGet({

        url: "../.system/session.xml",
        handleAs: "xml",
        sync: true,
        preventCache: true,

        load: function(response) {

          if (!dojo.isIE) response.normalize();

          var LNodes = response.documentElement.getElementsByTagName("*");

          for (var i = 0; i != LNodes.length; i++)
          if (LNodes[i].nodeName == "querydata") query = LNodes[i].childNodes.item(0).nodeValue
          else if (LNodes[i].nodeName == "handler") handler = LNodes[i].childNodes.item(0).nodeValue
          else if (LNodes[i].nodeName == "htmldata") html = LNodes[i].childNodes.item(0).nodeValue

          return (response);

        }
      });

      if (query) {
        parus.database.connected = handler;
        html = parus.balanceIndexConsComparation.printRender(dojo.fromJson(query), false);
      };

      if (html) document.body.insertAdjacentHTML("afterBegin", html);

    }

  }
});