today= new Date();
todayDate= today.getDate();
todayMonth= today.getMonth();
todayYear= today.getFullYear();
numberofmonths = 1;

thisMonth= today.getMonth();
thisYear= today.getFullYear();
start = new Date(thisYear,thisMonth,1);
startofyear = new Date(thisYear,0,1);
weekday = start.getDay();
todayDay = today.getDay();
lasttest= new Date();
ADay = 60*1000*60*24;

var WeekClassDay = new Array([[8,0,3,5,2,1,8],[8,1,6,7,4,0,8]],[[8,7,5,2,3,4,8],[8,2,4,1,0,6,8]],[[8,4,1,3,4,5,8],[8,6,2,0,1,7,8]],[[8,1,7,6,1,2,8],[8,5,0,4,5,3,8]],[[8,5,6,1,7,0,8],[8,3,7,2,6,4,8]],
[[8,3,1,6,4,2,8],[8,0,5,3,7,6,8]],[[8,1,4,0,7,6,8],[8,7,3,5,1,2,8]],[[8,6,2,4,5,3,8],[8,1,3,0,2,7,8]],[[8,2,0,5,6,7,8],[8,5,4,1,3,1,8]],[[8,3,0,7,0,1,8],[8,4,1,6,2,5,8]]);
//var WeekClassDay = new Array([[B,T,G,W,K],[L,K,D,S,B]],[[K,G,W,S,D],[S,L,B,K,T]],[[G,B,D,T,W],[D,S,W,L,K]],[[W,G,K,D,L],[T,L,S,G,B]],[[L,W,T,K,S],[S,D,L,B,G]],
//[[L,K,D,S,T],[W,B,G,T,L]],[[T,L,S,D,G],[K,W,B,L,D]],[[D,S,L,B,K],[G,W,T,W,L]],[[S,L,B,L,T],[T,G,K,D,W]],[[G,D,L,G,B],[B,T,W,K,S]])
var techs = new Array ("Basics", "Locks", "Kicks", "Strikes", "Weapons", "Grappling", "Self-Defense", "Throws/Rolls","Open Practice");
var MonthName = new Array ("January","February","March","April","May","June","July","August","September","October","November","December");
var DayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var MonthDays = new Array (31, todayYear%4==0?29:28, 31,30,31,30,31,31,30,31,30,31);

var tests = new Array ("02/28/2009", "05/09/2009","07/18/2009", "09/26/2009", "12/05/2009");
var holidays = new Array ("12/31/2009","01/01/2009", "01/19/2009", "05/25/2009", "07/04/2009","09/07/2009", "11/26/2009", "11/27/2009" ,
	"12/23/2009", "12/24/2009", "12/25/2009", "12/26/2009","12/31/2009","01/01/2010");
var seminarsdate = new Array ("01/17/2009","06/06/2009","09/12/2009","11/21/2009");
var seminars = new Array ("10am-2pm: New Curriculum","10am-2pm: Gun Defense","10am-2pm: Close Combat","10am-2pm: Pressure Points");
var camps = new Array ("07/13/2009", "07/14/2009","07/15/2009", "07/16/2009", "07/17/2009");

function lookuptoday()
{
	thedate = new Date(thedate.getFullYear(),thedate.getMonth(),thedate.getDate());
	startofyear = new Date(thedate.getFullYear(),0,1);
	weekofyear =  	 Math.floor(((60*1000*60*2 + thedate.getTime()) - (startofyear.getTime() - startofyear.getDay()*ADay))/(ADay*7))+1;
	weeksfromtest =  (weekofyear)%10;

	a_string = "No Classes";
	special = "";
	theevent = "";

	if (thedate.getDay() == 6)
		a_string = "10am "+techs[WeekClassDay[weeksfromtest][0][thedate.getDay()]];	
	if (thedate.getDay() == 2)
			a_string = "7:30pm "+techs[WeekClassDay[weeksfromtest][1][thedate.getDay()]];
	if (thedate.getDay() == 4 || thedate.getDay() == 5)
			a_string = "6pm "+techs[WeekClassDay[weeksfromtest][0][thedate.getDay()]];
	if (thedate.getDay() == 1 || thedate.getDay() == 3)
			a_string = "6pm "+techs[WeekClassDay[weeksfromtest][0][thedate.getDay()]]+" <br>7:30pm "+techs[WeekClassDay[weeksfromtest][1][thedate.getDay()]];

	for (x=0; x < tests.length; x++)
	{
		a_date = new Date(tests[x])
		if (thedate.getYear() == a_date.getYear() && thedate.getMonth() == a_date.getMonth() && thedate.getDate() == a_date.getDate())
			special = "<b>Belt Test</b>";
	}
	for (x=0; x < holidays.length; x++)
	{
		a_date = new Date(holidays[x])
		if (thedate.getYear() == a_date.getYear() && thedate.getMonth() == a_date.getMonth() && thedate.getDate() == a_date.getDate())
			special = "<b>Holiday</b>";
	}

	theevent = "<b>"+DayName[thedate.getDay()]+"</b> ("+ MonthName[thedate.getMonth()]+" "+thedate.getDate()+", "+thedate.getFullYear() + ") <br>";
	if (special == "")
		theevent += a_string;
	else
		theevent += special;
	return(theevent);	
}

function writeDays(days)
{
	thedate = new Date();
	ss ="";
	type = 2;
	for (ii=0; ii<days; ii++)
	{
		ss = ss + lookuptoday()+"<br><br>";
		thedate.setTime(thedate.getTime()+ 24*60*60*1000);
	}
	return(ss);	
}


