title: Move js script to external file
body: <p>I have the following code in a div to move the div when clicking on he move button:</p>
  
  <pre><code>    &lt;input id="move1" class="smallButtonidle" type="button" value="M" style="top: 0px; left: 0px; float: left;"  /&gt;
  &lt;script type="text/javascript"&gt;
  var isDown1 = false;
  document.getElementById('move1').addEventListener('mousedown', function(e1)
   {
      isDown1 = true;
      offset = [document.getElementById('jsmolwindow1').offsetLeft - e1.clientX,
          document.getElementById('jsmolwindow1').offsetTop - e1.clientY];
  }, true);
  window.addEventListener('mouseup', function() {
      isDown1 = false;
  }, true);
  window.addEventListener('mousemove', function(event) {
      if (isDown1) {
         mousePosition = {
            x : event.clientX,
           y : event.clientY
     };
          document.getElementById('jsmolwindow1').style.left = (mousePosition.x + offset[0]) + 'px';
          document.getElementById('jsmolwindow1').style.top  = (mousePosition.y + offset[1]) + 'px';
      }
  }, true);
  &lt;/script&gt;
  </code></pre>
  
  <p>I would like to move this js script to an external file to clarify my html</p>
  
  <p>I modify my html code the following way :</p>
  
  <pre><code> &lt;input id="move1" class="smallButtonidle" type="button" value="M" style="top: 0px; left: 0px; float: left;"  onclick="move1js()"/&gt;
  </code></pre>
  
  <p>And put in an include js external file:</p>
  
  <pre><code>function move1js()
  {
  var isDown1 = false;
  document.getElementById('move1').addEventListener('mousedown', function(e1)
   {
      isDown1 = true;
      offset = [document.getElementById('jsmolwindow1').offsetLeft - e1.clientX,
          document.getElementById('jsmolwindow1').offsetTop - e1.clientY];
  }, true);
  window.addEventListener('mouseup', function() {
      isDown1 = false;
  }, true);
  window.addEventListener('mousemove', function(event) {
      if (isDown1) {
         mousePosition = {
            x : event.clientX,
           y : event.clientY
     };
          document.getElementById('jsmolwindow1').style.left = (mousePosition.x + offset[0]) + 'px';
          document.getElementById('jsmolwindow1').style.top  = (mousePosition.y + offset[1]) + 'px';
      }
  }, true);
  }
  </code></pre>
  
  <p>Doing so my move button stop working. I don't understand why.</p>
  
  <p>Any ideas?</p>