<?php

// Prevent Direct Access
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$services_image = get_theme_mod('services_image');
$services_title = get_theme_mod('services_title');
$services = get_theme_mod('services', array());

if( $services ){

	$count = count($services);
	
	if($count == 1){
		$column_class = 'col-xs-12';
	}
	else if($count == 2 || $count == 4){
		$column_class = 'col-sm-6';
	}
	else{
		$column_class = 'col-sm-4';
		
		if($services_image){
			$column_class .= ' col-md-6';
		}
	}
}

$section_id = get_theme_mod('services_menu_id', 'services');
?>

<section class="bg bglight" id="<?php echo $section_id ?>">
	
	<div class="container-fluid">
		<div class="row">
			<div class="<?php echo $services_image ? 'col-md-6' : '' ?> col-sm-12">
				<div class="padding darkcolor equalheight left">
				
					<?php if( $services_title != '' ){ echo '<h2 class="heading_space secondary_font">'.$services_title.'</h2>'; } ?>
					
					<?php if( $services ){ ?>
					<div class="updates">
						<div class="update_slide row">
						
							<?php foreach ($services as $service){ ?>
							<div class="latest_updates bottom40 <?php echo $column_class ?>">
								<div class="update_text">
									<?php
									if( $service['title'] != '' ){ echo '<h6 class="bottom20">'.$service['title'].'</h6>'; }
									if( $service['text'] != '' ){ echo '<p>'.nl2br($service['text']).'</p>'; }
									?>
								</div>
							</div>
							<?php } ?>
							
						</div>
					</div>
					<?php } ?>
					
				</div>
			</div>
		</div>
	</div>

	<?php if($services_image){ ?>
	<div class="bghalf imgleft equalheight hidden-xs" style="background-image:url(<?php echo wp_get_attachment_url($services_image) ?>);"></div>
	<?php } ?>

</section>