
<?php if(isset($poll)) : ?>
<script type="text/javascript">
//<![CDATA[
    function validatePollAnswerIsSelected()
    {
        var options = $$('input.poll_vote');
        for( i in options ) {
            if( options[i].checked == true ) {
                return true;
            }
        }
        return false;
    }
//]]>
</script>
<?php $_tpl = Mage::helper('designer')->createTemplate($this->getBlockTemplate(), $this->getBlockId()) ?>
    
<?php $_tpl->section('header') ?>

<?php echo $this->__('Community Poll') ?>

<?php $_tpl->section('content') ?>

    <form id="pollForm" action="<?php echo $action ?>" method="post" onsubmit="return validatePollAnswerIsSelected();">
        <p class="block-subtitle"><?php echo $this->htmlEscape($poll->getPollTitle()); ?></p>
        <?php if( $poll_answers ): ?>
        <ul id="poll-answers">
            <?php foreach( $poll_answers as $answer ): ?>
            <li>
                <input type="radio" name="vote" class="radio poll_vote" id="vote_<?php echo $answer->getId() ?>" value="<?php echo $answer->getAnswerId() ?>" />
                <span class="label"><label for="vote_<?php echo $answer->getId() ?>"><?php echo $this->htmlEscape($answer->getAnswerTitle()) ?></label></span>
            </li>
            <?php endforeach; ?>
        </ul>
        <script type="text/javascript">decorateList('poll-answers');</script>
        <?php endif; ?>
        <div class="actions">
            <button type="submit" title="<?php echo $this->__('Vote') ?>" class="button"><span><span><?php echo $this->__('Vote') ?></span></span></button>
        </div>
    </form>
<?php echo $_tpl->render($this) ?>

<?php endif; ?>
