<script>
    $(document).ready(function() {
        $(document).on('click', '.change-res', function(ev) {
            ev.preventDefault();
            var sid = $(this).attr('icon');
            $(this).closest('div').find('#icon-res').html('<img src="/images/icons/' +sid+ '.png" alt="*" />');
            $(this).closest('.input-group-btn').removeClass('open');
            if (sid == 'iron') {
                $('#MailForm_resource').val('iron');
            }
            else {
                $('#MailForm_resource').val('bottles');
            }
        });
    });
</script>
<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'dialog-form',
    'htmlOptions' => array(
        'role' => 'form',
    ),
        ));
echo $form->error($message, 'number', array('class' => 'error-message'));
?>
<div class="dialog-block">
    <div class="form-group">
        <div class="input-group">
                <div class="input-group-btn">
                        <button type="button" class="btn btn-default dropdown-toggle h_36p" data-toggle="dropdown"><span id="icon-res"><img src="/images/icons/iron.png"></span> <span class="caret"></span></button>
                        <ul class="dropdown-menu resources">
                            <li><a href="#iron" class="change-res" icon="iron"><img src="/images/icons/iron.png" /></a></li>
                            <li><a href="#bottle" class="change-res" icon="bottle"><img src="/images/icons/bottle.png" /></a></li>
                        </ul>
                </div>
                <?php echo $form->textField($message, 'number', array('class' => 'form-control h_36p', 'placeholder' => 'Количество')); ?>
        </div>
    </div>
    <?php echo $form->hiddenField($message, 'resource'); ?>
    <div class="dialog-block_buttons">
        <div class="pull-left">
            <?php echo CHtml::submitButton('Отправить', array('class' => 'btn-xs dialog-block_button')); ?>
        </div>
        <div class="pull-right">
            <?php echo CHtml::link('<img src="/images/icons/clothes.png" alt="*" />', array('/mail/list/', 'id' => $id, 'type' => 'items'), array('class' => 'dialog-block_button text-center')); ?>
            <?php echo CHtml::link('<img src="/images/icons/money_gold.png" alt="*" />', array('/mail/list/', 'id' => $id, 'type' => 'money'), array('class' => 'dialog-block_button text-center')); ?>
            <?php echo CHtml::link('Т', array('/mail/list/', 'id' => $id), array('class' => 'dialog-block_button text-center')); ?>
        </div>
        <div class="clearfix"></div>
    </div>
    <hr>Стоимость <img src="/images/icons/money_silver.png">05 за каждые: 
    <img src="/images/icons/iron.png">10 000 или <img src="/images/icons/bottle.png">10
</div>
<?php $this->endWidget(); ?>