<?php global $freshy_options; ?>
	
	<div id="sidebar">
		<div>
		<?php if ( !function_exists('dynamic_sidebar')
        || !dynamic_sidebar() ) : ?>
		<?php if(function_exists('yy_menu')) : ?>
			<h2><?php _e('Navigation',TEMPLATE_DOMAIN); ?></h2>
			<ul>
			<?php yy_menu('sort_column=menu_order&title_li=',
								'hide_empty=0&sort_column=name&optioncount=1&title_li=&hierarchical=1&feed=RSS&feed_image='.get_bloginfo('stylesheet_directory').'/images/icons/feed-icon-10x10.gif'); ?>
			</ul>
	
		<?php elseif (function_exists('freshy_menu')) : 
			freshy_menu($freshy_options['args_pages'],$freshy_options['args_cats']);
		endif; ?>
				
			<h2><?php _e('Search',TEMPLATE_DOMAIN); ?></h2>
			<?php include (TEMPLATEPATH . '/searchform.php'); ?>

			<h2><?php _e('Links',TEMPLATE_DOMAIN); ?></h2>
			<ul>
			 <?php
			 $ver = substr(get_bloginfo('version'), 0, 3);
			 if ($ver == "2.1") {
				$link_cats = $wpdb->get_results("SELECT DISTINCT cat_name, category_id FROM $wpdb->categories INNER JOIN $wpdb->link2cat ON $wpdb->categories.cat_id=$wpdb->link2cat.category_id");
				foreach ($link_cats as $link_cat) {
				?>
				<li id="linkcat-<?php echo $link_cat->cat_id; ?>"><?php echo $link_cat->cat_name; ?>
				<ul>
				<?php wp_get_links('category='.$link_cat->category_id.'&before=<li>&after=</li>&show_description=0&limit=100'); ?></li>
				</ul>
				<?php }
			 }
			 //if ($ver>2) echo 'yes';
			 else {
			 $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
			 foreach ($link_cats as $link_cat) {
			 ?>
			  <li id="linkcat-<?php echo $link_cat->cat_id; ?>"><?php echo $link_cat->cat_name; ?>
			   <ul>
			    <?php wp_get_links($link_cat->cat_id); ?>
			   </ul>
			  </li>
			 <?php }
			 } ?>
			</ul>
		<?php endif; ?>
		</div>
	</div>