if (dts_mode == "default") {
    connect(window, "populated", function(e) {
        forEach($$(".dts_document"), function(doc) {
            var title = scrapeText(getElementsByTagAndClassName(null, "dts_field_data_titre", doc)[0]);
            var link = getElementsByTagAndClassName(null, "dts_field_data_file2", doc)[0].childNodes[0];
            var buildForm = function() {
                var cookie = parseQueryString(document.cookie);
                cookie["from"] = (cookie["from"]) ? cookie["from"].split(";")[0] : "";
                if (/(MSIE)/.test(navigator.userAgent) && cookie["address"]) {
                    cookie["address"] = cookie["address"].replace(/\n/g, "");
                }
                var form = 
                    FORM({"method": "POST", "action": "http://toolbox.keirn.fr/sendmail/"}, 
                        DIV(null,
                            "Afin de vous tenir informé d'éventuelles " +
                            "modifications apportées à ce marché, merci de " +
                            "renseigner les informations suivantes."
                        ),
                        FIELDSET(null, 
                            DIV(null, 
                                LABEL({"for": "name"}, "Vos noms et prénoms :"),
                                INPUT({"type": "text", "id": "name", "name": "name", 
                                    "value": cookie["name"] || ""})
                            ),
                            DIV(null,
                                LABEL({"for": "address"}, "Nom et adresse de votre entreprise :"),
                                TEXTAREA({"id": "address", "name": "address"}, 
                                    cookie["address"] || "")
                            ),
                            DIV(null,
                                LABEL({"for": "phone"}, "Numéro de téléphone :"),
                                INPUT({"type": "text", "id": "phone", "name": "phone", 
                                    "value": cookie["phone"] || ""})
                            ),
                            DIV(null,
                                LABEL({"for": "from"}, "Votre adresse électronique :"),
                                INPUT({"type": "text", "id": "from", "name": "from", 
                                    "value": cookie["from"] || ""})
                            ),
                            INPUT({"type": "hidden", "name": "to", "value": "marches.publics@ccl-valleedoree.fr"}),
                            INPUT({"type": "hidden", "name": "subject", "value": "[marché public] " + title}),
                            INPUT({"type": "hidden", "name": "title", "value": title}),
                            INPUT({"type": "hidden", "name": "url", "value": link.href}),
                            INPUT({"type": "hidden", "name": "body", "value": "L'archive de ce marché public a été téléchargée. Voici les informations renseignées lors de ce téléchargement."})
                        ),
                        INPUT({"type": "submit", "name": "", "value": (/(MSIE)/.test(navigator.userAgent)) ? "Envoyer" : "Télécharger"})
                    );
                setStyle(form, {
                    "clear": "both"
                });
                connect(form, "onsubmit", function(e) {
                    try {
                        var data = formContents(form);
                        document.cookie = queryString(data);
                        data[0].push("_signal");
                        data[1].push("mailSent");
                        appendChildNodes($$("body")[0], createDOM("SCRIPT", {
                            "type": "text/javascript",
                            "src": form.action + "?" + queryString(data)
                        }));
                    }
                    catch(err) {
                        alert(err);
                    }
                    var _form = form;
                    var _link = link;
                    connect(window, "mailSent", bind(function(e) {
                        if (/(MSIE)/.test(navigator.userAgent)) {
                            var link = A({"href": _link.href}, "Télécharger");
                            connect(link, "onclick", function(e) {
                                removeElement(_form);
                            });
                            removeElement(_form.childNodes[2]);
                            appendChildNodes(_form, link);
                        }
                        else {
                            removeElement(_form);
                            location.href = _link.href;
                        }
                    }, this));
                    e.stop();
                });
                return form;
            };
            connect(link, "onclick", function(e) {
                var form = getElementsByTagAndClassName("form", null, doc)[0];
                if (! form) {
                    form = buildForm();
                    appendChildNodes(doc, form);
                }
                else {
                    removeElement(form)
                }
                e.stop();
            });
        });
    });
}
