function buildCal(m, y, cM, cH, cDW, cD, brdr){
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='<div class="'+cM+'">';
	
t+='<table class="'+cM+'" cols="7" cellpadding="0" border="'+brdr+'" cellspacing="0"><tr align="center">';
t+='<td colspan="7" align="center" class="'+cH+'">'+mn[m-1]+' - '+y+'</td></tr><tr align="center">';
for(s=0;s<7;s++)t+='<td class="'+cDW+'">'+"SMTWTFS".substr(s,1)+'</td>';
t+='</tr><tr align="center">';
for(i=1;i<=42;i++){
var x=((i-oD.od>=0)&&(i-oD.od<dim[m-1]))? i-oD.od+1 : '&nbsp;';
var y=null;

//if (x==scanfortoday) //DD added
//x='<span id="today">'+x+'</span>' //DD added

//-------------------------------------------------------------------------------------------
// JANUARY
//-------------------------------------------------------------------------------------------



if((m==1)&&(x==2))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group C Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==1)&&(x==9))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group D Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==1)&&(x==16))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group E Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}


else if((m==1)&&(x==23))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'SHO-DAN CLASS\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==1)&&(x==30))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group A Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

//-------------------------------------------------------------------------------------------
// FEBRUARY
//-------------------------------------------------------------------------------------------

else if((m==2)&&(x==6))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group B Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==2)&&(x==13))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group C Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==2)&&(x==20))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group D  Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==2)&&(x==27))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group E  Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

//-------------------------------------------------------------------------------------------
// MARCH
//-------------------------------------------------------------------------------------------


else if((m==3)&&(x==5))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'NI-DAN CLASS\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==3)&&(x==12))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group A Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==3)&&(x==19))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group B Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==3)&&(x==26))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group C Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}


//---------------------------------------------------------------------------------------------------
//APRIL 
//---------------------------------------------------------------------------------------------------
else if((m==4)&&(x==2))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group D Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==4)&&(x==9))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group E  Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==4)&&(x==16))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'SAN-DAN & YON-DAN CLASS\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==4)&&(x==21))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'SATURDAY = SHIAI 9am to 12n (schedule to be announced soon)\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==4)&&(x==23))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group A Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==4)&&(x==30))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group B Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

//-----------------------------------------------------------------------------------------------------
//  MAY
//-----------------------------------------------------------------------------------------------------

else if((m==5)&&(x==7))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group C Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==5)&&(x==14))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group D Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==5)&&(x==21))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group E Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==5)&&(x==28))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'DOJO CLOSED - HOLIDAY\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

//-----------------------------------------------------------------------------------------------------
//  JUNE
//-----------------------------------------------------------------------------------------------------

else if((m==6)&&(x==4))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'SHO-DAN CLASS\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}


else if((m==6)&&(x==11))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group A Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}


else if((m==6)&&(x==15))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Gasshuku\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==6)&&(x==16))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Gasshuku\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==6)&&(x==17))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Gasshuku\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==6)&&(x==18))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group B Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==6)&&(x==25))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group C Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

//-----------------------------------------------------------------------------------------------------
//  JULY
//-----------------------------------------------------------------------------------------------------

else if((m==7)&&(x==2))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group D Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==7)&&(x==4))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'HOLIDAY - DOJO CLOSED\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==7)&&(x==9))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group E Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==7)&&(x==16))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group A Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}


else if((m==7)&&(x==23))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group B Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==7)&&(x==30))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'NI-DAN CLASS\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

//-----------------------------------------------------------------------------------------------------
//  AUGUST
//-----------------------------------------------------------------------------------------------------

else if((m==8)&&(x==6))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group C Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}


else if((m==8)&&(x==13))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group D Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==8)&&(x==20))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group E Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==8)&&(x==27))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'SAN-DAN & YON-DAN CLASS\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

//-----------------------------------------------------------------------------------------------------
//  SEPTEMBER
//-----------------------------------------------------------------------------------------------------
else if((m==9)&&(x==3))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'DOJO CLOSED - HOLIDAY\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==9)&&(x==10))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group A Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==9)&&(x==17))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group B Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==9)&&(x==24))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group C Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

//-----------------------------------------------------------------------------------------------------
//  OCTOBER
//-----------------------------------------------------------------------------------------------------
else if((m==10)&&(x==1))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group D Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==10)&&(x==8))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group E Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==10)&&(x==15))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'SHO-DAN CLASS\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==10)&&(x==22))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group A Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==10)&&(x==29))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group B Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==10)&&(x==31))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'HOLIDAY - DOJO CLOSED\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

//-----------------------------------------------------------------------------------------------------
//  NOVEMBER
//-----------------------------------------------------------------------------------------------------

else if((m==11)&&(x==5))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group C Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==11)&&(x==12))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group D Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==11)&&(x==19))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group E Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==11)&&(x==22))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'DOJO CLOSED - HOLIDAY\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==11)&&(x==23))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'DOJO CLOSED - HOLIDAY\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==11)&&(x==24))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'DOJO CLOSED - HOLIDAY\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==11)&&(x==26))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'NI-DAN CLASS\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

//-----------------------------------------------------------------------------------------------------
//  DECEMBER
//-----------------------------------------------------------------------------------------------------


else if((m==12)&&(x==3))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group A Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==12)&&(x==10))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group B Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==12)&&(x==17))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'Group C Kobudo\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==12)&&(x==24))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'DOJO CLOSED - HOLIDAY\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==12)&&(x==25))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'DOJO CLOSED - HOLIDAY\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==12)&&(x==26))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'DOJO CLOSED - HOLIDAY\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==12)&&(x==27))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'DOJO CLOSED - HOLIDAY\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==12)&&(x==28))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'DOJO CLOSED - HOLIDAY\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==12)&&(x==29))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'DOJO CLOSED - HOLIDAY\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==12)&&(x==30))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'DOJO CLOSED - HOLIDAY\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}

else if((m==12)&&(x==31))
{

	t+='<td class="'+cD+'"><a onmouseover="popup(\'DOJO CLOSED - HOLIDAY\')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">'+x+'</a></td>';

}


else
{
	t+='<td class="'+cD+'">'+x+'</td>';
}
if(((i)%7==0)&&(i<36))t+='</tr><tr align="center">';

}
t+='</tr></table></div>';
return t;
}


