    jQuery(document).ready(function($){
        while ($("p__g").length > 0) {
            $("p__g").each(function () {
                       $(this).replaceWith("<div class='pg'>" + $(this).html() + "</div>");
            })
        }
        $("p__g").each(function () {
                   $(this).replaceWith("<div class='pg'>" + $(this).html() + "</div>");
        });
        $("note_list").each(function () {
                   $(this).replaceWith("<div class='note_list'>" + $(this).html() + "</div>");
        });
        $("note_ref").each(function () {
                   $(this).replaceWith("<span class='note_ref'>" + $(this).html() + "</span>");
        });
        $("note_body").each(function () {
                   $(this).replaceWith("<div class='note_body'>" + $(this).html() + "</div>");
        });
        $(".note_ref").addClass("note_ref_closed");
        $(".note_body").addClass("note_body_closed");
        $(".note_ref").click(function(event){
          var noteRef = $(this); 
          var note = $(this).next();
          if (noteRef.hasClass("note_ref_closed")) {
           noteRef.removeClass("note_ref_closed");
           noteRef.addClass("note_ref_open");
           note.removeClass("note_body_closed");
           note.slideDown("fast"); 
           note.addClass("note_body_open"); 
          } else {
           noteRef.removeClass("note_ref_open");
           noteRef.addClass("note_ref_closed");
           note.removeClass("note_body_open");
           note.slideUp("fast"); 
           note.addClass("note_body_closed"); 
          }
         });
       });