<?php
$i=1;
$cat = get_query_var('cat');
$categories = get_categories('parent='.$cat.'');
foreach ($categories as $category) { $i++; }
if ($i > 1) {
echo "<ul>";
foreach ($categories as $category) { ?>
<li><a href="<?php echo get_category_link($category->term_id); ?>" ><?php echo $category->name; ?></a></li>
<?php }
echo "</ul>";
} else {
$pcat = get_category(get_query_var('cat'),false);
$pcatid = $pcat->category_parent;
$categories = get_categories('parent='.$pcatid.'');
echo "<ul>";
foreach ($categories as $category) { ?>
<li<?php if ($category->term_id == $cat) { ?> class="active"<?php } ?>><a href="<?php echo get_category_link($category->term_id); ?>" ><?php echo $category->name; ?></a></li>
<?php }
echo "</ul>";
}
?>