
  var arg = "cdown="
  now = new Date
  var mois = new Array("Janvier/January", "Fevrier/February", "Mars/March", "Avril/April", "Mai/May", "Juin/June", "Juillet/July", "Aout/August", "Septembre/September", "Octobre/October", "Novembre/November", "Decembre/December");

function setCookie() {
  cdDay = document.chanceux.date1.value.split("/")[0];
  cdMonth = document.chanceux.date1.value.split("/")[1];
  expireDate = new Date
  expireDate.setYear(expireDate.getYear()+1)
  document.cookie = arg+cdMonth+","+cdDay+";expires=" + expireDate.toGMTString()
  updateChanceux()
}

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.chanceux.dodos.value =" Calculez le nombre de dodos avant votre depart. Le: ";
//        document.chanceux.dodoe.value =" Calculate the number of nights before your departure. The: " 
//        document.chanceux.cdDay.value = " ";
//        document.chanceux.cdMonth.value = " ";
//        updateChanceux();
        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 updateChanceux() {
  tday = getCookie(1);
  if (tday == null) {
    document.chanceux.cdDay.value = " ";
    document.chanceux.cdMonth.value = " ";  
    document.chanceux.dodos.value =" Calculez le nombre de dodos avant votre depart.  Le: " 
    document.chanceux.dodoe.value =" Calculate the number of nights before your departure. The: " }
  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.chanceux.dodos.value = "YOUPPIE, c'est aujourd'hui qu'on part... ";
//      document.chanceux.dodoe.value = "YAHOO, departure is today... ";
      status = "YOUPPIE, c'est aujourd'hui qu'on part... / YAHOO, departure is today... "; }
    else if ("1" == "1") {
      if (dte.getTime() < now.getTime()) { dte.setYear(dte.getYear()+1) }
//      document.chanceux.dodos.value = "Plus que " + daysTill(dte) + " dodos avant le "; 
//      document.chanceux.dodoe.value = "Only " + daysTill(dte) + " nights before "; 
      status = "Plus que " + daysTill(dte) + " dodos / Only " + daysTill(dte) + " nights"; }
//    document.chanceux.cdDay.value = cdDay;
//    document.chanceux.cdMonth.value = cdMonth;
  }
   
  return "OK"
}

function checkDodos() {
  tday = getCookie(1);
  if (tday != null) {
    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() ) {
      status = "YOUPPIE, c'est aujourd'hui qu'on part... / YAHOO, departure is today... ";}
    else if ("1" == "1") {
      if (dte.getTime() < now.getTime()) { dte.setYear(dte.getYear()+1) }
      status = "Plus que " + daysTill(dte) + " dodos / Only " + daysTill(dte) + " nights"; }
  }
  return "OK"
}




