<?php get_header(); ?>
<?php if(get_option('tigu_homepage-news-ticker') == 'true' && get_option('tigu_newsticker_search_page') == 'true'): ?>
<div class="newstickers" style="height:36px;"><?php jnewsticker_display( get_option('tigu_ticker_choosed_id') ) ?></div>
<?php endif; ?>
<!-- BEGIN SEARCH -->
    <div id="main">
    <div class="grids_box_sidebar"><div class="widget-title"><h1><?php _e('Search results for', 'Gameleon'); ?> "<?php echo get_search_query(); ?>"</h1></div></div>
    <div class="block archive">
    <div class="block-rich">
<?php   

if( get_option('tigu_search_post_order', 'Date') == 'Date')  {

query_posts($query_string . '&paged='.$paged .'&orderby=date&order='.get_option('tigu_search_post_ascdesc').'&posts_per_page='.get_option('tigu_search_post_number') . '&paged='.$paged); 

} elseif ( get_option('tigu_search_post_order', 'Name') == 'Name')  {

query_posts($query_string . '&paged='.$paged .'&orderby=title&order='.get_option('tigu_search_post_ascdesc').'&posts_per_page='.get_option('tigu_search_post_number') . '&paged='.$paged); 

} elseif ( get_option('tigu_search_post_order', 'Number of Views') == 'Number of Views')  {

query_posts($query_string . '&paged='.$paged .'meta_key=post_views_count&orderby=meta_value_num&order='.get_option('tigu_search_post_ascdesc').'&posts_per_page='.get_option('tigu_search_post_number') . '&paged='.$paged); 

} elseif ( get_option('tigu_search_post_order', 'Popularity') == 'Popularity')  {

query_posts($query_string . '&paged='.$paged .'&orderby=comment_count&order='.get_option('tigu_search_post_ascdesc').'&posts_per_page='.get_option('tigu_search_post_number') . '&paged='.$paged); 

} elseif ( get_option('tigu_search_post_order', 'Random') == 'Random')  {

query_posts($query_string . '&paged='.$paged .'&orderby=rand&posts_per_page='.get_option('tigu_searchs_post_number') . '&paged='.$paged); 

} else { 

query_posts($query_string . '&paged='.$paged .'&orderby=date&order='.get_option('tigu_search_post_ascdesc').'&posts_per_page='.get_option('tigu_search_post_number') . '&paged='.$paged); 

}	

?>

<?php if ( have_posts() ) : ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div id="post-<?php the_ID(); ?>" <?php post_class('high-grid'); ?>>
<?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 if(has_post_thumbnail() || is_myarcade_game() ): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'blog-style-image'); ?>
<?php if ( empty($image[0]) ) $image[0] = myarcade_featured_image(); ?>
<div class="grid-image"><a class=<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>"hover_play_small-wp"<?php else: ?>"hover_play_small"<?php endif; ?> href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<img src="<?php echo $image[0]; ?>" width="174" height="100" alt="<?php the_title(); ?>" />
</a><?php echo $icon; ?></div>
<?php else: ?>
<div class="grid-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<img src="<?php echo get_template_directory_uri(); ?>/images/thumbnail.png" width="174" height="100" alt="<?php the_title(); ?>" />
</a><?php echo $icon; ?></div>
<?php endif; ?>

  <h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?></a></h2>
<div class="somepadd block-metas">
<?php if(get_option('tigu_postdatetime_search', 'true') == 'true'): ?>
<span class="postdatetime-wp">
<?php the_time('Y-m-d') ?>
</span>
<?php endif; ?>

<?php if(get_option('tigu_mostplayed_search', 'true') == 'true'): ?>
<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>
<span class="postviews-wp" title="<?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?></span>
<?php else: ?>
<span class="clubs" title="<?php _e('Played', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php echo getMostPlayed(get_the_ID()); ?> <?php _e('plays', 'Gameleon'); ?></span>
<?php endif; ?>
<?php endif; ?>

<?php if(get_option('tigu_likes_search', 'true') == 'true'): ?>
<span class="minilikes">
<?php _e('Likes', 'Gameleon'); ?>: <?php echo $wp_superlike->show_likes($post->ID);?>
</span>
<?php endif; ?>

<?php if(get_option('tigu_comments_search', 'false') == 'true'): ?>
<?php $comment_count = get_comment_count($post->ID); ?>
<?php if ($comment_count['approved'] > 0) : ?>
<span class="heading-comments-exist">
<?php if( get_option('tigu_comments_type', 'WordPress') == 'WordPress') : ?>
<?php comments_popup_link('0','1','%'); ?>
<?php else: ?>
<fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count>
<?php endif; ?>
</span>
<?php else: ?>
<span class="heading-comments">
<?php if( get_option('tigu_comments_type', 'WordPress') == 'WordPress') : ?>
<?php comments_popup_link('0','1','%'); ?>
<?php else: ?>
<fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count>
<?php endif; ?>
</span>
<?php endif; ?>
<?php endif; ?>

</div>

    <p><?php echo get_excerpt(get_option('tigu_search_post_excerpt', '200')); ?></p>  </div>

<?php endwhile; endif; ?><?php else : ?>
<div class="block">
<p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'Gameleon'); ?></p>
<br class="clear">
</div>

<?php endif; ?>
    </div>
<?php kriesi_pagination($pages = '', $range = 2); ?>
    </div>
    </div>
<!-- END SEARCH -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>