/*********************************************************************************
*
*  Written by Nick Korbel : nkorbel@hotmail.com
*  for free use by anyone.
*
*  Please read these comments completely before
*  using this script.
*
*  ================================================
*  | This script will display the current date in |
*  | the following format:                        |
*  |                                              |
*  | Day, Month Date, Year                        |
*  | ie) Thursday, June 27th, 2002                |
*  ================================================
*
*
*  ==========================  
*  Installation instructions:
*  ==========================
*
*  This script can be linked into a your web page
*  or pasted directly into the code
*
*  -------------------------------------------------
*  + To link the script, insert the following line
*    anywhere before where you wish to display the date
*    
*  <script language="javascript" type="text/javascript" src="getDate.js"></script>
*  -------------------------------------------------
*
*  -------------------------------------------------
*  + To paste script directly, insert the following
*    line, followed by the script itself, and a
*    closing </script> tag
*  
*  <script language="javascript" type="text/javascript">
*        // paste script here
*  </script>
*  -------------------------------------------------
*
*  -------------------------------------------------  
*  + To use this script to display the current date,
*    simply paste the following code where you want
*    the date to appear: 
*    (Note: the script must be pasted or linked before 
*     this code is inserted)
*
*  <script language="javascript" type="text/javascript"> writeDate(); </script>
*  -------------------------------------------------
*
*  NOTE:     The font can be changed by enclosing the writeDate() script
*            line with font tags or CCS markups.
*
*  WARNING!: When pasting or linking this script, completely 
*            delete all comments (every line starting with a *).
*            This is crucial, or else the script will not work.
*
*********************************************************************************/


function writeDate() {

	var theDate = new Date();
	var day = theDate.getDay();
	var year = theDate.getYear();
	var month = theDate.getMonth();
	var date = theDate.getDate();

	// format day name
	switch(day) {
		case 1:
			dayString = "Monday";
			break;
		case 2:
			dayString = "Tuesday";
			break;
		case 3:
			dayString = "Wednesday";
			break;
		case 4:
			dayString = "Thursday";
			break;
		case 5:
			dayString = "Friday";
			break;
		case 6:
			dayString = "Saturday";
			break;
		case 7:
			dayString = "Sunday";
			break;
		}

	dayString += ", ";	// add some formatting

	// format month name
	switch(month) {
		case 0:
			dayString += "January";
			break;
		case 1:
			dayString += "February";
			break;
		case 2:
			dayString += "March";
			break;
		case 3:
			dayString += "April";
			break;
		case 4:
			dayString += "May";
			break;
		case 5:
			dayString += "June";
			break;
		case 6:
			dayString += "July";
			break;
		case 7:
			dayString += "August";
			break;
		case 8:
			dayString += "September";
			break;
		case 9:
			dayString += "October";
			break;
		case 10:
			dayString += "November";
			break;
		case 11:
			dayString += "December";
			break;
		}

	// determine appending formatting
	if (date < 21)
		append = date;
	else
		append = date % 10;
	
	// apply appending formatting
	switch(append) {
		case 1:
			appendString = "st";
			break;
		case 2:
			appendString = "nd";
			break;
		case 3:
			appendString = "rd";
			break;
		default:
			appendString = "th";
			break;
	}
	
	// fix for non-IE browsers
	if (year < 2000)
		year+=1900;
		
	dayString += " " + date + appendString + ", " + year;  // put it all together

	document.write(dayString);  // write it out
}