title: Run IF only once in FOR loop
body: <p>I am trying to put thumbnails into the Diapo gallery by Pixadelic (<a href="http://www.pixedelic.com/plugins/diapo/" rel="nofollow">link</a>), but I am running into one issue. I am using the code below, and I need the IF statement to run only once, as if not, <em>counter</em> will stay with value 0 forever, and I want it to start adding 1 each time it loops after applying 0 to its value. Any ideas? </p>
  
  <pre><code>if(thumbnails==true) {
          $('#pix_pag').append('&lt;div id="thumb_div"/&gt;');
          var thumbNum;
          var counter;
          for (thumbNum = 0,counter=0; thumbNum &lt; amountSlide; thumbNum++,counter++){ 
  
  
              var dataThumb = selector.eq(thumbNum).attr('data-thumb');
              var newImg = new Image();
              newImg.src = dataThumb;
              var leftVal = 25+25*counter;
              var thumbsWidth = $("#pix_pag").width(); 
              var totalVal = 75*(thumbNum+1)+25+25*thumbNum+75;
              var checker = true;
  
              if(totalVal&gt;=thumbsWidth &amp;&amp; checker==true){
                  counter=0;
                  checker=false;
              }
  
  
  
              $('#thumb_div').append($(newImg).attr({'class':'thumb_nav_'+thumbNum,'style':'position:relative;width:75px;height:75px;top:25px;left:'+leftVal+'px;cursor:pointer;border:solid 1px;box-shadow: 2px 2px 1px #888888;'}));
  
  
  
              }
          }
  </code></pre>
  
  <p>Thanks in advance. :) </p>