When I examine the source code for this page I think I can spot the problem. It looks like you are only redefining the image value in the loop like this:
This only will set the value for a single instance, you will need to copy all of the code that this part was taken from and have it all in the loop. The most important part is the line of code that should come before this:
var icon_0 = new GIcon();
You must have this and the other parts of the code inside of the loop for this to work.