function pad(num, n) { return Array(n>(num.toString()).split('').length?(n-(''+num).length+1):0).join(0)+num; }