title: settimeout & cleartimeout to start time with a click
body: <p>I'm pretty new with Javascript and jQuery and can't quite figure out <code>settimeout</code>.</p>
  <p>What I'm trying to do it start a timer with a click. It will slide a page to where there is an input to enter an email. If, in 20 seconds, there is nothing typed, I want it to do something. But if they do enter something, I'd like the 20 second timer reset to 20 seconds <code>onkeyup</code>. And finally, if the form is submitted, I want the timeout cancelled.</p>
  <pre><code>$('#button').click(function(){
    $('#pane').scrollTo( '1000px', 500);
    setTimeout(goback, 20000);
    function goback() {
    $('#pane').scrollTo ('0px', 500);
    $('#input').keyup(function(){
      clearTimeout(goback);
      setTimeout(goback, 20000);
  };
  $('#submitemail').click(function(){
    //form submit stuff
    clearTimeout(goback);
  });
  </code></pre>
  <p>Could you please point me in the right direction?</p>
  <pre><code>var timer;
  $('#button').click(function(){
       $('#pane').scrollTo( '768px', 0 );
       $('#emailinput').delay(1000).focus();
       $('#slide2fadeout').css(&quot;display&quot;, &quot;block&quot;).fadeOut();
       timer = setTimeout(goback, 20000);              //in 20 seconds start goback function
       function goback(){
           $('#like').scrollTo( '0px', 0 );            //scroll back to top
           $('#emailinput').val('');                   //clear any partial entry
       };
       $('#emailinput').keyup(function(){
           clearTimeout(timer);
           timer = setTimeout(goback, 20000);
       };
  });
  </code></pre>
  <p>Here's my actual code... can't seem to get it working right. Any help appreciated.</p>