<?php
if(count($reviews) > 0){
    $module_action = $sf_request->getParameter('module') . '_' . $sf_request->getParameter('action');

    if($module_action == 'product_show') { ?>
        <div class="product_section product__reviews background_lightgrey">
            <div class="caption">
                <a href="/<?php echo $culture; ?>/review/?tag_id=<?php echo $tag_id; ?>" class="green_link"><?php echo __('Отзывы клиентов'); ?></a>
            </div>
            <div class="max_width">

    <?php } elseif($module_action == 'main_index') { ?>
        <tr>
            <td>
                <div class="lending_area_4 lending_area_review background_lightgrey">
                <div style="text-align: center" class="caption">
                    <a class="green_link" href="/<?php echo $culture; ?>/review/"><?php echo __('Отзывы клиентов'); ?></a>
                </div>
                <i class="br20"></i>
    <?php } ?>


    <div class="reviews_slideshow slideshow_wrap mobile_hide">
        <div class="slideshow"
             data-cycle-fx="scrollHorz"
             data-cycle-swipe="true"
             data-cycle-swipe-fx="scrollHorz"
             data-cycle-slides="> .reviews_slideshow__item"
             data-cycle-timeout="0"
             data-cycle-prev=".for_reviews.slideshow_arrow.left"
             data-cycle-next=".for_reviews.slideshow_arrow.right"
             data-cycle-log="true"
             data-cycle-pager=".for_reviews.cycle-pager"
             data-cycle-pager-template="<li></li>">

            <?php foreach ($reviews as $review) { ?>
                <div class="reviews_slideshow__item">
                    <div class="reviews_slideshow__item_review">
                        <table class="to_div" cellspacing="0" cellpadding="0" width="100%">
                            <tbody align="left" valign="top">
                            <tr>
                                <td rowspan="2" class="reviews_slideshow__item_review_img">
                                    <div class="reviews_item__image_slider" style="background-image: url(/u/i/<?php echo $review['file'] ?>);" ></div>
                                </td>
                                <td></td>
                                <td class="reviews_slideshow__item_review_text" <?php echo (strlen($review['file']) > 3 ? 'style="width: 70%"' : '') ?> >
                                    <?php echo $review['body'] ?>
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td class="reviews_slideshow__item_author">
                                    <?php echo $review['name'] ?>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            <?php } ?>
            </div>

        <div class="for_reviews slideshow_arrow left mobile_hide"></div>
        <div class="for_reviews slideshow_arrow right mobile_hide"></div>
        <ul class="for_reviews cycle-pager"></ul>

    </div>

    <div class="reviews_slideshow slideshow_wrap mobile">
        <div class="slideshow"
             data-cycle-fx="scrollHorz"
             data-cycle-swipe="true"
             data-cycle-swipe-fx="scrollHorz"
             data-cycle-slides="> .reviews_slideshow__item"
             data-cycle-timeout="0"
             data-cycle-prev=".for_reviews.slideshow_arrow.left"
             data-cycle-next=".for_reviews.slideshow_arrow.right"
             data-cycle-log="true"
             data-cycle-auto-height="container"
             data-cycle-pager=".for_reviews.cycle-pager"
             data-cycle-pager-template="<li></li>">

            <?php foreach ($reviews as $review) { ?>
                <div class="reviews_slideshow__item">
                    <div class="reviews_slideshow__item_review">
                        <table class="to_div" cellspacing="0" cellpadding="0" width="100%">
                            <tbody align="left" valign="top">
                            <tr>
                                <td rowspan="2" class="reviews_slideshow__item_review_img">
                                    <div class="reviews_item__image_slider" style="background-image: url(/u/i/<?php echo $review['file'] ?>);" ></div>
                                </td>
                                <td></td>
                                <td class="reviews_slideshow__item_review_text" <?php echo (strlen($review['file']) > 3 ? 'style="width: 70%"' : '') ?> >
                                    <?php echo $review['body'] ?>
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td class="reviews_slideshow__item_author">
                                    <?php echo $review['name'] ?>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            <?php } ?>
            </div>

        <div class="for_reviews slideshow_arrow left mobile_hide"></div>
        <div class="for_reviews slideshow_arrow right mobile_hide"></div>
        <ul class="for_reviews cycle-pager"></ul>

    </div>

    <script type="text/javascript">
        if(!$('.mobile').is(":visible")) {
            $('.reviews_slideshow.mobile_hide .slideshow').cycle();
        } else {
            $('.reviews_slideshow.mobile .slideshow').cycle();
        }
    </script>


    <?php if($module_action == 'product_show') { ?>
            </div>
        </div>

    <?php } elseif($module_action == 'main_index') { ?>
                </div>
            </td>
        </tr>
    <?php }
}
?>