<?php if (!defined('MAX_PATH')) { exit; } ?>
    <br />
    <table border='0' cellpadding='0' cellspacing='0' width='100%'>
    <tr>
        <td colspan='2' align='center'>
            <div id='displayDbError' style='display:block'>
        <?php
            if ($displayError == true) {
            	include 'install-messages.html';
            }
        ?>
            </div>
        </td>
    </tr>
    <tr>
        <td valign='top'>
        <img src='<?php echo $imgPath; ?>images/install-database.gif'></td>
        <td width='100%' valign='top'>
        <br>
        <span class='tab-s'><?php echo $strDbSetupTitle; ?></span><br><img src='<?php echo $imgPath; ?>images/break-el.gif' width='100%' height='1' vspace='8'><span class='install'><?php echo ($_COOKIE['oat'] == OA_UPGRADE_UPGRADE) ? $strDbUpgradeIntro : $strDbSetupIntro; ?></span>
        </td>
    </tr>
    </table>
    <br />
    <br />
    <script type='text/javascript'>

    function showLoaders(f) {
        noerrors = max_formValidate(f);
        if (noerrors == true) {
            var errObj = new getObj('displayDbError');
            var pgsqlWarn  = new getObj('pgSqlWarning');
            errObj.style.display='none';
            pgsqlWarn.style.display = 'none';
            showLoader();
        }
        return(noerrors);
    }

    function switchDbTypes() {
        var dbType     = new getObj('aConfig[database][type]');
        var portObj    = new getObj('aConfig[database][port]');
        var TblTypeObj = new getObj('aConfig[table][type]');
        var pgsqlWarn  = new getObj('pgSqlWarning');
        if (dbType.obj.value == 'mysql') {
            portObj.obj.value = 3306;
            if (!portObj.obj.disabled) {
                TblTypeObj.obj.disabled = false;
            }
            pgsqlWarn.style.display = 'none';
        } else if (dbType.obj.value == 'pgsql') {
            portObj.obj.value = 5432;
            TblTypeObj.obj.disabled = 'disabled';
            pgsqlWarn.style.display = 'block';
        }
    }
    </script>

<div id="pgSqlWarning" class="sysmessage sysinfoerror" style="display:none;">Please understand that support for PostgreSQL is currently experimental. Proceed with caution!</div>

<?php OA_GUI_getHtmlForDbLoader("Processing..."); ?>

<form name="frmOpenads" id="frmOpenads" method="POST" action="install.php" onSubmit='return showLoaders(this);' style="margin:0; padding:0;">

<?php

    // Disable the form items if user is upgrading
    // Change $inputType so that disabled selects are text fields, so that the correct value can be displayed
    if ($_COOKIE['oat'] == OA_UPGRADE_UPGRADE) {
        $disableForm = true;
        $inputType   = 'text';
    } else {
        $disableForm = false;
        $inputType   = 'select';
    }

    phpAds_ShowSettings(array (
        array (
            'text'  => $strDatabaseSettings,
            'items' => array (
                array (
                    'type'    => $inputType,
                    'name'    => 'aConfig[database][type]',
                    'text'    => $strDbType,
                    'enabled' => $disableForm,
                    'onchange' => 'switchDbTypes(this);',
                    'value'   => $aDatabase['database']['type'],
                    'items'   => getSupportedDbTypes()
                ),
                array (
                    'type'    => 'break'
                ),
                array (
                    'type'    => 'text',
                    'name'    => 'aConfig[database][host]',
                    'text'    => $strDbHost,
                    'enabled' => $disableForm,
                    'req'     => true,
                    'value'   => $aDatabase['database']['host']
                ),
                array (
                    'type'    => 'break'
                ),
                array (
                    'type'    => 'text',
                    'name'    => 'aConfig[database][port]',
                    'text'    => $strDbPort,
                    'enabled' => $disableForm,
                    'req'     => true,
                    'value'   => $aDatabase['database']['port']
                ),
                array (
                    'type'    => 'break'
                ),
                array (
                    'type'    => 'text',
                    'name'    => 'aConfig[database][username]',
                    'text'    => $strDbUser,
                    'enabled' => $disableForm,
                    'req'     => true,
                    'autooff' => true,
                    'value'   => $aDatabase['database']['username']
                ),
                array (
                    'type'    => 'break'
                ),
                array (
                    'type'    => 'password',
                    'name'    => 'aConfig[database][password]',
                    'text'    => $strDbPassword,
                    'enabled' => $disableForm,
                    'req'     => false,
                    'autooff' => true,
                    'value'   => $aDatabase['database']['password']
                ),
                array (
                    'type'    => 'break'
                ),
                array (
                    'type'    => 'text',
                    'name'    => 'aConfig[database][name]',
                    'text'    => $strDbName,
                    'enabled' => $disableForm,
                    'req'     => true,
                    'value'   => $aDatabase['database']['name']
                )
            )
        ),
        array (
            'text'  => $strAdvancedSettings,
            'items' => array (
                array (
                    'type'      => $inputType,
                    'name'      => 'aConfig[table][type]',
                    'text'      => $strTablesType,
                    'enabled'   => $disableForm,
                    'value'     => $aDatabase['table']['type'],
                    'items'     => getSupportedTableTypes()
                ),
                array (
                    'type'      => 'break'
                ),
                array (
                    'type'      => 'text',
                    'name'      => 'aConfig[table][prefix]',
                    'text'      => $strTablesPrefix,
                    'enabled'   => $disableForm,
                    'req'       => false,
                    'maxlength' => '7',
                    'value'     => $aDatabase['table']['prefix']
                )
            )
        )
    ), $errormessage, 0, $imgPath);
?>
                <script type='text/javascript'>
                    switchDbTypes();
                </script>
                <input type="submit" class="button" name="btn_upgrade" value="<?php echo ($displayError ? $strBtnRetry : $strBtnContinue); ?>" tabindex="<?php echo ($tabindex++); ?>" <?php echo $disableButton; ?>>
                <input type="hidden" name="dirPage" id="dirPage" value="" />
</form>

<form name="frmOpenads2" id="frmOpenads2" method="POST" action="install.php" style="margin:0; padding:0;">
                <input type="submit" class="button floatleft" name="btn_syscheck" value="<?php echo $strBtnGoBack; ?>" tabindex="<?php echo ($tabindex++); ?>" />
</form>
<form>


