// Get the name of the current month
function getMonthName()
{
   var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
   var monthnumber = new Date().getMonth();
   return months[monthnumber];
}

// Get the today's day
function getMonthDay()
{
   return new Date().getDate();
}

// Countdown to the next CLT Race Day (the race date is set in "footer.inc")
function countdown(yr,m,d)
{
   var current    = "Today!"
   var past       = "The race is run (and biked and swum)!"
   var montharray = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

   theyear = yr;
   themonth = m;
   theday = d;
   var today=new Date();
   var todayy=today.getYear();
   if (todayy < 1000) {todayy += 1900;}
   var todaym = today.getMonth();
   var todayd = today.getDate();
   var todayh = today.getHours();
   var todaymin = today.getMinutes();
   var todaysec = today.getSeconds();
   var todaystring = montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec;
   futurestring = montharray[m-1]+" "+d+", "+yr;
   dd=Date.parse(futurestring)-Date.parse(todaystring);
   dday=Math.floor(dd/(60*60*1000*24)*1);
   dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
   dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
   dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
   if (dday < 0 || dhour < 0 || dmin < 0 || dsec < 0)
      {
	   $clockDIV = document.getElementById('countdownclock');
		if (dday < -1)
		   {$clockDIV.innerHTML = past;}
		else
		   {$clockDIV.innerHTML = current;}
      return;
      }
   else
      {
	  $clockDIV = document.getElementById('countdownclock');
	  $clockFace = dday+ " days, "+dhour+" hrs. "+dmin+" mins. "+dsec+" secs.";
	  $clockDIV.innerHTML = $clockFace;
	  }
   var countdownTimer = setTimeout("countdown(theyear,themonth,theday)",1000)
}

// Handle tab requests to expand and collapse the sub navigation areas
function showSubNav(forTab)
{
   if (forTab == "aboutus")
	  {
	  $tabIMG = document.getElementById("aboutustab");
	  $tabDIV = "sectionSubMenuAboutUs";
	  }
   if (forTab == "calendar")
	  {
	  $tabIMG = document.getElementById("calendartab");
	  $tabDIV = "sectionSubMenuCalendar";
	  }
   if (forTab == "membership")
	  {
	  $tabIMG = document.getElementById("membershiptab");
	  $tabDIV = "sectionSubMenuMembership";
	  }
   if (forTab == "training")
	  {
	  $tabIMG = document.getElementById("trainingtab");
	  $tabDIV = "sectionSubMenuTraining";
	  }
   if (forTab == "cltrace")
	  {
	  $tabIMG = document.getElementById("clttab");
	  $tabDIV = "sectionSubMenuCLT";
	  }
	  
   $tabState = $tabIMG.src;
   if ($tabState.indexOf('More') > -1)
      {
	  oba_wipe_div($tabDIV,0,24,1,'down');
	  $tabIMG.src = "../images/tabs/tab-Less.png";
	  }
   else
      {
      oba_wipe_div($tabDIV,24,0,1,'up');
	  $tabIMG.src = "../images/tabs/tab-More.png";
	  }
}

// Turn specific Google calendars on or off
function showGoogleCalendar(whichCalendar)
{
	// first turn all the calendars off
    oba_setDivDisplay('ITCAllArea','none');
    oba_setDivDisplay('ITCEventsArea','none');
    oba_setDivDisplay('ITCWorkoutArea','none');

	// Now turn the selected calendar on
	if (whichCalendar == "All")
	{oba_setDivDisplay('ITCAllArea','block');}
	if (whichCalendar == "Events")
	{oba_setDivDisplay('ITCEventsArea','block');}
	if (whichCalendar == "Workouts")
	{oba_setDivDisplay('ITCWorkoutArea','block');}
}
