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

<script type="text/javascript">
jQuery(document).ready(function() {	

	var $container = $('.features-videos');
      var $isoID = $('#filters .active').attr('data-filter');

	  $container.isotope({
		itemSelector: '.gg',
		animationEngine: 'jquery',
		animationOptions: {
		duration: 350,
		easing: 'linear',
		queue: true
		}
	  });
	  $container.isotope({ filter: $isoID });

	jQuery('#filters li a').click(function() {
		$('#filters li a').removeClass('active');
		$(this).addClass('active');
		$isoID = $(this).attr('data-filter');
		$container.isotope({ filter: $isoID });
		return false;
	});
});	
</script>

<div id="main">
  <div id="fullContent">
    <div class="filter-wrap"> 
      
      <!-- BEGIN FILTERS -->
      <ul id="filters" class="mainBorder">
        
        <!-- BEGIN FILTER -->
        <li id="filter-title">
          <?php if ( $filter = get_option('of_filter') ) { ?>
          <?php echo stripslashes ( $filter ) ; ?>
          <?php } ?>
          
          <!-- END FILTER --> 
        </li>
        
        <!-- LI -->
        <li id="all"><a class="active" href="#" data-filter="*"><?php _e('All Videos','lioit') ?></a></li>
        <?php 
			$terms = get_terms("videos_sorting");
			$count = count($terms);
			if ( $count > 0 ){
			$sPattern = '/\s*/m';
			$sReplace = '';
			foreach ( $terms as $term ) {
			$isoTax = preg_replace( $sPattern, $sReplace, $term->name);
			echo '<li><a href="#" data-filter=".' . $isoTax . '">' . $term->name . '</a></li>';
				}
			} 
			?>
        
        <!-- END FILTERS -->
      </ul>
    </div>
    <div class="row features-videos mainBorder" id="latest-features">
      <?php query_posts( 'post_type=videos&posts_per_page=-1&paged='.$paged); ?>
      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      <?php $terms_l = get_the_terms ($post->id, 'videos_sorting'); ?>
      <?php $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'features-thumb'); ?>
      <?php $video = get_post_meta($post->ID, 'siiimple_static_video', TRUE); ?>
      <div class="three columns gg <?php unset($term_links);
					$sPattern = '/\s*/m';
					$sReplace = '';
					foreach ($terms_l as $term) {
					$term_links[] = preg_replace( $sPattern, $sReplace, $term->name); }
					$on_draught = join(" ", $term_links);
					echo $on_draught; 
					?>">
        <div class="smallVideoitem">
        <div class="listVideoContent">
            <h3 class="videoTitle"><a href="<?php the_permalink(); ?>">
              <?php the_title(); ?>
              </a></h3>
          </div>
          <!--End Video Content--> 
          <?php
					$video_type = get_post_meta($post->ID, 'lioit_video_type', true);
					$video_id = get_post_meta($post->ID, 'lioit_video_id', true);
					$video_thumb = get_post_meta($post->ID, 'lioit_video_thumb', true);
					$featured_image = get_post_meta($post->ID, 'featured_image', true);
					$video = get_post_meta($post->ID, 'video', true);
					?>
          <?php if($video_thumb == 'video') { ?>
          <?php if($video_type == 'Youtube') { ?>
          <iframe width="294" height="180" src="http://www.youtube.com/embed/<?php echo $video_id; ?>?rel=0" frameborder="0" allowfullscreen></iframe>
          <?php } elseif($video_type == 'Vimeo') { ?>
          <iframe src="http://player.vimeo.com/video/<?php echo $video_id; ?>?title=0&amp;byline=0&amp;portrait=0&amp;color=ba0d16" width="294" height="180" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
          <?php } elseif($video_type == 'Dialymotion') { ?>
          <iframe frameborder="0" width="294" height="180" src="http://www.dailymotion.com/embed/video/<?php echo $video_id ?>?logo=0"></iframe>
          <?php } ?>
          <?php } elseif($video_thumb == 'featured_image') { ?>
          <div class="homeVThumb ThumbCover">
          <div class="cover" style="top: 100%;">
                                            <a class="postype" href="<?php the_permalink(); ?>"></a>
                                            <a class="detail" href="<?php the_permalink(); ?>" title="View detail"></a>										
                                        </div>
            <?php $img = catch_that_image($post->ID); ?>
            <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"> <img src="<?php echo Lioit_URI; ?>/scripts/timthumb.php?src=<?php echo $img ?>&amp;w=294&amp;h=180&amp;zc=1" alt="<?php the_title(); ?>" /> </a> </div>
          <!--End HomeVideo Thumb-->
          <?php } ?>
          
        </div>
        <!--End Small Video item-->
        
       </div>
      <!-- END THREE -->
      
      <?php endwhile; ?>
      <?php endif; ?>
      <br style="clear:both">
    </div>
    <!-- END ISOTOPE --> 
  </div>
  <!--End Main Content--> 
  
</div>
<!--End Main-->
<?php require Lioit_TM . '/lio.php';?>
</div>
<!--End Content-->
<?php get_footer();?>
