/*
  
   Author: Mike Shepard
   Date:   10/07/2009

   Function List:
   showDate(dateObj)
      Returns the current date in the format mm/dd/yyyy

   showTime(dateObj)
      Returns the current time in the format hh:mm:ss am/pm

   calcDays(currentDate)
      Returns the number of days between the current date and January 1st
      of the next year

*/

function showDate(dateObj)  {
	thisDate = dateObj.getDate();
	thisMonth = dateObj.getMonth()+1;
	thisYear = dateObj.getFullYear();
	return thisMonth + "/" + thisDate + "/" + thisYear;
	
}
function showTime(dateObj)  {
	thisSecond=dateObj.getSeconds();
	thisMinute=dateObj.getMinutes();
	thisHour=dateObj.getHours();
	// change this hour from 24 hour time to 12 hour timeby:
	//1) if thisHour < 12 then set ampm to "am" otherwise set it to "pm"
	var ampm = (thisHour < 12) ? " am" :" pm";
	// 2)subtract 12 from the thisHour variable
	thisHour = (thisHour > 12) ? thisHour - 12 : thisHour;
	//3)if thisHour equals 0, change it to 12
	thisHour = (thisHour == 0) ? 12 : thisHour;
	
	//add leading zeros to minutes and seconds less than 10
	thisMinute = thisMinute <10?"0"+thisMinute : thisMinute;
	thisSecond = thisSecond <10?"0"+thisSecond : thisSecond;			  
	return thisHour + ":" + thisMinute + ":" + thisSecond + ampm;
}
function calcDays(currentDate)  {
	// create a date object for January 1 of the next year
	newYear = new Date("August 6, 2010"); //insert a temporary date for January 1
	nextYear = currentDate.getFullYear()+1; //the year value of the next year
	newYear.setFullYear(thisYear); // change newYear to the next year
	
	// calculate the difference between currentDate and January 1
	days = (newYear - currentDate)/(1000*60*60*24);
	return days;
	

}
