var MonthDays = new Array(0 , 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var MonthNames = new Array('','January','February','March','April','May','June','July','August','September','October','November','December');
BDdir = (BorD=="B")? "birthdays" : "deaths" ;

context_root = (!ROOTDIR)? "" : ROOTDIR;

OH="";

currentMonth=smonth/1;
dmonth = (smonth<10)? "0" + currentMonth : smonth ;
lfile = context_root + BDdir + "/"+ MonthNames[currentMonth];


OH += "<table cellspacing=0 cellpadding=0 width='100%' id=thecal  class=maincal >";
OH +="<tr><td colspan=5 >";
//for(x=1;x<13;x++){
//	ext = (x==smonth)?" selected " : "" ;
//	OH +="<option value=" + x + ext + " >" + MonthNames[x] + "</option >" ;
//}
NMONTH = (smonth + 1>12)? 1 : smonth + 1; 
PMONTH = (smonth - 1==0)? 12 : smonth - 1;
//OH +="<div id=monthhead align=center ><a class=la href='javascript:void(0);' onclick='doCal(" + PMONTH + ");' >&lt;&lt;&nbsp;&nbsp;</a>";
//OH += "<span>" + MonthNames[smonth] + "</span>";
//OH +="<a href='javascript:void(0);'  class=ra onclick='doCal(" + NMONTH + ");' >&nbsp;&nbsp;&gt;&gt;</a>";

//OH +="<div id=calMonth><div id=calMonthSel ></div><a href='javascript:void(0);' onclick='doCal2();' >March</a></div>";

OH +="<div id=monthhead align=center >";
OH +="<select id=monthDrop onChange='doCal();' >";
for(x=1;x<13;x++){
	selectedText = (x==smonth)?"  selected " : "";
	OH += "<option value='" + x + "' " + selectedText + " >" + MonthNames[x] + "</option>";
}
OH += "	</select >";


OH +="</td></tr>";

dday=0;vstyle="visible;";
for(x=1;x<8;x++){
	OH +="<tr>";
	for(y=1;y<6;y++){
		dday++;
	var tempDateString = (dday<10)? "0"+dday : dday ;
if(dday>MonthDays[smonth])vstyle="hidden;";
xstyle = (dday==sday)? "border:1px #FFFFFF solid;" : "" ;
		OH += "<td ><a href='"+lfile + tempDateString +".php' id='CD" + dday + "' style='visibility:" + vstyle + xstyle +"' >" + tempDateString + "</td>" ;
	}
OH +="</tr>";


}
	
OH +="</table>";
document.getElementById("caldiv").innerHTML=OH;

function doCal(){
inMonth = document.getElementById("monthDrop").value;
smonth=inMonth;

	currentMonth=inMonth/1;
dmonth = (inMonth<10)? "0" + currentMonth : inMonth ;
lfile = context_root + BDdir + "/"+ MonthNames[currentMonth];
for(x=1;x<32;x++){
	
	obj = document.getElementById("CD"+x);
	
	var tempDateString = (x<10)? "0"+x : x ;
    tref = lfile + tempDateString +".php";
	obj.href=tref;
	obj.style.visibility = (x>MonthDays[currentMonth])? "hidden" : "visible" ;
}

}


