<?php
/**
 * The template for displaying the full width grid section.
 *
 * @package WordPress
 * @subpackage Edition
 * @since Edition 1.0
 */
global 
$tw_order_class, // section order 
$tw_section; // section object

$tw_section = themewich_section_object(); // Get section object 

// Set post classes
$tw_section->post_classes  = array(
	'homesection',
	'ad-section',
	'section',
	$tw_order_class,
	$tw_section->title_class
); ?>

<?php if ( isset($tw_section->ad_code) || ($tw_section->ad_type == 'image' && isset($tw_section->ad_image)) ) : ?>
	<div <?php post_class($tw_section->post_classes); ?>>
		<?php themewich_section_edit(); // Edit link ?>

		<div class="container">
			<div class="col-md-12">
				<?php get_template_part( TW_SECTIONS_DIR .'/section-title'); // Section title  ?>

				<div class="ad-wrapper">
					<div class="ad-image">
						<?php 
						  	if ($tw_section->ad_type) {
								switch($tw_section->ad_type) {
									case 'image': 
										if ( $tw_section->ad_image && $tw_section->ad_url ) {
											echo '<a href="' . $tw_section->ad_url  .'" target="_blank">';
											echo '<img src="' . $tw_section->ad_image['url'] . '" alt="' . $tw_section->ad_image['alt'] . '" title="' . $tw_section->ad_image['title'] . '" class="scale-with-grid" />';
											echo '</a>';
										}
									break;
									default : 
										if ( isset($tw_section->ad_code) ) {
											echo htmlspecialchars_decode( esc_html( $tw_section->ad_code ) );
										}
									break; 
								}
							} 
						?>
					</div>
				</div>

	        </div><!--.col-md-12-->
	    </div><!--.container-->
	    <div class="clear"></div>
	</div><!--.homesection-->
<?php endif; ?>