/* the calendar callback is set on the template */
function calendarCallback(calendar) 
{
  if (calendar.dateClicked) 
  {
    var y = calendar.date.getFullYear();
    var m = calendar.date.getMonth() + 1;
    
    if (m < 10)
    {
      m = "0"+m;
    }
    
    var d = calendar.date.getDate();
    
    if (d < 10)
    {
      d = "0"+d;
    }
    
    var btn = $("topUserOfTheDay");
    btn.href = "/nutzerliste/statistik/nach-datum/" + y+m+d;
    btn.className = btn.className.gsub('disabled', '');
    
    btn = $('topUserOfTheMonth');
    btn.href = null; 
    btn.className = 'disabled';
  }
}

function archiveCalendarSelectMonthCallBack() 
{
  var btn = $('topUserOfTheMonth');
  btn.href = "/nutzerliste/statistik/nach-monat/" + this.value;
  btn.className = btn.className.gsub('disabled', '');
  
  btn = $("topUserOfTheDay");
  btn.href = null;
  btn.className = 'disabled';
}

function topuserArchiveBtnOnClickCallback()
{
  Effect.toggle('topuser_archive_filter', 'appear', { duration: 0.30 });
  
  if (typeof $('topuser_archive_btn').parentNode.firstChild.toggleClassName == 'undefined')
  {
    $('topuser_archive_btn').parentNode.toggleClassName('sb_link10', 'sb_link09');
  }
  else
  {
    $('topuser_archive_btn').parentNode.firstChild.toggleClassName('sb_link10', 'sb_link09');
  }
  
  $('topUserListOfTheMonth').onclick = archiveCalendarSelectMonthCallBack;
}

document.observe("dom:loaded", function() 
{  
  $('topuser_archive_btn').onclick = topuserArchiveBtnOnClickCallback;
  
  if (location.hash.indexOf('#statistic') != -1)
  {
    topuserArchiveBtnOnClickCallback();
  }
});
