<?php get_header(); ?>
<?php if(get_option('tigu_homepage-news-ticker') == 'true' && get_option('tigu_newsticker_single_post') == 'true'): ?>
<div class="newstickers" style="height:36px;"><?php jnewsticker_display( get_option('tigu_ticker_choosed_id') ) ?></div>
<?php endif; ?>
<?php $featured_image = get_post_meta(get_the_ID(), 'tiguan_featured_image', true); ?>

<div id="main">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php if(get_option('tigu_categories') == 'true'): ?>
<div class="grids_box_sidebar" style="border-bottom:#d5d5d5 solid 1px !important"><div class="widget-title-2"><h3><?php the_category(', ') ?> &raquo;</h3><h1><?php the_title(); ?></h1></div></div>
<?php else: ?>
<div class="grids_box_sidebar" style="border-bottom:#d5d5d5 solid 1px !important"><div class="widget-title"><h1><?php the_title(); ?></h1></div></div>
<?php endif; ?>

<!-- ADS START -->
<div class="gamepage">

<!-- ************************************************************************************ -->

<?php if(get_option('tigu_featured-ads') == 'Advertisement and text content'): ?>

<?php if ($featured_image == 'No'): ?>
<?php else: ?>

<?php if(get_option('tigu_banner300x250_on') == 'true'): ?>
<!-- START 300x250 BANNER -->

<?php if(get_option('tigu_post_300x250_image')): ?>
   <div id="banner300x250" class="banner300x250" style="margin-bottom:5px;">
<a target="<?php echo (get_option('tigu_post_300x250_target')); ?>" href="<?php echo (get_option('tigu_post_300x250_url')); ?>" title="<?php echo (get_option('tigu_post_300x250_title')); ?>"><img src="<?php echo (get_option('tigu_post_300x250_image')); ?>" alt="<?php echo (get_option('tigu_post_300x250_alt')); ?>"></a>
</div>
<?php else: ?>
<div id="banner300x250" class="banner300x250" style="margin-bottom:5px;">
<?php echo stripslashes (get_option('tigu_banner300x250')); ?>
</div>
<?php endif; ?>

<!-- END 300x250 BANNER -->
<?php endif; ?>
<?php endif; ?>

<div class="post-entry">
<?php the_content(); ?>
</div>

<!-- ADS END -->
<?php endif; ?>

<!-- ************************************************************************************ -->

<?php if(get_option('tigu_featured-ads', 'Featured Image and text content') == 'Featured Image and text content'): ?>
<!-- START FEATURED IMAGE -->
  <script type="text/javascript">
    jQuery(document).ready(function($) {
     $('.post-entry a').has('img').addClass('prettyPhoto');
    });
  </script>  

<?php if ($featured_image == 'No'): ?>
 
<?php else: ?>

<?php if(has_post_thumbnail() ): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'post-image'); ?>
<?php if ( empty($image[0]) ) $image[0] = myarcade_featured_image(); ?>
<div class="game-image">
<a href="<?php echo $image[0]; ?>" rel="prettyPhoto">
<img src="<?php echo $image[0]; ?>" width="292" height="242" alt="<?php the_title(); ?>" />
</a></div>
<?php else: ?>
<div class="game-image">
<img src="<?php echo get_template_directory_uri(); ?>/images/thumbnail-post.png" width="292" height="242" alt="<?php the_title(); ?>" />
</div>
<?php endif; ?>
<?php endif; ?>

<div class="post-entry">
<?php the_content(); ?>
</div>

<!-- END FEATURED IMAGE -->
<?php endif; ?>

<!-- ************************************************************************************ -->

<?php if(get_option('tigu_featured-ads') == 'Random'): ?>
<!-- RANDOM START -->
<ul id="randomize">

<li>

<?php if ($featured_image == 'No'): ?>
<?php else: ?>

<?php if(has_post_thumbnail() ): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'post-image'); ?>
<?php if ( empty($image[0]) ) $image[0] = myarcade_featured_image(); ?>
<div class="game-image">
<a href="<?php echo $image[0]; ?>" rel="prettyPhoto">
<img src="<?php echo $image[0]; ?>" width="292" height="242" alt="<?php the_title(); ?>" />
</a></div>
<?php else: ?>
<div class="game-image">
<img src="<?php echo get_template_directory_uri(); ?>/images/thumbnail-post.png" width="292" height="242" alt="<?php the_title(); ?>" />
</div>
<?php endif; ?>
<?php endif; ?>
<div class="post-entry">
<?php the_content(); ?>
</div>

</li>
<li>

<?php if ($featured_image == 'No'): ?>
<?php else: ?>

<?php if(get_option('tigu_banner300x250_on') == 'true'): ?>
<!-- START 300x250 BANNER -->
<?php if(get_option('tigu_post_300x250_image')): ?>
<div id="banner300x250" class="banner300x250"  style="margin-bottom:5px">
<a target="<?php echo (get_option('tigu_post_300x250_target')); ?>" href="<?php echo (get_option('tigu_post_300x250_url')); ?>" title="<?php echo (get_option('tigu_post_300x250_title')); ?>"><img src="<?php echo (get_option('tigu_post_300x250_image')); ?>" alt="<?php echo (get_option('tigu_post_300x250_alt')); ?>"></a>
</div>
<?php else: ?>
<div id="banner300x250" class="banner300x250">
<?php echo stripslashes (get_option('tigu_banner300x250')); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<!-- END 300x250 BANNER -->
<?php endif; ?>

<div class="post-entry">
<?php the_content(); ?>
</div>

</li>

</ul>
<!-- RANDOM END -->
<?php endif; ?>

<!-- ************************************************************************************ -->

<?php if(get_option('tigu_post_navi_info') == 'true'): ?>
<!-- START POST INFO NAVIGATION -->
<?php get_template_part('navigation-wp'); ?>
<!-- END POST INFO NAVIGATION -->
<?php endif; ?>
</div>

<?php if(get_option('tigu_banner660x90_on') == 'true'): ?>
<!-- START 660x90 BANNER -->
<?php if(get_option('tigu_post_660x90_image')): ?>
<div id="banner660x90" class="banner660x90">
<a target="<?php echo (get_option('tigu_post_660x90_target')); ?>" href="<?php echo (get_option('tigu_post_660x90_url')); ?>" title="<?php echo (get_option('tigu_post_660x90_title')); ?>"><img src="<?php echo (get_option('tigu_post_660x90_image')); ?>" alt="<?php echo (get_option('tigu_post_660x90_alt')); ?>"></a>
</div>
<?php else: ?>
<div id="banner660x90" class="banner660x90">
<?php echo stripslashes (get_option('tigu_banner660x90')); ?>
</div>
<?php endif; ?>
<!-- END 660x90 BANNER -->
<?php endif; ?>

<?php if(get_option('tigu_postshare_box') == 'true'): ?>
<!-- START POST SHARE -->
<?php get_template_part('post-share'); ?>
<!-- END POST SHARE -->
<?php endif; ?>

<?php if(get_option('tigu_all_tabs') == 'true'): ?>

<!-- START POST TABS -->
<div class="toppad"></div>
<div class="tabs-wrapper">
 <ul class="tabs">

<?php if(get_option('tigu_about_author') == 'true'): ?>
<li>
<a href="#tab1"><?php _e('About Author', 'Gameleon'); ?></a>
</li>
<?php endif; ?>

<?php if(get_option('tigu_post_tags') == 'true'): ?>
<li class="">
<a href="#tab2"><?php _e('Tags', 'Gameleon'); ?></a>
</li>
<?php endif; ?>

<?php if(get_option('tigu_related') == 'true'): ?>
<li class="">
<a href="#tab3">
<?php if(get_option('tigu_related_title') == 'Related [Category Title] Articles'): ?>
<?php _e('Related', 'Gameleon'); ?> <?php $category = get_the_category($post->ID); echo $category[0]->cat_name; ?> <?php _e('Articles', 'Gameleon'); ?>
<?php else: ?>
<?php _e('Related Articles', 'Gameleon'); ?>
<?php endif; ?>
</a>
</li>
<?php endif; ?>

<?php if(get_option('tigu_custom_tab') == 'true'): ?>
<li class=""> 
<a href="#tab4"><?php echo get_option('tigu_custom_tab_title', 'Custom Tab'); ?></a>
</li>
<?php endif; ?>

</ul>

<?php if(get_option('tigu_about_author', 'false') == 'true'): ?>
<div id="tab1" class="tab_content" style="display:block;">
<div class="author-box-div">
<div class="authorbox-avatar">

<a href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>"><?php echo get_avatar( get_the_author_meta('user_email'), '100', '' ); ?></a>

<?php if (get_the_author_url()): ?>
<a class="name_authorbox" href="<?php the_author_meta('user_url'); ?>">
<?php endif; ?> 
<span class="name_authorbox">
<?php if(get_the_author_meta('first_name')|| get_the_author_meta('last_name')) : ?>
<?php the_author_meta('first_name') ; ?> <?php the_author_meta('last_name'); ?> - <?php the_author(); ?>
<?php else: ?>
<?php the_author(); ?>
<?php endif; ?> 
</span>
<?php if (get_the_author_url()): ?>
</a>
<?php endif; ?> 

<span><?php the_author_meta("description"); ?></span>
<div style="font-weight:bold"><span class="name_authorbox">

<?php if(get_the_author_meta('first_name')) : ?><?php the_author_meta('first_name'); ?><?php else: ?><?php the_author(); ?><?php endif; ?></span> <?php _e('has written', 'Gameleon'); ?> <span class="count_authorbox"><?php the_author_posts(); ?></span> <?php _e('awesome articles', 'Gameleon'); ?>.

</div>
 
<div class="author-box_socials">
<?php if(get_the_author_meta('twitter') || get_the_author_meta('facebook') || get_the_author_meta('dribbble') || get_the_author_meta('yim') || get_the_author_meta('google') || get_the_author_meta('google') || get_the_author_meta('youtube')): ?>

<?php if(get_the_author_meta('twitter')): ?>
<a target="new" href="<?php echo get_the_author_meta('twitter'); ?>">
<img src="<?php echo get_template_directory_uri(); ?>/images/profile/twitter.png" alt="Twitter" />
</a>
<?php endif; ?>

<?php if(get_the_author_meta('facebook')): ?>
<a target="new" href="<?php echo get_the_author_meta('facebook'); ?>">
<img src="<?php echo get_template_directory_uri(); ?>/images/profile/facebook.png" alt="Facebook" />
</a>
<?php endif; ?>

<?php if(get_the_author_meta('dribbble')): ?>
<a target="new" href="<?php echo get_the_author_meta('dribbble'); ?>">
<img src="<?php echo get_template_directory_uri(); ?>/images/profile/dribbble.png" alt="Dribbble" />
</a>
<?php endif; ?>

<?php if(get_the_author_meta('yim')): ?>
<a href="ymsgr:sendIM?<?php echo get_the_author_meta('yim'); ?>">
<img src="<?php echo get_template_directory_uri(); ?>/images/profile/yahoo.png" alt="Yahoo YIM" />
</a>
<?php endif; ?>

<?php if(get_the_author_meta('google')): ?>
<a target="new" href="<?php echo get_the_author_meta('google'); ?>">
<img src="<?php echo get_template_directory_uri(); ?>/images/profile/google.png" alt="Google" />
</a>
<?php endif; ?>

<?php if(get_the_author_meta('youtube')): ?>
<a target="new" href="<?php echo get_the_author_meta('youtube'); ?>">
<img src="<?php echo get_template_directory_uri(); ?>/images/profile/youtube.png" alt="Youtube" />
</a>
<?php endif; ?>

<a href="<?php echo get_author_posts_url($authordata->ID, $authordata->user_nicename); ?>feed/" >
<img src="<?php echo get_template_directory_uri(); ?>/images/profile/rss.png" alt="RDD FEED" />
</a>
 
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>

<?php if(get_option('tigu_post_tags') == 'true'): ?>

<?php if(get_option('tigu_about_author') == 'false'): ?>
<div id="tab2" class="tab_content" style="display:block;">
<?php else: ?>
<div id="tab2" class="tab_content" style="display:none;">
<?php endif; ?>
<div class="gamepage" style="padding-bottom:12px !important; padding-left:13px !important">
<p class='tag_cloud'><?php the_tags(' ',' '); ?></p>
</div>
</div>
<?php endif; ?>

<!-- START DISPLAY RELATED POSTS BY TAGS -->
<?php if (get_option('tigu_related_display_by', 'Related Posts by Tags') == 'Related Posts by Tags'): ?>
<?php $related = get_related_posts($post->ID); ?>

<?php if($related->have_posts() && $related->found_posts >= 3 && get_option('tigu_related') == 'true'): ?>


<?php if(get_option('tigu_about_author') == 'false' && get_option('tigu_post_tags') == 'true'): ?> 
<div id="tab3" class="tab_content" style="display:none;">
<?php endif; ?>

<?php if(get_option('tigu_about_author') == 'true' && get_option('tigu_post_tags') == 'false'): ?> 
<div id="tab3" class="tab_content" style="display:none;">
<?php endif; ?>

<?php if(get_option('tigu_about_author') == 'false' && get_option('tigu_post_tags') == 'false'): ?> 
<div id="tab3" class="tab_content" style="display:block;">
<?php endif; ?>
 
<?php if(get_option('tigu_about_author') == 'true' && get_option('tigu_post_tags') == 'true'): ?> 
<div id="tab3" class="tab_content" style="display:none;">
<?php endif; ?>


<div class="gamepage">

<?php while($related->have_posts()): $related->the_post(); ?>
<?php if(has_post_thumbnail() || is_myarcade_game() ): ?>
<?php
if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
$icon = '<span class="' . get_post_format($post->ID) . '-icon"></span>';
} else {
$icon = '';
}
?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'related-thumb'); ?>
<?php if ( empty($image[0]) ) $image[0] = myarcade_get_thumbnail_url(); ?>
<div class="related-posts block" >
<?php echo $icon; ?>
<a class=<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>"hover_play_small-wp tooltip"<?php else: ?>"hover_play_small tooltip"<?php endif; ?> href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<img src="<?php echo $image[0]; ?>" width="74" height="60" alt="<?php the_title(); ?>" />
</a>
</div>
<?php else: ?>
<div class="related-posts block">
<a class="hover_play_small" href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<img src="<?php echo get_template_directory_uri(); ?>/images/thumbnail-76.png" width="74" height="60" alt="<?php the_title(); ?>" />
</a>
</div>
<?php endif; ?>
<?php endwhile; ?>
</div>
</div>
<?php endif; ?>

<!-- END DISPLAY RELATED POSTS BY TAGS -->

<?php else: ?>

<!-- START DISPLAY RELATED POSTS BY CATEGORY -->

<?php if(get_option('tigu_related') == 'true'): ?>
<?php if(get_option('tigu_about_author') == 'false' && get_option('tigu_post_tags') == 'true'): ?> 
<div id="tab3" class="tab_content" style="display:none;">
<?php endif; ?>

<?php if(get_option('tigu_about_author') == 'true' && get_option('tigu_post_tags') == 'false'): ?> 
<div id="tab3" class="tab_content" style="display:none;">
<?php endif; ?>

<?php if(get_option('tigu_about_author') == 'false' && get_option('tigu_post_tags') == 'false'): ?> 
<div id="tab3" class="tab_content" style="display:block;">
<?php endif; ?>
 
<?php if(get_option('tigu_about_author') == 'true' && get_option('tigu_post_tags') == 'true'): ?> 
<div id="tab3" class="tab_content" style="display:none;">
<?php endif; ?>

<div class="gamepage">


<?php
$categories = get_the_category($post->ID);
if ($categories) {
$category_ids = array();
foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
$args=array(
        'category__in' => $category_ids,
        'post__not_in' => array($post->ID),
 
    //  'post__not_in' => array( get_the_ID() ),
 
        'showposts'=>7,
        'caller_get_posts'=>1
    );
    $my_query = new wp_query($args);
    if( $my_query->have_posts() ) {
         
      
        while ($my_query->have_posts()) {
            $my_query->the_post();
        ?>


<?php if(has_post_thumbnail() || is_myarcade_game() ): ?>
<?php
if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
$icon = '<span class="' . get_post_format($post->ID) . '-icon"></span>';
} else {
$icon = '';
}
?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'related-thumb'); ?>
<?php if ( empty($image[0]) ) $image[0] = myarcade_get_thumbnail_url(); ?>
<div class="related-posts block" >
<?php echo $icon; ?>
<a class=<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>"hover_play_small-wp tooltip"<?php else: ?>"hover_play_small tooltip"<?php endif; ?> href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<img src="<?php echo $image[0]; ?>" width="74" height="60" alt="<?php the_title(); ?>" />
</a>
</div>
<?php else: ?>
<div class="related-posts block">
<a class="hover_play_small" href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<img src="<?php echo get_template_directory_uri(); ?>/images/thumbnail-76.png" width="74" height="60" alt="<?php the_title(); ?>" />

</a>
</div>
<?php endif; ?>
<?php
        }
         
    }
}
?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>

<!-- END DISPLAY RELATED POSTS BY CATEGORY -->

<?php if(get_option('tigu_custom_tab') == 'true'): ?>
<div id="tab4" class="tab_content" style="display:none;">
<div class="instructions">
<?php echo do_shortcode( stripslashes( get_option( 'tigu_custom_tab_code' ) ) ); ?>
</div>
</div>
<?php endif; ?>
</div>

<!-- END POST TABS -->
<?php endif; ?>

<?php if(get_option('tigu_banner468x60_on') == 'true'): ?>
<!-- START 468X60 BANNER -->
<?php if(get_option('tigu_post_468x60_image')): ?>
<div id="banner468x60" class="banner468x60">
<a target="<?php echo (get_option('tigu_post_468x60_target')); ?>" href="<?php echo (get_option('tigu_post_468x60_url')); ?>" title="<?php echo (get_option('tigu_post_468x60_title')); ?>"><img src="<?php echo (get_option('tigu_post_468x60_image')); ?>" alt="<?php echo (get_option('tigu_post_468x60_alt')); ?>"></a>
</div><div class="toppad"></div>
<?php else: ?>
<div id="banner468x60" class="banner468x60">
<?php echo stripslashes (get_option('tigu_banner468x60')); ?>
</div><div class="toppad"></div>
<?php endif; ?>
<!-- END 468X60 BANNER -->
<?php endif; ?>

<div class='clear'></div>

<?php wp_reset_query(); ?>

<!-- START COMMENTS AREA -->

<?php if( get_option('tigu_comments_type', 'WordPress') == 'WordPress') : ?>
<div class="grids_box_sidebar" style="border-bottom:#d5d5d5 solid 1px !important">
<div class="widget-title">

<h3><?php _e('Comments', 'Gameleon'); ?>:</h3>

</div>
</div>
<div id="comments">
<div class="gamepage">
<div class="gamepagewhite">
<?php comments_template(); ?>

</div>
</div>
</div>

<?php elseif( get_option('tigu_comments_type', 'WordPress') == 'Facebook') : ?>
<div class="grids_box_sidebar" style="border-bottom:#d5d5d5 solid 1px !important">
<div class="widget-title">

<h3><?php _e('Facebook Comments', 'Gameleon'); ?>:</h3>

</div>
</div>
<div id="comments">
<div class="gamepage">
<div class="gamepagewhite">
<?php $url = (!empty($_SERVER['HTTPS'])) ? "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] : "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; ?>	
<div class="fb-comments" data-href="<?php echo $url; ?>" data-num-posts="10" data-width="630"></div>

</div>
</div>
</div>


<?php elseif( get_option('tigu_comments_type', 'None') == 'None') : ?>

<?php else: ?>

<?php comments_template(); ?>

<?php endif; ?>


<?php if(get_option('tigu_pagination') == 'true'): ?>
<div class="hide-pagination-code">
<?php paginate_links();
$args="";
wp_link_pages( $args );
?>
</div>
<?php endif; ?>

<!-- END COMMENTS AREA -->

<br class="clear">
<?php endwhile; endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>