// Converts integer to roman numeral function romanize(num) { var lookup = {M:1000,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1}, roman = '', i; for ( i in lookup ) { while ( num >= lookup[i] ) { roman += i; num -= lookup[i]; } } return roman; } // Builds a "); } $('#toc').append(toc); }; // Executes the createToc function setTimeout(function(){createTOC();},100); // Rebuild to TOC every minute setInterval(function(){createTOC();},60000);