<?php
/**
 * @var $this SiteController
 * @var $sidebar string
 * @var $content string
 * @var $certificates GalleryPhoto[]
 */
?>
<?php $this->renderPartial('//snippets/headerGallery');?>
<!-- header end-->
<div class="wrapper content-wrapper">
    <div class="col-wrapper">
        <div class="col2 aside-no-title">
            <div class="text-content">
                <?php echo $sidebar ?>
            </div>
        </div>
        <div class="col10">
            <h1><?php echo CHtml::encode($this->pageName);?></h1>

            <div class="text-content">
                <?php echo $content ?>
            </div>
            <div class="warranty-list">
                <?php foreach ($certificates as $photo): ?>
                <div class="warranty-item">
                    <div class="warranty-image">
                        <?php
                        echo CHtml::link(
                            CHtml::image($photo->getUrl('preview'), $photo->i18n->name),
                            $photo->getUrl(''),//medium
                            array(
                                'rel' => 'gallery',
                                'data-name' => $photo->i18n->name,
                                'data-description' => $photo->i18n->description,
                            )
                        );
                        ?>
                    </div>
                    <div class="warranty-name">
                        <?php echo CHtml::encode($photo->i18n->name);?>
                    </div>
                </div>
                <?php endforeach;?>
            </div>
        </div>
    </div>
</div>

<?php
$cs = Yii::app()->clientScript;
$cs->registerCoreScript('jquery');
//$cs->registerScriptFile(Yii::app()->baseUrl . '/js/fancybox/jquery.mousewheel-3.0.4.pack.js');
$cs->registerScriptFile(Yii::app()->baseUrl . '/js/fancybox/jquery.fancybox-1.3.4.pack.js');
$cs->registerCssFile(Yii::app()->baseUrl . '/js/fancybox/jquery.fancybox-1.3.4.css');
$src = <<<JS
$("a[rel=gallery]").fancybox({
	'transitionIn'	: 'none',
	'transitionOut'	: 'none',
	'titlePosition' : 'over',
	'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {

	    var name = $(currentArray[currentIndex]).data('name'), r = '';
	    var description = $(currentArray[currentIndex]).data('description');
	    name = name?name:''; description = description?description:'';
	    if(name.length) r+='<b>'+name+'</b> ';
		if(description.length) r+=description;
		if(r.length) return '<span id="fancybox-title-over">'+r+'</span>';
        else return '';
	}
});
JS;

$cs->registerScript('fancybox_gallery', $src);
?>