// JavaScript Document

// Taken from Philadelphia Distance Run web site (http://www.runphilly.com)
// added header option to function to keep text on same line as counter
// fixed typo: ##Days -> ## Days
// dan@widyono.net 20050614

//Countdown Script Start

// The following script defines time


var day="";
var month="";
var myweekday="";
var year="";
newdate = new Date();
mydate = new Date();
dston =  new Date('April 4, 2005 2:00:00');
dstoff = new Date('October 31, 2005 2:00:00');
var myzone = newdate.getTimezoneOffset();
newtime=newdate.getTime();


var zone = 8; 

if (newdate > dston && newdate < dstoff ) {
zonea = zone - 1 ;
//dst = " CDT";
}
else {
zonea = zone ; 
//dst = "  CST";
}
var newzone = (zonea*60*60*1000);
newtimea = newtime+(myzone*60*1000)-newzone;
mydate.setTime(newtimea);
myday = mydate.getDay();
mymonth = mydate.getMonth();
myweekday= mydate.getDate();
myyear= mydate.getYear();
year = myyear;

if (year < 2000)    // Y2K Fix, Isaac Powell
year = year + 1900; // http://onyx.idbsu.edu/~ipowell
myhours =mydate.getHours();
if (myhours >= 12) {
myhours = (myhours == 12) ? 12 : myhours - 12; mm = " PM";
}
else {
myhours = (myhours == 0) ? 12 : myhours; mm = " AM";
}
myminutes = mydate.getMinutes();
if (myminutes < 10){
mytime = ":0" + myminutes;
}
else {
mytime = ":" + myminutes;
};
arday = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
armonth = new Array("Jan. ","Feb. ","Mar. ","Apr. ","May ","Jun. ","Jul. ","Aug. ","Sept. ", "Oct. ","Nov. ","Dec. ")
ardate = new Array("0th","1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th","14th","15th","16th","17th","18th","19th","20th","21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th","31st");

// I remarked the following two lines out of the code 
//because I couldn't get the time zone funtion to work

//var time = (armonth[mymonth] +" "+ardate[myweekday] + ", " + year+ " " + myhours + mytime + mm  + dst );
//var customtime = (armonth[mymonth] +" "+ardate[myweekday] + " " + myhours + mytime + mm  + dst );


var time = (armonth[mymonth] +" "+ardate[myweekday] + ", " + year+ " " + myhours + mytime + mm  );
var customtime = (armonth[mymonth] +" "+ardate[myweekday] + " " + myhours + mytime + mm );



<!-- Countdown in Java Script .. Cameron Gregory http://www.bloke.com/
// permission to use and modify as long as you leave these 4 comment
// lines in tact and unmodified.
// http://www.bloke.com/javascript/Countdown/

speed=1000;
len=40;
tid = 0;
num=0;
clockA = new Array();
timeA = new Array();
formatA = new Array();
dd = new Date();
var d,x;

function doDate(x)
{
  for (i=0;i<num;i++) {
    dt = new Date();
  
    if (timeA[i] != 0) {
      v1 = Math.round(( timeA[i] - dt )/1000) ;
      if (v1 < 0)
        clockA[i].date.value = "**BANG!**";
      if (formatA[i] == 1)
        clockA[i].date.value = v1;
      else if (formatA[i] ==2) {
        sec = v1%60;
	v1 = Math.floor( v1/60);
	min = v1 %60 ;
	hour = Math.floor(v1 / 60);
	if (sec < 10 ) sec = "0"+sec;
	if (min < 10 ) min = "0"+min;
        clockA[i].date.value = hour+"h "+min+"m "+sec+"s";
        }
      else if (formatA[i] ==3) {
        sec = v1%60;
	v1 = Math.floor( v1/60);
	min = v1 %60 ;
	v1 = Math.floor(v1 / 60);
	hour = v1 %24 ;
	day = Math.floor(v1 / 24);
	if (sec < 10 ) sec = "0"+sec;
	if (min < 10 ) min = "0"+min;
	if (hour < 10 ) hour = "0"+hour;
        clockA[i].date.value = day+" Days "+hour+":"+min+":"+sec+"";
        }
     else if (formatA[i] ==4 ) {
	sec = v1%60;
	v1 = Math.floor( v1/60);
	if (sec < 10 ) sec = "0"+sec;
	min = v1 %60 ;
	v1 = Math.floor(v1 / 60);
	if (min < 10 ) min = "0"+min;
	hour = v1 %24 ;
	v1 = Math.floor(v1 / 24);
	day = v1 %30.5 ;
	v1 = Math.floor(v1 / 30.5);
	month = v1 %12 ;
        clockA[i].date.value = month+(month==1?"":":")+(Math.floor(day))+(day==1?":":":")+(hour-1)+(hour==1?":":":")+min+(min==1?":":":")+sec+(sec==1?":":"")
        }
      else
        clockA[i].date.value = "Invalid Format spec";
      }
    else
      clockA[i].date.value = "Countdown till when?";
    }

  tid=window.setTimeout("doDate()",speed);
}

function start(d,x,format) {
  clockA[num] = x
  timeA[num] = new Date(d);
  formatA[num] = format;
//window.alert(timeA[num]+":"+d);
  if (num == 0)  
    tid=window.setTimeout("doDate()",speed);
  num++;
}

function CountdownLong(t,format,len)
{
  document.write('<FORM name=form'+num+'><input name=date size=')
  document.write(len)
  document.write(' value="Countdown: Requires Javascript"></FORM>')
  start(t,document.forms["form"+num],format);
}

function CountdownLongHeader(t,format,len,header)
{
  document.write('<FORM name=form'+num+'>')
  document.write(header)
  document.write('<input name=date size=')
  document.write(len)
  document.write(' value="Countdown: Requires Javascript"></FORM>')
  start(t,document.forms["form"+num],format);
}

function Countdown(t)
{
CountdownLong(t,4,30);
}
