You can use a loop on the buttons so you don't need to repeat it. If you made the square block an individual image you'd use something like this
The square block would be 32x32, leaving 2 pixels inbetween each
HTML Code:
temp.boxes = 5; //How many boxes to show
temp.vertical = true; //False for horizontal
temp.opos = {32, 32}; //X & Y of the origional position of the boxes
for (temp.i = 0; temp.i < temp.boxes; temp.i++) { //Would show four boxes
temp.add = temp.i * 34;
temp.img = showimg(200 + temp.i, "boximage.png", (!temp.vertical? temp.opos[0] + temp.add: temp.opos[0]), (!temp.vertical? temp.opos[1]: temp.opos[1] + temp.add));
temp.img.layer = 4;
}
Not tested, but it should work.
