title: set every 1st and fourth element with a class
body: <p>I have a jquery carousel set to 620px wide. I am using the grid 960 to place the images inside. I show 4 images at a time.</p>
  
  <p>In order to do that I set the every first image class to 'grid_2 alpha' and every fourth to 'grid_2 omega' in the group of 4 shown while all in between I set to just grid_2.</p>
  
  <p>This gives me the 620px I need. I am pulling from the database and I am trying to set the class dynamically but cant quite get every first and fourth in the group with the classes.</p>
  
  <pre><code>                    &lt;?php $loopIndex = 1; ?&gt;
                      &lt;?php foreach ($pub_values as $v) { 
                      if($v['pub_of_the_month'] == 1)
                      {
                      ?&gt;
                      &lt;?php if ($loopIndex == 1 || $grid_class=="grid_2 omega") $grid_class="grid_2 alpha";
                              else if($loopIndex%4 == 0) $grid_class="grid_2 omega"; 
                              else $grid_class="grid_2"; 
                            $filename = "images/pub_images/120x160/".$v['id'].".jpg";
                            if (!file_exists($filename)) $filename = "images/pub_images/120x160/blank.gif";       
                      ?&gt;
                          &lt;div class="&lt;?php echo $grid_class?&gt;"&gt;
                              &lt;a href="#"&gt;
                                  &lt;img src="&lt;?=$filename;?&gt;" alt="&lt;?=$v['name'];?&gt;" width="120" height="160" /&gt;
                                  &lt;?=$v['name'];?&gt;
                              &lt;/a&gt;
                          &lt;/div&gt;
                      &lt;?php $loopIndex = $loopIndex + 1; } }?&gt;
  </code></pre>
  
  <p>The above code is my best attempt of achieving the following.</p>
  
  <p>Images</p>
  
  <p>1 - grid_2 alpha</p>
  
  <p>2 - grid_2</p>
  
  <p>3 - grid_2</p>
  
  <p>4 - grid_2 omega</p>
  
  <p>5 - grid_2 alpha</p>
  
  <p>6 - grid_2</p>
  
  <p>7 - grid_2</p>
  
  <p>8 - grid_2 omega</p>
  
  <p>9 - grid_2 alpha</p>