/***********************************************
* Basic Calendar-By Brian Gosselin at http://scriptasylum.com/bgaudiodr/
* Script featured on Dynamic Drive (http://www.dynamicdrive.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function buildCal(d, m, y, cM, cH, cDW, cD){
if(d==0) return '';
var mn=['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'];
var dim=[31,0,31,30,31,30,31,31,30,31,30,31];


var oD = new Date(y, m-1, 1); //DD replaced line to fix date bug when current day is 31st
oD.od=oD.getDay()+1; //DD replaced line to fix date bug when current day is 31st

var todaydate=new Date() //DD added
var scanfortoday=(y==todaydate.getFullYear() && m==todaydate.getMonth()+1)? todaydate.getDate() : 0 //DD added

dim[1]=(((oD.getFullYear()%100!=0)&&(oD.getFullYear()%4==0))||(oD.getFullYear()%400==0))?29:28;

y=y+'';
y=y.substr(-2);

var t='<table cols="7" cellpadding="0" cellspacing="0" class="'+cM+'" width="120px">';
t+='<caption class="'+cH+'"><div class="cap-left"><div class="cap-right">&nbsp;'+mn[m-1]+' '+y+'&nbsp;</div></div></caption><tr align="center">';
for(s=0;s<7;s++)t+='<td class="'+cDW+'">'+"LuMaMeGiVeSaDo".substr(s*2,2)+'</td>';
t+='</tr><tr align="center">';
for(i=1;i<=42;i++){
var x=((i+1-oD.od>=0)&&(i+1-oD.od<dim[m-1]))? i+1-oD.od+1 : '';
if(x==d) x='<span id="thisday">'+x+'</span>';
if (x==scanfortoday) x='<u>'+x+'</u>'; //DD added
t+='<td class="'+cD+'">'+x+'</td>';
if(((i)%7==0)&&(i<36))t+='</tr><tr align="center">';
}
return t+='</tr></table>';
}