﻿(function() {
    if (typeof (this.ModuleSchedulePublic.Intervention) == "undefined") {
    this.ModuleSchedulePublic.Intervention = {};
    }

    // Affichage de la fenetre modale du detail d'une intervention
    ModuleSchedulePublic.Intervention.DisplayAbstract = function(presentationAbout, interventionTitle) {
        dojo.require("dijit.Dialog");

        var divPresentation = document.createElement('div');
        divPresentation.id = 'divPresentation';
        divPresentation.name = 'divPresentation';

        var divPresentationChild = document.createElement('div');
        divPresentationChild.id = 'divPresentationChild';
        divPresentationChild.name = 'divPresentationChild';
        divPresentation.appendChild(divPresentationChild);

        document.getElementsByTagName('body')[0].appendChild(divPresentation);

        //creation de la modalPopup
        if (dijit.byId('divPresentation') != undefined) {
            dijit.byId("divPresentation").destroy();
        }
        var PresentationDialog = new dijit.Dialog({}, dojo.byId('divPresentation'));
        if (ModuleSchedulePublic.i18n.dijitCloseByClick) {
            dojo.connect(dojo.byId('divPresentation'), 'onclick', function() {
                dijit.byId('divPresentation').hide();
            });
        }

        var url = 'DisplayAbstract.phtml?presentationAbout=' + presentationAbout + '&random=' + Math.random();
        var form = ModuleSchedulePublic.CreateDummyForm('dummyForm', url);
        var d = cyim.ajax.xhrPost({ form: form, url: url, handleAs: "text" });
        d.addCallback(dojo.hitch(cyim.ajax, "getDataBack", document.getElementById('divPresentationChild'), function() {
            PresentationDialog.show();
            PresentationDialog.titleNode.innerHTML = interventionTitle
        }
        ));
        d.addErrback(function() { ModuleSchedulePublic.Common.Manage.ErrorLog(); });
    }

})();
