<!-- Some code from http://javascript.internet.com -->


<!-- Begin
<!--

// Some global constants
var THREE_CHARS = 1;
var FULL_TEXT = 2;
var STAMP = 1092830588;	// Sample timestamp

function js_stamp2date(the_date, format, time_stamp)
{
	var dateObj
	
	if (the_date == "")
		// Get a "snapshot" of the local client's time by instantiating this date object
		dateObj = new Date();
	
	else
		// Use a for the new date object (which wants milliseconds, so multiply by 1000)
		dateObj = new Date(the_date*1000);
		
	new_date = "";
		
   switch(format)
   {
   case 1:
   	new_date = dateObj.getDate() + "-" + getMonthText(dateObj.getMonth(), THREE_CHARS) + "-" + getCorrectedYear(dateObj);
   	//new_date = date("j-M-Y",$the_date);
   	break;
   
   case 2:
   	new_date = getMonthText(dateObj.getMonth(), FULL_TEXT) + " " + dateObj.getDate() + ", " + getCorrectedYear(dateObj);
   	//new_date = date("F d, Y",$the_date);
   	break;
   
   case 3:
   		new_date = dateObj.getMonth()+1 + "/" + dateObj.getDate() + "/" + getCorrectedYear(dateObj);
   	//$new_date = date("m/d/y",$the_date);
   	break;
   
   case 4:
   	new_date = dateObj.getDate() + " " + getMonthText(dateObj.getMonth(), THREE_CHARS) + " " + getCorrectedYear(dateObj);
   	//$new_date = date("j M Y",$the_date);
   	break;
   
   case 5:
   	new_date = getMonthText(dateObj.getMonth(), THREE_CHARS) + " " + dateObj.getDate() + ", " + getCorrectedYear(dateObj);
   	//$new_date = date("M j, y",$the_date);
   	break;
   	
   case 6:
   	// We need to switch from 24 hour time format to 12 hour, while also determining AM or PM
   	
   	
   	new_date = getMonthText(dateObj.getMonth(), FULL_TEXT) + " " + dateObj.getDate() + ", " + getCorrectedYear(dateObj) + ", " + getHour(dateObj) + ":" + getPaddedMinutes(dateObj.getMinutes()) + ":" + getPaddedSeconds(dateObj.getSeconds()) + " " + get_AM_PM(dateObj);
   	
   	//$new_date = date("F d, Y, h:i:s A",$the_date);
   	break;
   	
   case 7:
   	new_date = getDayText(dateObj.getDay()) + " " + dateObj.getDate() + getSuffix(dateObj) + " of " + getMonthText(dateObj.getMonth(), FULL_TEXT) + " " + getCorrectedYear(dateObj) + " " + getHour(dateObj) + ":" + getPaddedMinutes(dateObj.getMinutes()) + ":" + getPaddedSeconds(dateObj.getSeconds()) + " " + get_AM_PM(dateObj);
   	//$new_date = date("l dS of F Y h:i:s A",$the_date);
   	break;				
   	
   case 9:
   	new_date = dateObj.toString();
   	break;
   	
   	case 10:
   		new_date = getHour(dateObj) + "h " + getPaddedMinutes(dateObj.getMinutes()) + "m " + getPaddedSeconds(dateObj.getSeconds())+"s";
   	//$new_date = date("h:i:s A",$the_date);
   	break;
   
   default:
   	new_date = dateObj.getDate() + "-" + getMonthText(dateObj.getMonth(), THREE_CHARS) + "-" + getCorrectedYear(dateObj);
   	//new_date = date("j-M-Y",$the_date);
   	break;
   }
	
	return new_date;

}

function getMonthText(month, flag)
{
 	var monthArray;
	
	if (flag == THREE_CHARS)
		monthArray = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	else
		monthArray = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
 
	return monthArray[month];
}

function getDayText(day)
{
 	var dayArray = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

	return dayArray[day];
}

function getHour(dateObj)
{
	if (dateObj.getHours() >= 12)
		return (dateObj.getHours() == 12 ? 12 : dateObj.getHours()-12);
	else if (dateObj.getHours() == 0)
		return 12;
	else
		return dateObj.getHours();
}

// IE will return the full 4 digit year, whereas Netscape will just return 101 for 2001,
// 104 for 2004, etc. In that case, add 1900 to obtain the 4 digit full year
function getCorrectedYear(dateObj)
{
	if (dateObj.getYear() < 2000)
		return dateObj.getYear() + 1900;
	else
		return dateObj.getYear();
}

// Return AM or PM depending on the hour
function get_AM_PM(dateObj)
{
	if (dateObj.getHours() >= 12)
		return "PM";
	else
		return "AM";
}

function getSuffix(dateObj)
{
	day = dateObj.getDate();
	if ( day == 1 || day == 21 || day == 31)
		return "st";
	else if (day == 2 || day == 22)
		return "nd";
	else if (day == 3 || day == 23)
		return "rd";
	else
		return "th";
}

function getPaddedHour(hour)
{
	if (hour < 10)
		return "0"+hour;
	else
		return hour;
}

function getPaddedMinutes(minutes)
{
	if (minutes < 10)
		return "0"+minutes;
	else
		return minutes;
}

function getPaddedSeconds(seconds)
{
	if (seconds < 10)
		return "0"+seconds;
	else
		return seconds;
}


function showCurrentConversion()
{
	alert(js_stamp2date("", 1)+"\n\n"+js_stamp2date("", 2)+"\n\n"+js_stamp2date("", 3)+"\n\n"+js_stamp2date("", 4)+"\n\n"+js_stamp2date("", 5)+"\n\n"+js_stamp2date("", 6)+"\n\n"+js_stamp2date("", 7)+"\n\n"+js_stamp2date("", 9));
}

function showConversion()
{
	alert(js_stamp2date(STAMP, 1)+"\n\n"+js_stamp2date(STAMP, 2)+"\n\n"+js_stamp2date(STAMP, 3)+"\n\n"+js_stamp2date(STAMP, 4)+"\n\n"+js_stamp2date(STAMP, 5)+"\n\n"+js_stamp2date(STAMP, 6)+"\n\n"+js_stamp2date(STAMP, 7)+"\n\n"+js_stamp2date(STAMP, 9));
}

function showStampConversion(time_stamp)
{
	alert(js_stamp2date(time_stamp, 1)+"\n\n"+js_stamp2date(time_stamp, 2)+"\n\n"+js_stamp2date(time_stamp, 3)+"\n\n"+js_stamp2date(time_stamp, 4)+"\n\n"+js_stamp2date(time_stamp, 5)+"\n\n"+js_stamp2date(time_stamp, 6)+"\n\n"+js_stamp2date(time_stamp, 7)+"\n\n"+js_stamp2date(time_stamp, 9));
}

function showCurrentStamp()
{
	var t2 = new Date();

	if (t2.getFullYear) 
		year = t2.getFullYear();
	else
	{
		year = t2.getYear();
		if (year < 1999) year += 1900;
	}
	
	var temp = new Date(Date.UTC(year, t2.getMonth(), t2.getDate(), t2.getHours(), t2.getMinutes(), t2.getSeconds()));
	
	return (temp.getTime()/1000.0)+(60*t2.getTimezoneOffset());
}


function js_date2stamp(time_zone, year, month, day, hour, minute, second)
{
    // "24 Dec 1997 18:00:00 EST" is the format date_string needs to be
		// Then the Date.parse function will take that and convert it to GMT time.
		// Once we have that, then we create a new Date() and use that to get the unix timestamp
	 
	 var date_string = day + " " + getMonthText(month-1, THREE_CHARS) + " " + year + " " + getPaddedHour(hour) + ":" + getPaddedMinutes(minute) + ":" + getPaddedSeconds(second) + " " + time_zone;
	 

	var new_date = new Date(Date.parse(date_string));
	document.form1.timeStamp.value = (new_date.getTime()/1000.0);	// divide by 1000 because the Date object returns milliseconds, not seconds
}

function elapsed_time_display(secs){

	var hrs = 0;
	var mins = 0;
	var days = 0;
	
	if (secs >= 86400) {
	tsecs = secs;
		days = Math.floor(secs / 86400);
		secs = (secs % 86400);
	
	}
	//echo "days, tsecs / 86400 = secs";
	if (secs >= 3600) {
		hrs = Math.floor(secs / 3600);
		secs = (secs % 3600);
	}
	
	if (secs >= 60) {
		mins = Math.floor(secs / 60);
		secs = (secs % 60);
	}
	
	days=(days < 1)? '' : days+'d ';
	hrs=(hrs < 1)? '': hrs +'h ';
	mins=(mins < 10 && hrs > 0)? '0'+mins+'m ':mins +'m ';
	secs=(secs < 10)? '0'+secs+'s':secs+'s';
	
	display_time = days+hrs+mins+secs;
	
	return display_time;

}
  // http://developer.netscape.com/viewsource/goodman_dateobject.html#just
  
//  End -->
