<?php
/*
Template Name: Contact
*/

if ( get_theme_mod('slider_display') == 1 ) :
	get_header('slider');
elseif ( get_theme_mod('video_display') == 1 ) :
	get_header('video');
elseif ( get_theme_mod('rev_display') == 1 ) :
	get_header('rev');
else :
	get_header();
endif;
?>

	<div id="primary" class="fp-content-area">
		<main id="main" class="site-main" role="main">

			<header class="entry-header">
				<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
			</header><!-- .entry-header -->				
			<div class="contact-content">			
				<?php while ( have_posts() ) : the_post(); ?>
					<?php the_content(); ?>
				<?php endwhile; ?>
			</div><!-- .entry-content -->	
			
			<?php
				$address = get_post_meta( $post->ID, '_moesia_map_address', true );
				$marker = get_post_meta( $post->ID, '_moesia_map_marker', true );
				$form = get_post_meta( $post->ID, '_moesia_map_contact', true );
			?>
			<?php if ($address !='') : ?>
				<div id="single-map" class="map"></div>
			<?php endif; ?>				
			<?php if ($form !='') : ?>
				<div class="single-contact">
					<?php echo do_shortcode('[contact-form-7 id="' . absint($form) . '"]'); ?>
				</div>
			<?php endif; ?>	
			<script>		
			   jQuery(function($) {
					$('#single-map').gmap3({
					 map: {
					    options: {
					    	maxZoom: 18,
					    }  
					 },
					 marker:{
					    address: "<?php echo $address; ?>",
					    <?php if ($marker) : ?>
					    options: {
					      icon: new google.maps.MarkerImage("<?php echo $marker; ?>"),
					    },
					    <?php endif; ?>				    					    
					 }
					},
					"autofit" );
			    });
		    </script>

		</main><!-- #main -->
	</div><!-- #primary -->

<?php get_footer(); ?>
