var seconds = 0;
var startSeconds = 25;
var begun = false;

var clickCount = 0;

function begin() {

  if (!begun) {  
	  document.getElementById('click_me').style.display='none';
    document.getElementById('countdown_timer').style.display='block';
    document.getElementById('countdown_timer').value = startSeconds;
    countdown();
    begun = true;
  } else {
	  document.getElementById('vibrator').src = 'img/vibrator.png';
		document.getElementById('arrows').src = 'img/placeholder.png';
    increment_clicks();
  }
}

function countdown() {
  seconds += 1;
  document.getElementById('countdown_timer').value = startSeconds - seconds;
  if (document.getElementById('countdown_timer').value > 0) {
    setTimeout("countdown()",1000)
    document.getElementById('countdown_timer').value += ' SECONDS REMAIN';
  } else {
    document.getElementById('countdown_timer').style.display='none';
    document.getElementById('click_count').value = clickCount;
    alert('Times up! Lets see how you did');
    document.getElementById('vibrate_form').submit();
  }
}

function increment_clicks() {
  clickCount++;
  document.getElementById('score_fill').style.width = Math.round((clickCount * 1.95)) + 'px';
  document.getElementById('temp').innerHTML = clickCount; 

  if (clickCount % 2 == 0) {
    document.getElementById('vibrator').src = 'img/vibrator_clicked.png';
		document.getElementById('arrows').src = 'img/arrows.png';
  }
   
}

function show_html() {
	document.getElementById('html').style.display = 'none';
	document.getElementById('html_code').style.display = 'block';
}