<script>
    $(document).ready(function() {
        $(document).on('click', '.chose-item', function(ev) {
            ev.preventDefault();
            $('.chose-item').removeClass('active').text('Выбрать');
            $(this).addClass('active');
            $(this).text('Выбрано');
            $('#MailForm_item').val($(this).attr('id'));
        });
    });
</script>
<?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'dialog-form',
    'htmlOptions' => array(
        'role' => 'form',
    ),
        ));
echo $form->error($message, 'item', array('class' => 'error-message'));
?>
<div class="dialog-block">
    <div class="form-group">
        <?php if (!$items): ?>
                <div class="info">Предметов в рюкзаке не найдено</div>
        <?php else: ?>
            <?php foreach($items as $item):?>
                <div class="item-view text-left">
                    <div class="item-view_img">
                        <img src="/images/items/<?php echo $item->img;?>.jpg">
                    </div>
                    <div class="item-view_info">
                        <?php echo UserItems::itemName($item->id_item)?><br /> 
                        <?php echo $item->level;?> ур<br /> 
                        <?php echo CHtml::link('Выбрать', 'item-'.$item->id_item, array('class' => 'block small-block inline chose-item', 'id'=>$item->id_item)); ?>
                    </div>
                </div>
                <hr />
            <?php endforeach;?>
            <?php echo $form->hiddenField($message, 'item'); ?>
        <?php endif; ?>
    </div>
    <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('Т', array('/mail/list/', 'id' => $id), array('class' => 'dialog-block_button text-center')); ?>
            <?php echo CHtml::link('<img src="/images/icons/iron_bottle.png" alt="*" />', array('/mail/list/', 'id' => $id, 'type' => 'resources'), 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')); ?>
        </div>
        <div class="clearfix"></div>
    </div>
    <hr>Стоимость: <img src="/images/icons/money_silver.png">05
</div>
<?php $this->endWidget(); ?>