// JQuery function for removing empty "children" ul as it shows in silly IE
$(document).ready(function(){
  $("#children:empty").remove();
});

// JQuery function for removing duplicate navigation items
$(document).ready(function(){
  var cursib = $("a.current").text();
  $("a.sibling").each(function(){
    if ($(this).text() == cursib) {
      $(this).parent().remove();
    }
  });
  var curpar = $("a.c-p-inactive").text();
  $("a.top-level").each(function(){
    if ($(this).text() == curpar) {
      $(this).parent().remove();
    }
  });
});

// JQuery function for restyling byte-based file sizes to be readable
$(document).ready(function(){
  $(".assetsize").each(function(){
    var spancontents = $(this).text();
    var filesize = spancontents.replace(/ bytes/i, '') / 1024; // KB filesize
    filesize = Math.round(filesize * 10) / 10; // round
    if (filesize > 1000) {
      filesize = filesize / 1024; // MB filesize
      filesize = Math.round(filesize * 10) / 10; // round
      $(this).empty().text(filesize + " MB"); // or could be in MiB to be correct
    } else {
    $(this).empty().text(filesize + " KB"); // or could be in KiB to be correct
    }
  });
});
