<script type="text/javascript"> type="text/javascript">
function pad( a ){
  var t, b = '';

  a = ''+a;

  if( a.length>=3 ) {
    return a;
  } else {
    t = pad( '0' + a ); 
  }

  return t;
}

document.writeln( pad( 1 ) + '<br />' );
document.writeln( pad( 2 ) + '<br />' );
document.writeln( pad( 10 ) + '<br />' );
document.writeln( pad( 100 ) );
</script>