<?php get_header(); ?>

<div id="content_game">
  <?php // Include Breadcrumb ?>
  <?php include (TEMPLATEPATH . '/breadcrumb.php'); ?>
  
  <?php // Include the login box ?>
  <?php include (TEMPLATEPATH . '/loginform.php'); ?>  
  
  <?php // Show content banner if configured ?>
  <?php $banner = get_option('fungames_adtop'); ?>
  <?php if ($banner) : ?>
    <div class="adtop">
      <?php echo stripslashes($banner); ?>
    </div>
    <?php if ( get_option('fungames_150_space') == 'enable' ) : ?>
      <div style="margin-bottom: 130px;"> </div>
    <?php endif; ?>
  <?php endif; ?>  
    
  <center>
    <?php if ( get_option('fungames_progressbarstatus') == 'enable' ) : ?>
      <?php $gamesize='0px'; ?>
      <?php include (TEMPLATEPATH . '/inc/myabp_progressbar.php'); ?>
          
      <div id="showprogressbar" style="display:block; margin: 15px 0px;"> 
        <?php
        $banner2 = stripslashes(get_option('fungames_loadinggameadcode'));
        if ($banner2) : ?>
          <div id="loadinggame_ad" style="margin: 15px auto;">
            <?php echo $banner2; ?>
          </div>                  
        <?php endif; ?>
              
        <div id="progressbar" style="width:400px; background-color: <?php echo get_option('fungames_progressbarbackgroundcolor'); ?>; border: solid 1px <?php echo get_option('fungames_progressbarbordercolor'); ?>;"> 
          <span id="progresstext" style="color: <?php echo get_option('fungames_progressbartextcolor'); ?>">0%</span> 
          <div id="progressbarloadbg" style="background-color: <?php echo get_option('fungames_progressbarloadcolor'); ?>; border-right: solid 1px <?php echo get_option('fungames_progressbarbordercolor'); ?>; z-index: 2;">&thinsp;</div>
        </div>
      </div>
            
      <div id="progressbarloadtext" style="display:none; text-align: center; margin: 20px auto;"  onclick="window.hide();"> 
        <?php echo get_option('fungames_progressbartextload'); ?>
      </div>
    
    <?php else : ?>
      <?php $gamesize='100%'; ?>  
    <?php endif; ?>		
          
    <div class="clear"></div>  

    <div id="my_game" style="overflow:hidden; height: <?php echo $gamesize; ?>; width: <?php echo $gamesize; ?>;">
  		<div class="cont1">
        <div class="cont2">
          <div class="cont3">
            <div id="escenario">
              <div id="play_game">
                <?php 
                if (function_exists('get_game')) { ?>
                  <div id= "bordeswf">
                    <?php 
                    $embedcode = get_game($post->ID);
                    global $mypostid; $mypostid = $post->ID;
                    echo myarcade_get_leaderboard_code();        
                    echo $embedcode; 
                    ?> 
                  </div> 
                <?php } ?>
              </div><?php // end play_game ?> 
            </div>
          </div>
        </div>
      </div>
  
  		<div id="game_buttons">
        <a href="<?php bloginfo('url'); ?>/?gid=<?php echo $post->ID;?>&play=fullscreen" class="fullscreen" title="<?php _e('Fullscreen', 'fungames'); ?>"><img src="<?php bloginfo('template_directory'); ?>/images/blank.png" border="0" alt="<?php _e('Fullscreen', 'fungames'); ?>" /></a>
        <div class="command">
          <a href="#" title="<?php _e('Turn lights off / on', 'fungames'); ?>" class="interruptor"><img src="<?php bloginfo('template_directory'); ?>/images/blank.png" border="0" alt="<?php _e('Lights Toggle', 'fungames'); ?>" /></a>
        </div>
        <?php if (function_exists('fungames_favorite')) { fungames_favorite(); } ?>
      </div>            
    </div>
  </center>
    
  <div id="content" class="content<?php echo get_option('fungames_sidebar_position'); ?>">
    <?php if (have_posts()) : ?>
      <?php while (have_posts()) : the_post(); ?>
        <div class="single_game" id="post-<?php the_ID(); ?>">
          <div class="title">
            <h2>
              <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
            </h2>
            
            <div align="right" style="padding-right:10px;">
              <?php if(function_exists('the_ratings')) { the_ratings(); } ?>
            </div>        
          </div> <?php // end title ?>
    
          <div class="cover">
            <div class="entry">
              <?php // Check if this is a game post ?>
              <?php // Show content banner if configured ?>
              <?php $banner = get_option('fungames_adcontent'); ?>
              <?php if ($banner) : ?>
                <div class="adright">
                  <?php echo stripslashes($banner); ?>
                </div>
              <?php endif; ?>
              
              <?php the_content(); ?>

              <?php if (function_exists('the_views')) : ?>
                <h3><?php _e("Game Stats", "fungames"); ?></h3>              
                <?php the_views(); ?>
                <br /><br />
              <?php endif; ?>
                              
              <?php 
              // Display game screen shots if available              
              if ( (get_option('fungames_dispay_screens') == 'enable') && myabp_count_screenshots() ) {
                ?>
                <div class="clear"></div>
                <h3><?php the_title(''); ?> <?php _e('Screen Shots', 'fungames'); ?></h3>
                <div class="screencenter">
                <?php
                myabp_print_screenshot_all(130, 130, 'screen_thumb');
                ?>
                </div>
                <?php
              }
              ?>              
                           
              <?php the_tags( '<h3>'.__("Game Tags", "fungames").'</h3><p>', ', ', '</p>'); ?>
              
              <h3><?php _e("Game Categories", "fungames"); ?></h3>
              <div class="category">
                <?php the_category(', '); ?>
              </div>
              
              <?php
              // Display some manage buttons if logged in user is a admin
              if ( current_user_can('delete_posts') ) {
                // Show edit and delete links
                echo '<div class="clear"></div>';
                echo "<div style='float:right'><strong>Admin Actions: </strong><a href='" . wp_nonce_url("/wp-admin/post.php?action=delete&amp;post=".$post->ID, 'delete-post_' . $post->ID) . "'>Delete</a>";
                echo " | ";
                echo "<a href='" . wp_nonce_url("/wp-admin/post.php?post=".$post->ID."&action=edit") . "'>Edit</a></div>";
              }
              ?>              
              
              <?php // Display sexy bookmarks if plugin installed ?>
              <?php if( function_exists('selfserv_shareaholic') ) { echo '<div class="clear"></div>'; selfserv_shareaholic(); } ?>
              
              <div class="clear"></div>              
            </div> <?php // end entry ?>
          </div> <?php // end cover ?>
        </div> <?php // single_game ?>

        <?php // Show the game share box ?>       
        <?php if ( (get_option('fungames_share_box') == 'enable') && (get_post_meta($post->ID, "mabp_game_type", true) != 'embed') ) : ?>
        <div class="single_game">
          <h2><?php _e("Do You Like This Game?", "fungames"); ?></h2>
          <p><?php _e("Embed this game on your MySpace or on your Website:", "fungames"); ?></p>
          <form name="select_all"><textarea name="text_area" onClick="javascript:this.form.text_area.focus();this.form.text_area.select();"><a href="<?php bloginfo('url');?>"><?php bloginfo('name'); ?></a><br /><?php echo $embedcode; ?></textarea>
          </form>
        </div> <?php // end single_game ?>
        <?php endif; ?>
       
        <div class="clear"></div>
      
        <div class="allcomments"> 
          <?php comments_template(); ?>
        </div>  
      <?php endwhile; ?>
        
      <?php // Display Related Games ?>
      <?php 
      if ( function_exists('related_entries') ) {
        related_entries();
      } else {        
        include (TEMPLATEPATH . '/related.php');
      }
      ?>
        
    <?php else: ?>
      <h1 class="title"><?php _e("Not Found", "fungames"); ?></h1>
      <p><?php _e("I'm Sorry, you are looking for something that is not here. Try a different search.", "fungames"); ?></p>  
    <?php endif; ?>
  </div> <?php // end content ?>
  <div id="turnoff"></div>    
</div><?php // end content_game ?>

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