function buildCal(m, y, cM, cH, cDW, cD, brdr,url){
var mn=['January','February','March','April','May','June','July','August','September','October','November','December'];
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;
var t='<table id="calendar"  cellspacing="0" cellpadding="0" >';
if((m)==1){prevyear= y-1;prevmonth=12}else{prevyear = y;prevmonth = m-1;};
if((m)==12){nextyear= y+1;nextmonth=1}else{nextyear = y;nextmonth = m+1;};
//t+='<caption> <a href="#" class="nav" onclick="updatecalendarText('+prevmonth+','+prevyear+');new Ajax.Updater(\'populateDates\', \'populateDates/monthDrop/'+(prevmonth-1)+'|'+prevyear+'\', {asynchronous:true, evalScripts:true});return false;"><<</a> '+mn[m-1]+' - '+y+' <a href="#" class="nav" onclick="updatecalendarText('+nextmonth+','+nextyear+');new Ajax.Updater(\'populateDates\', \'populateDates/monthDrop/'+(nextmonth-1)+'|'+nextyear+'\', {asynchronous:true, evalScripts:true});return false;">>></a> </caption><tbody><tr>';
t+='<caption> <a href="#" class="nav" onclick="updatecalendarText('+prevmonth+','+prevyear+');new Ajax.Updater(\'populateDates\', \''+url+'/populateDates/monthDrop/'+(prevmonth-1)+'|'+prevyear+'\', {asynchronous:true, evalScripts:true});return false;"><<</a> <a href="'+url+'/date/year/'+y+'/month/'+m+'/day/all" class="caption">'+mn[m-1]+' - '+y+'</a> <a href="#" class="nav" onclick="updatecalendarText('+nextmonth+','+nextyear+');new Ajax.Updater(\'populateDates\', \''+url+'/populateDates/monthDrop/'+(nextmonth-1)+'|'+nextyear+'\', {asynchronous:true, evalScripts:true});return false;">>></a> </caption><tbody><tr>';
for(s=0;s<7;s++)t+='<th scope="col">'+"SMTWTFS".substr(s,1)+'</th>';
t+='</tr><tr>';
for(i=1;i<=42;i++){
var x=((i-oD.od>=0)&&(i-oD.od<dim[m-1]))? i-oD.od+1 : '&nbsp;';
if (x==scanfortoday) //DD added
{x='<td id="day'+x+'" class="today"><a href="'+url+'/date/year/'+y+'/month/'+m+'/day/'+x+'">'+x+'</a></td>'}
else {x='<td id="day'+x+'" class="notToday"><a href="'+url+'/date/year/'+y+'/month/'+m+'/day/'+x+'">'+x+'</a></td>'}
; //DD added
//t+='<td>'+x+'</td>';
t+=x;
if(((i)%7==0)&&(i<36))t+='</tr><tr>';
}
return t+='</tr></tbody></table>';
}

