
/**

	Gestion des heures, locales, utc, gmt, et truc bidule

**/

/**

	Affiche l'heure locale
	 et l'heure utc du pays choisi

**/

function affiche01 () {

	var el = document.getElementById('pays');
	var ato = document.getElementById('fuseau');
	var heure = new Date();
	var date = heure.getDate();
	ato.innerHTML = el.selectedIndex + ' ' + fuseau[ el.selectedIndex ];
	
}


/**

	Crée les tableaux des heures pour choisir

**/

function choisirjour ( tt, plus) {
	var sd = document.getElementById('selday');
	var ndate = new Date(tt);
	
	sd.value = ndate.toLocaleString() ;
	document.getElementById('daysel').innerHTML = ndate.toLocaleString() ;
	for (var i = 0; i <= 6 ; i++) {
		var ed = document.getElementById('chaq' + i);
		if ( i == plus  ) {
			ed.style.background = "gray";
		} else {
			ed.style.background = "white";
		}
	}

}

var old;

function selectHeure (jour,heure,plus2,cdata) {
	var he = document.getElementById('heures');
	var ttl = document.getElementById('tt');
	var milli = ttl.value;
	var hora = new Date( plus2  + 0  );
	var date = hora.getDate();

	var htt = new Date( milli * 1 );
	var hd = htt.getDate();
	
	
	var joursel = document.getElementById('jour');
	joursel.value= plus2 ;
	he.innerHTML = '<br><span class="hloc">' +hora.toLocaleString() + "</span>";				
	if ( old ) {
		var oldimg = document.getElementById(old);
		oldimg.src = "/images/g.gif";
	}
	if ( dejajour  ) {
		 document.getElementById(dejajour).src = "/images/g.gif";;
	}
	
	var monimg = document.getElementById('img'+ jour + heure);
	monimg.src = "/images/o.gif";
	old = 'img'+ jour + heure;
	document.getElementById('case').value = 'img'+ jour + heure;
	
	var heure = hora.getHours();
	var dur = document.getElementById('duree');
	dur.options[0].text = ' - ' +  heure + ":" + '00'  + ' -  ' ;
	dur.options[1].text = ' - ' +  heure + ":" + '15' + ' - ' ;
	dur.options[2].text = ' - ' + heure + ":" + '30'  + ' - ' ;
	dur.options[3].text = ' - ' + heure + ":" + '45' + ' - '  ;
	
}

function remetHeure () {

}

/**

	le pays doit être défini

**/


function afficheHeure (heure) {
}

function queljour (heure) {
	var hora = new Date( heure * 1000  );
//	document.write( hora.toLocaleDateString() );
	document.write( hora.getDate() + "/" +  (hora.getMonth() + 1 ) );
}
/**

	Affichage des périodes par rapport à l'heure choisie

**/

function quelleheure (heure) {
	var hora = new Date( heure * 1000  );
	document.write( hora.getHours() + ":" + hora.getMinutes() );
//	document.write( hora.toLocaleTimeString() );
}

function hfiche (temps,dd,sig,pp,pays) {
	var mom;
	if ( dd ) {
		mom = new Date( (((temps + dd) + (pp * 3600  ) ) ) * 1000  );
		document.write( "- " + pays + " "  + mom.getDate() + "/" + (mom.getMonth() + 1)  + " " +  mom.getUTCHours() + ':' + mom.getUTCMinutes() +   '<br>'
				);
	} else {
	 	mom = new Date(  (temps )  * 1000   );
		document.write( "- " + pays + " " + mom.getDate() + "/" + (mom.getMonth()  + 1 ) + " " + mom.getHours() + ':' + mom.getMinutes()
				+  '<br>'
				);
	}
}


function isoDate ( heure ) {
	var hora = new Date( heure * 1000  );
	
	return(	 hora.getFullYear() + "-"
				+ ( (hora.getMonth() +  1 ) < 10 ? "0" + (hora.getMonth() + 1 ) : (hora.getMonth() + 1 ) ) + "-" 
				+ ( hora.getDate() < 10 ? "0" + hora.getDate() : hora.getDate() ) + " "  
				+ ( hora.getHours() < 10 ? "0" + hora.getHours() : hora.getHours()  ) + ":" 
				+ ( hora.getMinutes() < 10 ? "0" + hora.getMinutes() : hora.getMinutes() ) 
			);

}


function lastup (ut) {
    var time=new Date(ut * 1000);
    var mn = time.getMinutes();
    if (mn < 10) {
        mn = "0" + mn ;
    }
    var sec = time.getSeconds();
    if (sec < 10) {
        sec = "0" + sec;
    }
    document.write( time.getHours() + ":" + mn + ":" +  sec);

}

