function expandYear(year)
{
  var newYearDiv = $('#archiveYearContents'+year);
  if($('#archiveCurrentYear').html() == year) {
    $('#archiveCurrentYear').html('');
    $('.archiveMonthContents').slideUp();
    newYearDiv.slideUp();
    return;
  }
  
  //hide all showing years
  $('.archiveMonthContents').slideUp();
  $('.archiveYearContents').slideUp();
  
  //reset the month and save the new year
  $('#archiveCurrentMonth').html('');
  $('#archiveCurrentYear').html(year);
  
  //contents were already received, just reveal them, otherwise make an ajax call
  if(newYearDiv.html() != "") {
    newYearDiv.slideDown();
  } else {
    newYearDiv.load('archive/archive.ajax.php', {action:'getYear',year:year}, onAjaxComplete);
  }
}

function expandMonth(month)
{
  var year = $('#archiveCurrentYear').html();
  var newMonthDiv = $('#archiveMonthContents'+year+month);
  
  if($('#archiveCurrentMonth').html() == month) {
    $('#archiveCurrentMonth').html('');
    newMonthDiv.slideUp();
    return;
  }
  
  //set the current month
  $('#archiveCurrentMonth').html(month);
  
  //hide all showing months
  $('.archiveMonthContents').slideUp();
  
  //contents were already received, just reveal them, otherwise make an ajax call
  if(newMonthDiv.html() != "") {
    newMonthDiv.slideDown();
  } else {
    newMonthDiv.load('archive.ajax.php', {action:'getMonth',year:year,month:month}, onAjaxComplete);
  }
}

function onAjaxComplete() {
  $(this).slideDown();
}
