// Copyright Medina Truck & Tractor Pullers Assocation, 2008
// Coded by Ryan Winland, BSCS

// Function to Return the Given Date in the Following String Format: Weekday, Month, XXth YYYY
function getFormatedDate( date ) {
	var date = new Date(date);
	return formatWeekday(date) + ' ' + formatMonth(date) + ' ' + date.getDate() + formatDateSuffix(date) + ', ' + date.getFullYear();
}

// Function to Return a Weekday String from the Given Date
function formatWeekday ( date ) {
	var weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
	return weekdays[date.getDay()];
}

// Function to Return a Month String from the Given Date
function formatMonth ( date ) {
	var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
	return months[date.getMonth()];
}

// Function to Return a Date String w/Suffix (e.g. 1st, 2nd, 3rd) from the Given Date
function formatDateSuffix ( date ) {
	var date = date.getDate();
	switch ( (date % 10) * (date < 11 || date > 13) ) {
		case 1: return "st"; case 2: return "nd"; case 3: return "rd"; default: return "th";
	}
}

