var months = Array ("janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre");
var days = new Array('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi');

function displayTime () {
  var now = new Date(); 
  var hours = "" + now.getHours(); 
  var minutes = now.getMinutes(); 
  var secondes = now.getSeconds();
  hours = ((hours == 0) ? "24" : hours);
  hours = ((hours < 10) ? "0" : "") + hours;
  hours += ((minutes < 10) ? ":0" : ":") + minutes; 
  hours += ((secondes < 10) ? ":0" : ":") + secondes; 
  document.date.time.value = hours;
  setTimeout("displayTime()",1000);
}
function displayDate () {
  var now = new Date(); 
  var currentDay = " " + now.getDate();
  currentDay = ((currentDay < 10) ? "0" : "") + currentDay;
  var month = now.getMonth()+1;
  month = ((month < 10) ? "0" : "") + month;
  var years = now.getYear(); 
  currentDay += "/" + month + "/" + years; 
  document.date.date.value = currentDay; 
}
function displayFullDate () {
   
  document.date.date.value = getDateFormat(); 
}

function getDateFormat() {
  var now = new Date();
  var currentDayOfWeek = days[now.getDay()];
  var currentDay = now.getDate();
  currentDay = ((currentDay < 10) ? "0" : "") + currentDay;
  var month = now.getMonth();
  month = months[month];
  var years = now.getFullYear(); 
  var value= " " + currentDayOfWeek + " " + currentDay + " " + month + " " + years;
  return value;
}
function displayFullDateOnDiv (currentName) {
  var now = new Date();
  var currentDayOfWeek = days[now.getDay()];
  var currentDay = now.getDate();
  currentDay = ((currentDay < 10) ? "0" : "") + currentDay;
  var month = now.getMonth();
  month = months[month];
  var years = now.getFullYear(); 
  var currentValue= "<font class=\"clock\">" + getDateFormat() +"</font>"; 
  setElementInnerHTML(currentName, currentValue);
}
function getWeek(){	
	// ********
	// ISO 8601 function to return the week number corresponding to any date
	// ********
	var n = new Date();
	var kP3D = 259200000;
	var kP7D = 604800000;
	var y = n.getYear();
	y = (y<1000)? 1900+y : y;
	var s = Math.floor((Date.UTC(y,n.getMonth(),n.getDate())+kP3D)/kP7D);
	var tmp = new Date(s*kP7D);
	var j = tmp.getYear();
	j = (j<1000?1900+j:j);
	return 1+s-Math.floor((Date.UTC(j,0,4)+kP3D)/kP7D) 
}
function startClock (time, date) {
  if (time) {
  	displayTime();
  }
  if (date) {
    displayDate();	
  }
}
function getCurrentDayNumber () {
	var now = new Date();
	return now.getDay();
}
