<?php
/**
 * @var $this QuestionController
 * @var $questions Question[]
 * @var $questionCategories QuestionCategory[]
 * @var $contacts Contact[]
 * @var $currentCategory QuestionCategory
 */
?>
<?php $this->renderPartial('//snippets/headerGallery');?>
<!-- header end-->
<div class="wrapper content-wrapper">
    <div class="col-wrapper">
        <div class="col2">
            <p class="section-title"><?php echo Yii::t('site', 'Рубрики');?></p>
            <ul class="sidebar-nav">
                <?php
                foreach ($questionCategories as $item) {
                    if ($item->id == $currentCategory->id) echo '<li class="active">'; else echo '<li>';
                    echo CHtml::link($item->i18n->name, array('question/index', 'category' => $item->link)), '</li>';
                }
                ?>
            </ul>
        </div>
        <div class="col8">
            <h1><?php echo CHtml::encode($this->pageName);?></h1>
            <?php foreach ($questions as $question): ?>
            <div class="faq-box">
                <div class="question">
                    <span class="faq-indicator">+</span>
                    <a><?php echo $question->i18n->question?></a>
                </div>
                <div class="answer text-content" style="display: none;">
                    <?php echo $question->i18n->answer ?>
                </div>
            </div>
            <?php endforeach;?>
        </div>
        <div class="col2">
            <p class="section-title"><?php echo Yii::t('site','Есть вопросы?');?></p>

            <div class="text-content">
                <?php echo Yii::t('site','Обращайтесь к вашему персональному консультанту.');?>
            </div>
            <?php $this->renderPartial('//snippets/sidebarContacts');?>
        </div>
    </div>
</div>
<?php
/** @var $cs CClientScript */
$cs = Yii::app()->clientScript;
$src = <<<JS
(function(){
    var c = false;
    function open(e){
        var a = $('.answer', e);
        var i = $('.question >.faq-indicator',e);
        i.text('-');
        a.css('display','block');
    }
    function close(e){
        var a = $('.answer', e);
        var i = $('.question >.faq-indicator',e);
        i.text('+');
        a.css('display','none');
    }
    c = $('.faq-box').each(function(){
        var t = this;
        $('.question',this).click(function(){
            if(t!==c) {
                if(c!==false) close(c);
                open(t); c = t;
            } else {
                close(t); c=false;
            }
        });
    });
    c=c[0];
    open(c);
})();
JS;
$cs->registerScript('faq', $src);

?>