title: How do you make a blinking animation in Javascript?
body: <p>I'm trying to make some ascii art blink by alternating between "0" and "_" for eyes. I pasted the code I currently have below. The ascii person will simply be closing and then opening her eyes once every few seconds. I don't see why my code doesn't work and I'm open to using other ways too. Thanks!</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function startBlinking() {
     window.setInterval(blinking(),2000);
  }
  
  function blinking() {
      var left=document.getElementById("leftEye");
      var right=document.getElementbyId("rightEye");
  
      left.innerHTML="_";
      right.innerHTML="_";
      window.setTimeout(function(){
            left.innerHTML="0";
            right.innerHTML="0";
      },500);
  }
  
  startBlinking();
  &lt;/script&gt;
  </code></pre>
  
  <p>And here is the rest of the code!</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&gt;
      &lt;title&gt;Girl&lt;/title&gt;
      &lt;style type="text/css"&gt;
          pre {
              font-family: monospace;
              font-size: small;
      }
  
  &lt;/style&gt;
  
  &lt;script type="text/javascript"&gt;
  
  function startBlinking() {
     window.setInterval(blinking(),2000);
  }
  
  function blinking() {
      var left=document.getElementById("leftEye");
      var right=document.getElementbyId("rightEye");
  
      left.innerHTML="_";
      right.innerHTML="_";
        window.setTimeout(function(){
            left.innerHTML="0";
            right.innerHTML="0";
        },500);
  }
  
  function buttonClicked() {
    var lines=new Array();
    lines=["You should not stay up so late...",
                     "Light roast coffee please.",
                     "Fire Emblem is so good.",
                     "How's the weather today?",
                     "I hope you studied for finals.",
                     "What else should I say?",
                     "No more ramen for dinner.",
                     "Placement text",
                     "Placement text",
                     "Placement text"];
  
    var ran=Math.floor(Math.random()*10);
    var parsedStr=parse(lines[ran]);
    document.getElementById("text1").innerHTML=parsedStr[0];
    document.getElementById("text2").innerHTML=parsedStr[1];
    document.getElementById("text3").innerHTML=parsedStr[2];
  }
  
  function parse(str){
    var length=str.length;
    var strArray= new Array();
    strArray=["           ","           ","           "];
  
    if(length &gt; 33) {
       return parse("Too many characters!");
    } else {
       if(length&lt;11) {
           var spaces="";
           for(var i=0; i&lt;(11-length);i++) {
              spaces+= " ";
           }
           strArray[0]=str.slice(0,length)+spaces;
       } else if(length&gt;11 &amp;&amp; length &lt;22) {
           var spaces="";
           for(var i=0; i&lt;(22-length);i++) {
              spaces+= " ";
           }
           strArray[0]=str.slice(0,11);
           strArray[1]=str.slice(11,length)+spaces;
       } else {
           var spaces="";
           for(var i=0; i&lt;(33-length);i++) {
              spaces+= " ";
           }
           strArray[0]=str.slice(0,11);
           strArray[1]=str.slice(11,22);
           strArray[2]=str.slice(22,length)+spaces;
       }
  
       return strArray;
    } 
     }
  
     startBlinking();
     &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;pre&gt;
       _____        ,--------------,
      /////\\       |  &lt;span id="text1"&gt;You should &lt;/span&gt; |
     ///////\\      |  &lt;span id="text2"&gt;not stay up&lt;/span&gt; |
     \|&lt;span id="leftEye"&gt;0&lt;/span&gt; &lt;span id="rightEye"&gt;0&lt;/span&gt; \\\\     |  &lt;span id="text3"&gt;so late... &lt;/span&gt; |
     ||    /|||    &amp;lt;,______________|
     //\^_,|\\\
    ||+--| |--_|
    |/  `-_-'  \
    /\/|  V   \_\
   / /\| __   |\ \
  / /  ||_ |) | \ \
  \ \  ||\\|__|__\ \
   \ \ | \_________/
    \ \|      |
  &lt;/pre&gt;
  &lt;p&gt;&lt;button type="button" id="talkButton" onclick="buttonClicked()"&gt;Talk&lt;/button&gt;&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>