Theming Image fields in page.tpl.php I need to have have something like this:

&lt;div class="gal-wrapper"&gt;
   &lt;div class="gallery" id="r1"&gt;&lt;img src="image01.jpg"&gt;&lt;/div&gt;
   &lt;div class="gallery" id="r2"&gt;&lt;img src="image02.jpg"&gt;&lt;/div&gt;
   &lt;div class="gallery" id="r3"&gt;&lt;img src="image03.jpg"&gt;&lt;/div&gt;
   &lt;div class="gallery" id="r4"&gt;&lt;img src="image04.jpg"&gt;&lt;/div&gt;....
&lt;/div&gt;


My CCK Image field name is filed_image.
In page.tpl.php I have the following code:

&lt;div class="gal-wrapper"&gt;
    &lt;?php foreach ((array)$node-&gt;field_image as $item) { ?&gt;
      &lt;div id="" class="gallery"&gt;&lt;?php print $item['view'] ?&gt;&lt;/div&gt;
    &lt;?php } ?&gt;
&lt;/div&gt;


So with this I am able to print all images form my Image Field. 

But I don't know how to dynamically change the value of id="r1", id="r2", id="r3" ....

That value must start from 1 and be auto increment. For example  if I have 3 images the id should be id="1", id="2", id="3" or If there are 10 images I need id from 1 to 10.
This code should do it:

&lt;div class="gal-wrapper"&gt;
    &lt;?php foreach ((array)$node-&gt;field_image as $item_id =&gt; $item) { ?&gt;
      &lt;div id="&lt;?php print $item_id+1?&gt;" class="gallery"&gt;&lt;?php print $item['view'] ?&gt;&lt;/div&gt;
    &lt;?php } ?&gt;
&lt;/div&gt;