// JavaScript Document
$(document).ready(function() 
{
	var secs = 59, msecs=100, bheight=0, on="false";
	$('#timer').html("01:00:0");
	var theInterval;
	
	function timerop()
	{	
		if(on=="true"){
		msecs-=10;
			if(msecs==0)
			{
				secs--;
				msecs=100;
				if(secs<10){
					$('#timer').html("00:" + "0" + secs + ":0");
				}
				else{
					$('#timer').html("00:" + secs + ":0");
				}
				
		
			}
			else
			{
				if(secs<10){
					$('#timer').html("00:" + "0" + secs + ":" + msecs/10);
				}
				else{
				$('#timer').html("00:" + secs + ":" + msecs/10);
				}
			}
			if(secs==0)
			{
				clearInterval(theInterval);
				on="false";
				secs=59; msecs=100;
				$('#timer').html("KLART!");
			}
		}
	};

	$('.clicksound').mousedown(function() {
		
		if(on=="false")
		{
		on="true";
		theInterval = setInterval(timerop, 100);
		}
		else
		{
  clearInterval(theInterval);
		on = "false";
		}
});
	
});
		

