function getTimeLeft() {
   now = new Date();
   nowTime = now.getTime();

   period = new Date();
   if (today.current_period == -1) {
       return '<div class="countdown_tryagain">Ltd Daily Deals are asleep at the mo, but check out our 365 Deals <a href="365_deals_all">here</a>!</div>';
   } else if (nowTime > today.period_times[today.current_period].end*1000) {
       window.location.reload();
   }

   period.setTime(today.period_times[today.current_period].end*1000);
   hours = (period.getHours()-now.getHours())-1;
   mins  = 59-now.getMinutes();
   secs  = 59-now.getSeconds();
   string = '';
   if (hours < 10) string += ('0'+hours+':');
   else string += hours+':';
   if (mins < 10) string += '0'+mins+':';
   else string += mins+':';
   if (secs < 10) string += '0'+secs;
   else string += secs;

   return string;
}

function countdown() {

   timeString = getTimeLeft();
    if ((document.getElementById('countdown-timer') && ( /365_deals/.test(window.location))) || (document.getElementById('permanent365')) ){
    //if ((document.getElementById('countdown-timer') && ( /365_deals/.test(window.location))) || (trim(jQuery('permanent365').html()) != "")) {
       
      jQuery('#countdown-timer').html("Ages!");
      jQuery('#period').html("365 Deals");
      jQuery('#countdown-timer').addClass = "ages";  

    } else if (document.getElementById('countdown-timer')) {
      //document.getElementById('countdown-timer').innerHTML = timeString;
      jQuery('#countdown-timer').html(timeString);
      jQuery('#countdown-timer').removeClass = "ages";
    }
   setTimeout('countdown()',1000); // 1 second
}

