var bg="#ffffff";//Specify bgcolor of calendar
var numMonths = 1;var theCMonth = pdy.getMonth();var theCYear = pdy.getFullYear();
var flg = 0; var theInHTML = "" ;var fs=1;
M = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
D = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
M1 = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
function getBgn() 
{mo = pdy.getMonth();    // start month
 pyr = pdy.getFullYear();     // todays year
 theInHTML += '<TABLE bgcolor="#ffffff" align="center" cellspacing="0" cellpadding="0" width="250" BORDER="0"><TR><TD VALIGN=TOP>';
 for (var lC = 0;lC < numMonths;lC++)
	{if (lC!=0)
		{mo++;}
	 pyr =((mo)>11?pyr+1:pyr);
	 mo = ((mo)>11?0:mo);
	 bgn = new Date(M[mo]+" 1,"+pyr); // assign to date
	 Calendar();           // build Month
	theInHTML += '</TD></TR><tr><td colspan="3" align="center" class="td9" bgcolor="#ffffff">Click a date to select it</td></tr></TABLE>';
	document.getElementById("theCal").innerHTML =(theInHTML)
	}
 }
function Calendar()
{dy = bgn.getDay();
yr = eval(pyr);
d = "312831303130313130313031";
if (yr / 4 == Math.floor(yr / 4)) 
	{d = d.substring(0, 2) + "29" + d.substring(4, d.length);}
pos = (mo * 2);
ld = eval(d.substring(pos, pos + 2));
theInHTML += '<TABLE BORDER="0" width="250" BGCOLOR="' + bg + '"><TR><TD ALIGN="CENTER" COLSPAN="7" class="td8" valign="top"><table align="center" cellpadding="0" cellspacing="0" width="100%"><tr><td width="13" valign="top"><img src="Images/homePage/Components/calendarPrevious.gif" width="16" height="13" align="top" hspace="5" vspace="1" style="cursor:pointer;" onclick="doNextDate(-1)" title="click here to see all the events for the previous month"></td><td class="td8"><span onclick="doMonthDate()" style="cursor:pointer;color:#339933;" title="click here to see all the events for this month">'+ M[mo] + '</span> ' + yr+ '</td><td width="13"><img src="Images/homePage/Components/calendarNext.gif" width="16" height="13" align="top" hspace="5" vspace="1" style="cursor:pointer;" onclick="doNextDate(1)" title="click here to see all the events for the next month"></td></tr></table></td></TD></TR><TR><TR>';
for (var i = 0;i < 7;i ++)
	{theInHTML += '<TD ALIGN="CENTER" class="td7">' + D[i]+'</TD>';}
theInHTML += "</TR><TR>";
ctr = 0;
for (var i = 0;i < 7; i++)
	{if (i < dy) 
		{theInHTML += "<TD ALIGN=CENTER>"+"<FONT SIZE=" + fs + "> </FONT>"+"</TD>";}
	 else 
		 {ctr++; if(theEventDate[ctr] ==1){eventTxt=' style="border:1px #ff0000 solid;" '+' onclick="doSetDate(' + ctr + ',' + mo + ',' + yr + ')"'}else{eventTxt=' style="cursor:default;" '} 
		  theInHTML += '<TD ALIGN="CENTER"'+eventTxt  +' onclick="doSetDate(' + ctr + ',' + mo + ',' + yr + ')" class="td6">'+ ctr + '</TD>';
		 }
	}
theInHTML += "</TR><TR>";
while (ctr < ld) 
	{for (var i = 0;i < 7; i++)
		{ctr++;
			if (ctr > ld)
				{theInHTML += "<TD ALIGN=CENTER>"+ " </TD>";}
			else 
				{if(theEventDate[ctr] ==1){eventTxt=' style="border:1px #ff0000 solid;" '+' onclick="doSetDate(' + ctr + ',' + mo + ',' + yr + ')"'}else{eventTxt=' style="cursor:default;" '} 
				 theInHTML += '<TD ALIGN="CENTER"'+eventTxt +' class="td6">'+ ctr + '</TD>';}
		 		
		}
	 theInHTML += "</TR><TR>";
	}
theInHTML += "</TR></TABLE>";

}
function doNextDate(n)
{var theCMonth = pdy.getMonth() + 1;var theCYear = pdy.getFullYear();
 theCMonth += n;
 theCMonth > 12 ? theCYear += 1 :theCYear += 0
 theCMonth > 12 ? theCMonth = 1 : theCMonth += 0
 theCMonth < 1 ? theCYear -= 1 :theCYear += 0
 theCMonth < 1 ? theCMonth = 12 : theCMonth += 0
 window.location="index.cfm?theMonth="+theCMonth.toString(10)+"&theYear="+theCYear.toString(10);
}
function doSetDate(dd,mm,yy)
{window.location="events.cfm?theReqMonth="+dd.toString(10)+" "+M1[theEmonth - 1]+" "+theEYear.toString(10)+"&theMonth="+theEmonth.toString(10)+"&theYear="+theEYear.toString(10)+"&theMode=1";}
function doMonthDate()
{window.location="events.cfm?theReqMonth="+theEDate+"&theMonth="+theEmonth.toString(10)+"&theYear="+theEYear.toString(10);}
