<?PHP
include("config.php");
require_once("rating/classes/include.all.php");
include("rating/int.to.words.php");

$results = mysql_query("SELECT COUNT(DISTINCT(grr.rating_ip)) AS respondents, ROUND(AVG(grr.rating_vote), 2) AS score, COUNT(grr.rating_vote) AS votes, gr.runshop_id, gr.runshop_name, gr.runshop_address, gr.runshop_address_two, gr.runshop_city, gr.runshop_state, gr.runshop_zip, gr.runshop_phone, gr.runshop_fax, gr.runshop_email, gr.runshop_website, gr.runshop_cart FROM ".$prefix."RunshopsRating AS grr RIGHT JOIN ".$prefix."Runshops AS gr ON gr.runshop_id = grr.runshop_id_fk GROUP BY grr.runshop_id_fk HAVING COUNT(grr.rating_vote) > 10 ORDER BY score DESC, votes DESC LIMIT 10");

// set the page title
$pagetitle = "Top Running Stores";

// set meta tags
$meta_keywords = "top ranked running stores";
$meta_description = "Top ranked running stores based on rankings submitted by the user.";
?>

<? include("include_common_head.php"); ?>

<body class="listings">
  <? include($common_path . "/ads/ad_wallpaper.html"); ?>

  <div class="container">
    <? include($common_path . "/templates/include_header.php"); ?>
    <div class="main">
      <div class="contentwrapper clearfix">
        <? include("include_breadcrumb.php"); ?>

        <section class="section listings section-has-widgets section-static remove-sidebar">
          <div class="sidebar-b">
            <? $selected_item = 'top'; ?>
            <? include("include_sidebar.php"); ?>
          </div>
          <div class="content content-has-widgets">
            <div class="grid">

              <div class="clearfix">
                <h1>Top Ranked Running Stores</h1>
                <hr class="line" />
                <? include("include_region_list.php"); ?>

                <?
                if($none == TRUE){
                  echo "<p>No running stores have been entered yet for $regionname.</p>";
                }
                ?>
                <p/>

                <? while ($row = mysql_fetch_array($results)) {
                  include("include_store.php");
                } ?>

              </div><!-- end col-2/3 -->


            </div><!-- end grid -->
          </div><!-- end content -->
        </section>

      </div><!-- end contentwrapper -->
    </div> <!-- end main -->

  <? include($common_path . "/templates/include_footer.php") ?>
  </div> <!-- container  -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>
