If it is an URL parameter you can use

    $pageId = Mage::app()->getRequest()->getParam('pageid', 0)

For [tag:category] pages

    $pageId = Mage::registry('current_category')->getId()

For CMS pages:

    $pageId = Mage::getSingleton('cms/page')->getId() // use getIdentifie‌​r()