// JavaScript Document
// pour gerer le changement de class


function minute(){

Nom = navigator.appName;

if(Nom == 'Microsoft Internet Explorer'){
classe = 'className';
}else{
classe = 'class';
}


		if ($('timemin') != null && $('timemin').firstChild.data == 0){ 
		
		
		$("sepem").parentNode.previousSibling.style.display = 'none';
		$("sepem").parentNode.style.display = 'none';
		target = $("sepem").parentNode.nextSibling;
		
		
		
		
		if ($("sepem").parentNode.nextSibling.style.display == 'none'){
			$("sepem").parentNode.nextSibling.style.display == '';
		}

		
		

		
		nextdurree = target.getElementsByTagName("b")[1].innerHTML;
		
		time = $('horloge').innerHTML;
		$("horloge").parentNode.removeChild($("horloge"));
		var lhorloge = document.createElement("b");
		lhorloge.setAttribute('id', 'horloge');
		var horlogetxt = document.createTextNode(time);
		lhorloge.appendChild(horlogetxt);
		//target.appendChild(lhorloge);

 		target.getElementsByTagName("b")[0].replaceChild(lhorloge, target.getElementsByTagName("b")[0].firstChild);


		
		var barremin = document.createElement("div");
		barremin.setAttribute('id', 'barremin');
		var duree = document.createTextNode("dur\351e : ");
		barremin.appendChild(duree);
			var timein = document.createElement("b");
			timein.setAttribute('id', 'timemin');
			timein.setAttribute('name', nextdurree);
			var tduree = document.createTextNode(nextdurree);
			timein.appendChild(tduree);
		
		barremin.appendChild(timein);
		var dureem = document.createTextNode("min");
		barremin.appendChild(dureem);
		target.appendChild(barremin);
		
			var separ = document.createElement("div");
		separ.setAttribute('id', 'sepem');
		separ.setAttribute(classe, 'sep');
		separ.setAttribute('width', '300px');
		separ.setAttribute('style', 'height:10px;');
		target.appendChild(separ);
		
		var timebar = document.createElement("div");
		timebar.setAttribute('id', 'timebar');
		timebar.setAttribute(classe, 'sep');
		timebar.setAttribute('width', '200');
		timebar.setAttribute('style', 'height:10px !important; margin-top:-10px;');
		target.appendChild(timebar);
		//alert ('next');
		
		$("barremin").parentNode.removeChild($("barremin"));
		$("timebar").parentNode.removeChild($("timebar"));
		$("sepem").parentNode.removeChild($("sepem"));
		
		
		}else if($('timemin') != null){
		$('timemin').firstChild.data = $('timemin').firstChild.data-1;
		nbr = ($('timebar').style.width.substring(0,2)*1)+(101/($('timemin').getAttribute('name')));
		
		if ($('horloge').firstChild.data.substring(0,2) >= 10){
			if ($('horloge').firstChild.data.substring(3,5) >= 60){
				$('horloge').firstChild.data = ($('horloge').firstChild.data.substring(0,2)*1+1)+'h00';
			}else{
				$('horloge').firstChild.data = $('horloge').firstChild.data.substring(0,2)+'h'+($('horloge').firstChild.data.substring(3,5)*1+1);
			}
			
		}else{
			if ($('horloge').firstChild.data.substring(2,4) >= 60){
				$('horloge').firstChild.data = ($('horloge').firstChild.data.substring(0,1)*1+1)+'h00';
			}else{
				$('horloge').firstChild.data = $('horloge').firstChild.data.substring(0,1)+'h'+($('horloge').firstChild.data.substring(2,4)*1+1);
			}
		}

		$('timebar').style.width = nbr+'%';

		}
		
		setTimeout("minute()",60000);
	}
	
	
	