/*
   Play Time Toys, Inc
   Author: Tony Gianfransico
   Date:   October 1, 2010

   Filename:         countdown.js
     
*/


//add the next holiday date and name below.
	holidayDate = new Date("March 31, 2012");
	holidayName = "to Purchase Easter Plush"

function showTime(dateObj){
	thisSec = dateObj.getSeconds();
	thisMin = dateObj.getMinutes();
	thisHr = dateObj.getHours();

	//change thisHr from 24hr time to 12hr time
	//if hour is < 12 then set AMPM to am, otherwise PM
	var AMPM = (thisHr < 12) ? " a.m." : " p.m.";

	//if thisHr is > 12 then subtract 12 from thisHr
	thisHr = (thisHr > 12) ? thisHr - 12 : thisHr;

	//if thisHr is = 0 then set thisHr = 12
	thisHr = (thisHr == 0) ? 12 : thisHr;

	//add leading "0" to mins & secs less than 10
	thisMin = thisMin < 10 ? "0"+thisMIn : thisMin;
	thisSec = thisSec < 10 ? "0"+thisSec : thisSec;	
	
	return thisHr + ":" + thisMin + ":" + thisSec + AMPM;
	}


function calcDays(currentDate){

	//calc the diff between currentDate and nextHoliday
	days = (holidayDate - currentDate)/(1000*60*60*24);
	return days;
	}

function countdown() {
	//the today variable contains the current date & time
	var today = new Date();
	
	//calc days left till next holiday
	var days = calcDays(today);
	var daysLeft = Math.floor(days);
	
	if (days >0) {
    document.indexPage.daysLeft.value = "Only " + daysLeft + " days remain to ";
	document.indexPage.nextHoliday.value = holidayName;
	
	}else{
	document.indexPage.daysLeft.value = "";
	document.indexPage.nextHoliday.value = "";
	document.getElementById("order").style.display = 'none';
	}
}
