title: Moving a div left and right continously
body: <p>I've been trying to get this javascript animation to work for hours now, and I got nothing. The problem isn't getting my div box to move from left to right(or from top to bottom), it's the opposite of each case that I have trouble with it. Here's what I have so far(In addition, I have set boundaries set to keep my moving box contained within the view window so if it hits any one of sides, it should move to the opposite direction). Any help is awesome at this point.</p>
  
  <p>Note: the next step is to create a bouncing effect for the box, but i'll worry about that once i get simple animation working.</p>
  
  <pre><code>      setInterval(function(){
  
  
      if(parseInt(box.style.left) &gt; parseInt(viewDim.width - 57)){
  
          box.style.left -= parseInt(box.style.left) - 2 + 'px';
  
  
  
      /* } else if(parseInt(box.style.left) &lt; 0){
  
          //debug_log("HIT!!");
          //parseInt(box.style.left) += 2 + 'px';
  
      } else if(parseInt(box.style.top) &gt; parseInt(viewDim.height-58)){
  
  
  
      } else if(parseInt(box.style.top) &lt; 0){*/
  
  
  
      } else {
  
          box.style.left = parseInt(box.style.left) + 2 + 'px';
          //box.style.top = parseInt(box.style.top) + 5 + 'px';
      } 
  
  }, 20);
  </code></pre>