var DC20030227 = null;
DOMCalendar = function()
{
 DC20030227 = this;
 this.aDC = new Array();
 this.imgPath = "";
 this.dCtrl = new DateControl();
 this.sD = this.sM = this.sY = "";
 this.dD = this.dM = this.dY = "";
 this.dcActive = null;

 this.SetImgPath = function( inPATH )
 {
  this.imgPath = inPATH;
 };

 this.SetDateFormat = function( inNAME, inFMT )
 {
  var oCal = this.GetCalendar(inNAME);
  if (oCal) {
   oCal.dFmt = inFMT;
  }
 };

 this.SetLanguage = function( inNAME, inLNG )
 {
  var oCal = this.GetCalendar(inNAME);
  if (oCal) {
   oCal.lng = inLNG;
  }
 };

 this.SetFirstDayOfWeek = function( inNAME, inFDW )
 {
  var oCal = this.GetCalendar(inNAME);
  if (oCal) {
   oCal.fDayWeek = inFDW;
  }
 };

 this.SetPosition = function( inNAME, inLEFT, inTOP )
 {
  var oCal = this.GetCalendar(inNAME);
  if (oCal) {
   oCal.left = inLEFT;
   oCal.top = inTOP;
  }
 };

 this.HideSelectList = function( inNAME, inSELECT )
 {
  var oCal = this.GetCalendar(inNAME);
  if (oCal) {
   oCal.hideSelect[oCal.hideSelect.length] = inSELECT;
  }
 };

 this.LoadImg = function()
 {
  var i = 0, oImg = null, aImg = ["c_b", "c_bd", "c_bg", "c_hd", "c_hg", "c_mp", "c_ms"];
  for (i = 0; i < aImg.length; i++) {
   oImg = new Image();
   oImg.src = this.imgPath + aImg[i] + ".gif";
  };
 };

 this.DeleteAll = function()
 {
  var i = 0;
  document.getElementById("DCYear").innerHTML = "&nbsp;";
  document.getElementById("DCMonth").innerHTML = "&nbsp;";
  for (i = 0; i < 42; i++) {
   document.getElementById("DCTd" + i).innerHTML = "&nbsp;";
   document.getElementById("DCTd" + i).onmouseover = null;
   document.getElementById("DCTd" + i).onmouseout = null;
   document.getElementById("DCTd" + i).onclick = null;
  };
  for (i = 0; i < 7; i ++) {
   document.getElementById("DCDay" + i).innerHTML = "&nbsp;";
  };
 };

 this.GetCalendar = function( inNAME )
 {
  var i = 0, oObj = null;
  for (i = 0; i < this.aDC.length; i++) {
   if (this.aDC[i].name == inNAME) {
    oObj = this.aDC[i];
    break;
   }
  };
  return oObj;
 };

 this.AddCalendar = function( inNAME, inFORM )
 {
  this.aDC[this.aDC.length] = new DC_Structure(inNAME, inFORM);
 };
 this.Show = function( inNAME )
 {
  var oCal = this.GetCalendar(inNAME), oValue = "", d = null, aD = null, oFmt = null, dOK = 1;
  if (oCal) {
   oValue = "" + oCal.form.value;
   oFmt = this.dCtrl.GetObject(inNAME);
   if (oValue == "") {
    d = new Date();
    this.dD = d.getDate();
    this.dM = d.getMonth();
    this.dY = d.getFullYear();
    this.sD = this.sM = this.sY = "";
   } else {
    if (this.dCtrl.IsValidDate(inNAME)) {
     aD = oValue.split(oFmt.oFmt.sDel);
     this.dD = this.sD = Math.round(parseFloat(aD[oFmt.oFmt.aFmt[1]]));
     this.dM = this.sM = Math.round(parseFloat(aD[oFmt.oFmt.aFmt[2]])) - 1;
     this.dY = this.sY = Math.round(parseFloat(aD[oFmt.oFmt.aFmt[3]]));
    } else {
     dOK = 0;
    }
   }
   if (dOK != 0) {
    //this.Close();
    this.dcActive = oCal;
    this.GetContent(oCal, oFmt);
    for (var i = 0; i < oCal.hideSelect.length; i++) {
     oCal.hideSelect[i].style.visibility = "hidden";
    };
    this.Open(oCal);
   }
  }
 };

 this.Open = function( inOBJ )
 {
  var oTbl = document.getElementById("DCTable");
  with (oTbl.style) {
   top = inOBJ.top;
   left = inOBJ.left;
   visibility = "visible";
   display = "";
  }
 };

 this.Close = function(){ return true;  };
 
 function raz()
 {
  var oTbl = document.getElementById("DCTable");
  this.DeleteAll();
  with (oTbl.style) {
   visibility = "hidden";
   display = "none";
  }
  var oCal = this.dcActive;
  if (oCal) {
   for (var  i = 0; i < oCal.hideSelect.length; i++) {
    oCal.hideSelect[i].style.visibility = "visible";
   };
  }
  this.dcActive = null;
 };

 this.Prev = function( inNAME )
 {
  var oCal = this.GetCalendar(inNAME), oFmt = null;
  if (oCal) {
   this.dM--;
   if (this.dM < 0) {
    this.dY--;
    this.dM = 11;
   }
   oFmt = this.dCtrl.GetObject(inNAME);
   this.DeleteAll();
   this.GetContent(oCal, oFmt);
  }
 };

 this.YearPrev = function( inNAME )
 {
  var oCal = this.GetCalendar(inNAME), oFmt = null;
  if (oCal) {
   this.dY--;
   if (this.dY < 1) {
    this.dY = 1;
   }
   oFmt = this.dCtrl.GetObject(inNAME);
   this.DeleteAll();
   this.GetContent(oCal, oFmt);
  }
 };
 this.YearPrev2 = function( inNAME )
 {
  var oCal = this.GetCalendar(inNAME), oFmt = null;
  if (oCal) {
   this.dY-=10;
   if (this.dY < 1) {
    this.dY = 1;
   }
   oFmt = this.dCtrl.GetObject(inNAME);
   this.DeleteAll();
   this.GetContent(oCal, oFmt);
  }
 };
 
 this.Next = function( inNAME )
 {
  var oCal = this.GetCalendar(inNAME), oFmt = null;
  if (oCal) {
   this.dM++;
   if (this.dM > 11) {
    this.dY++;
    this.dM = 0;
   }
   oFmt = this.dCtrl.GetObject(inNAME);
   this.DeleteAll();
   this.GetContent(oCal, oFmt);
  }
 };

 this.YearNext = function( inNAME )
 {
  var oCal = this.GetCalendar(inNAME), oFmt = null;
  if (oCal) {
   this.dY++;
   oFmt = this.dCtrl.GetObject(inNAME);
   this.DeleteAll();
   this.GetContent(oCal, oFmt);
  }
 };
 
 this.YearNext2 = function( inNAME )
 {
  var oCal = this.GetCalendar(inNAME), oFmt = null;
  if (oCal) {
   this.dY+=10;
   oFmt = this.dCtrl.GetObject(inNAME);
   this.DeleteAll();
   this.GetContent(oCal, oFmt);
  }
 };

 this.SetDateBack = function( inNAME,e )
 {
  var dC;
  if(window.event)
  {
  	dC = window.event.srcElement.innerHTML;
  }else{
	dC = e.target.innerHTML;
  };
  oCal = this.GetCalendar(inNAME);
  oFmt = null;
  date_test = new Date();
  if(dC != 'X' ){
	  if (oCal) {
	   oFmt = this.dCtrl.GetObject(inNAME);   
	   oCal.form.value = oFmt.oFmt.GetDateFormatted(dC, this.dM, this.dY);
	  // change_date();
	   signs(); 
	   this.Close();
	  }
  }else{
	alert('Date dépassée');  
  }
 };

 this.GetContent = function( inOBJ, inFMT )
 {
  var fDayMonth = 0, indx = 0, lDayMonth = 0, i = 0, oTd = null;
  for (i = 0; i < inOBJ.aLng.a[1].length; i++) {
   oTd = document.getElementById("DCDay" + i);
   indx = i + inOBJ.fDayWeek;
   if (indx > 6) {
    indx = indx - 7;
   }
   oTd.innerHTML = inOBJ.aLng.a[1][indx];
  };
  fDayMonth = (new Date(this.dY, this.dM, "01")).getDay();	
  fDayMonth = fDayMonth - inOBJ.fDayWeek;
  if (fDayMonth < 0) {
   fDayMonth = fDayMonth + 7;
  }
  lDayMonth = fDayMonth + this.dCtrl.DaysIn(this.dM, this.dY);
  indx = 1;
  for (i = fDayMonth; i < lDayMonth; i++) {
   if (indx == this.sD && this.dM == this.sM && this.dY == this.sY) {
    document.getElementById("DCTd" + i).style.color = "#FF0000";
   } else {
    document.getElementById("DCTd" + i).style.color = "#0000FF";
   }
   document.getElementById("DCTd" + i).style.cursor = "pointer";
   //path pas de jour avant aujourd'hui :
   another_date = new Date();
   //alert('choix date');
  /* if((this.dM == another_date.getMonth() && this.dY == another_date.getFullYear() && indx > another_date.getDate()) || this.dM > another_date.getMonth() || this.dY > another_date.getFullYear())
   {*/
	   	document.getElementById("DCTd" + i).innerHTML = indx;  
   /*}else{
		document.getElementById("DCTd" + i).innerHTML = "X";    
		document.getElementById("DCTd" + i).onclick = null;
   }*/
   //appeler la fonction qui affiche-------------------------------------------------------------------------  
   document.getElementById("DCTd" + i).onclick = function(e) {
	DC20030227.SetDateBack(inOBJ.name,e);
 /* if(document.getElementById('valid_form')!=null)
 {
	if(valid_form==1)
	{
		form_liste.submit();
 		valid_form=0;
	}
 }*/
   };
   indx = indx + 1;
  };
  document.getElementById("DCYear").innerHTML = this.dY;
  document.getElementById("DCMonth").innerHTML = inOBJ.aLng.a[2][this.dM];
  //document.getElementById("DCClose").onmouseover = function() {fStatusOver(inOBJ.aLng.a[3][3]);};
  //document.getElementById("DCClose").onmouseout = fStatusOut;
  document.getElementById("DCPrev").onmouseover = function() {fStatusOver(inOBJ.aLng.a[3][0]);};
  document.getElementById("DCPrev").onmouseout = fStatusOut;
  document.getElementById("DCPrev").onclick = function() {DC20030227.Prev(inOBJ.name);};
  document.getElementById("DCNext").onmouseover = function() {fStatusOver(inOBJ.aLng.a[3][1]);};
  document.getElementById("DCNext").onmouseout = fStatusOut;
  document.getElementById("DCNext").onclick = function() {DC20030227.Next(inOBJ.name);};
  document.getElementById("DCYearPrev").onmouseover = function() {fStatusOver(inOBJ.aLng.a[3][4]);};
  document.getElementById("DCYearPrev").onmouseout = fStatusOut;
  document.getElementById("DCYearPrev").onclick = function() {DC20030227.YearPrev(inOBJ.name);};
  
  document.getElementById("DCYearPrev2").onmouseover = function() {fStatusOver(inOBJ.aLng.a[3][4]);};
  document.getElementById("DCYearPrev2").onmouseout = fStatusOut;
  document.getElementById("DCYearPrev2").onclick = function() {DC20030227.YearPrev2(inOBJ.name);};
  
  document.getElementById("DCYearNext").onmouseover = function() {fStatusOver(inOBJ.aLng.a[3][4]);};
  document.getElementById("DCYearNext").onmouseout = fStatusOut;
  document.getElementById("DCYearNext").onclick = function() {DC20030227.YearNext(inOBJ.name);};
  
  document.getElementById("DCYearNext2").onmouseover = function() {fStatusOver(inOBJ.aLng.a[3][4]);};
  document.getElementById("DCYearNext2").onmouseout = fStatusOut;
  document.getElementById("DCYearNext2").onclick = function() {DC20030227.YearNext2(inOBJ.name);};
 };

 this.InitTable = function()
 {
  var str = "", i = 0;
  str += "<table id=\"DCTable\" border=\"0\" cellspacing=\"0\" style=\"background-color:#FFFFFF;visibility:visible;z-index:1000;display:block;position:relative;top:0;left:0;\">";
  str += "<tr height=\"8\">";
  str += "<td width=\"19\" style=\"font-size:1px;\">&nbsp;</td>";
  str += "<td width=\"140\" colspan=\"7\" style=\"border-top:0px solid #8183A2;font-size:1px\">&nbsp;</td>";
  str += "<td width=\"19\" style=\"font-size:1px;\">&nbsp;</td>";
  str += "</tr>";
  str += "<tr height=\"20\">";
  str += "<td id=\"DCPrev\" align=\"center\" valign=\"middle\" style=\"border-left:0px solid #8183A2;cursor:hand;\"><img src=\"" + this.imgPath + "c_mp.gif\" border=\"0\" width=\"11\" height=\"11\"></td>";
  str += "<td id=\"DCMonth\" colspan=\"7\" align=\"center\" style=\"font-family:Tahoma;font-size:x-small;font-weight:bold;\">&nbsp;</td>";
  str += "<td id=\"DCNext\" align=\"center\" valign=\"middle\" style=\"border-right:0px solid #8183A2;cursor:hand;\"><img src=\"" + this.imgPath + "c_ms.gif\" border=\"0\" width=\"11\" height=\"11\"></td>";
  str += "</tr>";
  str += "<tr height=\"20\">";
  str += "<td style=\"border-left:0px solid #8183A2;font-size:1px\">&nbsp;</td>";
  for (var i = 0; i < 7; i++) {
   str += "<td id=\"DCDay" + i + "\" align=\"center\" width=\"20\" style=\"font-family:Tahoma;font-size:x-small;font-weight:bold;\">&nbsp;</td>";
  };
  str += "<td style=\"border-right:0px solid #8183A2;font-size:1px\">&nbsp;</td>";
  str += "</tr>";
  str += "<tr height=\"20\">";
  str += "<td style=\"border-left:0px solid #8183A2;font-size:1px\">&nbsp;</td>";
  for (var i = 0; i < 42; i++) {
   if (i != 0) {
    if (i % 7 == 0) {
     str += "<td style=\"border-right:0px solid #8183A2;font-size:1px\">&nbsp;</td>";
     str += "</tr>";
     str += "<tr height=\"20\">";
     str += "<td style=\"border-left:0px solid #8183A2;font-size:1px\">&nbsp;</td>";
    }
   }
   str += "<td id=\"DCTd" + i + "\" align=\"center\" width=\"20\" style=\"font-family:Tahoma;font-size:x-small;font-weight:bold;\">&nbsp;</td>";
  };
  str += "<td style=\"border-right:0px solid #8183A2;font-size:1px\">&nbsp;</td>";
  str += "</tr>";
  str += "<tr height=\"17\">";
  str += "<td style=\"font-size:1px;\">&nbsp;</td>";
  str += "<td align=\"center\" valign=\"middle\"><div id='DCYearPrev2' style=\"border-bottom:0px solid #8183A2;cursor:pointer;padding-bottom:2px;\"><img src=\"" + this.imgPath + "c_mpl.png\" border=\"0\" width=\"11\" height=\"11\"></div><div id=\"DCYearPrev\" style=\"border-bottom:0px solid #8183A2;cursor:pointer;\"><img src=\"" + this.imgPath + "c_mp.gif\" border=\"0\" width=\"11\" height=\"11\"></div></td>";
  str += "<td id=\"DCYear\" colspan=\"5\" align=\"center\" style=\"border-bottom:0px solid #8183A2;font-family:Tahoma;font-size:x-small;font-weight:bold;\">&nbsp;</td>";
  str += "<td align=\"center\" valign=\"middle\"><div id=\"DCYearNext2\"  style=\"border-bottom:0px solid #8183A2;cursor:pointer;padding-bottom:2px;\"><img src=\"" + this.imgPath + "c_mpr.png\" border=\"0\" width=\"11\" height=\"11\"></div><div id=\"DCYearNext\"  style=\"border-bottom:0px solid #8183A2;cursor:pointer;\"><img src=\"" + this.imgPath + "c_ms.gif\" border=\"0\" width=\"11\" height=\"11\"></div></td>";
  str += "<td id=\"DCClose\">&nbsp;</td>";
  str += "</tr>";
  str += "</table>";
 //document.body.insertAdjacentHTML("beforeend", str);
 document.getElementById('insertcal').innerHTML = str;
 };

 this.IsValidDate = function( inNAME )
 {
  this.dCtrl.IsValidDate(inNAME)
 };

 this.InitAll = function()
 {
  var i = 0, n = "";
  for (i = 0; i < this.aDC.length; i++) {
   n = this.aDC[i].name;
   this.aDC[i].aLng = new CLanguage(this.aDC[i].lng);
   this.dCtrl.Add(n, this.aDC[i].form);
   this.dCtrl.SetDateFormat(n, this.aDC[i].dFmt);
   this.dCtrl.SetErrMsg(n, this.aDC[i].aLng.a[4]);
   this.aDC[i].form.onblur = function() {DC20030227.IsValidDate(n)}
  };
 };

 this.Init = function()
 {
  this.LoadImg();
  this.InitAll();
  this.InitTable();
 };

};

DC_Structure = function( inNAME, inFORM )
{
 this.name = inNAME;
 this.form = inFORM;//nom du champ à remplir
 this.dFmt = "jj/mm/aaaa";
 this.lng = "FR";
 this.aLng = null;
 this.fDayWeek = 0;
 this.top = 0;
 this.left = 0;
 this.hideSelect = new Array();
};

fStatusOver = function( inSTATUS )
{
 window.status = inSTATUS;
 return true;
};

fStatusOut = function()
{
 window.status = " ";
 return true;
};
var CLANG = 
[
 [
  "FR",
  ["D", "L", "M", "M", "J", "V", "S"],
  ["JANVIER", "FEVRIER", "MARS", "AVRIL", "MAI", "JUIN", "JUILLET", "AOUT", "SEPTEMBRE", "OCTOBRE", "NOVEMBRE", "DECEMBRE"],
  ["Mois précédent", "Mois suivant", "Afficher le calendrier", "Fermer le calendrier", "Année précédente", "Année suivante"],
  "Veuillez vérifier le format de la date."
 ],
 [
  "EN",
  ["S", "M", "T", "W", "T", "F", "S"],
  ["JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"],
  ["Previous month", "Next month", "Show calendar", "Close calendar", "Previous year", "Next year"],
  "Please check date format."
 ]
];

CLanguage = function( inLANG )
{
 this.a = CLANG[0];
 this.Init = function()
 {
  if (inLANG + "" != "") {
   var i = 0, lng = inLANG.toUpperCase();
   for (i = 0; i < CLANG.length; i++) {
    if (CLANG[i][0].toUpperCase() == lng) {
     this.a = CLANG[0];//toujours en francais :p
     break;
    }
   };
  }
 };
 this.Init();
};
// DateControl v1.0 - Aurelien
//
// v1.0 :           18/01/2003
//   - DateControl  : v1.0
//   - DC_Instance  : v1.0
//   - DC_Format    : v1.0

// Array des delimiteurs :
var aDel =
[
 "/",
 "-",
 ":"
];

DateControl = function() {

 // Array de stockage des differentes
 // instances de controles de date
 this.gDC = new Array();

 // Methode d'ajout d'une instance
 this.Add = function( inNAME, inFORM )
 {
  this.gDC[this.gDC.length] = new DC_Instance(inNAME, inFORM);
 };

 // Methode de recuperation d'une instance
 this.GetObject = function( inNAME )
 {
  var i = 0, oObj = null;
  for (i = 0; i < this.gDC.length; i++) {
   if (this.gDC[i].name == inNAME) {
    oObj = this.gDC[i];
    break;
   }
  };
  return oObj;
 };

 // Methode publique pour la verification de date
 this.IsValidDate = function( inNAME )
 {
  var oObj = this.GetObject(inNAME);
  if (oObj) {
   if (oObj.vInit == 0) {
    oObj.Init();
    oObj.vInit = 1;
   }
   if (oObj.input.value + "" != "") {
    if (this.CheckDate(oObj.input.value, oObj.oFmt)) {
     return true;
    } else {
     oObj.input.value = "";
     alert(oObj.sErrMsg + " ( " + oObj.sFmt + " )");
     return false;
    }
   }
  }
 };

 // Methodes de changement des proprietes d'une instance
 this.SetErrMsg = function( inNAME, inMSG )
 {
  if ("" + inMSG != "") {
   var oObj = this.GetObject(inNAME);
   if (oObj) {
    oObj.sErrMsg = inMSG;
   }
  }
 };
 this.SetDateFormat = function( inNAME, inFMT )
 {
  if ("" + inFMT != "") {
   var oObj = this.GetObject(inNAME);
   if (oObj) {
    oObj.sFmt = inFMT;
    oObj.Init();
    oObj.vInit = 1;
   }
  }
 };


 // Methode de controle sur date
 // en fonction du format selectionne
 this.CheckDate = function( inDATE, inFMT )
 {
  var aD, dD, dM, dY, s, dYDigit;
  s = inDATE;
  aD = s.split(inFMT.sDel);
  dD = Math.round(parseFloat(aD[inFMT.aFmt[1]]));
  dM = Math.round(parseFloat(aD[inFMT.aFmt[2]])) - 1;
  dY = Math.round(parseFloat(aD[inFMT.aFmt[3]]));
  s = dY + "";
  dYDigit = s.length;
  if (isNaN(dD) || isNaN(dM) || isNaN(dY) || (dY < 1) || (dD < 1) || (dM < 0) || (dM > 11) || (dYDigit != 4) || (dD > this.DaysIn(dM, dY))){
   return false;
  } else{
   if (dM == 1) {
    if (!this.IsLeap(dY) && dD == 29) {
     return false;
    } else {
     return true;
    }
   } else {
    return true;
   }
  }
 };

 // Methode pour connaitre le nombre de jours dans un mois
 this.DaysIn = function( inMONTH, inYEAR )
 {
  var m = 0;
  if (("§0§§2§§4§§6§§7§§9§§11§").indexOf("§" + inMONTH + "§") >= 0) {
   m = 31;
  } else if (("§3§§5§§8§§10§").indexOf("§" + inMONTH + "§") >= 0) {
   m = 30;
  } else {
   if (this.IsLeap(inYEAR)) {
    m = 29;
   } else {
    m = 28;
   }
  }
  return m;
 };

 // Methode de verification annee bissextile
 this.IsLeap = function( inYEAR )
 {
  if (inYEAR % 400 == 0) {
   return true;
  } else if ((inYEAR % 4 == 0) && (inYEAR % 100 != 0)){
   return true;
  } else {
   return false;
  }
 };

};

DC_Instance = function( inNAME, inFORM ) {

 // Proprietes par defaut
 this.sFmt = "jj/mm/aaaa";
 this.sErrMsg = "Veuillez vérifier le format de date.";
 this.name = inNAME;
 this.input = inFORM;
 this.vInit = 0;

 // Methode d'initialisation de l'instance
 this.Init = function()
 {
  this.oFmt = new DC_Format(this.sFmt, this);
  this.vInit = 1;
 };

};

DC_Format = function( inFMT )
{

 // Attention : Si aucune combinaison ne correspond
 //             au format d'entree ( inFMT ), le format
 //             jj/mm/aaaa sera selectionne par defaut

 // Proprietes par defaut
 this.eMsg = 0;
 this.sDel = "";
 this.aFmt = null;

 // Methode d'initialisation de l'instance
 // Cette methode recherche le format de date
 // parametre en fonction des delimiteurs
 // possibles et des combinaisons de format
 this.Init = function()
 {
  var i = 0, dOK = 0, s = "", fOK = 0, a;
  // On cherche le delimiteur
  for (i = 0; i < aDel.length; i++) {
   if (inFMT.split(aDel[i]).length == 3) {
    this.sDel = aDel[i];
    dOK = 1;
    break;
   }
  };
  if (dOK == 0) {
   // Le delimiteur n'existe pas, on selectionne "/" par defaut
   this.sDel = this.aDel[0];
   oObj.sFmt = "jj/mm/aaaa";
  } else {
   // On cherche la combinaison
   a = inFMT.split(this.sDel);
   for (i = 0; i < a.length; i++) {
    s += a[i];
   };
   for (i = 0; i < aFmt.length; i++) {
    if (s == aFmt[i][0]) {
     this.aFmt = aFmt[i];
     fOK = 1;
     break;
    }
   };
   if (fOK == 0) {
    // Le format n'existe pas, on selectionne jjmmaaaa par defaut
    this.aFmt = aFmt[0];
   }
  }
 };

 // Methode de recuperation de la date
 // avec le format selectionne
 this.GetDateFormatted = function( inDAY, inMONTH, inYEAR )
 {
  var dD = "", dM = "", i = 0, s0 = "", s1 = "", s2 = "", s = "";
  if ((inDAY + "").length < 2) {dD = "0" + inDAY;} else {dD = inDAY;}
  dM = inMONTH + 1;
  if ((dM + "").length < 2) {dM = "0" + dM;}
  for (i = 1; i < this.aFmt.length; i++) {
   eval("s" + this.aFmt[i] + " = '§" + i + "§';");
  };
  s = s0 + this.sDel + s1 + this.sDel + s2;
  s = s.replace("§1§", dD);
  s = s.replace("§2§", dM);
  s = s.replace("§3§", inYEAR);
  return s;
 };

 // On initialise
 this.Init();

};

// Array des combinaisons de format de date
var aFmt =
[
 ["jjmmaaaa", "0", "1", "2"],
 ["jjaaaamm", "0", "2", "1"],
 ["mmjjaaaa", "1", "0", "2"],
 ["mmaaaajj", "2", "0", "1"],
 ["aaaammjj", "2", "1", "0"],
 ["aaaajjmm", "1", "2", "0"],
 ["ddmmyyyy", "0", "1", "2"],
 ["ddyyyymm", "0", "2", "1"],
 ["mmddyyyy", "1", "0", "2"],
 ["mmyyyydd", "2", "0", "1"],
 ["yyyymmdd", "2", "1", "0"],
 ["yyyyddmm", "1", "2", "0"]
];

var DCAL = null;

GetDomLeft = function ( oNode )
{
  var oCurrentNode = oNode;
  var iLeft = 0;
  while (oCurrentNode.tagName != "BODY") {
    iLeft += oCurrentNode.offsetLeft;
    oCurrentNode = oCurrentNode.offsetParent;
  };
  return iLeft;
};
GetDomTop = function ( oNode )
{
  var oCurrentNode = oNode;
  var iTop = 0;
  while (oCurrentNode.tagName != "BODY") {
    iTop += oCurrentNode.offsetTop;
    oCurrentNode = oCurrentNode.offsetParent;
  };
  return iTop;
};
function myInit(nom) {

 // On recupere les objets images
 
 oImg1 = document.getElementById("iDC1");

 // On instancie l'objet Calendar
 DCAL = new DOMCalendar();

 // On affecte le repertoire image
 DCAL.SetImgPath(repertoire+"/Img/");

 // On ajoute des zones Calendar
 // Name, Form : Nom et formulaire a controler

 DCAL.AddCalendar("DC1", document.getElementById(nom));

  // On affecte le premier jour de la semaine
 // 0 : Dimanche -> 6 : Samedi
 DCAL.SetFirstDayOfWeek("DC1", 1);  
 // On affecte la position par rapport a l'image
 if(ecart_top==null)
{ ecart_top=0; }
if(oImg1!=null)
{
DCAL.SetPosition("DC1", GetDomLeft(oImg1) + oImg1.offsetWidth - ecart_left, GetDomTop(oImg1) +40 + ecart_top);
}else{
DCAL.SetPosition("DC1", ecart_left, ecart_top);
}
// On affecte les SelectList
 
/* DCAL.HideSelectList("DC1", document.DCForm.tSelect_1);
 DCAL.HideSelectList("DC1", document.DCForm.tSelect_2);
*/
 DCAL.Init();
 DCAL.Show('DC1');

};
