var myDay = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]
var myMonth = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]

var clockid=new Array()
var clockidoutside=new Array()
var i_clock=-1
var thistime= new Date()
var hours=thistime.getHours()
var minutes=thistime.getMinutes()
var seconds=thistime.getSeconds()
var days=myDay[thistime.getDay()]
var date=thistime.getDate()
var months=myMonth[thistime.getMonth()]
var year=thistime.getFullYear()
var ampm = "am"
if (eval(hours) > 12) {ampm = "pm"; hours = hours -12}
if (eval(minutes) < 10) {minutes="0"+minutes}
if (seconds < 10) {seconds="0"+seconds}
var thistime = hours+":"+minutes+":"+seconds+ampm+" | "+days+" "+writedate(date.toString())+" "+months+", "+year

function writedate(_date)
{
	if (_date.charAt(_date.length - 1) == "1")
	{
		return _date + "st"
	}
	else if (_date.charAt(_date.length - 1) == "2")
	{
		return _date + "nd"
	}
	else if (_date.charAt(_date.length - 1) == "3")
	{
		return _date + "rd"
	}
	
	return _date + "th"
}
	
function writeclock() {
	i_clock++
	if (document.all || document.getElementById || document.layers) {
		clockid[i_clock]="clock"+i_clock
		document.write("<span id='"+clockid[i_clock]+"' style='position:relative'>"+thistime+"</span>")
	}
}

function clockon() {
	thistime= new Date()
	hours=thistime.getHours()
	minutes=thistime.getMinutes()
	seconds=thistime.getSeconds()
	days=myDay[thistime.getDay()]
	date=thistime.getDate()
	year=thistime.getFullYear()
	months=myMonth[thistime.getMonth()]
	if (eval(hours) > 12) {ampm = "pm"; hours = hours -12}	
	if (eval(minutes) < 10) {minutes="0"+minutes}
	if (seconds < 10) {seconds="0"+seconds}
	thistime = hours+":"+minutes+":"+seconds+ampm+" | "+days+" "+writedate(date.toString())+" "+months+", "+year
		
	if (document.all) {
		for (i=0;i<=clockid.length-1;i++) {
			var thisclock=eval(clockid[i])
			thisclock.innerHTML=thistime
		}
	}
	
	if (document.getElementById) {
		for (i=0;i<=clockid.length-1;i++) {
			document.getElementById(clockid[i]).innerHTML=thistime
		}
	}
	var timer=setTimeout("clockon()",1000)
}