Javascript/JQuery bouncing text off left and right sides of a div
<p>I want text to bounce of the left and right sides of a div tag (<code>#header</code>). It works fine when it bounces of the right, then goes back and hits the left. The problem is that after it hits the left and starts to go right again it never hits the right side. It just keeps going and the window scrollbar appears. It appears as soon as it hits the left side. It seems that the div tag.</p>

<pre><code>var finishedGoingRight = false;

setInterval(function() {
   slideText();
}, 10);


function slideText(){
   if(!finishedGoingRight){
      $('#header h1').css("right","-=1");
   }else{
      $('#header h1').css("left","-=1");
   }

   if($('#header h1').css("right") == "20px"){
      finishedGoingRight = true;
   }

   if($('#header h1').css("left") == "485px"){
      finishedGoingRight = false;
   }
}
</code></pre>

<p>Hope I explained it clearly :)</p>
