﻿function addAccordian() {

    // Delete any existing content the range contains
    RTE.Cursor.get_range().deleteContent();

    // Get a handle on the current range of the cursor inside the RTE
    var rng = RTE.Cursor.get_range().$3_0;

    // Create DOM objects for the divs
    var doc = rng.ownerDocument;

    var titleDiv = doc.createElement("div");
    titleDiv.setAttribute("class", "ddaccordionTitle");
    titleDiv.innerHTML = "Title";

    var bodyDiv = doc.createElement("div");
    bodyDiv.setAttribute("class", "ddaccordionBody");
    bodyDiv.innerHTML = "<p><span class='date'>DD.MM.YYYY</span><a href='#'>Hyperlink</a><br/><span class='date'>DD.MM.YYYY</span><a href='#'>Hyperlink</a><br/><span class='date'>DD.MM.YYYY</span><a href='#'>Hyperlink</a><br/></p>";

    // Insert the divs into the RTE at the current cursor range position
    SP.UI.UIUtility.insertAfter(bodyDiv, rng);
    SP.UI.UIUtility.insertAfter(titleDiv, rng);
}
