If it is an URL parameter you can use
$pageId = Mage::app()->getRequest()->getParam('pageid', 0)
For category pages:
$pageId = Mage::registry('current_category')->getId()
You can also modify your single category from your_layout.xml
Layout handles for categoris look like:
<CATEGORY_{yourId}>
<reference ...
For CMS pages:
$pageId = Mage::getSingleton('cms/page')->getId() // use getIdentifier()