// JavaScript Document

/*the following js is for creating different dates features on your webpage. The code is self explanitory.*/

function dateString(date,string) {//begin date function
var year=date.getFullYear();//get the current year
var month=date.getMonth();//begin get month by number
var realMonth=month+1;
var fillMonth = realMonth;
	if (realMonth<10) {
	  fillMonh = '0' + realMonth;
	}//end get month by number
var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];//get month by name
var monthName = months[month];//end get month by name
var day = date.getDate();//get date by number
var fillDate = day;
	if (day<10) {
	  fillDate = '0' + day;
	}//end get date by number
var weekday = date.getDay();//begin get weekday by name
var weekdays = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
var dayName = weekdays[weekday];//end get weekday by name
//begin string token changes
string = string.replace(/%Y/g,year);//changes any %Y match to the year value example 2009
string = string.replace(/%y/g,year.toString().slice(-2));//changes any %y match to the two digit year example 09
string = string.replace(/%M/g,monthName);//changes month value
string = string.replace(/%m/g,monthName.slice(0,3));//abbreviates month name to first three letters
string = string.replace(/%N/g,fillMonth);
string = string.replace(/%n/g,realMonth);
string = string.replace(/%W/g,dayName);
string = string.replace(/%w/g,dayName.slice(0,3));
string = string.replace(/%D/g,fillDate);
string = string.replace(/%d/g,day);
return string;
//end string token changes
}//end date function
//The next variable allows you to setup the dateString the way you want it displayed on your page. Fill in the display info between the quotes.
//Run the var message inside the body of the page where ever you would like it displayed.
//var message = dateString(today, '');
//Remember that variable message has been used in the above function. DO NOT use it again.