<?php
/*
Template Name:Home 2
*/
?>
<?php get_header();?>
 <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_background_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">
    		<div class="row-fluid">
    			<div class="span6">
				<?php 	setup_postdata($post); ?>
    			<h3><?php get_field('page_title')? the_field('page_title') :  the_title(); ?></h3>
    				<div id="carousel-example-generic" class="carousel slide" style="clear:left;">
					  <!-- Indicators -->
					  <!--<ol class="carousel-indicators">	
						<?php 
						 $args = array(
								'post_type' => 'work_post',
								'posts_per_page' => -1,	
								'order' => 'DESC'
							);
							$the_query = new WP_Query($args);
							$counter = 0;
							while ( $the_query->have_posts()):$the_query->the_post();
								 if($counter==0)		
									echo '<li data-target="#carousel-example-generic" data-slide-to="'.$counter.'" class="active"></li>';
							     else
									echo '<li data-target="#carousel-example-generic" data-slide-to="'.$counter.'"></li>';
								   $counter++;
								   endwhile;
						   ?>
					  </ol>-->
					  <!-- Wrapper for slides -->
					  <div class="carousel-inner">					 
							<?php
							$counter = 0;
							while ( $the_query->have_posts()):$the_query->the_post();
							?>						
							<?php if($counter==0)		
									echo '<div class="item active">';
								  else
									echo '<div class="item">';
								   $counter++;
									?>
							<?php if(has_post_thumbnail()): 
									 $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'home2-featured');
                                        echo '<img src="'.$image[0].'"/>';
								?>								
							<?php endif; ?>						     
					      <div class="carousel-caption">
					        <a href="<?php echo the_permalink(); ?>"><p class="post-title"><?php the_title();?></p></a>
					      </div>
					    </div>
						<?php endwhile ;?>					   
					  </div>

					  <!-- Controls -->
					  	<ul class="pg_paging_bp carousel-nav" style="z-index: 9999;">
							<li class="pg_previous_bp transition">
								<a href="#carousel-example-generic" data-slide="prev">
									<i class="icon-caret-left transition"></i>
								</a>
							</li>
							<li class="pg_next_bp transition">
								<a href="#carousel-example-generic" data-slide="next">
									<i class="icon-caret-right transition"></i>
								</a>
							</li>
						</ul>					  
					</div>
    			</div>
    			<div class="span3">
	    			<h3><?php echo get_field('articles_title',get_queried_object_id());?></h3>
	    			<div class="accordion" id="accordion" style="clear:both;">
						<?php
							$args1 = array(
								'post_type' => 'post',
								'posts_per_page' => -1,
							);
							$the_query = new WP_Query($args1);
							$counter = 0;
							$collapser = array('collapseOne','collapseTwo','collapseThree', 'collapseFour');
							while ( $the_query->have_posts() && $counter<4):
								$the_query->the_post();								
                        ?>						
					  	<div class="accordion-group">
							<?php if($counter == 0)
									echo '<div id="'.$collapser[$counter].'" class="accordion-body collapse in">';
								  else
									echo '<div id="'.$collapser[$counter].'" class="accordion-body collapse">';
									?>
							<div class="accordion-inner">								
								<?php if(has_post_thumbnail()): ?>
                                        <?php
                                        $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'home1-blog');
                                        echo '<a href="'.get_permalink().'"><img src="'.$image[0].'"/></a>';
                                        ?>
                                    <?php endif; ?>
							</div>
						    </div>						
					    <div class="accordion-heading">
							<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#<?php echo $collapser[$counter];?>">
								<div class="border-container">
									<div class="comment-size-box">
										<p class="comment-number"> 
											<?php echo get_comments_number();?>
										</p></div>
									<div class="triangle-box">
										<div class="triangle triangle-border"></div>
										<div class="triangle triangle-body"></div>
									</div>
								</div>
								<p class="post-title smaller-title"><?php the_title();?></p>
								<p class="post-categoty smaller-category">
								<?php 
									$post_categories = wp_get_post_categories( $post->ID );								
										$categories = '';	
										foreach($post_categories as $c){
											$cat = get_category( $c );									
											$categories = $categories.' '.$cat->name;
										}
									echo 'Posted in '.$categories;
								 ?></p>
							</a>
					    </div>
					  	</div>	
						<?php 
						$counter++;
						endwhile ;?>						
					</div>						
	    		</div>
	    		<div class="span3">
	    			<h3><?php echo get_field('accordion_title',get_queried_object_id());?></h3>
	    			<div class="accordion fixed-accordion" id="accordion2" style="clear:both;">
					<?php $posts = get_field('accordions', get_queried_object_id());
						if($posts):?>		
							<?php 
							$counter = 0;							
							foreach($posts as $post): ?>
							<div class="accordion-group">
								<div class="accordion-heading acc-heading-color">
									<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapse<?php echo $counter;?>">										
								   <p class="post-title smaller-title"><?php echo $post['accordion_title'];?></p>
								  </a>
								</div>
								<?php if($counter == 0)
											echo '<div id="collapse'.$counter.'" class="accordion-body collapse in">';
										else
											echo '<div id="collapse'.$counter.'" class="accordion-body collapse">';
											?>
								  <div class="accordion-inner">
									<div class="acc-container">
										<p class="post-categoty acc-inner-text">										
											<?php echo $post['accordion_text'];?>
										</p>
									</div>
								  </div>
								</div>
							</div>
							<?php $counter++;
								endforeach; ?>
						</ul>
						<?php endif; ?>					
					</div>
	    		</div>				
    		</div>    
				<?php if(!get_field('disable_homebar',get_queried_object_id())):?>									 
				<div class="row-fluid">
						<div class="span12">				  
							 <?php if(is_active_sidebar('sidebar-3')):?>
									<?php  if ( !function_exists('dynamic_sidebar') ||  !dynamic_sidebar('sidebar-3') ) ?>
							 <?php endif;?>										
						</div>
				 </div>
				<?php endif;?>			
    	</div><!--container-->
    </div><!--.content-wrapper-->
	<div class ="theContent">
	    <?php wp_reset_postdata();?>
        <?php setup_postdata($post);?>
        <?php the_content();?>
        <?php wp_reset_postdata();?>
    </div>
<?php get_footer();?>