

<?php get_header(); ?>

<?php
$cat_id = get_query_var('cat');
$cat_data = get_option("category_$cat_id");
?>	

<div id="main_content"> 
<div class="inner">


<?php if($cat_data['extra1'] == ''){} else { ?>
<?php wp_enqueue_script('stellar', BASE_URL . 'js/jquery.stellar.js', false, '', true); ?>
<div class="photo" style="background-image: url(<?php if (isset($cat_data['extra1'])){ echo $cat_data['extra1'];} ?>);" data-stellar-background-ratio="0.5">
<div class="photo_bg_shadow">
<div class="photo_bg">
<h1><?php single_cat_title(''); ?></h1>
<?php echo category_description( ); ?>
</div>
</div>
</div>
<?php } ?>


<?php if($cat_data['extra2'] == '_small_sidebar_left'){ ?>
<div class="index_small_left">
<?php get_sidebar('small'); ?>
</div>
<?php } ?>	

<div id="content" class="<?php if (isset($cat_data['extra2'])){ echo $cat_data['extra2'];} ?>">	

<?php if (get_option('op_crumbs') == 'on') { ?>
<div id="content_bread_panel">	
<?php if (function_exists('wp_breadcrumbs')) wp_breadcrumbs(); ?>
</div>
<div class="clear"></div>
<?php } ?>

 
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>	
 
  	<?php 
		$format = get_post_format(); if ( false === $format ) { 
		$post_format_image = '<div class="post_format"></div>'; 
		}
					
		if(has_post_format('video')) { 
		$post_format_image = '<div class="post_format_video"></div>';
		}
					
		if(has_post_format('image')) {
		$post_format_image = '<div class="post_format_image"></div>';
		}
		
		if(has_post_format('audio')) {
		$post_format_image = '<div class="post_format_audio"></div>';
		}
	?> 
 
	<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">	

		<?php if(has_post_thumbnail()) { ?>
		<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'post-thumbnails', false, '' ); $thumbnailSrc = $src[0]; ?>		
		
		<div class="post_img_box">
        <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
		<?php $image = aq_resize( $thumbnailSrc, 830, 'auto', false); ?>
        <img src="<?php echo $image ?>" alt="<?php the_title(); ?>" title="<?php the_title(); ?>"/>
		</a>
		</div>	
		
		<?php if (get_option('op_blog_meta_line') == 'on') { ?>
		<div class="category_time">
        <?php the_time('j M'); ?>
		<div class="clear"></div>
		<?php the_time('Y'); ?>
		</div>
		
		<div class="cat_author"><?php echo get_option('op_author'); ?> <?php the_author_link(); ?></div> 
		<?php } ?>
        <?php } else {} ?>


		
		<h1><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" ><?php the_title(); ?> &raquo;</a></h1>

	    <?php if (get_option('op_blog_meta_line') == 'on') { ?>
	    <div class="cat_meta">
		     
			<div class="post_cats"><?php
					$categories_string = '';
					foreach((get_the_category()) as $category) {
                    $category_term = $category->category_nicename . '';
					$categories_string .= '<a class="custom_cat_class '. $category_term .'" href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "%s", 'my-text-domain' ), $category->name ) ) . '">'.$category->cat_name.'</a>';
	                } 
					$categories_string = trim($categories_string);
					echo $categories_string;
					?>
			</div> 
			<div class="post_views"><?php echo getPostViews(get_the_ID()); ?></div>
		   
		</div> 
        <?php } ?>
		
		<?php $post_text = get_post_meta($post->ID, 'r_post_text', true); ?>
	    <?php if($post_text !== '') { ?>
	    <p>
	    <?php echo $post_text; ?>
        </p> 

		<a class="read_more" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" ><?php echo get_option('op_read_more'); ?></a>
	    <?php } else { ?>
		<?php the_excerpt(); ?>
        <?php } ?>

	</div>
			
		<?php endwhile; ?>
		<?php else : ?>
		
		<div class="post_nr">
        <h2><?php echo get_option('op_nothing_found'); ?></h2>
        <div class="single-entry">
		<?php echo get_option('op_nothing_found_text'); ?>
		<div class="clear"></div>
		<?php get_search_form(); ?>
		<div class="clear"></div>
		</div>
		<?php get_template_part('includes/archive_layout'); ?>
        </div>

	    <?php endif; ?>	 
		

		
<div class="clear"></div>


        <?php if(function_exists('wp_pagenavi')) { ?>
		<div class="postnav"> 
		<?php wp_pagenavi(); ?>
        </div>
		
        <?php } else { ?>
        <?php custom_pagination(); ?>
        <?php } ?>
 
	    <div class="clear"></div>

</div>

<?php if($cat_data['extra2'] == '_2_sidebar'){ ?>
<div class="index_2_sidebar">
<?php get_sidebar('small'); ?>
</div>
<?php } ?>	

<?php get_sidebar('right'); ?>	
	
</div>
</div>


<div class="clear"></div>
	
<?php get_footer(); ?>

	