function playVideo() {
	var video = document.getElementById('video');
	var audio = document.getElementById('audio');
	var t; // This is for the timer
	var mute =  document.getElementById('mute');
	

	//autoplay on
	video.play();

	startCount();
	
// Function to begin the timer
	function startCount() {
		t = window.setInterval(function() {
			if (video.ended != true) {
				
			} else {
				window.clearInterval(t);
				video.play();
				
				startCount(); 
			}
		},1000);		
	}
// Function to pause the timer
	function pauseCount() {
		window.clearInterval(t);
	}
	
document.getElementById('audio').addEventListener('ended', function(){
this.currentTime = 0;
}, false);
	mute.addEventListener('click',muteControl,false);
	function muteControl() {
		if (audio.volume > 0) {
			audio.volume = 0;
			this.firstChild.nodeValue = 'ton an';
			
		} else {
			audio.volume = 1;
			this.firstChild.nodeValue = 'ton aus';
			
		}
	}

}
window.onload = playVideo;
