<?PHP 

include("config.php");
require_once("class/rating/classes/include.all.php");

$idhere = intval(mysql_escape_string($_GET[''.$field_lead.'id']));
$results = mysql_query("SELECT * FROM ".$prefix.$main_table." WHERE ".$field_lead."id='".$idhere."' LIMIT 1");
$row = mysql_fetch_array($results);
if (!$row){header('Location: '.$site_url.'/?error=invalid_id');}

if($row[$field_lead.'valid'] == 0) {
  if(!is_admin()){
    header('Location: '.$site_url);
    exit();
  }
}

// set the page title
$pagetitle = $row[$field_lead.'name'];

// set meta tags
$meta_keywords = "triathlon, ".$row[$field_lead.'name'].", ".$row[$field_lead.'state'].", slowtwitch road show";
$meta_description = "Considering attending ".$row[$field_lead.'name']."? Here is all of the information about this ".$local_singular_lc;

?>

<? 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">Road Show</h1>
                <hr class="line">
                <div class="details grid">
                   <h2><? echo stripslashes(stripslashes($row[$field_lead.'name'])) ; echo " "; ?></h2>
                   <? if($_GET[wiki_change] == 'success') { ?>
                   <p class="success"><strong>Editor:</strong> your changes have been submitted and will be validated within 24 hours.</p>
                   <? } ?>
                   
                   <?
                    $wikiFetchSQL = "SELECT edit_id FROM ".$prefix.$main_table."Edits WHERE ".$field_lead."id_fk = '".intval(mysql_escape_string($_GET[$field_lead.'id']))."'";
                    $boolEdits = mysql_num_rows(mysql_query($wikiFetchSQL));
                    if($boolEdits !== 0 && $_GET[wiki_change] != 'success') { ?>
                    <p  class="error"><strong>Group Edits:</strong> there are group edits waiting to be validated.</p>
                   <? } ?>

                   
                   <div class="col-6-12 address">
                    <? $datetime = new DateTime($row[$field_lead.'date']); ?>
                    Date: <? echo $datetime->format('Y-m-d'); ?><br>
                    Time: <? echo $datetime->format('g:i A'); ?><br>
                    Street Address: <? echo stripslashes(htmlspecialchars($row[$field_lead.'address'])); ?><br>
                    <? if ($row[$field_lead.'address_two'] <> "") {
                        echo("Street Address Two:"); 
                        echo stripslashes(htmlspecialchars($row[$field_lead.'address_two']));
                        echo("<br>");
                    } ?>
                    City: <? echo stripslashes(htmlspecialchars($row[$field_lead.'city'])); ?><br>
                    State: <? echo stripslashes(htmlspecialchars($row[$field_lead.'state'])); ?><br>
                    Zip/Postal Code: <? echo stripslashes(htmlspecialchars($row[$field_lead.'zip'])); ?>
                   </div>
                   <div class="col-6-12 contact">
                    Phone: <? echo stripslashes(htmlspecialchars($row[$field_lead.'phone'])); ?><br>
                    E-mail: <a href="mailto:<? echo $row[$field_lead.'email']; ?>"><? echo stripslashes(htmlspecialchars($row[$field_lead.'email'])); ?></a><br>
                    <?
                        $substring = "http";
                        if (!is_int(strpos($row[$field_lead.'website'], $substring))) {
                            $row[$field_lead.'website'] = "http://".$row[$field_lead.'website'];
                        }
                        $website = $row[$field_lead.'website'];

                    ?>
                    Shop Website: <? echo "<a target=\"_blank\" href=\"$website\">$website</a>"; ?>
                   </div>
                   <div class="col-1-1">
                       <? /**START COMMENT BLOCK OUT**/
                        $substring = "http";
                        if (!is_int(strpos($row[$field_lead.'raffle'], $substring))) {
                           $row[$field_lead.'raffle'] = "http://".$row[$field_lead.'raffle'];
                        }
                        $raffle = $row[$field_lead.'raffle'];
                        ?>
                        <?
                            $substring = "http";
                            if (!is_int(strpos($row[$field_lead.'facebook'], $substring))) {
                                $row[$field_lead.'facebook'] = "http://".$row[$field_lead.'facebook'];
                            }
                            $facebook = $row[$field_lead.'facebook'];
                        ?>
                        Raffle Link: <? echo "<a target=\"_blank\" href=\"$raffle\">$raffle</a>"; ?><br>
                        RSVP on Facebook: <? echo "<a target=\"_blank\" href=\"$facebook\">$facebook</a>"; ?>

                        <? /**END COMMENT BLOCK OUT**/ ?>
                   </div>
                   <div class="col-1-1">
                       <? include("include_buttons.php") ?>
                       <? include ('include_share.php'); ?>
                   </div>
                   <div class="col-1-1 detail-block">
                        <h3>Appointment Only Services</h3>
                        <div class="highlight-block">
                            <p><i>Saddle Optimizer</i>: Rides several saddles back-to-back on stationary equipment built for the purpose</p>
                            <p><i>Complete Bike Solver</i>: Discover, in granular details, what tri bikes fit you perfectly.</p>
                        </div>
                        <h3>Brands</h3>
                        <div class="highlight-block">
                        <?
                        $implosion = $row[$field_lead.'apparel_tri'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."ApparelTri WHERE apparel_tri_id IN ($implosion) ORDER BY apparel_tri_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[apparel_tri_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Triathlon Apparel: </strong>";
                            echo $temp_list;
                        }

                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'bike'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."Bike WHERE bike_id IN ($implosion) ORDER BY bike_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[bike_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Bike(s): </strong>";
                            echo $temp_list;
                        }


                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'bikeaccessory'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."BikeAccessory WHERE bikeaccessory_id IN ($implosion) ORDER BY bikeaccessory_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[bikeaccessory_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Bike Saddles/Footwear/Aerobars/Bike Hydration: </strong>
                        ";
                            echo $temp_list;
                        }

                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'bikehelmet'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."BikeHelmet WHERE bikehelmet_id IN ($implosion) ORDER BY bikehelmet_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[bikehelmet_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Bike Helmets/Eyewear: </strong>";
                            echo $temp_list;
                        }


                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'bikebody'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."BikeBody WHERE bikebody_id IN ($implosion) ORDER BY bikebody_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[bikebody_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Bike Nutritionals/Lubricants/Botanicals: </strong>";
                            echo $temp_list;
                        }


                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'biketrainer'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."BikeTrainer WHERE biketrainer_id IN ($implosion) ORDER BY biketrainer_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[biketrainer_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Bike Stationary Trainer(s): </strong>";
                            echo $temp_list;
                        }


                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'bikeelectronic'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."BikeElectronic WHERE bikeelectronic_id IN ($implosion) ORDER BY bikeelectronic_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[bikeelectronic_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Bike Electronics/Cameras/Metrics: </strong>";
                            echo $temp_list;
                        }


                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'bikewheel'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."BikeWheel WHERE bikewheel_id IN ($implosion) ORDER BY bikewheel_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[bikewheel_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Bike Wheels/Tires: </strong>";
                            echo $temp_list;
                        }


                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'bikecomponent'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."BikeComponent WHERE bikecomponent_id IN ($implosion) ORDER BY bikecomponent_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[bikecomponent_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Bike Component(s): </strong>";
                            echo $temp_list;
                        }


                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'sock'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."Sock WHERE sock_id IN ($implosion) ORDER BY sock_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[sock_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Sock(s): </strong>";
                            echo $temp_list;
                        }


                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'shoe'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."Shoe WHERE shoe_id IN ($implosion) ORDER BY shoe_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[shoe_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Running Shoe(s): </strong>";
                            echo $temp_list;
                        }


                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'apparel_run'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."ApparelRun WHERE apparel_run_id IN ($implosion) ORDER BY apparel_run_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[apparel_run_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Run Apparel: </strong>";
                            echo $temp_list;
                        }


                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'runhydrate'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."RunHydrate WHERE runhydrate_id IN ($implosion) ORDER BY runhydrate_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[runhydrate_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Run Hydration: </strong>";
                            echo $temp_list;
                        }


                        echo $temp_list;

                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'wetsuit'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."Wetsuit WHERE wetsuit_id IN ($implosion) ORDER BY wetsuit_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[wetsuit_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Wetsuit(s): </strong>";
                            echo $temp_list;
                        }


                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'swimgear'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."Swimgear WHERE swimgear_id IN ($implosion) ORDER BY swimgear_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[swimgear_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Swim Apparel/Gear: </strong>";
                            echo $temp_list;
                        }


                        $temp_list = "";

                        ?>

                        <?

                        $implosion = $row[$field_lead.'bodycare'];

                        $sql = ("SELECT * FROM ".$prefix.$resource_table."Bodycare WHERE bodycare_id IN ($implosion) ORDER BY bodycare_name ASC");

                        //echo $sql;

                        $results = mysql_query($sql) or die(mysql_error());

                        $temp_list = "";
                        while ($temp_row = mysql_fetch_array($results)) {
                            $temp_list = $temp_list."$temp_row[bodycare_name], ";
                        }
                        $temp_list = rtrim($temp_list, ', ');
                        if ($temp_list <> "") { 
                            echo "<br /><strong>Bodycare Tools: </strong>";
                            echo $temp_list;
                        }

                        $temp_list = "";

                        ?>
                        </div>
                        <h3>Road Show Itinerary</h3>
                        <div class="highlight-block">
                            <p><strong>Itinerary: </strong><? echo stripslashes(stripslashes($row[$field_lead.'activity'])) ?></p>
                        </div>
                        <? include("include_appointment.php") ?>
                       </div>
                       
                        <div class="col-1-1">
                            <div id="map" class="map map-single" data-name="single" data-category="roadshow" data-lat="<? echo $row[$field_lead.'lat'] ?>" data-lng="<? echo $row[$field_lead.'lng'] ?>"></div>
                            <div class="map-description">
                                <small>Map location is based off of a geocode of the addressed entered using Google's Google Maps API. If your address does not geocode properly, you can either update the address (we will attempt to re-geocode after any updates to your entry) <strong>or</strong> you can use Google's geocoding tool found here: <a href="http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html">http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html</a> to obtain a lat/long for your location and enter that. To use the utility, type in an address that is close to your location and then drag-and-drop the marker to obtain the desired lat/long. If you choose to enter a lat/long, you <strong>must</strong> check the box on the edit page that says, "override geocode with entered lat/long."</small>
                            </div>
                        </div>
                        <div class="col-1-1 detail-block">
                            <!-- BEGIN LIST OF USERS -->
                            <a name="goinghere"></a>
                            <? 
                                $testresults = mysql_query("SELECT ".$field_lead."user_tags FROM ".$prefix.$main_table." WHERE ".$field_lead."id=".$idhere);
                                $testrow = mysql_fetch_array($testresults) or die(mysql_error());
                                $tags = explode(",", $testrow[$field_lead.'user_tags']);
                                $numcount = count($tags) - 1;
                                if($numcount == 0){ $phrase = "No users have tagged this ".$local_singular_lc." yet."; }
                                else if($numcount == 1){ $phrase = "There is 1 user which has tagged this ".$local_singular_lc.":"; } 
                                else{ $phrase = "There are $numcount users which have tagged this ".$local_singular_lc.": "; }
                                echo "<br />";
                            ?>
                            <h3><? echo $phrase; ?></h3>
                            <div class="highlight-block">
                                <?
                                //List users
                                $i = 0;
                                foreach($tags as $value){
                                if($i > 0){
                                $tempresults = mysql_query("SELECT user_username FROM ".$prefix."User WHERE user_id='$value'") or die (mysql_error());
                                $temprow = mysql_fetch_array($tempresults);
                                if($i > 1){ echo ", "; }
                                // TODO: SLOWTWITCH EDIT
                                //echo "<a href=\"profiles/$temprow[user_username].html\">$temprow[user_username]</a>";
                                // replace the link above with the link below for integration into gforum
                                echo "<a href=\"http://forum.slowtwitch.com/gforum.cgi?username=$temprow[user_username]&session=".$_SESSION['session_id']."&from=".$from_name."\">$temprow[user_username]</a>";
                                // TODO: SLOWTWITCH EDIT END
                                }
                                $i++;
                                }
                                if(count($tags) <= 1){ echo "No users"; }
                                ?>
                            </div>
                        </div>
                        <div class="col-1-1 detail-block">
                            <!-- BEGIN LIST OF EDITORS -->
                            <a name="editors"></a>
                            <? 
                                $testresults = mysql_query("SELECT * FROM ".$prefix.$main_table."Editors WHERE ".$field_lead."id_fk=".$idhere." ORDER BY edit_timestamp DESC");
                                $numcount = mysql_num_rows($testresults);
                                if($numcount == 0){ $phrase = "No updates have been made this ".$local_singular_lc." yet."; }
                                else if($numcount == 1){ $phrase = "There has been 1 update to this ".$local_singular_lc.":"; } 
                                else{ $phrase = "There have been $numcount updates to this ".$local_singular_lc.": "; }
                                echo "<br />";
                            ?>
                            <h3><a name="tagged"></a><? echo $phrase; ?></h3>
                            <div class="highlight-block">
                                <?
                                //List users
                                $i = 0;
                                while($row=mysql_fetch_array($testresults)){
                                if($i >= 0){
                                $tempresults = mysql_query("SELECT user_username FROM ".$prefix."User WHERE user_id='$row[user_id_fk]'") or die (mysql_error());
                                $temprow = mysql_fetch_array($tempresults);
                                if($i >= 1){ echo "<br />"; }
                                    // TODO: SLOWTWITCH EDIT
                                    //echo "<a href=\"profiles/$temprow[user_username].html\">$temprow[user_username]</a>";
                                    // replace the link above with the link below for integration into gforum
                                    echo "<a href=\"http://forum.slowtwitch.com/gforum.cgi?username=$temprow[user_username]&session=".$_SESSION['session_id']."&from=".$from_name."\">$temprow[user_username]</a> at ".date("F j, Y g:i A", $row[edit_timestamp]);
                                    // TODO: SLOWTWITCH EDIT END
                                }
                                $i++;
                                }
                                if($numcount <= 0){ echo "No users"; }
                                ?>
                            </div>
                    </div>
                  </div>
                  <div class="content-divider-bottom"></div>
                  <!-- BEGIN COMMENTS -->
                  <? include ('comments_show.php');?>
                  <!-- END COMMENTS -->
                       


              </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>

