var dayObjectArr = new Array();	

function daysInMonthArr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11) {
	this[0]  = m0;
	this[1]  = m1;
	this[2]  = m2;
	this[3]  = m3;
	this[4]  = m4;
	this[5]  = m5;
	this[6]  = m6;
	this[7]  = m7;
	this[8]  = m8;
	this[9]  = m9;
	this[10] = m10;
	this[11] = m11;
}

function monthNameArr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11) {
	this[0]  = m0;
	this[1]  = m1;
	this[2]  = m2;
	this[3]  = m3;
	this[4]  = m4;
	this[5]  = m5;
	this[6]  = m6;
	this[7]  = m7;
	this[8]  = m8;
	this[9]  = m9;
	this[10] = m10;
	this[11] = m11;
}

function weekDayNameArr(w0, w1, w2, w3, w4, w5, w6) {
	this[0]  = w0;
	this[1]  = w1;
	this[2]  = w2;
	this[3]  = w3;
	this[4]  = w4;
	this[5]  = w5;
	this[6]  = w6;
}

function alert_msg(str) {
	alert(str);
}

function monthFont(face, size, color) {
	this.fface  = face;
	this.fsize  = size;
	this.fcolor = color;
}

function dayObject() {
	this.fday     = 0;
	this.fface    = "Arial";
	this.fsize    = "2";
	this.fbgcolor = "white";
	this.furl	  = "";
	this.ftooltip = "";
}

function createDayObject(day) {
	dayObjectArr[day] = new dayObject();
}

function setDayFace(day, face) {
	dayObjectArr[day].fface = face;
}

function setDaySize(day, size) {
	dayObjectArr[day].fsize = size;
}

function setDayBgColor(day, bgcolor) {
	dayObjectArr[day].fbgcolor = bgcolor;
}

function setDayURL(day, url) {
	dayObjectArr[day].furl = url;
}

function setDayToolTip(day, tooltip) {
	dayObjectArr[day].ftooltip = tooltip;
}

function weekFont(face, size, color, bgcolor) {
	this.fface  = face;
	this.fsize  = size;
	this.fcolor = color;
	this.fbgcolor = bgcolor;
}

function writeCalendar(monthNames, weekDays, bgColor, monthFont, weekFont, initialDate) {
	/* OG
	if(!bgColor) {
		bgColor = "";
	}

	var date = (initialDate == null) ? new Date() : initialDate; // set initial date of calendar

	var monthDays = new daysInMonthArr(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	year = date.getYear();
	if((year - 1900) < 0) year = year + 1900;
	if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monthDays[1] = 29;

	nDays = monthDays[date.getMonth()];
	firstDay = date;
	firstDay.setDate(1);
	startDay = firstDay.getDay();

	document.write('<table border="2" bordercolor="#000000">');

	document.write('<tr>');
		document.write('<td bgcolor="#D7D7D7" align="center" colspan=1>');
			var preMonth = Number(getReqMonth());
			var preYear = Number(getReqYear());
			if(preMonth == 1) {
				preMonth = 12;
				preYear = preYear - 1;
			} else {
				preMonth = preMonth - 1;
			}
			var preLink = "javascript:reloadCalendar(" + preYear + ", " + preMonth + ")";
			document.write('<a href="', preLink, '"><img src="/evenue/linkID=test2/images/arrow-left.gif" width="8" height="15" alt="Back" border="0"><a>');
		document.write('</td>');

		document.write('<td align="center" bgcolor="#D7D7D7" colspan="5"> <font color="', monthFont.fcolor, '" face="', monthFont.fface, '" size="', monthFont.fsize, '"><b>');
		document.write(monthNames[date.getMonth()], ' ');
		document.write(year);
		document.write("</b></font size>");
		document.write('</td>');

		document.write('<td bgcolor="#D7D7D7" align="center" colspan=1>');
			var nextMonth = Number(getReqMonth());
			var nextYear = Number(getReqYear());
			if(nextMonth == 12) {
				nextMonth = 1;
				nextYear = nextYear + 1;
			} else {
				nextMonth = nextMonth + 1;
			}
			var nextLink = "javascript:reloadCalendar(" + nextYear + ", " + nextMonth + ")";
			document.write('<a href="', nextLink, '"><img src="/evenue/linkID=test2/images/arrow-right.gif" width="8" height="15" alt="Next" border="0"><a>');
		document.write('</td>');
	document.write('</tr>');

	document.write('<tr bgcolor="', weekFont.fbgcolor, '">',
		'<th>', '<font color="', weekFont.fcolor, '" face="', weekFont.fface, '" size="', weekFont.fsize, '">', weekDays[0], '</th>', 
		'<th>', '<font color="', weekFont.fcolor, '" face="', weekFont.fface, '" size="', weekFont.fsize, '">', weekDays[1], '</th>', 
		'<th>', '<font color="', weekFont.fcolor, '" face="', weekFont.fface, '" size="', weekFont.fsize, '">', weekDays[2], '</th>', 
		'<th>', '<font color="', weekFont.fcolor, '" face="', weekFont.fface, '" size="', weekFont.fsize, '">', weekDays[3], '</th>', 
		'<th>', '<font color="', weekFont.fcolor, '" face="', weekFont.fface, '" size="', weekFont.fsize, '">', weekDays[4], '</th>', 
		'<th>', '<font color="', weekFont.fcolor, '" face="', weekFont.fface, '" size="', weekFont.fsize, '">', weekDays[5], '</th>', 
		'<th>', '<font color="', weekFont.fcolor, '" face="', weekFont.fface, '" size="', weekFont.fsize, '">', weekDays[6], '</th>' );
	document.write("</tr>");

	document.write('<tr>');
	var column = 0;
	var row = 0;
	for (var i = 0; i < startDay; i++)
	{
		document.write('<td></td>');
		column++;
	}

	for (var i = 0; i < nDays; i++)
	{
		document.write('<td bgcolor="', dayObjectArr[i].fbgcolor, '">');
		document.write('<font face="', dayObjectArr[i].fface, '" size="', dayObjectArr[i].fsize, '">');
		if(dayObjectArr[i].furl) {
			if(isMac && isNav && false) {
				document.write('<a href="', '#Package', Number(i+1), '"', ' title="', dayObjectArr[i].ftooltip, '" class="calendarmenu">');
			} else {
				document.write('<a href=\"', dayObjectArr[i].furl , '\"', ' title="', dayObjectArr[i].ftooltip, '" class="calendarmenu">');
			}
		}
		document.write(i+1);
		document.write('</a>');

		column++;

		document.write('</td>');

		if (column == 7)
		{
			if(row != 5) {
				document.write("</tr>");
				document.write("<tr>");
			}
			column = 0;
			row++;
		}
	}
	
	document.write("</tr>");

	document.write("</table><br>");
	END OG */


	/* ----------------------------------------
		Upgrade Fix
	---------------------------------------- */
		
	// init variables
	var current_date = new Date();
	var current_year = current_date.getFullYear();
	var current_month = current_date.getMonth();
	
	var event_date = initialDate;
	var event_year = event_date.getFullYear();
	var event_month = event_date.getMonth();
	var event_day = event_date.getDay();
	
	var prev_year = (event_month==0 ? Number(event_year) - 1 : event_year);
	var prev_month = (event_month==0 ? 11 : Number(event_month) - 1);
	var prev_day = "";

	var next_year = (event_month==11 ? Number(event_year) + 1 : event_year);
	var next_month = (event_month==11 ? 0 : Number(event_month) + 1);
	var next_day = "";

	var temp_date = new Date(event_year, event_month+1, 0);
	var temp_day = temp_date.getDay();

	document.write(
		'<table align="center" border="0" cellpadding="0" cellspacing="1" id="calendar">',
		'	<tr>',
		'		<th class="month"><a href="javascript:reloadCalendar(', prev_year ,', ', Number(prev_month)+1 ,')">&laquo;</a></th>',
		'		<th class="month" colspan="5" nowrap><big>', moyf[event_month] ,' ', event_year ,'</big></th>',
		'		<th class="month"><a href="javascript:reloadCalendar(', next_year ,', ', Number(next_month)+1 ,')">&raquo;</a></th>',
		'	</tr>',
		'	<tr>',
		'		<th>S</th>',
		'		<th>M</th>',
		'		<th>T</th>',
		'		<th>W</th>',
		'		<th>T</th>',
		'		<th>F</th>',
		'		<th>S</th>',
		'	</tr>'
	);
	
	// print calendar spacer days
	if(event_day != 0) document.write('<tr><th colspan="', event_day ,'" class="nothing">&nbsp;</th>');
	
	next_day = event_day;

	for(var a=1; a<=temp_date.getDate(); a++) {
		if(next_day==0) document.write('<tr>');
		
		document.write('<td', (dayObjectArr[a-1].furl ? '' : ' class="calNoLink"') ,'>');
		
		if(dayObjectArr[a-1].furl) {
			if(isMac && isNav && false)
				document.write('<a href="#Package', a ,'" title="', dayObjectArr[a-1].ftooltip ,'">', a ,'</a>');
			else
				document.write('<a href="', dayObjectArr[a-1].furl ,'" title="', dayObjectArr[a-1].ftooltip ,'" class="focus">', a ,'</a>');
		} else {
			document.write(a);
		}
		
		document.write('</td>');
		
		if(next_day==6) document.write('</tr>');
		
		if(next_day==6) next_day = 0;
		else next_day++
	}

	// print calendar spacer days
	if(next_day != 0) document.write('<th colspan="', 7-next_day ,'" class="nothing">&nbsp;</th></tr>');
	
	document.write(
		'</table><br>'
	);
}

