// teclan Countdown Functionality
var montharray = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

function countdown(yr, m, d, h, minute, s, dID) {
   theyear = yr;
   themonth = m;
   theday = d;
   thehour = h;
   theminute = minute;
   thesecond = s;
   theDid = dID;
   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();
   /*if ((m-1) < todaym) m = todaym + 1;
   if (d < todayd && (m-1 == todaym)) d = todayd + 1;*/
   
   
   var todaystring = montharray[todaym] + " " + todayd + ", " + todayy + " " + todayh + ":" + todaymin + ":" + todaysec;
   futurestring = montharray[m - 1] + " " + d + ", " + yr + " " + h + ":" + minute + ":" + s;
   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) {
     document.getElementById('countw' + theDid).style.display = 'none';
   }
   else {
	 var dspan = "<div class='days'>" + dday + "</div>";
	 var hspan = "<div class='hrs'>" + dhour + "</div>";
	 var mspan = "<div class='minutes'>" + dmin + "</div>";
	 var sspan = "<div class='secs'>" + dsec + "</div>";
	 document.getElementById('count' + theDid).innerHTML = dspan + hspan + mspan + sspan + "<div style='clear:left'></div>";
   }
}
