title: Using JS to move a div around the page
body: <p>All,</p>
  
  <p>A total newbie here but could someone please review this code and let me know where I am going wrong? </p>
  
  <p>What effect I am trying to achieve: I have about 9 divs on the webpage, consisting of images and text, the text comes into focus when the user hovers over the image inside the div. I want these divs to 'appear' to be floating around the page.</p>
  
  <p>So what I did: I absolutely positioned the divs using CSS on the webpage. Now I am using JS to move the divs from their position to set positions on the page (will do this for each div) and try to give the effect of random movement to the divs. Here is the code:</p>
  
  <pre><code>        &lt;script language="javascript"&gt;
              var x = document.getElementById("cr001").style.left;
              var y = document.getElementById("cr001").style.top;
              var d_x = 75;
              var d_y = 100;
              var interval = 2;                   //move by only 2px...
  
              function moveImage() {
                  if(x &lt; d_x) x = x + interval;
                  if(y &lt; d_y) y = y + interval - 1;                   //move y by only 1px
  
                  document.getElementById("cr001").style.left = x+'px';
                  document.getElementById("cr001").style.top = y+'px';
  
                  if ((x + interval &lt; d_x) &amp;&amp; (y + interval &lt; d_y)) {
                      window.setTimeout('moveImage()',100);
                  }
              }   
      &lt;/script&gt;   
  &lt;/head&gt;
  
  &lt;body onload="moveImage()"&gt;
      &lt;div id="blackhole"&gt;&lt;img src="img/bimg.png" alt="blackhole" /&gt;&lt;/div&gt;
      &lt;div id="container"&gt;
  
              &lt;div id="cr001" class="twinkles"&gt;
                  &lt;a href="#"&gt;
                  &lt;img src="img/cr.png" alt="Co is about your freedom" /&gt;
                  &lt;span&gt;Co is about your freedom&lt;/span&gt;&lt;/a&gt;
  
      &lt;/div&gt;
  
  &lt;/body&gt; 
  </code></pre>
  
  <p>Could someone please explain where I am going wrong?</p>
  
  <p>Cheers,</p>