<?php 
/**
 * Category layered navigation state
 *
 * @see Mage_Catalog_Block_Layer_State
 * http://docs.magentocommerce.com/Mage_Catalog/Mage_Catalog_Block_Layer_State.html
 *
 * ./app/design/frontend/default/default/template/catalog/layer/state.phtml
 * based on
 * ./app/design/frontend/base/default/template/catalog/layer/state.phtml
 */
?>

<?php $_filters = $this->getActiveFilters() ?>
<?php if(!empty($_filters)): ?>
    <script type="text/javascript">
    <!--
    function magejump(targ, selObj, restore) {
        eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");
        if (restore) {
            selObj.selectedIndex = 0;
        }
    }
    //-->
    </script>

    <p class="block-subtitle active"><?php echo $this->__('Currently Shopping by') ?><span><a href="<?php echo $this->getClearUrl() ?>" class="btn-remove" title="<?php echo $this->__('Clear All') ?>"><?php echo $this->__('Clear All') ?></a></span></p>
    <?php foreach ($_filters as $_filter): ?>
        <ol class="currently">
            <li>
                <span class="label"><?php echo $this->__($_filter->getName()) ?>:</span>
            </li>
        </ol>
        <select name="magestp" id="magestp" onChange="magejump('parent', this, 0)">
            <option value="<?php echo $_filter->getRemoveUrl() ?>"><?php echo $this->__('All') ?></a></option>

            <?php
                $attributeCode = $_filter->getFilter()->getRequestVar();
                $product = Mage::getModel('catalog/product');



                $collection = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter($attributeCode);
                // ->setEntityTypeFilter($product->getResource()->getTypeId())
                $_attribute = $collection->getFirstItem()->setEntity($product->getResource());
                $attribute_options = $_attribute->getSource()->getAllOptions(false);



/*
$layer = Mage::getModel("catalog/layer");
//foreach($categories as $categoryid) {
//    $category = Mage::getModel("catalog/category")->load($categoryid);
$category = Mage::registry('current_category');
    $layer->setCurrentCategory($category);
    $attributes = $layer->getFilterableAttributes();
    echo "xxxxxxxxxxxx" . print_r($attributes);
//}
//$_activefilters = Mage::getSingleton(’Mage_Catalog_Block_Layer_State’)->getActiveFilters();
*/
            ?>

            <?php foreach($attribute_options as $option): ?>
                <?php $optionLabel = $option['label']; ?>
                <?php $optionValue = $option['value']; ?>
                <?php if(strrpos($_filter->getRemoveUrl(), "?")) $token = "&"; else $token = "?"; ?>
                <?php $link = $token . $attributeCode . "=" . $optionValue; echo $link; ?>
                <option value="<?php echo ($_filter->getRemoveUrl()) . $link; ?>"
                <?php if($optionLabel == $_filter->getLabel()) echo " selected"; ?>><?php echo $optionLabel // $_filter->getLabel() ?></option>
            <?php endforeach; ?>
        </select>
    <?php endforeach; ?>
<?php endif; ?>
