window.onload=function(){
	$(".start-btn").click(function(){
		startbtn= $(this);
		var examid=$(this).prev().val();
		$.post(
		'ajax/startexam.php',
		{
		idexam : examid
		},
		function(data){
			//alert(data);
			if(data=="OK"){
				window.location.href="composition.php";
			}else if(data=="NO"){
				startbtn.html("Terminé");
				startbtn.attr("class","start-btn btn btn-danger btn-rounded waves-effect waves-light m-t-20");
				$("#erreur-examen-fini").click();
			}else{
				
			}
		},
		'html');
		});
		
	$(".note-btn").click(function(){
		startbtn= $(this);
		var examid=$(this).prev().val();
		$.post(
		'ajax/voir_note.php',
		{
		idexam : examid
		},
		function(data){
			
			if(data=="OK"){
				window.location.href="composition_terminee.php";
			}
		},
		'html');
	});
		
	/***************************Liste des fonction sutilisées pour l'accueil********************************/
	function verification_reguliere(){
		setTimeout(function(){
		$('.start-btn').each(function(){
			console.log("Encore");
			var startbtn= $(this);
			var examid=$(this).prev().val();
			
			setTimeout(function(){
				$.post(
				'ajax/startexam.php',
				{
				idexam : examid
				},
				function(data){
					
					if(data=="OK"){
						window.location.href="composition.php";
					}
					if(data=="NO"){
						startbtn.html("Terminé");
						startbtn.attr("class","start-btn btn btn-danger btn-rounded waves-effect waves-light m-t-20");
					}
				},
				'html');
			},3000);
			
			});
		},2000);
	}

}