<?php if (!defined('MAX_PATH')) { exit; } ?>
<br>
<table border='0' cellpadding='0' cellspacing='0' width='100%'>
<?php
if ($errMessage) {
?>

    <tr>
        <td colspan='2' align='center'>
        <div class="sysmessage sysinfoerror"><?php echo $errMessage; ?></div>
        </td>
    </tr>
<?php
}

?>
<tr>
<td valign='top'><img src='<?php echo $imgPath; ?>images/install-welcome.gif'></td>
<td width='100%' valign='top'>
<br>
<span class='tab-s'><?php echo $strConfigurationSetup; ?></span>
<br>
<img src='<?php echo $imgPath; ?>images/break-el.gif' width='100%' height='1' vspace='8'>
<span class='install'><?php echo $strConfigSettingsIntro; ?></span>
</td>
</tr>
</table>
<br>

<form id="frmOpenads" name="frmOpenads" method="POST" action="install.php" onSubmit='return max_formValidate(this);'>

<?php

        if ($aConfig && is_array($aConfig) && (count($aConfig)>0))
        {

            // Setup list of all timezones, calculate selected timezone
            require_once('../../lib/OA/Admin/Timezones.php');
            $aTimezones = OA_Admin_Timezones::AvailableTimezones(true);
            if ($_POST['aConfig']['timezone']['location']) {
                $selTimezone = $_POST['aConfig']['timezone']['location'];
            } else {
                $aTimezone = OA_Admin_Timezones::getTimezone();
                $selTimezone = $aTimezone['tz'];
            }

            // What display string do we need to show for the timezone?
            if ($aTimezone['calculated']) {
                $errorImage = "<img src='".$imgPath."images/icon-x.gif' width='10' height='9' />";
                $strTimezoneToDisplay = $strTimezoneEstimated . '<br /><small class="red">' . $errorImage . $strTimezoneGuessedValue . '</small>';
            } else {
                $strTimezoneToDisplay = $strTimezone;
            }
            // For language, setup English as first choice
            $langVal = 'english';

            phpAds_ShowSettings(array (
                array (
                    'text'  => $strConfigurationSettings,
                    'items' => array (
                        array (
                            'type'  => 'select',
                            'name'  => 'aConfig[max][language]',
                            'text'  => $strLanguageSelection,
                            'req'   => true,
                            'value' => $langVal,
                            'items' => MAX_Admin_Languages::AvailableLanguages()
                        ),
                        array (
                            'type'  => 'break'
                        ),
                        array (
                            'type'  => 'select',
                            'name'  => 'aConfig[timezone][location]',
                            'text'  => $strTimezoneToDisplay,
                            'req'   => true,
                            'value' => $selTimezone,
                            'items' => $aTimezones
                        ),
                        array (
                            'type'  => 'break'
                        ),
                        array (
                            'type'  => 'url',
                            'name'  => 'aConfig[webpath][admin]',
                            'text'  => $strWebPathSimple,
                            'size'  => '50',
                            'value' => $aConfig['webpath']['admin'],
                            'enabled' => true
                        ),
                        array (
                            'type'  => 'break'
                        ),
                        array (
                            'type'  => 'urln',
                            'name'  => 'aConfig[webpath][delivery]',
                            'text'  => $strDeliveryPath,
                            'req'   => true,
                            'size'  => '50',
                            'value' => $aConfig['webpath']['delivery']
                        ),
                        array (
                            'type'  => 'break'
                        ),
                        array (
                            'type'  => 'urln',
                            'name'  => 'aConfig[webpath][images]',
                            'text'  => $strImagePath,
                            'req'   => true,
                            'size'  => '50',
                            'value' => $aConfig['webpath']['images']
                        ),
                        array (
                            'type'  => 'break'
                        ),
                        array (
                            'type'  => 'urls',
                            'name'  => 'aConfig[webpath][deliverySSL]',
                            'text'  => $strDeliverySslPath,
                            'req'   => true,
                            'size'  => '50',
                            'value' => $aConfig['webpath']['deliverySSL']
                        ),
                        array (
                            'type'  => 'break'
                        ),
                        array (
                            'type'  => 'urls',
                            'name'  => 'aConfig[webpath][imagesSSL]',
                            'text'  => $strImageSslPath,
                            'req'   => true,
                            'size'  => '50',
                            'value' => $aConfig['webpath']['imagesSSL']
                        ),
                        array (
                            'type'  => 'break'
                        ),
                        array (
                            'type'  => 'text',
                            'name'  => 'aConfig[store][webDir]',
                            'text'  => $strImageStore,
                            'req'   => true,
                            'size'  => '50',
                            'value' => $aConfig['store']['webDir']
                        )
                    )
                )
            ), $errormessage, 0, $imgPath);
    }
    else
    {
    ?>
        <table border='0' width='100%' cellpadding='0' cellspacing='0'><tr>
    <input type='hidden' name='submitok' value='true'>
    <td height='25' colspan='4'><img src='<?php echo $imgPath; ?>images/icon-setup.gif' width='16' height='16' align='absmiddle'>&nbsp;<b><?php echo $strConfigurationSettings; ?></b></td></tr>
    <tr height='1'>
    <td bgcolor='#888888' width='30'><img src='<?php echo $imgPath; ?>images/break.gif' height='1' width='30'></td>
    <td bgcolor='#888888' width='250'><img src='<?php echo $imgPath; ?>images/break.gif' height='1' width='250'></td>
    <td bgcolor='#888888' width='100%'><img src='<?php echo $imgPath; ?>images/break.gif' height='1' width='1'></td>

    <td bgcolor='#888888' width='30'><img src='<?php echo $imgPath; ?>images/break.gif' height='1' width='30'></td>
    </tr><tr><td height='10' colspan='4'><img src='<?php echo $imgPath; ?>images/spacer.gif' width='30' height='1'></td></tr>
    <tr><td>&nbsp;</td>
    <td class='cellenabled' valign='top'>
    Configuration setup not needed, config file is present
    </td>
    <td width='100%' valign='top'>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr><td><img src='<?php echo $imgPath; ?>images/spacer.gif' height='1' width='100%'></td>
    <td><img src='<?php echo $imgPath; ?>images/break-l.gif' height='1' width='400' vspace='10'></td>
    <td>&nbsp;</td><td><img src='<?php echo $imgPath; ?>images/spacer.gif' height='1' width='100%'></tr>
    </table>
    <?php
    }

if ($errMessage) {
?>
                <input type="submit" class="button" id="btn_adminsetup" name="btn_adminsetup" value="<?php echo $strBtnRetry; ?>" tabindex="<?php echo ($tabindex++); ?>" />
<?php
} else {
?>
                <input type="submit" class="button" id="btn_adminsetup" name="btn_adminsetup" value="<?php echo $strBtnContinue; ?>" tabindex="<?php echo ($tabindex++); ?>" />
<?php
}
?>
