<?php
/**
 * Created by PhpStorm.
 * User: marco
 * Date: 29/06/18
 * Time: 0.59
 */
$isBoxed = false; ?>
<?php
/**
 * Created by PhpStorm.
 * User: marco
 * Date: 20/11/17
 * Time: 17.55
 */
$sliderPostId       = get_field('slider_post', $post->ID);

$sliderPostObject   = get_post( $sliderPostId );
$slidesAcfRows      = get_field( 'slides', $sliderPostId );
$SlidesAcfRowsCount = count( $slidesAcfRows );
//array_push($slidesAcfRows, $slidesAcfRows[0]);
$arrayImmagini = array();
$conta         = 0;
//var_dump($slidesAcfRows);

if ( $slidesAcfRows > 0 ) : array_push( $slidesAcfRows, $slidesAcfRows[0] ); ?>
    <div class="blok o66slider" id="sliderInst">
        <div class="o66slider-monitor">
            <div class="o66slider-container">
                <div class="blok">
                    <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/slider-empty-desktop.png"
                         class="img-responsive hidden-sm hidden-xs">
                    <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/slider-empty-mobile.png"
                         class="img-responsive hidden-md hidden-lg">
                </div>

				<?php //while ( have_rows( 'slides', $sliderPostId ) ) : the_row();
				foreach ( $slidesAcfRows as $slide ) :
					$conta ++;
					?>
					<?php

					$desktopImageSize = o66_image_sizes::slider_full;
					$mobileImageSizes = o66_image_sizes::quad;

					$immagine_sfondo        = $slide['immagine_sfondo'];
					$immagine_sfondo_mobile = $slide['immagine_sfondo_mobile'];

					$link_slide_field = $slide['link_slide']['url'];


					if ( empty( $immagine_sfondo_mobile ) ) {
						$immagine_sfondo_mobile = $immagine_sfondo;
					}

					$widthDesktop  = $immagine_sfondo['sizes'][ $desktopImageSize . '-width' ];
					$heightDesktop = $immagine_sfondo['sizes'][ $desktopImageSize . '-height' ];

					$widthMobile  = $immagine_sfondo_mobile['sizes'][ $mobileImageSizes . '-width' ];
					$heightMobile = $immagine_sfondo_mobile['sizes'][ $mobileImageSizes . '-height' ];

					$ratioWidthHeight = [ $widthDesktop, $heightDesktop, $widthMobile, $heightMobile ];

					$immagine        = $immagine_sfondo['sizes'][ $desktopImageSize ];
					$immagine_mobile = $immagine_sfondo_mobile['sizes'][ $mobileImageSizes ];
					$alt             = $immagine_sfondo['alt'];
					//$immagine = $immagine_sfondo['url'];
					array_push( $arrayImmagini, $immagine );
					$hP       = 'center';
					$vP       = 'bottomSl';
					$testo    = $slide['contenuto'];
					$isBoxed  = true;
					$classBox = 'boxed';
					 ?>
                    <?php if (!empty($link_slide_field)) : ?><a href="<?php echo $link_slide_field;?>"><?php endif;?>
                    <div class="o66slider-slide-container" id="slide-<?php echo $conta; ?>">

                        <img src="<?php echo $immagine; ?>" class="img-slide-desktop hidden-sm hidden-xs img-responsive"
                             alt="<?php echo $alt; ?>"/>
                        <img src="<?php echo $immagine_mobile; ?>"
                             class="img-slide-desktop hidden-md hidden-lg img-responsive" alt="<?php echo $alt; ?>"/>
                      <div class="blok slider-fullr">
                        <div class="container over-container">


                            <div class="slider-box-container <?php echo $classBox; ?> sl-<?php echo $hP; ?> <?php echo $vP; ?>"
                                 id="slide-box-<?php echo $conta; ?>">
                                <div class="float-box">
                                    <div class="blok slider-box"><?php echo $testo; ?></div>
                                </div>
                            </div>


                        </div>
                      </div>

                    </div>
                    <?php if (!empty($link_slide_field)) : ?></a><?php endif;?>
				<?php endforeach; ?>
            </div>
        </div>
    </div>
<?php endif;
//var_dump( $immagine_sfondo );
//$arrayOpt = array( 'idSlider' => 'sliderInst', 'ratioArray' => $ratioWidthHeight );
//o66s::enqueueLibJs( 'GSDevTools' );
//o66s::enqueueJs( 'o66slider', $arrayOpt );
//		<?php the_sub_field( 'vertical_position' ); ?>
<?php $hP = get_sub_field( 'horiziontal_position' ); ?>
<?php $vP = get_sub_field( 'contenuto' );
$isBoxed  = false;

?>
<?php if ( get_sub_field( 'is_boxed' ) == 1 ) {
	$isBoxed = true;
} ?>