<?php
/**
 * Template Name: Contact
 */
get_header(); ?>

		<div id="primary" class="content-area">
			<div id="content" class="site-content" role="main">
			<?php while ( have_posts() ) : the_post(); ?>
				<?php $prefix = 'wpfc_';
				$page_description = get_post_meta($post->ID, $prefix.'page_description', true);
				?>

				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
					<header class="entry-header">
						<h1 class="entry-title"><?php the_title(); ?></h1>
						<?php if(!empty($page_description)) { ?>
							<div class="page-description">
								<?php echo $page_description; ?>
							</div><!-- .page-description -->
						<?php } ?>
					</header><!-- .entry-header -->

					<div class="entry-content">
						<?php
							$morgan_address = of_get_option( 'morgan_address' );
							if( $morgan_address ) :
								morgan_contact_map(); 
							endif; ?>
						<?php the_content(); ?>
						<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'morgan' ), 'after' => '</div>' ) ); ?>
					</div><!-- .entry-content -->
					
					<footer class="entry-meta">
						<?php edit_post_link( __( 'Edit', 'morgan' ), '<span class="edit-link"> <i class="icon-edit"></i> ', '</span>' ); ?>
					</footer><!-- .entry-meta -->
				</article><!-- #post-<?php the_ID(); ?> -->

			<?php endwhile; // end of the loop. ?>
			</div><!-- #content .site-content -->
		</div><!-- #primary .content-area -->
		<?php
			$morgan_fb = of_get_option( 'social_fb' );
			$morgan_twitter = of_get_option( 'social_twitter' );
			$morgan_gplus = of_get_option( 'social_gplus' );
			$morgan_email = of_get_option( 'social_email' );
			$morgan_phone = of_get_option( 'morgan_phone' );
			$morgan_street = of_get_option( 'morgan_street' );
			
			if( $morgan_fb || $morgan_twitter || $morgan_gplus || $morgan_phone || $morgan_street || $morgan_address ) :
			?>							
		<div id="secondary" class="widget-area" role="complementary">

				<aside id="contact-info" class="widget morgan-address clearfix">
					<h1 class="widget-title"><?php echo _e('Connect With Us','morgan'); ?></h1>

						<?php if ( $morgan_address ) : 
							$address_url = preg_replace( '![^a-z0-9]+!i', '+', $morgan_street. ' ' .$morgan_address );?>
							<p><i class="icon-map-marker"></i> <a href="<?php echo 'http://maps.google.com/maps?q=' . $address_url; ?>" title="<?php esc_attr_e( 'Directions', 'morgan' ); ?>"><?php echo $morgan_street. '<span class="city-state">' .$morgan_address. '</span>'; ?> </a></p>
						<?php endif; ?>

						<?php if ( $morgan_phone ) : ?>
							<p><i class="icon-phone"></i> <a href="tel:<?php echo $morgan_phone; ?>"><?php echo $morgan_phone; ?></a></p>
						<?php endif; ?>

						<?php if ( $morgan_email ) : ?>
							<p><i class="icon-envelope"></i> <a href="mailto:<?php echo antispambot( $morgan_email ); ?>"><?php echo $morgan_email; ?></a></p>
						<?php endif; ?>
						
						<div id="contact-social">
							<ul class="contact-social">
								<?php if ( $morgan_fb ) : ?>
									<li class="facebook"><a href="<?php echo esc_url( $morgan_fb ); ?>" title="<?php esc_attr_e( 'Facebook', 'morgan' ); ?>"><i class="icon-facebook"></i><span><?php _e( 'Facebook', 'morgan' ); ?></span></a></li>
								<?php endif; ?>

								<?php if ( $morgan_twitter ) : ?>
									<li class="twitter" ><a href="<?php echo esc_url( $morgan_twitter ); ?>" title="<?php esc_attr_e( 'Twitter', 'morgan' ); ?>"><i class="icon-twitter"></i><span><?php _e( 'Twitter', 'morgan' ); ?></span></a></li>
								<?php endif; ?>

								<?php if ( $morgan_gplus ) : ?>
									<li class="gplus"><a href="<?php echo esc_url( $morgan_gplus ); ?>" title="<?php esc_attr_e( 'Google+', 'morgan' ); ?>"><i class="icon-google-plus"></i><span><?php _e( 'Google+', 'morgan' ); ?></span></a></li>
								<?php endif; ?>
							</ul>
						</div><!-- #contact-social -->
				</aside>

		</div><!-- #secondary .widget-area -->
		<?php else :
		get_sidebar();
		endif; ?>

<?php get_footer(); ?>