pdha2n = null;
function choix2(koi,code)
{
if (koi!=null)
{
if (code) 
{  
koi.select_old = koi.style.background;
koi.style.background = '#c0c0FF';
}
else 
{
koi.style.background = koi.select_old;
}
}
}
//affiche le calendrier
function view_microcal2(actif,ki,source,mxS,axS)
{
if (actif)
{
//decalage du mois su on clique sur -/+
if (mxS!=-1) 
{
clearTimeout(cc);
ki.focus();
fermable_microcal=true;
dateS.mois=mxS;
dateS.annee=axS;
if (dateS.mois<1) {dateS.annee--;dateS.mois+=12;}
if (dateS.mois>12) {dateS.annee++;dateS.mois-=12;}
}
//init
Dstart=(premJourMois(dateS.mois,dateS.annee)+7-startWeek)%7;
jmaxi=JmaxMois(dateS.mois,dateS.annee);
jmaxiAvant=JmaxMois((dateS.mois-1),dateS.annee);
//si on veux ajouter le numero de la semaine ...
//idxWeek=parseInt(nbJAnnee(strucDate(new Date(dateS.mois+'-01-'+dateS.annee)))/7,10)+1;
ymaxi=parseInt((jmaxi+Dstart+1)/7,10);
//generation du tableau
//--entête
htm="<table bgcolor='#FFCC00'><tr style='font-size:9px;font-family:Tahoma;text-align:center;color:#e0e0e0;' bgcolor='#000000'>";
htm+="<td style='cursor:hand;' onclick=\"view_microcal2(true,"+ki.id+","+source.id+","+(dateS.mois-1)+","+dateS.annee+");\"><</td>";
htm+="<td colspan='5'  style='font-size:10px;font-family:Tahoma;'> <b> "+moisX[dateS.mois]+"</b>&nbsp;"+dateS.annee+"</td>";
htm+="<td  style='cursor:hand;' onclick=\"view_microcal2(true,"+ki.id+","+source.id+","+(dateS.mois+1)+","+dateS.annee+")\">></td></tr>";
//--corps
htm+="<tr>";
//affichage des jours DLMMJVS
for (x=0;x<7;x++) 
htm+="<td  style='font-size:10px;font-family:Tahoma;'><b>"+JourM[(x+startWeek)%7]+"</b></td>";
htm+="</tr>"
//------------------------
for (y=0;y<=ymaxi;y++)
{
htm+="<tr>";
for (x=0;x<7;x++)
{
idxP=y*7+x-Dstart+1;   //numero du jour
aa=dateS.annee;
xx=(x+startWeek)%7;
//jour du mois précedent
if (idxP<=0)
{
jj=idxP+jmaxiAvant;mm=dateS.mois-1;
if (mm==0)
{mm=12;aa--;}
htm+="<td style='"+testTravail(false,xx,jj,mm,aa)+"' onclick=\"choix2(pdha2n,false);pdha2n=this;choix2(this,true);"+(ki.id)+".value='"+aa+"-"+((mm<10)?"0":"")+mm+"-"+((jj<10)?"0":"")+jj+"';"+(ki.id)+".style.color='black';\">"+jj+"</td>";
}
else if (idxP>jmaxi) //jour du mois suivant
{
jj=idxP-jmaxi;mm=dateS.mois+1;
if (mm==13)
{mm=1;aa++;}
htm+="<td style='"+testTravail(false,xx,jj,mm,aa)+"' onclick=\"choix2(pdha2n,false);pdha2n=this;choix2(this,true);"+(ki.id)+".value='"+aa+"-"+((mm<10)?"0":"")+mm+"-"+((jj<10)?"0":"")+jj+"';"+(ki.id)+".style.color='black';\">"+jj+"</td>";}
else //jour du mois en cours
{
jj=idxP;mm=dateS.mois;
htm+="<td style='"+testTravail(true,xx,jj,mm,aa)+"' onclick=\"choix2(pdha2n,false);pdha2n=this;choix2(this,true);"+(ki.id)+".value='"+aa+"-"+((mm<10)?"0":"")+mm+"-"+((jj<10)?"0":"")+jj+"';"+(ki.id)+".style.color='black';\">"+jj+"</td>";}
}
htm+="</tr>"
}//-------------------------
htm+="</table>"
//affiche le tableau
source.innerHTML=htm;
source.style.visibility="";
} else
{
//ferme le calendrier
if (fermable_microcal) 
   cc=setTimeout(source.id+".style.visibility='hidden'",500);
}
}
