posts ";
	$sql .= "WHERE DATE_FORMAT(post_date, '%Y') <> '0000'";
	$sql .= " AND post_status = 'publish'";
	$sql .= " AND post_type = 'post' ";
	$sql .= "GROUP BY DATE_FORMAT(post_date, '%Y'), DATE_FORMAT(post_date, '%m') ";
	$sql .= "ORDER BY DATE_FORMAT(post_date, '%Y') DESC, DATE_FORMAT(post_date, '%m') ASC;";
	$months = $wpdb->get_results($sql);
	if (!empty($months))
	{
		foreach ($months as $month)
		{
			// Add in the year heading
			if (($year == "") || ($year != $month->Year))
			{
				if (strlen($output))
				{
					$output .= "
\n" . $month->Year . ": ";
				}
				else
				{
					$output .= "\n" . $month->Year . ": ";
				}
			}
			// Add in the monthly archive links
			if ($year == $month->Year)
				$output .= $month_separator;
			$output .= '' . date($month_format, mktime(0, 0, 0, $month->Month, 1, $month->Year)) . '';
			$year = $month->Year;
		}
	}
	else
	{
		$output = "
None available
\n"; } print $output; } ?>