
This post describes how Magento navigation works. I hope it will help you.
The begining of all is in template file: “category/navigation/top.phtml”
1.<ul id="nav">2.< ?php3.foreach ($this->getStoreCategories() as $_category): ?>4.< ?php5.echo $this->drawItem($_category);6.?>7.< ?php endforeach ?>8.</ul>
