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

$results = mysql_query("SELECT regionlong FROM gforum_TriathlonsRegions WHERE regionid = '".mysql_real_escape_string($_GET[region])."' LIMIT 1");

$row = mysql_fetch_array($results);
$selected_item = mysql_real_escape_string($_GET[region]);
$regionname = $row[regionlong];

/*$results = mysql_query("SELECT gtr.regionlong, gt.onetype, gt.twotype, threetype, oneunit, twounit, threeunit, name, nametag, gt.statetag, swim, bike, run, city, state, uid, UNIX_TIMESTAMP(date) as fooFROM gforum_TriathlonsRegions WHERE gtr.regionid = $_GET[region] LEFT JOIN gforum_TriathlonsStates AS gts ON gts.regionid = gtr.regionid LEFT JOIN gforum_Triathlons AS gt ON gt.statetag = gts.statetag AND valid=1 AND date > '2008-01-01' ORDER BY gt.date ASC");*/

$results = mysql_query("SELECT gr.retailer_id, gr.retailer_name, gr.retailer_address, gr.retailer_address_two, gr.retailer_city, gr.retailer_state, gr.retailer_zip, gr.retailer_phone, gr.retailer_fax, gr.retailer_email, gr.retailer_website, gr.retailer_cart
FROM gforum_Retailers AS gr
RIGHT JOIN gforum_TriathlonsStates AS gts
ON gts.regionid = '".mysql_real_escape_string($_GET[region])."' AND gr.retailer_state_tag = gts.statetag
WHERE gr.retailer_valid = 1 ORDER BY gr.retailer_name ASC");

$none = FALSE;
if (mysql_num_rows($results) == 0) {
  $none = TRUE;
}

/*$results = mysql_query("SELECT onetype, twotype, threetype, oneunit, twounit, threeunit, name, nametag, statetag, swim, bike, run, city, state, uid, UNIX_TIMESTAMP(date) as foo FROM gforum_Triathlons RIGHT JOIN WHERE regionid='$_GET[region]' AND valid=1 AND date > '2008-01-01' ORDER BY date ASC");**/

// set the page title
$pagetitle = $regionname;

// set meta tags
$meta_keywords = "triathlon retailers in ".$regionname;
$meta_description = "Trying to find triathlon retailers in ".$regionname."? Here is a listing of all ".$regionname." triathlon retailers.";
?>

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

<? 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">
            <? include("include_sidebar.php"); ?>
          </div>

          <div class="content content-has-widgets">
            <div class="grid">

              <div class="clearfix">
                <h1 class="float-left">Retailers</h1>
                <a href="<? echo $site_url ?>" class="btn btn-white float-right">Back</a>
                <? if (is_logged_in($user)) { ?>
                <a href="<? echo $site_url . "/add.php" ?>" class="btn btn-white float-right">Add Retailer</a>
                <? } ?>
                <hr class="line" />
                <? include("../runshops/include_region_list.php"); ?>

                <h2><? echo $regionname ?> Region</h2>
                <hr />
                <?
                if ($none == TRUE) {
                    echo "<p>No triathlon retailers have been entered yet for $regionname.</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>
