 var mx_date_dayMS = 86400000;
var mx_date_LastUTC = new Date().getTime();

function mx_date_MonthMatrix(UTCdate) {
	UTCdate = (UTCdate == null) ? mx_date_LastUTC : UTCdate;
	var MonthMatrix = new Array();
	var StartDate = new Date(UTCdate);
	var MonthStart = new Date(Date.UTC(StartDate.getFullYear(),StartDate.getUTCMonth(),1));
	MonthStart.setHours(MonthStart.getHours() + MonthStart.getTimezoneOffset()/60);
	var DayIteration = 0;
	var thisDate = new Date(MonthStart);
	for(var row = 0; row <=5; row++) {
		MonthMatrix[row] = new Array();
		for(var col = 0; col <= 6; col++) {
			if((col < MonthStart.getDay() && row == 0) || ((thisDate.getMonth() > MonthStart.getMonth() || thisDate.getYear() > MonthStart.getYear()))) {
				MonthMatrix[row][col] = '';
			} else {
				MonthMatrix[row][col] = (thisDate.getDate());
				thisDate.setDate(thisDate.getDate() + 1);
			}
		}
	}
	mx_date_LastUTC = UTCdate;
	return MonthMatrix;
}

function adjLocalTime(utctime){
	retDate = new Date(utctime);
	return retDate.getTimezoneOffset() * 60000;
}

function mx_date_isThisDay(UTCdate) {
	var TESTDATE = new Date(UTCdate).getDay();
	var VALIDATE = new Date().getDay();
	return(TESTDATE==VALIDATE?true:false);
}

function mx_date_isThisMonth(UTCdate) {
	var TESTMONTH = new Date(UTCdate).getMonth();
	var VALIMONTH = new Date().getMonth();
	return(TESTMONTH==VALIMONTH?true:false);
}

function mx_date_MonthDayList(listtype,listnum) {
	var LIST = new Array;
	LIST["MLong"]	= new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	LIST["MShort"]	= new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
	LIST["DLong"]	= new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
	LIST["DShort"]	= new Array('Sunday','Mon','Tue','Wed','Thr','Fri','Sat');
	if ((listnum >= 0) && (LIST[listtype][listnum])) {
		return LIST[listtype][listnum];
	} else {
		return LIST[listtype];
	}
}

function mx_date_MonthLength(UTCdate) {
	var thisMonth = new Date(UTCdate);
	thisMonth.setDate(1);
	var nextMonth = new Date(thisMonth);
	nextMonth.setMonth(nextMonth.getMonth()+1);
	return Math.ceil((nextMonth.getTime() - thisMonth.getTime() - (mx_date_dayMS/24))/mx_date_dayMS);
}

function mx_date_DayofYear(UTCdate){
	var tDate = new Date(UTCdate);
	var cDate = new Date(Date.UTC(tDate.getFullYear(),0,1));
	return ((tDate.getTime() - cDate.getTime()) / mx_date_dayMS);
}