function MyGetDate(champs) {
IE = !(document.all?0:1);
NS = !IE;
dest = champs;
if (IE) { 
// Taille du calendrier
  larg = 200; 
  Long = 140;
  posX = event.screenX; posY = event.screenY;
  if (posX+larg > screen.width) posX = screen.width - larg;
  if (posY+Long > screen.height) posY = screen.height - Long;
  eval("maFen = window.open('','','top='+posY+',left='+posX+',width="+larg+",height="+Long+"');");
  maFen.focus();
  dessine();
  } 
}

function dessine() {

txt  = '<html><head><title>Choisissez une date.</title>\n';
txt += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n';
txt += '<script>\n';
txt += 'var now = new Date(); var auj=new Date();\nIE = !(document.all?0:1);\nNS = !IE;\n';

txt += 'months = new Array(\'Janvier\',\'Février\',\'Mars\',\'Avril\',\'Mai\',\'Juin\',\'Juillet\',\'Août\',\'Septembre\',\'Octobre\',\'Novembre\',\'Décembre\');\n';
txt += 'mois = now.getMonth();\nan = now.getFullYear();\njour = now.getDate();\nvide = " .. ";\n \n';

// Affectation des dates aux bouttons
txt += 'function init() {\n';
txt += 'document.calendar.curMonth.value = months[mois] + " " + an;\n';
txt += 'document.calendar.curMonth.readOnly = true;\n';
txt += 'now.setMonth(mois);\n';
txt += 'now.setYear(an);\n';
txt += 'now.setDate(1);\n';
txt += 'var k = 0;\n';
txt += 'var l = now.getDay();\n';
txt += 'if(now.getDay()==0) { k=1; l=7 ;\n';
txt += '	    jour = "0"+now.getDate();\n';
txt += '		m = now.getMonth(); y=now.getYear();\n';
txt += '		eval("document.calendar.b00.value = \' "+jour+" \';");\n';
txt += '		border = "1px solid #999999"\n';
txt += '		if (jour == auj.getDate() && m == auj.getMonth() && y == auj.getYear()) {  col="blue"; back="#FAFAFA";} else {col="#000000"; back="#E5FCDD";}';
txt += '		eval("document.calendar.b00.style.color=\'"+col+"\';");\n';
txt += '		eval("document.calendar.b00.style.border=\'"+border+"\';");\n';
txt += '		eval("document.calendar.b00.style.backgroundColor=\'"+back+"\';");\n';
txt += '		}\n';
txt += 'for(i=1;i<l;i++) { eval("document.calendar.b"+0+i+".value = \' " + vide + " \' ;");eval("document.calendar.b"+0+i+".style.border=\'1px solid #C0C0C0\';"); eval("document.calendar.b"+0+i+".style.backgroundColor=\'#CECECE\';"); eval("document.calendar.b"+0+i+".style.color=\'#CECECE\';"); }\n';
txt += 'for(i=now.getDay();i<7;i++) {\n';
txt += '	    jour = "0"+now.getDate();\n';
txt += '		m = now.getMonth(); y=now.getYear();\n';
txt += '		eval("document.calendar.b"+k+""+i+".value = \' "+jour+" \';");\n';
txt += '		border = "1px solid #999999"\n';
txt += '		if (jour == auj.getDate() && m == auj.getMonth() && y == auj.getYear()) {  col="blue"; back="#FAFAFA";} else {col="#000000"; back="#E5FCDD";}';
txt += '		eval("document.calendar.b"+k+""+i+".style.color=\'"+col+"\';");\n';
txt += '		eval("document.calendar.b"+k+""+i+".style.border=\'"+border+"\';");\n';
txt += '		eval("document.calendar.b"+k+""+i+".style.backgroundColor=\'"+back+"\';");\n';
txt += '		now.setDate(now.getDate()+1);\n';
txt += '		}\n';
txt += 'for(j=k+1;j<6;j++) {\n';
txt += ' 	 for(i=0;i<7;i++) {\n';
txt += '		if (jour==vide || now.getDate() < jour) { jour = vide; } else { jour = now.getDate(); }\n';
txt += '		if (jour < 10) { jour = "0"+jour; }\n';
txt += '		m = now.getMonth(); y=now.getYear();\n';
txt += '		border = "1px solid #999999"\n';
txt += '		c = j ; if (i==0) { c = j-1 ; }\n';
txt += '		eval("document.calendar.b"+c+i+".value = \' "+jour+" \' ;");\n';
txt += '		if (jour == auj.getDate() && m == auj.getMonth() && y==auj.getYear()) { border="1px solid #000000"; col="blue"; back="#FAFAFA";} else {col="#000000"; back="#E5FCDD";}';
txt += '		if (jour==vide) { border = "1px solid #C0C0C0"; back = "#CECECE"; col = "#CECECE"}\n';
txt += '		eval("document.calendar.b"+c+i+".style.color=\'"+col+"\';");\n';
txt += '		eval("document.calendar.b"+c+i+".style.border=\'"+border+"\';");\n';
txt += '		eval("document.calendar.b"+c+i+".style.backgroundColor=\'"+back+"\';");\n';
txt += '		now.setDate(now.getDate()+1);\n';
txt += '		}\n';
txt += '	}\n';
txt += '		eval("document.calendar.b50.value = \' "+vide+" \' ;");\n';
txt += '		eval("document.calendar.b50.style.border=\'1px solid #C0C0C0\';"); eval("document.calendar.b50.style.backgroundColor=\'#CECECE\';"); eval("document.calendar.b50.style.color=\'#CECECE\';")';
txt += '}\n\n';

// Mois suivant
txt += 'function next() {\n';
txt += 'if (mois == 11) { mois = 0; an = an + 1; } else { mois += 1; }\n';
txt += 'init();\n';
txt += '}\n\n';

// Mois précédent
txt += 'function prev() {\n';
txt += 'if (mois == 0) { mois = 11; an -= 1; } else { mois -= 1; }\n';
txt += 'init();\n';
txt += '}\n\n';

// Année suivante
txt += 'function nexty() {\n';
txt += 'an = an + 1;\n';
txt += 'init();\n';
txt += '}\n\n';

// Année précédente
txt += 'function prevy() {\n';
txt += 'an = an - 1;\n';
txt += 'init();\n';
txt += '}\n\n';

// 
txt += 'function lz(valeur) { if (valeur < 10) return("0"+valeur); else return(valeur); }\n\n';

// retour et fermeture du calendrier
txt += 'function done(but) {\n';
txt += 'txt = but.value.substr(1,2);\n';
txt += 'if (txt == vide.substr(0,2)) return;\n';

/*
   Si on veut l'année sur 2 digits, ajouter ligne suivante :
   txt += 'an = an+""; an = an.substr(2,2);'; // Y2K compliant :o) comme ils disent là-bas.
*/

txt += 'txt = txt+"/"+lz(mois+1)+"/"+an;\n';
txt += 'opener.document.' + dest.form.name + '.' + dest.name + '.value = txt;\n';
txt += 'window.close();\n';
txt += '}\n';

txt += '</script>\n</head>\n<style>\n';
txt += 'td { color: white; font-weight: bold; text-align: center; }\n';

// Couleur des boutons
txt += '.bak { height:18px; background-color : #FDFDFD ; border-bottom: 1px solid #000000; border-top: 2px solid #000000; font: 9px Verdana, Arial; color : #000000;}\n';
txt += 'INPUT.form {FONT-WEIGHT: normal; FONT-SIZE: 9px; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px; FONT-STYLE: normal; FONT-FAMILY: Arial,Verdana,Helvetica; TEXT-DECORATION: none}';
// Texte
txt += 'td { font-size: 14px; color:#000000 ;}\n';

// Couleurs de fond de table et de document
txt += 'body { background: #D5D6DA; }\n';
txt += 'table { background:#D5D6DA; }\n';
txt += '.Input { width: 28px; background:#EEEEEE; border: 1px solid #999999; font: 9px Verdana, Arial; color : #000000; }\n';
txt += '.but { height: 17px ;width: 22px; background:#EEEEEE; border: 1px solid #999999; font: 10px Verdana, Arial; text-align : center; color : #000000; }\n';

txt += 'TD.normal { FONT-WEIGHT: normal; FONT-SIZE: 11px; COLOR: black; FONT-STYLE: normal; FONT-FAMILY: Arial,Verdana,Helvetica; TEXT-DECORATION: none}\n</style>\n';

txt += '<body leftmargin="0" topmargin="0"; onLoad="init();">\n';
txt += '<form name="calendar">\n';
txt += '<table border="0" cellspacing="0" cellpadding="0" bgcolor="#F1E1F1" align=center>\n';

txt += '<tr>\n';
txt += '<td colspan=7 align=center>\n';
txt += '<input type="button" class="but" style="background: url(images/calendar_but2_left.gif)" name="bk" value=" " onclick="prevy()" style="cursor:pointer"><input type="button" class="but" style="background: url(images/calendar_but1_left.gif)" name="bk" value=" " onclick="prev()" style="cursor:pointer"><input type="text" name="curMonth" class="but" style="width:110px;"><input type="button" name="bk" value=" " class="but" style="background: url(images/calendar_but1_right.gif)" onclick="next()"><input type="button" class="but" style="background: url(images/calendar_but2_right.gif)" name="bk" value=" " onclick="nexty()" style="cursor:pointer">\n';
txt += '</td>\n';
txt += '</tr>\n';
txt += '<tr><td class="bak">Lun</td><td class="bak">Mar</td><td class="bak">Mer</td><td class=bak>Jeu</td><td class="bak">Ven</td><td class="bak">Sam</td><td class="bak">Dim</td></tr>\n';
// Création des bouttons
for (i=0;i<6;i++) {
  txt += '<tr>\n';
  for (j=1;j<7;j++) {
	txt += '<td><input type="button" name="b'+i+j+'" onclick="done(this)" style="cursor:pointer" class="Input"></td>\n';
    }
	txt += '<td><input type="button" name="b'+i+0+'" onclick="done(this)" style="cursor:pointer" class="Input"></td>\n';
  txt += '</tr>\n';
  } 

txt += '</table></form></body>\n';

// Création de la page
txt += '<script>\n';
txt += 'init();\n';
txt += '</script></html>\n';
maFen.document.write(txt);
}
