title: change canvas image with javascript
body: <p>the desired behavior is when the document loads, canvas draws image 0.  when the invisible div is clicked, canvas draws image 1, on mouseup or mouseout, it reverts back to image 0.</p>
  
  <p>I left the css out because I got that working...just need to know what I'm doing wrong with the javascript function.  right now it doesn't display anything, not even the first image.</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;script type="text/javascript"&gt;
          function imgChange(imagePath)
              var c=document.getElementById("myCanvas");
              var ctx=c.getContext("2d");
              var img=new Image();
              img.onload = function(){
              ctx.drawImage(img,0,0);
              };
              img.src=imagePath; &lt;!-- I THINK THIS IS WRONG?
          &lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
  
              &lt;canvas id="myCanvas" width="506" height="319"
  onload="imgChange('0.gif')" style="border:1px solid #c3c3c3;"&gt;
              Your browser does not support the canvas element.
              &lt;/canvas&gt;
  
  
  
              &lt;div id="button1" onMouseDown="imgChange('1.gif')" onMouseUp="imgChange('0.gif')" onMouseOut="imgChange('0.gif')"&gt;&lt;/div&gt;
              &lt;div id="key2"&gt;&lt;/div&gt;
  
  
  
  
      &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>