/* 
 *	Veselin T. Petrov - June 12, 2006
 * 	JavaScript Clock
 */ 
 

function startTime(){
	var today=new Date();
	document.getElementById('date_time').innerHTML="<nobr>&nbsp;" + today.getClockFormat() + "&nbsp;</nobr>";
	t=setTimeout('startTime()',500);
}//startTime(name)

function checkTime(i){ return (i<10)?"0"+i:""+i; }

// Date Prototypes *****************************************
Date.prototype.getFullHours = function(){ return checkTime(this.getHours());  }
Date.prototype.getFullMinutes = function(){ return checkTime(this.getMinutes());  }
Date.prototype.getFullSeconds = function(){ return checkTime(this.getSeconds());  }

Date.prototype.nameOfMonth = function(){
	var month = "";
	switch(this.getMonth()){
		case 0:		month = "Jan"; break;
		case 1:		month = "Feb"; break;
		case 2:		month = "Mar"; break;
		case 3:		month = "Apr"; break;
		case 4:		month = "May"; break;
		case 5:		month = "Jun"; break;
		case 6:		month = "Jul"; break;
		case 7:		month = "Aug"; break;
		case 8:		month = "Sep"; break;
		case 9:		month = "Oct"; break;
		case 10:	month = "Nov"; break;
		case 11:	month = "Dec"; break;
	}
	return month;
}

Date.prototype.nameOfDay = function(){
	var day = "";
	switch(this.getDay()){
		case 0:		day = "Sun"; break;
		case 1:		day = "Mon"; break;
		case 2:		day = "Tue"; break;
		case 3:		day = "Wed"; break;
		case 4:		day = "Thu"; break;
		case 5:		day = "Fri"; break;
		case 6:		day = "Sat"; break;
	}
	return day;
}

Date.prototype.getFullYear = function(){
	var year = this.getYear();
	if ( year < 1900 ) year = year + 1900;
	return year;
}

Date.prototype.getClockFormat = function(){
	return this.nameOfDay() + ", " +	this.nameOfMonth() + " " + this.getDate() + ", " + this.getFullYear() + "  " + this.getFullHours() + ":" + this.getFullMinutes() + ":" + this.getFullSeconds();
}

if (window.addEventListener) window.addEventListener("load", startTime, false)
else if (window.attachEvent) window.attachEvent("onload", startTime)
else if (document.getElementById) window.onload=startTime

