
  var arg = "cdown="
  now = new Date
  var mois = new Array("Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre");

function setCookie() {
  cdDay = document.myForm.cdDay.value
  cdMonth = document.myForm.cdMonth.value
  expireDate = new Date
  expireDate.setYear(expireDate.getYear()+1)
  document.cookie = arg+cdMonth+","+cdDay+";expires=" + expireDate.toGMTString()
  updateMyForm()
}

function getCookie(actn) {
  var i = 0;
  while (i < document.cookie.length) {
    var j = i + arg.length;
    if (document.cookie.substring(i, j) == arg) {
      var endstr = document.cookie.indexOf (";", j);
      if (endstr == -1)
      endstr2 = document.cookie.length;
      if (actn == 0) {
        expireDate = new Date;
        expireDate.setYear(expireDate.getYear()-1);
        document.cookie = arg + ";expires=" + expireDate.toGMTString();
        document.myForm.dodos.value =" Calculez le nombre de nuits avant un évenement. Inscrivez le jour: ";
        document.myForm.cdDay.value = " ";
        document.myForm.cdMonth.value = " ";
        updateMyForm();
        return null;
      }
      else
        return unescape(document.cookie.substring(j, endstr2));
    }
    i = document.cookie.indexof(" ",i) + 1;
    if (i == 0) break;
  }
  return null;
}

function dayToDays(inTime) { return (Math.floor(inTime.getTime() / (1000 * 60 * 60 * 24))) }
	
function daysTill(inDate) { return dayToDays(inDate) - dayToDays(now) }

function updateMyForm() {
  tday = getCookie(1);
  if (tday == null) {
    document.myForm.cdDay.value = " ";
    document.myForm.cdMonth.value = " ";  
    document.myForm.dodos.value =" Calculez le nombre de nuits avant un évenement. Inscrivez le jour: " }
  else if ("1" == "1") {

    cdMonth = tday.split(",")[0];
    cdDay = tday.split(",")[1];
    dte = new Date (now.getYear(),cdMonth-1,cdDay);
    dte1 = dte;
    if (dte.getDate() + dte.getMonth() == now.getDate() + now.getMonth() ) {
      document.myForm.dodos.value = "YOUPPIE, c'est aujourd'hui... ";}
    else if ("1" == "1") {
      if (dte.getTime() < now.getTime()) { dte.setYear(dte.getYear()+1) }
      document.myForm.dodos.value = "Plus que " + daysTill(dte) + " nuits avant le "; }
    document.myForm.cdDay.value = cdDay;
    document.myForm.cdMonth.value = cdMonth;
  }
  return "OK"
}


