<?
$formname                    = "form_line_card";
$translation                 = \DynCom\mysyde\common\classes\Registry::get("translation");
$input_page_id               = (isset($_REQUEST["input_page_id"]) ? $_REQUEST["input_page_id"] : "");
$input_component_id          = (isset($_REQUEST["input_component_id"]) ? $_REQUEST["input_component_id"] : "");
$header_id                   = (isset($input_line["header_id"]) ? $input_line["header_id"] : "");
?>

<div id="overlaycrumb">
    <?php if ($input_line["id"] == "") {
        echo $translation->get("new_forwarding_field");
    } else {
        echo $translation->get("edit_forwarding_field");
    }
    ?>
    <div id="closeoverlay" onclick="disableOverlay();"></div>
</div>

<ul class="toolbar_menu">
    <?
    if (is_collection_edit()) {
        button("left", $translation->get("overview"), $formname, "loadCard('edit_collection', true)");
    } else {
        button("left", $translation->get("overview"), $formname, "loadCard('edit_forwarding', true)");
    }
    ?>
    <?= button("save", $translation->get("save"), $formname, "loadCard('save_line_forwarding', true)"); ?>
    <?= button("save", $translation->get("save_and_close"), $formname, "jQuery('#save_and_close', jQuery('#" . $formname . "')).val(1);loadCard('save_line_forwarding', true)"); ?>
    <?php
    if ($input_line["id"] != "") {
        echo button("delete", $translation->get("delete"), $formname, "loadCard('delete_line_forwarding', true, '{$translation->get('delete_forwarding_field_confirm')}')");
    }
    ?>
</ul>
<div class="clearfix"></div>

<?php

if ($messages !== null) {
    if (count($messages)) {
            echo '<div id="overlayMessages">' . join("\r\n", $messages) . '</div>';
    } 
 }
?>

<script>



</script>

<form id="<?= $formname ?>" name="<?= $formname ?>" method="post">

    <input name="input_line_id" type="hidden" value="<?= $input_line["id"] ?>" />
    <input name="input_id" type="hidden" value="<?= $header_id; ?>" />
    <input type="hidden" name="input_page_id" value="<?php echo $input_page_id; ?>" />
    <input type="hidden" name="input_component_id" value="<?php echo $input_component_id; ?>" />
    <input name="save_and_close" id="save_and_close" type="hidden" value="0" />
    <input type="hidden" name="linklist_form" value="form_field_forwarding_list">

    <table class="cardform" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td>

                <? create_preview_select($input_line) ?>

                <?php input($translation->get("description"), "input_description", "text", $input_line["description"], 255) ?>
                <?php input_select($translation->get("use_menuitem_for"), "input_forward_type", array(0 => "1", 1 => "2", 2 => "3"), array(
                    0 => $translation->get("assign_page"),
                    1 => $translation->get("internal_forward"),
                    2 => $translation->get("external_forward"),
                ), $input_line['forward_type'], FALSE, FALSE, 'onchange="select_forwardtype(this.value);"') ?>

                <div id="select_navigation_id" <?php echo $input_line['forward_type'] != 1 && $input_line['forward_type'] != 0  ? 'style="display:none;"' : ''; ?>>
                    <? navigation_select($translation->get("choose_navigation_item"), "input_forward_navigation_id", $input_line["forward_navigation_id"], $GLOBALS["site"]['id'], $GLOBALS["language"]['id'], FALSE); ?>
                </div>

                <div id="insert_path" <?php echo $input_line['forward_type'] != 2 ? 'style="display:none;"' : ''; ?>>
                    <? input($translation->get("internal_url"), "input_forward_url", "text", $input_line["forward_url"], 255) ?>
                </div>

                <div id="external_url" <?php echo $input_line['forward_type'] != 3 ? 'style="display:none;"' : ''; ?>>
                    <? input($translation->get("external_url"), "input_forward_url_external", "text", $input_line["forward_url"], 255) ?>
                </div>

                <? input($translation->get("insert_parameter"), "input_forward_parameter", "text", $input_line["forward_parameter"], 255) ?>

            </td>
        </tr>
    </table>


</form>


<script type="text/javascript">
    function select_forwardtype(value) {
        $('#select_navigation_id, #external_url, #insert_path').hide();
        value = parseInt(value);
        switch (value) {
            case 1:
                $('#select_navigation_id').show();
                break;
            case 2:
                $('#insert_path').show();
                break;
            case 3:
                $('#external_url').show();
                break;

        }
    }
</script>