+/* Show menu item for other versions of text.
+ * It's only present if there are any. */
+$("#menu-other").show();
+
+
+/* Load other version of text. */
+$(".display-other").click(function(e) {
+ e.preventDefault();
+ release_menu();
+
+ $("#other-text").show();
+ $("body").addClass('with-other-text');
+
+ $.ajax($(this).attr('data-other'), {
+ success: function(text) {
+ $("#other-text-body").html(text);
+ $("#other-text-waiter").hide();
+ $("#other-text-body").show();
+ loaded_text($("#other-text-body"));
+ }
+ });
+});
+
+
+/* Remove other version of text. */
+$(".other-text-close").click(function(e) {
+ release_menu();
+ e.preventDefault();
+ $("#other-text").hide();
+ $("body").removeClass('with-other-text');
+ $("#other-text-body").html("");
+});
+
+
+/* Release menu after clicking inside TOC. */
+$("#toc a").click(release_menu);
+
+
+if ($('#nota_red').length > 0) {
+ $("#menu-nota_red").show();
+}
+
+/* Show themes menu item, if there are any. */
+if ($('#themes li').length > 0) {
+ $("#menu-themes").show();
+}
+
+function loaded_text(text) {
+ /* Attach events to elements inside book texts here.
+ * This way they'll work for the other text when it's loaded. */
+
+ $(".theme-begin", text).click(function(e) {
+ e.preventDefault();
+ if ($(this).css("overflow") == "hidden" || $(this).hasClass('showing')) {
+ $(this).toggleClass("showing");
+ }
+ });
+
+}
+loaded_text("#book-text");
+