// JavaScript Document
// Wilson May Ltd. Copyright 2007
// Author: Paul May

// This script requires a markup div with id="date".
// Todays date in the form of "Saturday 03.07.2007" is
// inserted into the div.
function displayDate()
{
	var date  = new Date();
	
	var day   = paddZero( date.getUTCDate() );
	var month = paddZero( date.getUTCMonth() + 1 );
	var year  = date.getUTCFullYear();
	
	var today = new Array(7);
	
	today[0] = "Sunday";
	today[1] = "Monday";
	today[2] = "Tuesday";
	today[3] = "Wednesday";
	today[4] = "Thursday";
	today[5] = "Friday";
	today[6] = "Saturday";
	
	// Check if the methods are supported and
	// that the div id is present in the web page.
	if( !document.getElementById('date') ){
		
		// Not supported.
		return;
	}
	
	// Supported. Set the page date.
	document.getElementById('date').innerHTML = today[date.getUTCDay()] + "  " + day + "." + month + "." + year;

}

// Helper function to padd a number less that ten
// with an extra leading zero e.g. 5 becomes 05
function paddZero(number){
	
	return( (number < 10 ) ? "0" : "") + number;
		   
}