<div class="toppad"></div>
<div class="tabs-wrapper">
<ul class="tabs" style="width: 982px;">

<?php if(get_option('tigu_howtoplay') == 'true'): ?>
<li>
<a href="#tab1"><?php _e('How to play', '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_games') == 'Related [Category Title] Games'): ?>
<?php _e('Related', 'Gameleon'); ?> <?php $category = get_the_category($post->ID); echo $category[0]->cat_name; ?> <?php _e('Games', 'Gameleon'); ?>
<?php else: ?>
<?php _e('Related Games', 'Gameleon'); ?>
<?php endif; ?>
</a>
</li>
<?php endif; ?>
<?php if( is_myarcade_game() ): ?>
<?php if(get_option('tigu_embed_tab') == 'true'): ?>
<li class=""> 
<a href="#tab4"><?php _e('Embed', 'Gameleon'); ?></a>
</li>
<?php endif; ?>
<?php endif; ?>

<?php if ( (get_option('tigu_dispay_screenshots') == 'true') && myarcade_count_screenshots() ): ?>
<li class=""> 
<a href="#tab5"><?php _e('Game Screenshots', 'Gameleon'); ?></a>
</li>
<?php endif; ?>

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

</ul>

<?php if(get_option('tigu_howtoplay') == 'true'): ?>
<div id="tab1" class="tab_content" style="display:block;">
<div class="instructions post-entry">
<?php echo do_shortcode($instructions); ?>
</div>
</div>
<?php endif; ?>

<?php if(get_option('tigu_post_tags') == 'true'): ?>
<?php if(get_option('tigu_howtoplay') == '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 GAMES BY TAGS -->
<?php if (get_option('tigu_related_display_by', 'Related Games by Tags') == 'Related Games by Tags'): ?>

<?php $related = get_related_games($post->ID); ?>

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

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

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

<?php if(get_option('tigu_howtoplay') == 'false' && get_option('tigu_post_tags') == 'false'): ?> 
<div id="tab3" class="tab_content" style="display:block;">
<?php endif; ?>
 
<?php if(get_option('tigu_howtoplay') == '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-games block">
<?php echo $icon; ?>
<a class="hover_play_small tooltip" href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<img src="<?php echo $image[0]; ?>" width="81" height="60" alt="<?php the_title(); ?>" />
</a>
</div>
<?php else: ?>
<div class="related-games 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="81" height="60" alt="<?php the_title(); ?>" />
</a>
</div>
<?php endif; ?>
<?php endwhile; ?>
</div>
</div>
<?php endif; ?>

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

<?php else: ?>

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

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

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

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

<?php if(get_option('tigu_howtoplay') == 'false' && get_option('tigu_post_tags') == 'false'): ?> 
<div id="tab3" class="tab_content" style="display:block;">
<?php endif; ?>
 
<?php if(get_option('tigu_howtoplay') == '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'=>10,
        '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-games block">
 
<a class="hover_play_small tooltip" href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<img src="<?php echo $image[0]; ?>" width="81" height="60" alt="<?php the_title(); ?>" />
</a>
</div>
<?php else: ?>
<div class="related-games 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="81" height="60" alt="<?php the_title(); ?>" />
</a>
</div>
<?php endif; ?>
<?php
        }
         
    }
}
?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>

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

<?php if (function_exists('get_game')): ?>
<?php if(get_option('tigu_embed_tab') == 'true'): ?>
<div id="tab4" class="tab_content" style="display:none;">
<div class="instructions">

<form name="select_all" class="formembed">
<textarea class="formembedtext" name="text_area" onClick="javascript:this.form.text_area.focus();this.form.text_area.select();">
<?php if (function_exists('get_game')): ?><?php echo get_game($mypostid); ?>
<?php else: ?>
<?php echo get_game($post->ID); ?>
<?php endif; ?>
<?php if(get_option('tigu_embed_text')): ?>
<?php _e('Please support us and keep these credits&sources untouched! :) Thanks!', 'Gameleon'); ?>
<div style="padding:15px; background:#f2f2f2; border:1px solid #dcdcdc; width:auto; margin:0 auto;">
<?php echo do_shortcode( stripslashes( get_option( 'tigu_embed_text' ) ) ); ?>
</div>
<?php endif; ?>
</textarea>
</form>
</div>
</div>
<?php endif; ?>
<?php endif; ?>

<?php if ( (get_option('tigu_dispay_screenshots') == 'true') && myarcade_count_screenshots() ): ?>
<div id="tab5" class="tab_content" style="display:none;">
<div class="gamepage">
<div class="block">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
 <?php myarcade_all_screenshots(81, 60, 'gamescreenshots'); ?>
<?php endwhile; endif; ?>
</div>
</div>
</div>
<?php else: ?>
<div id="tab5" class="tab_content" style="display:none;">
<div class="gamepage">
<div class="block">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
 <?php myarcade_all_screenshots(81, 60, 'gamescreenshots'); ?>
<?php endwhile; endif; ?>
</div>
</div>
</div>
<?php endif; ?>

<?php if(get_option('tigu_custom_tab') == 'true'): ?>
<div id="tab6" 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>
