<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

/**
 * Install database configuration template
 *
 * @see Mage_Install_Block_Config
 * @var $this Mage_Install_Block_Config
 */
?>
<script type="text/javascript">
//<![CDATA[
var dbTypeIds = [];
function showContent(select)
{
    dbTypeIds.each(function (name) {
        $(name + '_conn_form').hide()
    });
    $(select.value + '_conn_form').show();
}
//]]>
</script>

<fieldset class="group-select">
 <legend><?php echo $this->__('Connection') ?></legend>
    <h4 class="legend"><?php echo $this->__('Database Connection') ?></h4>
    <ul>
        <?php $dbTypeOptions = $this->getDatabaseBlocks(); ?>
        <?php if (count($dbTypeOptions) > 0): ?>
        <li>
            <div class="input-box">
                <label for="prefix"><?php echo $this->__('Database Type') ?></label><br />
                <select name="config[db_model]" onchange="showContent(this)">
                    <?php foreach($dbTypeOptions as $block): ?>
                        <option value="<?php echo $block->getIdPrefix()?>" <?php if($this->getFormData()->getDbModel() == $block->getIdPrefix()):?>selected="selected"<?php endif;?>><?php echo $block->getTitle()?></option>
                    <?php endforeach; ?>
                </select>
            </div>
        </li>
        <?php endif ?>

        <?php foreach ($dbTypeOptions as $block): ?>
            <script type="text/javascript">
            //<![CDATA[
                dbTypeIds[dbTypeIds.length] = "<?php echo $block->getIdPrefix(); ?>";
            //]]>
            </script>
            <?php $block = $this->getDatabaseBlock($block->getIdPrefix()) ?>

            <div id="<?php echo $block->getIdPrefix() ?>_conn_form" <?php if($this->getFormData()->getDbModel() != $block->getIdPrefix()):?>style="display:none;"<?php endif;?>>
                <ul>
                    <?php echo $block->toHtml(); ?>
                </ul>
            </div>
        <?php endforeach; ?>
    </ul>
</fieldset>
