<!--

lat =  29.423433;  // decimal degrees
lon = -98.494621;

var NN = false;
var IE = false;
var Gecko = false;
var Timestamp = " ";
var intInterval = 0;

if (navigator.appName.indexOf("Netscape") != -1) 
	{
	 if ((navigator.appVersion.indexOf("3.") != -1) || (navigator.appVersion.indexOf("4.") != -1))
		NN = true;
	 if ((navigator.appVersion.indexOf("5.") != -1)  || (navigator.appVersion.indexOf("6.") != -1))
		Gecko = true;
	}

if(navigator.appVersion.indexOf("MSIE") != -1) 
	if ((navigator.appVersion.indexOf("4.") != -1)  || (navigator.appVersion.indexOf("5.") != -1)  || (navigator.appVersion.indexOf("6.") != -1))
		IE = true;

//if (Gecko | IE)
//	document.write('<div id="clock" style="text-align: center; border: thin solid blue; font-size: 8pt; color: blue;"> </div>');
//	document.write('<div id="clock" style="text-align: center; border: thin solid blue; font-size: 8pt; color: blue; position: absolute; margin-left: 0px; width: 160px; top: 320px; left: 165px;"> </div>'); 
//  	document.write('<div id="clock2" style="text-align: center; border: thin solid blue; font-size: 8pt; color: blue; position: absolute; margin-left: 0px; width: 160px; top: 350px; left: 165px;"> </div>');
//	document.write('<div id="clock" style="position: absolute; margin-left: 0px; width: 630px; top: 200px; left: 165px; text-align: center; padding: 0px 0px 0px 0px; margin-top: 0px; margin-bottom: 0px; border: thin solid blue; font-size: 10pt;"> </div>');

if (NN)
	document.write('<layer id="clock"> </layer>');

DaysofWeek = new Array()
  DaysofWeek[0]="Sunday"
  DaysofWeek[1]="Monday"
  DaysofWeek[2]="Tuesday"
  DaysofWeek[3]="Wednesday"
  DaysofWeek[4]="Thursday"
  DaysofWeek[5]="Friday"
  DaysofWeek[6]="Saturday"

Months = new Array()
  Months[0]="January"
  Months[1]="February"
  Months[2]="March"
  Months[3]="April"
  Months[4]="May"
  Months[5]="June"
  Months[6]="July"
  Months[7]="August"
  Months[8]="September"
  Months[9]="October"
  Months[10]="November"
  Months[11]="December"

ShortMonths = new Array()
  ShortMonths[0]="Jan"
  ShortMonths[1]="Feb"
  ShortMonths[2]="Mar"
  ShortMonths[3]="Apr"
  ShortMonths[4]="May"
  ShortMonths[5]="June"
  ShortMonths[6]="July"
  ShortMonths[7]="Aug"
  ShortMonths[8]="Sept"
  ShortMonths[9]="Oct"
  ShortMonths[10]="Nov"
  ShortMonths[11]="Dec"

var zone = (getStandardTimezoneOffset() / 60) * -1;
var dst = getDST();

function upclock(){
var now = new Date();
var hrs = now.getHours();
var min = now.getMinutes();
var sec = now.getSeconds();
var day = DaysofWeek[now.getDay()];
var date = now.getDate();
var month = Months[now.getMonth()];
var year = now.getFullYear();

JulianDate = getJulianDate(now, zone+dst);
txtJulianDate = 'Julian Date: ' + JulianDate;
GMT = getUT(now);
LMT = 'Local Sidereal Time<br>' + DMST(getLocalSiderealTime(now, JulianDate, lon));
UMT = 'Greenwich Sidereal Time<br>' + DMST(getGreenwichSiderealTime(now, JulianDate, lon));
LT = 'Local Mean Time<br>' + DMST(getLocalMeanTime(now, lon));

var col = ":";
var spc = " ";
var com = ",";
var apm;
var userMessage = " ";

if (hrs<=9) hrs="0"+hrs;
if (min<=9) min="0"+min;
if (sec<=9) sec="0"+sec;

// Timestamp = day+com+spc+month+spc+date+spc+com+spc+year+spc+spc+hrs+col+min+col+sec+'<br>'+GMT+'<br>'+txtJulianDate+'<br>'+LMT+'<br>'+LT+'<br>'+UMT;
intInterval++;
if (intInterval >= 30)
	intInterval = 1;
switch (true)
	{
	 case (intInterval <= 10) :
		Timestamp = date+spc+month+spc+year+spc+spc+hrs+col+min+col+sec;
		break;	
	 case ((intInterval > 10) && (intInterval <= 20)) :
		Timestamp = GMT;
		break;
	 case (intInterval > 20) :
		Timestamp = txtJulianDate;
		break;
	 default : 
		Timestamp = day+com+spc+month+spc+date+spc+com+spc+year+spc+spc+hrs+col+min+col+sec;
		break;	
	}
Timestamp2 ='<br>'+GMT+'<br>'+txtJulianDate+'<br>'+LMT+'<br>'+LT+'<br>'+UMT;
if (Gecko) {
document.getElementById("clock").innerHTML = Timestamp;
// document.getElementById("clock2").innerHTML = Timestamp2;
}

if (NN) {
document.clock.document.open();
document.clock.document.write(Timestamp);
document.clock.document.close();
}

if (IE){
clock.innerHTML = Timestamp;
// clock2.innerHTML = Timestamp2;
}
}

function getStandardTimezoneOffset() {
  var now = new Date()
  var msec = now.getTime()
  var offset = -999999
  for (var j = 0 ; j < 4 ; ++j) {
    now.setTime(msec + j * 7884000000)
    offset = Math.max(offset, now.getTimezoneOffset())
  }
  return offset
}

//
//    This function returns the universal time, given the date and time zone.
//
function getUT(now) 
{
    var Uyear = now.getUTCFullYear();
    var Umonth = ShortMonths[now.getUTCMonth()];
    var Udate = now.getUTCDate();
    var Uhour = now.getUTCHours();
    var Umin = now.getUTCMinutes();
    var Usec = now.getUTCSeconds();

//	gmt = ' Universal Time(UT)<br>';
	gmt = '';
	if (Udate < 10)
		gmt += "0" + Udate;
	else
		gmt += Udate;
	gmt += ' ' + Umonth + ' ' + Uyear + ' ' 
	if (Uhour < 10)
		gmt += "0" + Uhour;
	else
		gmt += Uhour;
	gmt += ':';
	if (Umin < 10)
		gmt += "0" + Umin;
	else
		gmt += Umin;
	gmt += ':';
	if (Usec < 10)
		gmt += "0" + Usec;
	else
		gmt += Usec;

	gmt += ' GMT';
	return gmt;
}

function getDecUT(now) 
{
    var Uyear = now.getUTCFullYear();
    var Umonth = Months[now.getUTCMonth()];
    var Udate = now.getUTCDate();
    var Uhour = now.getUTCHours();
    var Umin = now.getUTCMinutes();
    var Usec = now.getUTCSeconds();

	var gmt = Uhour;
	gmt += Umin/60;
	gmt += Usec/3600;

	return gmt;
}

function getDST()
{
var dst2, zon1, zon2; // used to determine d.s.t.

zon1 = NumFloat(getStandardTimezoneOffset() / 60);
dst2 = new Date() ; 
zon2 = NumFloat(dst2.getTimezoneOffset() / 60);

dst = zon2 - zon1

return dst;

}

//
//    This function returns the julian time, given the date and time zone.
//
function getJulianDate(now, zone) {
  var gmt = now.getHours() + now.getMinutes() / 100 + now.getSeconds() / 10000
  gmt = deg(gmt) + zone

//  var y = NumFloat(now.getYear()) + 1900 ; if (y >= 3900) y = y - 1900
  var y = NumFloat(now.getFullYear());
  var m = NumFloat(now.getMonth())+1
  var d = NumFloat(now.getDate()) + gmt/24

  if (m<=2) {m=m+12 ; y=y-1}
  var A = intr(y/100)
  var B = 2 - A + intr(A/4) ; if (y<1582) B=0
  if (y < 0) {
    var C = intr((365.25*y)-.75)
  } else {
    var C = intr(365.25*y)
  }
  var D = intr(30.6001 * (m + 1))
  return rnd(B + C + D + d + 1720994, 6);
}

function getGreenwichSiderealTime(now, jul, lon)
{
	var T = (jul - 2451545.0) / 36525.0;
	var T0 = getDecUT(now);
	var gst = 6.697374558 + (2400.051336*T) + (0.000025862*T*T) + (T0 * 1.0027379093);

	while (gst > 24)
		gst -= 24;

	return gst;

}

function getLocalSiderealTime(now, jul, lon)
{
	var gst = getGreenwichSiderealTime(now, jul, lon);
	lst = gst + lon/15;

	while (lst > 24)
		lst -= 24;

	return lst;

}

function getLocalMeanTime(now, lon)
{
	var lmt = getDecUT(now);
	lmt += lon/15;

	while (lmt > 24)
		lmt -= 24;

	return lmt;
}


function fraction(n)
{
	return n - Math.floor(n);
}

setInterval("upclock()",1000);
//-->
