<?php if ( empty( $instance['ids'] ) ) : ?>
	<div class="container mt30">
		<div class="alert alert-warning">
			<?php echo __( 'No property IDs specified.', 'realia' ); ?>
		</div><!-- /.alert -->
	</div><!-- /.container -->
<?php else: ?>        
	<div id="carousel-main" class="carousel slide" data-ride="carousel">
		<!-- SLIDES -->
		<div class="carousel-inner" <?php if ( ! empty( $instance['height'] ) ) : ?>style="height: <?php echo esc_attr( $instance['height'] ); ?>"<?php endif; ?>>
			<?php query_posts( array(
	            'post_type'         => 'property',
	            'posts_per_page'    => -1,
	            'post__in'          => $ids,
	            'orderby'           => 'post__in' 
	    	) ); ?>

			<?php $index = 0; ?>
			<?php while ( have_posts() ) : the_post(); ?>			
				<div class="item <?php if ( $index == 0 ) : ?>active<?php endif; ?>">
					<?php if (  empty( $instance['hide_property_descriptions'] ) ) : ?>
						<div class="carousel-caption-container container">
							<div class="carousel-caption">
								<h2>
									<a href="<?php the_permalink(); ?>">
										<?php the_title(); ?>
									</a>
								</h2>

								<?php $location = Realia_Query::get_property_location_name(); ?>
								<?php if ( ! empty( $location ) ) : ?>
									<h3><?php echo wp_kses( $location, wp_kses_allowed_html( 'post' ) ); ?></h3>
								<?php endif; ?>

								<?php $price = Realia_Price::get_property_price(); ?>

								<?php if ( ! empty( $price ) ) : ?>
									<a href="<?php the_permalink(); ?>" class="price"><?php echo wp_kses( $price, wp_kses_allowed_html( 'post' ) ); ?></a>
								<?php endif; ?>
							</div><!-- /.carousel-caption -->
						</div><!-- /.container -->
					<?php endif; ?>

					<?php $slider_images = get_post_meta( get_the_ID(), REALIA_PROPERTY_PREFIX . 'slider_image', true ); ?>
					<?php if ( is_array( $slider_images ) && count( $slider_images ) > 0 ) : ?>							
						<?php echo wp_get_attachment_image( key($slider_images), 'full' ); ?>							
					<?php endif; ?>
				</div><!-- /.item -->
				<?php $index++; ?>
			<?php endwhile; ?>			
		</div><!-- /.carousel-inner -->

		<?php wp_reset_query(); ?>

		<?php if ( $index > 1 ) : ?>
			<!-- CONTROLS -->
			<a class="left carousel-control" href="#carousel-main" role="button" data-slide="prev">
		    	<i class="fa fa-chevron-left"></i>
		    	<span class="sr-only"><?php echo __( 'Previous', 'realia' ); ?></span>
		  	</a><!-- /.carousel-control -->

			<a class="right carousel-control" href="#carousel-main" role="button" data-slide="next">
				<i class="fa fa-chevron-right"></i>
				<span class="sr-only"><?php echo __( 'Next', 'realia' ); ?></span>
			</a><!-- /.carousel-control -->

			<?php if ( is_active_sidebar( 'property-carousel' ) ) : ?>
				<div class="property-carousel-widget-area">
					<div class="container">
						<div class="row">
							<div class="col-sm-4 col-sm-offset-8 col-md-3 col-md-offset-9">
								<div class="property-carousel-widget-area-inner">
									<?php dynamic_sidebar( 'property-carousel' ); ?>
								</div><!-- /.property-carousel-widget-area-inner -->
							</div><!-- /.col-* -->
						</div><!-- /.row -->
					</div><!-- /.container -->
				</div><!-- /.property-carousel-widget-area -->
			<?php endif; ?>						
		<?php endif; ?>
	</div><!-- /.carousel -->
<?php endif; ?>		