<!-- CONFIGURE POLL | FREEZY -->
{* header *}{include file="1549864.tpl"}
<table width="100%">
    <tr>
        <!--left column-->
        <td width="23%" valign="top" align="center">
            {* node_settings *} {include file="1549925.tpl"}
            {* get_poll_box *} {include file="1549834.tpl"} <br>
            {* get_bookmark_statistics_box *} {include file="1549386.tpl"}
        </td>
        <!--end of left column-->

        <!--main central column-->
        <td width="77%"" valign="top" align="left">
            {if $node.node_permission == "master" or $node.node_creator == $user_id}
                <form method="post">
                    <table class="bordered" id="new_poll">
                        <tr>
                            <td colspan="3" align="center">create new poll</td>
                        </tr>
                        <tr>
                            <td colspan="3" align="center"><input type="text" name="question" value="{if $smarty.post.question neq false}{$smarty.post.question|escape:"html"|stripslashes}{else}?{/if}" /></td>
                        </tr>
                        <tr id="row_2">
                            <td>option:</td>
                            <td><input type="text" name="option[]" value="" /></td>
                            <td><input type="button" name="remove_option" value="x" id="option_2" onclick="remove_option_OnClick(this.id)" /></td>
                        </tr>
                        <tr>
                            <td colspan="3" align="center">
                                <input type="button" name="add_option" value="add_option" id="add_option" onclick="add_option_OnClick()" />
                                <input type="submit" name="event" value="create_poll" />
                            </td>
                        </tr>
                    </table>
                </form>
            {/if}
            {get_poll listing_amount=$listing_amount offset=$offset}

            {foreach from=$get_poll key=poll_id item=poll}
            <form method="post">
                <input type="hidden" name="poll_id" value="{$poll_id}" />
                <table class="bordered" id="poll_{$poll_id}">
                    <tr>
                        <td colspan="3" align="center"{if $poll.end == ""} style="font-weight: bold;"{/if}>
                            {$poll.question}
                        </td>
                    </tr>
                    {foreach from=$poll.option key=option_id item=option}
                        {math equation="(x / y) * 100" format="%.1f" x=$option.vote_count y=$poll.vote_count assign=option_percent}
                        <tr>
                            <td>
                                {if $poll.vote.date == "" and $poll.end == ""}
                                    <input type="radio" name="poll_option_id" value="{$option_id}" />
                                    {$option.option}
                                {else}
                                    {$option.option}
                                {/if}
                            </td>
                            <td>
                                {if $poll.vote.date == "" and $poll.end == "" and $poll.user_id != $user_id}
                                    <div style="width: 1px; margin-right: 49px; background-color: #6DAE42; height: 10px;">
                                        &nbsp;
                                    </div>
                                {else}
                                    <div style="width: {math equation="(x / 2) + 1" x=$option_percent format="%d"}px; margin-right: {math equation="((100 - x ) / 2) - 1" x=$option_percent format="%d"}px; background-color: #6DAE42; height: 10px;">
                                    &nbsp;
                                    </div>
                                {/if}
                            </td>
                            <td>
                                {if $poll.vote.date == "" and $poll.end == "" and $poll.user_id != $user_id}
                                    0%
                                {else}
                                    {$option_percent}%
                                {/if}
                            </td>
                        </tr>
                    {/foreach}
                    {if $poll.vote.date == "" && $poll.end == ""}
                        <tr>
                            <td colspan="3" align="center"><input type="submit" name="event" value="vote" /></td>
                        </tr>
                    {/if}
                    <tr>
                        <td colspan="3" align="center"{if $poll.end != ""} style="font-style: italic;"{/if}>
                            {$poll.vote_count} voted
                        </td>
                    </tr>
                    {if $node.node_permission == "master" or $node.node_creator == $user_id}
                        <tr>
                            <td colspan="3" align="center">
                                {if $poll.end == ""}
                                    <input type="submit" name="event" value="close_poll" />
                                {/if}
                                <input type="submit" name="event" value="delete_poll" />
                            </td>
                        </tr>
                    {/if}
                </table>
            </form>
            <br />
            {/foreach}
            <form method="post" id="movement">
                {* movement *}{include file="1549913.tpl"}
            </form>
        </td>
        <!--end of central column-->
    </tr>
</table>

{literal}
    <script type="text/javascript" language="javascript">
    <!--
    var new_poll = document.getElementById("new_poll");
    var tr, td, j, rows_length;
    function add_option_OnClick() {
        rows_length = new_poll.rows.length;
        tr = new_poll.insertRow(rows_length - 1);
        tr.id = "row_" + (rows_length - 1);
        td = tr.insertCell(0);
        td.innerHTML = "option:";
        td = tr.insertCell(1);
        td.innerHTML = "<input type='text' name='option[]' value='' />";
        td = tr.insertCell(2);
        td.innerHTML = "<input type='button' name='remove_option' value='x' id='option_"
                     + (rows_length - 1)
                     + "' onclick='remove_option_OnClick(this.id)' />";
    }

    function remove_option_OnClick(option) {
        rows_length = new_poll.rows.length;
        if (rows_length > 4) {
            for (j = 0; j < rows_length; j++) {
                if (new_poll.rows[j].id.substr(4) == option.substr(7))
                    new_poll.deleteRow(j);
            }
        }
    }
    -->
    </script>
{/literal}
{* footer *}{include file="1549377.tpl"}