var stm=Date();
var etm=Date();
var bw=false;
var bt=false;
var tm;
function bc()
  {
  document.rtm.but.value='Start';
  if(bt) {
    etm=new Date();
    var rt=(etm.getTime()-stm.getTime())/1000;
    alert("Your reaction time was " + rt + " seconds " + "\n\n" + com(rt));
    bw=false;
    bt=false;
   } else if (bw) {       
    clearTimeout(tm);
    bw=false;             
    alert('Oops. You are supposed to wait for the button to say "Now" before you click it. You probably want to try that again.');
    return;
   } else {
    bw=true; 
    tm=setTimeout('wait()', 6000*Math.random()+1000);
	document.rtm.but.value='Wait';
    }
  }
function wait()
  {
  document.rtm.but.value='Now';
  bt=true;
  stm=new Date();
  }
function com(rt)
  {
  if (rt<.02) return 'Congradulations Jedi Master!';
  if (rt<.06 ) return 'Astounding young Jedi!';
  if (rt<.15) return 'Very Good! You might have what it takes to become a Jedi?';
  if (rt<.3) return 'Respectable! Although you will need to get faster to become a Jedi Knight.';
  if (rt<.5) return 'Average. That is only good enough to qualify you to watch Jedi movies!';
  if (rt<.7) return 'You were supposed to hit the button ages ago. You must have blinked.';
  if (rt<1) return 'The instructions said hit the button as fast as you can. Do you want to try that again?';
  return 'We are glad you had time to stop and take that phone call...  Now can we get back to seeing how fast you can react?';
  }