dt=new Date();
text="Today is ";

day=dt.getDay()
if (day==0) text += "Sunday"
else if (day==1) text += "Monday"
else if (day==2) text += "Tuesday"
else if (day==3) text += "Wednesday"
else if (day==4) text += "Thursday"
else if (day==5) text += "Friday"
else if (day==6) text += "Saturday"
text+=", ";

month=dt.getMonth();
if (month==0) text += "January"
if (month==1) text += "February"
if (month==2) text += "March"
if (month==3) text += "April"
if (month==4) text += "May"
if (month==5) text += "June"
if (month==6) text += "July"
if (month==7) text += "August"
if (month==8) text += "September"
if (month==9) text += "October"
if (month==10) text += "November"
if (month==11) text += "December"

data=dt.getDate();
text+=" "+data+", ";

if (dt.getYear() < 2000) text += " " + (1900 + dt.getYear()) 
else text += " " + (dt.getYear())

hourGreat=dt.getHours();
if (hourGreat>=0 && hourGreat<5) {greeting="Fantastic dreamings!"; bgcolor="#000000"; color1="#AD9AEA"; color2="#ff8800"}
if (hourGreat>=5 && hourGreat<12) {greeting="Good morning!"; bgcolor="#66A8F4"; color1="#ffff00"; color2="#0000ff"}
if (hourGreat>=12 && hourGreat<19) {greeting="Good day!"; bgcolor="#aaaaaa"; color1="#f0f000"; color2="#000000"}
if (hourGreat>=19) {greeting="Time to have a supper!"; bgcolor="#464ECD"; color1="#00d0ff"; color2="#ffaa00"}

setInterval("clock()",1000);
function showFilled(Value) {return (Value > 9) ? "" + Value : "0" + Value;}
function clock() {
time=new Date();
chour=time.getHours();
cmin=time.getMinutes();
csec=time.getSeconds();
timeClock=choicemode()
timeClock += ":" + showFilled(cmin) + ":" + showFilled(csec) + military()
document.clock.real.value=timeClock}

function setmodeclock() {
verifymode()
clockmode = (clockmode=="24") ? "12" : "24"
var clock="clock=" + clockmode;
var expDays="30";
var exp=new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
clock=clock + "; expires=" + exp.toGMTString();
document.cookie=clock;
alert("Your choice: " + clockmode + " Hour Time Clock!")}

function verifymode() {
var clock = document.cookie;
var clock = unescape(clock);
clockmode = (clock.indexOf("clock=12")!=-1) ? "12" : "24"
return(clockmode)
}

function choicemode() {
verifymode()
if (clockmode=="24") return (showFilled(chour))
else {timeClock = ((chour>12) ? chour-12 : chour); if (timeClock == "0") timeClock=12; return(showFilled(timeClock))}
}

function military() {
verifymode()
if (clockmode=="24") return ("")
else {timeClock = (chour >= 12) ? " P.M." : " A.M."; return(timeClock)}}

document.write('<table width=\"100%\" bgcolor='+bgcolor+'><tr class=\"great\">')
document.write('<td valign="middle" width="20%">***</td>')
document.write('<td valign="middle" width="60%"><font color='+color1+'>'+greeting)
document.write('<br><font color='+color2+'><small>'+text+'</small></font>')
document.write("</td>")
document.write('<td valign="middle" width="20%">')
document.write('<form name="clock" title="The time is money!"><input type="button" onclick="setmodeclock()" name="real" title="This is a clock!\nClick on them for change mode!">')
document.write('</td></form>')
document.write("</tr></table>")
