<?php
/*
Template Name:Home 1
*/
?>
<?php get_header();	
global $post;
	setup_postdata( $post );
?>
 <div class="content-wrapper">
		<?php if(!get_field('disable_header')):?>
 		<!--big headline--> 	
		<?php $font = get_field('font');?>
        <div class="main-headline" style="background-color:<?php the_field('header_backgroud_color');?>;font-family:<?php echo $font['family']; ?>">		
 			<div class="container">
 				<div id="goto-anim">
					<a href="<?php the_field('header_link');?>" class="pull-right" style="color:<?php the_field('text_color');?>";>
					<i class="<?php the_field('icon');?>"></i>
					</a>
				</div>
	 			<h3 style="color:<?php the_field('text_color');?>;font-family:<?php echo $font['family']; ?>"><?php the_field('header_title');?></h3>
	 			<p  style="color:<?php the_field('text_color');?>;font-family:<?php echo $font['family']; ?>"><?php the_field('header_desc');?></p>
 			</div>
 		</div>
 		<!--end big headline-->
		<?php endif; ?>
    	<div class="container">
    		<h3>
			<?php $latest_works_title = get_field('latest_work');
				  echo $latest_works_title;
			?></h3>
    		<div class="row-fluid">			
    			<div class="span12">
    				<ul class="latestWorks">
					<?php 
						 $args = array(
								'post_type' => 'work_post',
								'posts_per_page' => -1		
							);
							$the_query = new WP_Query($args);
							$items_on_slider = get_field('items_on_slider');
							while ( $the_query->have_posts() ):$the_query->the_post();
							setup_postdata($post);
							?>							
								<?php echo  '<li class="'.$items_on_slider.'">';  ?>
							
								<div class="image-container">
									<a href="<?php the_permalink();?>">
										<?php if(has_post_thumbnail()): ?>
											<?php 
											$domsxe = simplexml_load_string(get_the_post_thumbnail());
											$thumbnailsrc = $domsxe->attributes()->src;
											$image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'home2-featured');
											echo '<img src="'.$image[0].'" alt="T 2" />';
											?>								
										<?php endif; ?>	
								
										<div class="image-hover">
											<!--<p><i class="icon-play icon-large"></i></p>-->
										</div>
									</a>
								</div>
								<a href="<?php echo the_permalink();?>"><h4><?php the_title();?></h4></a>
                                <a href="#"><p class="post-categoty capitalize">
                                    <?php $cat = get_terms('works_category');
                                    $current_categories = get_the_terms(get_the_ID(),'works_category');
                                    $className = '';
                                    if( $current_categories)
                                    {
                                        foreach($current_categories as $cat)
                                        {
                                            $className = $className.' '.$cat->name;
                                        }
                                    }
                                    echo $className ; ?>
                                </p></a>
							</li>
							<?php
							endwhile;
						?>
					</ul><!--latestWorks-->
    			</div>
    		</div>
            <?php  wp_reset_postdata();?>
		 <div class="row-fluid">
				<div class="span12">				  
					 <?php if(is_active_sidebar('sidebar-2')):?>
							<?php  if ( !function_exists('dynamic_sidebar') ||  !dynamic_sidebar('sidebar-2') ) ?>
					 <?php endif;?>								
				</div>
		 </div>
		</div>
    	</div><!--container-->
		 <?php  wp_reset_postdata();?>
    </div>	
	<div class ="theContent">
        <?php setup_postdata($post);?>
        <?php the_content();?>
        <?php wp_reset_postdata();?>
    </div>
<?php get_footer();?>