// returns current date
function printTimeStamp()
{
	DATE = getDay('W') + ', ' + getMonth('A') + ' ' + getDay('M') + ', ' + getYear();
	document.write( DATE );
}

// prints current date into page
function printDate()
{
	document.write( getDate() );
}

// returns the current time properly formatted as 00:00
function getTime(time)
{
	time += ""; // to convert time to string
	var TIME = "";
	
	if( time.length == 4 )
	{}
	else if( time.length == 3 )
		TIME = "0";
	else if( time.length == 2 )
		TIME = "00";
	else if( time.length == 1 )
		TIME = "00:0";
	else
		TIME = "00:00";
		
	for( p=0; p<time.length; p++ )
	{
		if( p == (time.length-2) )
			TIME += ":";
			
		TIME += time.charAt(p);
	}
	
	return TIME;
}

// returns current time in military time (e.g. 1200)
function getTime()
{
	return ( getHours() * 100 + getMinutes() );
}

// returns the current hours after midnight
function getHours()
{
	var DATE = new Date();
	return ( DATE.getHours() );
}

// returns the current minutes of the current time
function getMinutes()
{
	var DATE = new Date();
	return ( DATE.getMinutes() );
}

// returns the current day
// argument 'M' returns the day of the month (i.e. 1st, 2nd, etc)
// argument 'W' returns the day of the week (i.e. Monday, etc)
function getDay( weekMonth )
{
	var DATE = new Date();
	var DAY = DATE.getDay();
	
	if( weekMonth == 'M' )
		return ( DATE.getDate() );
	else if( weekMonth == 'W' )
	{
		if( DAY ==  0 )
			return "Sunday";
		else if( DAY == 1 )
			return "Monday";
		else if( DAY == 2 )
			return "Tuesday";
		else if( DAY == 3 )
			return "Wednesday";
		else if( DAY == 4 )
			return "Thursday";
		else if( DAY == 5 )
			return "Friday";
		else if( DAY == 6 )
			return "Saturday";
		else
			return "undefined";
	}
	else
		return "undefined";
}

// returns the current month
// argument '0' returns the number (i.e. 1-12)
// argument 'A' returns the name (i.e. January, etc)
function getMonth( alphaNum )
{
	var DATE = new Date();
	var MONTH = DATE.getMonth();
	
	if( alphaNum == '0' )
		return (MONTH + 1);
	else if( alphaNum == 'A' )
	{
		if( MONTH == 0 )
			return "January";
		else if( MONTH == 1 )
			return "February";
		else if( MONTH == 2 )
			return "March";
		else if( MONTH == 3 )
			return "April";
		else if( MONTH == 4 )
			return "May";
		else if( MONTH == 5 )
			return "June";
		else if( MONTH == 6 )
			return "July";
		else if( MONTH == 7 )
			return "August";
		else if( MONTH == 8 )
			return "September";
		else if( MONTH == 9 )
			return "October";
		else if( MONTH == 10 )
			return "November";
		else if( MONTH == 11 )
			return "December";
		else
			return "undefined";
	}
	else
		return "undefined";
}

function getYear()
{
	var DATE = new Date();
	var YEAR = DATE.getYear();
	if( YEAR < 1000 )
	{  YEAR += 1900; }
	return YEAR;
}

function getMonthLength(month)
{
	var LENGTH = new Array(31,28,31,30,31,30,30,31,30,31,30,31);
	if( getYear() % 4 == 0 && getYear() % 100 != 0 && month == 2 )
	{  LENGTH[1] = 29;  }
	return LENGTH[month-1];
}