Pad numbers in Javascript
function pad(num, size) { var s = "00000" + num; return s.substr(s.length-size); }