//************************
//Script by Roger Easley
//************************

var Calendar = new Date();

var year = Calendar.getFullYear();	    // Returns year
var nMonth = Calendar.getMonth();    // Returns month (0-11)
var today = Calendar.getDate();    // Returns day (1-31)
var weekday = Calendar.getDay();    // Returns day (1-31)
var month = nMonth; // instance of nMonth to compare for highlighting todays date

var mName = new Array();

mName[0] = new Array("January 08", "2", "31");  // Month Name, First day falls on, Days in month
mName[1] = new Array("February 08", "5", "29");
mName[2] = new Array("March 08", "6", "31");
mName[3] = new Array("April 08", "2", "30");
mName[4] = new Array("May 08", "4", "31");
mName[5] = new Array("June 08", "7", "30");
mName[6] = new Array("July 08", "2", "31");
mName[7] = new Array("August 08", "5", "31");
mName[8] = new Array("September 08", "1", "30");
mName[9] = new Array("October 08", "3", "31");
mName[10] = new Array("November 08", "6", "30");
mName[11] = new Array("December 08", "1", "31");


var events = new Array();
	events[0] = new Array(); // Jan
		events[0][0] = new Array("11", "images/icon/icon_hd.png", "Xtreme Quest Enemy Territory: Quake Wars Game Night<br>DWC Facility 6:00PM - 12:00PM");
		events[0][1] = new Array("18", "images/icon/icon_hd.png", "Xtreme Quest Enemy Territory: Quake Wars Game Night<br>DWC Facility 6:00PM - 12:00PM");
		events[0][2] = new Array("25", "images/icon/icon_hd.png", "Xtreme Quest Enemy Territory: Quake Wars Game Night<br>DWC Facility 6:00PM - 12:00PM");
		
	events[1] = new Array(); // Feb
	    events[1][0] = new Array("4", "images/icon/icon_hd.png", "Culdcept SAGA Demo Showcase<br>Each customer gets one free hour to try the game.");
		events[1][1] = new Array("5", "images/icon/icon_hd.png", "Call of Duty 4 PC Game Night<br>7pm - 10pm<br>more info at http://www.igames.org/CoD4GameNight<br>Culdcept SAGA Demo Showcase<br>Each customer gets one free hour to try the game.");
		events[1][2] = new Array("6", "images/icon/icon_hd.png", "Counter-Strike Source Game Night<br>7pm - 10pm<br>more info at http://www.igames.org/CSSGameNight<br>Culdcept SAGA Demo Showcase<br>Each customer gets one free hour to try the game.");
		events[1][3] = new Array("7", "images/icon/icon_hd.png", "Halo 3 Game Night<br>7pm - 10pm<br>more info at http://www.igames.org/Halo3GameNight<br>Culdcept SAGA Demo Showcase<br>Each customer gets one free hour to try the game.");
		events[1][4] = new Array("8", "images/icon/icon_hd.png", "Culdcept SAGA Demo Showcase<br>Each customer gets one free hour to try the game.");
		events[1][5] = new Array("9", "images/icon/icon_hd.png", "Culdcept SAGA Demo Showcase<br>Each customer gets one free hour to try the game.");
		events[1][6] = new Array("10", "images/icon/icon_hd.png", "Culdcept SAGA Demo Showcase<br>Each customer gets one free hour to try the game.");
		events[1][7] = new Array("12", "images/icon/icon_hd.png", "Call of Duty 4 PC Game Night<br>7pm - 10pm<br>more info at http://www.igames.org/CoD4GameNight");
		events[1][8] = new Array("13", "images/icon/icon_hd.png", "Counter-Strike Source Game Night<br>7pm - 10pm<br>more info at http://www.igames.org/CSSGameNight");
		events[1][9] = new Array("14", "images/icon/icon_hd.png", "Halo 3 Game Night<br>7pm - 10pm<br>more info at http://www.igames.org/Halo3GameNight");
		events[1][10] = new Array("16", "images/icon/icon_hd.png", "Madden 08 Promotion");
		events[1][11] = new Array("17", "images/icon/icon_hd.png", "Madden 08 Promotion");
		events[1][12] = new Array("19", "images/icon/icon_hd.png", "Call of Duty 4 PC Game Night<br>7pm - 10pm<br>more info at http://www.igames.org/CoD4GameNight");
		events[1][13] = new Array("20", "images/icon/icon_hd.png", "Counter-Strike Source Game Night<br>7pm - 10pm<br>more info at http://www.igames.org/CSSGameNight");
		events[1][14] = new Array("21", "images/icon/icon_hd.png", "Halo 3 Game Night<br>7pm - 10pm<br>more info at http://www.igames.org/Halo3GameNight");
		events[1][15] = new Array("23", "images/icon/icon_hd.png", "Madden 08 Promotion<br>Girls Wii Sports Tournament<br>Starting at 1pm");
		events[1][16] = new Array("26", "images/icon/icon_hd.png", "Call of Duty 4 PC Game Night<br>7pm - 10pm<br>more info at http://www.igames.org/CoD4GameNight");
		events[1][17] = new Array("27", "images/icon/icon_hd.png", "Counter-Strike Source Game Night<br>7pm - 10pm<br>more info at http://www.igames.org/CSSGameNight");
		events[1][18] = new Array("28", "images/icon/icon_hd.png", "Halo 3 Game Night<br>7pm - 10pm<br>more info at http://www.igames.org/Halo3GameNight");

		
	events[2] = new Array(); //March
		events[2][0] = new Array("3", "images/icon/icon_hd.png", "The Club Showcase<br>Try The Club for one hour, free!<br>Frontlines: Fuel of War Showcase<br>All Day Event!");
		events[2][1] = new Array("4", "images/icon/icon_hd.png", "Call of Duty 4 PC Game Night<br>7pm-10pm<br>more info at http://www.igames.org/CoD4GameNight<br>The Club Showcase<br>Try The Club for one hour, free!<br>Frontlines: Fuel of War Showcase<br>All Day Event!");
		events[2][2] = new Array("5", "images/icon/icon_hd.png", "Counter-Strike Source Game Night<BR>7pm-10pm<br>more info at http://www.igames.org/CSSGameNight<br>The Club Showcase<br>Try The Club for one hour, free!<br>Frontlines: Fuel of War Showcase<br>All Day Event!");
		events[2][3] = new Array("6", "images/icon/icon_hd.png", "Halo 3 Game Night<br>7pm-10pm<br>more info at http://www.igames.org/Halo3GameNight<br>The Club Showcase<br>Try The Club for one hour, free!<br>Frontlines: Fuel of War Showcase<br>All Day Event!");
		events[2][4] = new Array("7", "images/icon/icon_hd.png", "The Club Showcase<br>Try The Club for one hour, free!<br>Frontlines: Fuel of War Showcase<br>All Day Event!");
		events[2][5] = new Array("8", "images/icon/icon_hd.png", "The Club Showcase<br>Try The Club for one hour, free!<br>Frontlines: Fuel of War Showcase<br>All Day Event!");
		events[2][6] = new Array("9", "images/icon/icon_hd.png", "The Club Showcase<br>Try The Club for one hour, free!<br>Frontlines: Fuel of War Showcase<br>All Day Event!");
		events[2][7] = new Array("10", "images/icon/icon_hd.png", "The Club Showcase<br>Try The Club for one hour, free!<br>Frontlines: Fuel of War Showcase<br>All Day Event!");
		events[2][8] = new Array("11", "images/icon/icon_hd.png", "Call of Duty 4 PC Game Night<br>7pm-10pm<br>more info at http://www.igames.org/CoD4GameNight<br>The Club Showcase<br>Try The Club for one hour, free!<br>Frontlines: Fuel of War Showcase<br>All Day Event!");
		events[2][9] = new Array("12", "images/icon/icon_hd.png", "Counter-Strike Source Game Night<BR>7pm-10pm<br>more info at http://www.igames.org/CSSGameNight<br>The Club Showcase<br>Try The Club for one hour, free!<br>Frontlines: Fuel of War Showcase<br>All Day Event!");
		events[2][10] = new Array("13", "images/icon/icon_hd.png", "Halo 3 Game Night<br>7pm-10pm<br>more info at http://www.igames.org/Halo3GameNight<br>The Club Showcase<br>Try The Club for one hour, free!<br>Frontlines: Fuel of War Showcase<br>All Day Event!");
		events[2][11] = new Array("14", "images/icon/icon_hd.png", "The Club Showcase<br>Try The Club for one hour, free!<br>Frontlines: Fuel of War Showcase<br>All Day Event!");
		events[2][12] = new Array("15", "images/icon/icon_hd.png", "The Club Showcase<br>Try The Club for one hour, free!<br>Frontlines: Fuel of War Showcase<br>All Day Event!");
		events[2][13] = new Array("16", "images/icon/icon_hd.png", "The Club Showcase<br>Try The Club for one hour, free!<br>Frontlines: Fuel of War Showcase<br>All Day Event!");
		events[2][14] = new Array("18", "images/icon/icon_hd.png", "Call of Duty 4 PC Game Night<br>7pm-10pm<br>more info at http://www.igames.org/CoD4GameNight");
		events[2][15] = new Array("19", "images/icon/icon_hd.png", "Counter-Strike Source Game Night<BR>7pm-10pm<br>more info at http://www.igames.org/CSSGameNight");
		events[2][16] = new Array("20", "images/icon/icon_hd.png", "Halo 3 Game Night<br>7pm-10pm<br>more info at http://www.igames.org/Halo3GameNight");
		events[2][17] = new Array("25", "images/icon/icon_hd.png", "Call of Duty 4 PC Game Night<br>7pm-10pm<br>more info at http://www.igames.org/CoD4GameNight");
		events[2][18] = new Array("26", "images/icon/icon_hd.png", "Counter-Strike Source Game Night<BR>7pm-10pm<br>more info at http://www.igames.org/CSSGameNight");
		events[2][19] = new Array("27", "images/icon/icon_hd.png", "Halo 3 Game Night<br>7pm-10pm<br>more info at http://www.igames.org/Halo3GameNight");
		
	events[3] = new Array(); //April
		events[3][0] = new Array("1", "images/icon/icon_hd.png", "Call of Duty 4 PC Game Night<br>7pm-10pm<br>more info at http://www.igames.org/CoD4GameNight");
		events[3][1] = new Array("2", "images/icon/icon_hd.png", "Counter-Strike Source Game Night<BR>7pm-10pm<br>more info at http://www.igames.org/CSSGameNight");
		events[3][2] = new Array("3", "images/icon/icon_hd.png", "Halo 3 Game Night<br>7pm-10pm<br>more info at http://www.igames.org/Halo3GameNight");
		
	events[4] = new Array(); //May
		events[4][0] = new Array("8", "images/icon/icon_hd.png", "Halo 3 game night");
		events[4][1] = new Array("11", "images/icon/icon_hd.png", "Rainbow 6 Vegas 2 Game Night");
		events[4][2] = new Array("14", "images/icon/icon_hd.png", "Call of Duty 4 XBOX 360 Game night");
		events[4][3] = new Array("15", "images/icon/icon_hd.png", "Halo 3 game night");
		events[4][4] = new Array("16", "images/icon/icon_hd.png", "Girls Slumber Party");
		events[4][5] = new Array("18", "images/icon/icon_hd.png", "Rainbow 6 Vegas 2 Game Night");
		events[4][6] = new Array("21", "images/icon/icon_hd.png", "Call of Duty 4 XBOX 360 Game night");
		events[4][7] = new Array("22", "images/icon/icon_hd.png", "Halo 3 game night");
		events[4][8] = new Array("24", "images/icon/icon_hd.png", "Rockingham Toyota Scion Forza Racing Tournament");
		events[4][9] = new Array("25", "images/icon/icon_hd.png", "Rainbow 6 Vegas 2 Game Night");
		events[4][10] = new Array("28", "images/icon/icon_hd.png", "Call of Duty 4 XBOX 360 Game night");
		events[4][11] = new Array("29", "images/icon/icon_hd.png", "Halo 3 game night");
		
	events[5] = new Array(); // June
		events[5][0] = new Array("1", "images/icon/icon_hd.png", "Rainbow 6 Vegas 2 Game Night");
		events[5][1] = new Array("4", "images/icon/icon_hd.png", "Call of Duty 4 XBOX 360 Game night");
		events[5][2] = new Array("5", "images/icon/icon_hd.png", "Halo 3 game night");
		events[5][3] = new Array("8", "images/icon/icon_hd.png", "Rainbow 6 Vegas 2 Game Night");
		events[5][4] = new Array("11", "images/icon/icon_hd.png", "Call of Duty 4 XBOX 360 Game night");
		events[5][5] = new Array("12", "images/icon/icon_hd.png", "Halo 3 game night");
		events[5][6] = new Array("13", "images/icon/icon_hd.png", "Call of Duty 4 Tournament/Lock In with First Responders");
		events[5][7] = new Array("15", "images/icon/icon_hd.png", "Rainbow 6 Vegas 2 Game Night");
		events[5][8] = new Array("16", "images/icon/icon_hd.png", "School's out bash!");
		events[5][9] = new Array("18", "images/icon/icon_hd.png", "Call of Duty 4 XBOX 360 Game night");
		events[5][10] = new Array("19", "images/icon/icon_hd.png", "Halo 3 game night");
		events[5][11] = new Array("22", "images/icon/icon_hd.png", "Rainbow 6 Vegas 2 Game Night");
		events[5][12] = new Array("23", "images/icon/icon_hd.png", "Webkinz Tea party!");
		events[5][13] = new Array("25", "images/icon/icon_hd.png", "Call of Duty 4 XBOX 360 Game night");
		events[5][14] = new Array("26", "images/icon/icon_hd.png", "Halo 3 game night");
		events[5][15] = new Array("29", "images/icon/icon_hd.png", "Rainbow 6 Vegas 2 Game Night");
		
		
	events[6] = new Array(); // July
		
		
	events[7] = new Array(); //Aug
		
		
	events[8] = new Array(); //Sep
		
		
	events[9] = new Array(); //Oct
	
		
	events[10] = new Array(); //Nov
		
		
	events[11] = new Array(); //Dec
		


// Write enitial calendar
startDay=mName[month][1];
daysInMonth=mName[month][2];
count=1;
day=1;
var calendar='<tr><td colspan="7" align="center"><font size="4"><b><span style= "cursor: pointer" onclick=generate("bak")> <<< </span>  &nbsp <span id="mnth">' + mName[month][0] + '</span> &nbsp <span style= "cursor: pointer" onclick=generate("fwrd")> >>> </span></b></font></td></tr>\n<tr bgcolor="#363636"><td width="65" align="center"><font size="1">Monday</font></td><td width="65" align="center"><font size="1">Tuesday</font></td><td width="65" align="center"><font size="1">Wednesday</font></td><td width="65" align="center"><font size="1">Thursday</font></td><td width="65" align="center"><font size="1">Friday</font></td><td width="65" align="center"><font size="1">Saturday</font></td><td width="65" align="center"><font size="1">Sunday</font></td></tr>';


// Move ahead or back in time
function generate(drc){
	document.getElementById('txt').innerHTML="Click the Day for Event Details";

	if(drc=='bak'){
		month--;
	}
	else{
		month++;
	}
	if(month > 11){
		month = 0;
	}
	if(month < 0){
		month = 11;
	}
	document.getElementById('mnth').innerHTML=mName[month][0]; //write new month name
	startDay=mName[month][1];
	daysInMonth=mName[month][2];
	count=1;
	day=1;

	for(w=1; w<=42; w++){
		document.getElementById('d' + count).style.backgroundColor= '#535353';
		document.getElementById('d' + count).style.background='none';
		document.getElementById('d' + count).style.color='#D7D8D8';
		document.getElementById('d' + count).style.cursor='auto';
		document.getElementById('d' + count).innerHTML='';       // clear cell properties
					if(count >= startDay && day <= daysInMonth){
						document.getElementById('d' + count).style.backgroundColor= '#4A4A4A';
						document.getElementById('d' + count).innerHTML=day;


						for(j=0; j<events[month].length; j++){
							if(day == events[month][j][0]){
								document.getElementById('d' + count).style.cursor='pointer';
								document.getElementById('d' + count).style.background='url(' + events[month][j][1] + ')';
							}
						}

						day++;
					}
					count++;
			}
	if(month==nMonth){
		today=parseFloat(today);
		startDay=parseFloat(startDay);
		dDay=eval(today-1+startDay);
		document.getElementById('d'+ dDay).style.color='#3EB5FD';
	}
}

// Display text message
function display(elm){
	elm=elm-mName[month][1]+1;
		for(j=0; j<events[month].length; j++){
			if (elm == events[month][j][0]){
					document.getElementById('txt').innerHTML=events[month][j][2];
					return;
				}
				document.getElementById('txt').innerHTML="No Event Today";
			}
}
