<?php
//get current category
$category = Mage::getModel('catalog/layer')->getCurrentCategory();
$cat_id = $category->getId();
//load category
$category = Mage::getModel('catalog/category')->load($cat_id);
$catnames = array();
foreach ($category->getParentCategories() as $parent) {
$catnames[] = $parent->getId();
}
?>