<?php
if (!defined('IN_CONTEXT')) die('access violation error!');
?>
<script type="text/javascript" language="javascript">
<!--
function on_success(response) {
    var o_result = _eval_json(response);
    if (!o_result) {
        return on_failure(response);
    }
    
    var stat = document.getElementById("adminsinfofrm_stat");
    if (o_result.result == "ERROR") {
        document.forms["sinfoform"].reset();
        
        stat.innerHTML = o_result.errmsg;
        return false;
    } else if (o_result.result == "OK") {
	    stat.innerHTML = "<?php _e('Site information saved!'); ?>";
	    window.parent.tb_remove();
    } else {
        return on_failure(response);
    }
}

function on_failure(response) {
    document.forms["sinfoform"].reset();
    
    document.getElementById("adminsinfofrm_stat").innerHTML = "<?php _e('Request failed!'); ?>";
    return false;
}
//-->
</script>
<div class="content_title">
	<h3><?php _e('Site Infomation'); ?></h3>
</div>
<div class="space"></div>
<div class="content_toolbar">
	<table cellspacing="0" class="wrap_table">
		<tbody>
			<tr>
				<td><?php include_once(P_TPL.'/common/language_switch.php'); ?></td>
				<td>&nbsp;</td>
			</tr>
		</tbody>
	</table>
</div>
<div class="space"></div>
<div class="status_bar">
	<span id="adminsinfofrm_stat" class="status" style="display:none;"></span>
</div>
<div class="space"></div>
<?php
$sinfo_form = new Form('index.php', 'sinfoform', 'check_sinfo_info');
$sinfo_form->p_open('mod_site', 'save_info', '_ajax');
?>
<table id="sinfoform_table" class="form_table" cellspacing="1">
    <tfoot>
        <tr>
            <td colspan="2">
            <?php
            echo Html::input('reset', 'reset', __('Reset'));
            echo Html::input('submit', 'submit', __('Save'));
            echo Html::input('hidden', 'si[id]', $curr_siteinfo->id);
            echo Html::input('hidden', 'si[s_locale]', $lang_sw);
            ?>
            </td>
        </tr>
    </tfoot>
    <tbody>
        <tr>
            <td class="label"><?php _e('Site Name'); ?></td>
            <td class="entry">
            <?php
            echo Html::input('text', 'si[site_name]', $curr_siteinfo->site_name);
            ?>
            </td>
        </tr>
        <tr>
            <td class="label"><?php _e('Keyword'); ?></td>
            <td class="entry">
            <?php
            echo Html::input('text', 'si[keywords]', $curr_siteinfo->keywords, 
                'size="48"');
            ?>
            </td>
        </tr>
        <tr>
            <td class="label"><?php _e('Description'); ?></td>
            <td class="entry">
            <?php
            echo Html::textarea('si[description]', $curr_siteinfo->description, 
                'cols="48" rows="6"');
            ?>
            </td>
        </tr>
    </tbody>
</table>
<?php
$sinfo_form->close();
$running_msg = __('Saving site information...');
$custom_js = <<<JS
$("#adminsinfofrm_stat").css({"display":"block"});
$("#adminsinfofrm_stat").html("$running_msg");
_ajax_submit(thisForm, on_success, on_failure);
return false;

JS;
$sinfo_form->addCustValidationJs($custom_js);
$sinfo_form->writeValidateJs();
?>
