title: Javascript - random images error
body: <p>I have the following problem I have 21 little pictures, and I want them positioned randomly in a the window in defined time intervals.</p>
  
  <p>I have the following code, and I know what causes the problem, but I can't solve it. </p>
  
  <pre><code>function addLoadEvent(func) {
      var oldonload = window.onload;
      if (typeof window.onload != 'function') {
          window.onload = func;
      } else {
          window.onload = function () {
              if (oldonload) {
                  oldonload();
              }
              func();
          }
      }
  }
  
  addLoadEvent(Prep6);
  addLoadEvent(Prep7);
  
  function Prep6() {
  
      window_Height = window.innerHeight;
      window_Width = window.innerWidth;
  
      image_Element = document.getElementById("loader06");
      image_Height = image_Element.clientHeight;
      image_Width = image_Element.clientWidth;
  
      availSpace_V = window_Height - image_Height;
      availSpace_H = window_Width - image_Width;
  
      moveImage7();
  
      var changeInterval = 300;
      setInterval(moveImage7, changeInterval);
  }
  
  function moveImage6() {
      var randNum_V = Math.round(Math.random() * availSpace_V);
      var randNum_H = Math.round(Math.random() * availSpace_H);
  
      image_Element.style.top = randNum_V + "px";
      image_Element.style.left = randNum_H + "px";
  }
  
  function Prep7() {
  
      window_Height = window.innerHeight;
      window_Width = window.innerWidth;
  
      image_Element = document.getElementById("loader07");
      image_Height = image_Element.clientHeight;
      image_Width = image_Element.clientWidth;
  
      availSpace_V = window_Height7 - image_Height;
      availSpace_H = window_Width - image_Width;
  
      moveImage7();
  
      var changeInterval = 300;
      setInterval(moveImage7, changeInterval);
  }
  
  function moveImage7() {
      var randNum_V = Math.round(Math.random() * availSpace_V);
      var randNum_H = Math.round(Math.random() * availSpace_H);
  
      image_Element.style.top = randNum_V + "px";
      image_Element.style.left = randNum_H + "px";
  }
  </code></pre>
  
  <p>And the problem is:</p>
  
  <pre><code>moveImage7();
  function moveImage6()
  </code></pre>
  
  <p>How can I solve it?</p>