<?PHP 

include("config.php");

if(!isset($_GET[uid]) AND !$_POST AND !is_numeric($_GET[uid])) {
    header('Location: '.$site_url.'/?error=no_id_or_no_post');
    exit(); 
}

if(!is_logged_in($user)){ 
    header('Location: '.$site_url.'/?error=not_logged_in');
    exit(); 
}

// Populate with post data or populate with edit return data
if (isset($_POST[edit_return]) || isset($_POST[edit_race])) { 
    $row = $_POST;
} else {
    $race_idhere = intval(mysql_escape_string($_GET[uid]));
    $results = mysql_query("SELECT uid, onetype, twotype, threetype, oneunit, twounit, threeunit, name,  nametag, type, indivfee, teamfee, swim, bike, bike_surface, draft_legal, kids_race, run, state, statetag, city, address, phone, email, courseinfo, moreinfo, directions, register, website, submitted_by, valid, UNIX_TIMESTAMP(date) AS racedate, registration FROM gforum_Triathlons WHERE uid='".$race_idhere."' LIMIT 1");
    $row = mysql_fetch_array($results);
    //echo "valid: "$row[valid];
}


//Get user's session data information
$username = base64_decode($_SESSION['user']);
$useruid = base64_decode($_SESSION['user_id']);

if (!is_admin() && $row[valid] != 1 ) {
    header('Location: '.$site_url.'/?error=race_not_valid');
    exit();
}

// set the page title
$pagetitle = "Edit A Race";

// set meta tags
$meta_keywords = "edit race";
$meta_description = "edit screen for race information";

?>

<?  
if($_POST[edit_race] == 1){
    include("wiki_edit_X.php");
}

//Array of states for use in the form
$state_list = array('AL'=>"Alabama",  
    'AK'=>"Alaska", 
    'AB'=>'Alberta',
    'AZ'=>"Arizona",  
    'AR'=>"Arkansas", 
    'BC'=>'British Columbia',
    'CB'=>"Caribbean",
    'CA'=>"California",  
    'CM'=>"Central America",
    'CO'=>"Colorado",  
    'CT'=>"Connecticut",
    'DE'=>"Delaware",  
    'DC'=>"District of Columbia",
    'FL'=>"Florida",  
    'GA'=>"Georgia",  
    'HI'=>"Hawaii",  
    'ID'=>"Idaho",  
    'IL'=>"Illinois",  
    'IN'=>"Indiana",  
    'IA'=>"Iowa",  
    'KS'=>"Kansas",  
    'KY'=>"Kentucky",  
    'LA'=>"Louisiana",  
    'ME'=>"Maine",  
    'MB'=>'Manitoba',
    'MD'=>"Maryland",  
    'MA'=>"Massachusetts", 
    'MX'=>"Mexico",
    'MI'=>"Michigan",  
    'MN'=>"Minnesota",  
    'MS'=>"Mississippi",  
    'MO'=>"Missouri",  
    'MT'=>"Montana",
    'NE'=>"Nebraska",
    'NV'=>"Nevada",
    'NB'=>'New Brunswick',
    'NL'=>'Newfoundland',
    'NH'=>"New Hampshire",
    'NJ'=>"New Jersey",
    'NM'=>"New Mexico",
    'NY'=>"New York",
    'NC'=>"North Carolina",
    'ND'=>"North Dakota",
    'NS'=>'Nova Scotia',
    'OH'=>"Ohio",  
    'OK'=>"Oklahoma",
    'ON'=>'Ontario',
    'OR'=>"Oregon",  
    'PA'=>"Pennsylvania",
    'PE'=>'Prince Edward Island',
    'QC'=>'Quebec',
    'RI'=>"Rhode Island", 
    'SK'=>'Saskatchewan',
    'SC'=>"South Carolina",  
    'SD'=>"South Dakota",
    'TN'=>"Tennessee",  
    'TX'=>"Texas",  
    'UT'=>"Utah",  
    'VT'=>"Vermont",  
    'VA'=>"Virginia",  
    'WA'=>"Washington",  
    'WV'=>"West Virginia",  
    'WI'=>"Wisconsin",  
    'WY'=>"Wyoming");
?>

<? 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">
          <div class="content content-has-widgets">
            <div class="grid">

              <div class="col-8-12 col-flex">
                <?
                if( $_GET[confirmed] == "yes" ) { ?>
                <h1><strong>Thank you</strong></h1>
                <? echo "<p class=\"cont\">Thank you. Your race should be added within 24 hours. You will now be redirected back to the add page.</p>";
                echo "<META HTTP-EQUIV=Refresh CONTENT=\"4; URL=add.php\">"; 
                } else if($confirm == 1){ ?>
                <h1><strong>Edit a Race: Step 2 of 2</strong></h1>
                <? }else if( ($confirm !=1) && ($_POST[confirm_entry] != 1)){ ?>
                <h1><strong>Edit a Race: Step 1 of 2</strong></h1>
                <? }else if( ($_POST[edit_race] == 1) && (!$errmsg) && ($_POST[confirm_entry] == 1)){ ?>
                <h1><strong>Thank you</strong></h1>
                <? } 
                 if(($confirm != 1) && ($_POST[confirm_entry] != 1) && $_GET[confirmed] != "yes"){ ?>
                <p class="cont">To edit a race, simply change the data you wish. If you make a mistake, just hit the reset button. <span style="color: red;">To save the changes as a NEW race (for instance, if you have multiple races in the same location), hit the "SAVE AS A NEW RACE" button. To save changes to the existing race entry, hit the "SAVE CHANGES TO YOUR RACE" button. You will have a chance to review the data before confirming.</span></p>
                <? } ?>

                <? if( $_GET[confirmed] != "yes" && (($_POST[edit_race] != 1) || ($errmsg) || (($confirm != 1) && ($_POST[confirm_entry] != 1))) ){ ?>
                <form enctype="multipart/form-data" name="edit_form" action="wiki_edit.php" method="post">
                    <p class="cont"><font color="red"><? echo $errmsg; ?></font></p>
                    <div class="dtable form">
                      <div class="drow">
                        <div class="dcell name">Race Name</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input value="<? echo stripslashes($row[name]); ?>" type="text" name="name" class="txt lngtext" />
                        </div>
                      </div>
                      <? // we need to convert the UNIX timestamp to individual parts //
$row[month] = date("m", $row[racedate]);
$row[day] = date("d", $row[racedate]);
$row[year] = date("Y", $row[racedate]);
$row[hour] = date("h", $row[racedate]);
$row[minute] = date("i", $row[racedate]);
$row[daypart] = date("A", $row[racedate]);
?>
                      <div class="drow">
                        <div class="dcell name">Race Date</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <select name="month">
                                <option value="0">Month</option>
                                <option value="01" <? if(strcmp($row[month], "01") == 0){ echo ("selected"); } ?>>January</option>
                                <option value="02" <? if(strcmp($row[month], "02") == 0){ echo ("selected"); } ?>>February</option>
                                <option value="03" <? if(strcmp($row[month], "03") == 0){ echo ("selected"); } ?>>March</option>
                                <option value="04" <? if(strcmp($row[month], "04") == 0){ echo ("selected"); } ?>>April</option>
                                <option value="05" <? if(strcmp($row[month], "05") == 0){ echo ("selected"); } ?>>May</option>
                                <option value="06" <? if(strcmp($row[month], "06") == 0){ echo ("selected"); } ?>>June</option>
                                <option value="07" <? if(strcmp($row[month], "07") == 0){ echo ("selected"); } ?>>July</option>
                                <option value="08" <? if(strcmp($row[month], "08") == 0){ echo ("selected"); } ?>>August</option>
                                <option value="09" <? if(strcmp($row[month], "09") == 0){ echo ("selected"); } ?>>September</option>
                                <option value="10" <? if(strcmp($row[month], "10") == 0){ echo ("selected"); } ?>>October</option>
                                <option value="11" <? if(strcmp($row[month], "11") == 0){ echo ("selected"); } ?>>November</option>
                                <option value="12" <? if(strcmp($row[month], "12") == 0){ echo ("selected"); } ?>>December</option>
                            </select>
                            <select name="day">
                                <option value="0">Day</option>
                                <option value="01" <? if(strcmp($row[day], "01") == 0){ echo ("selected"); } ?>>1</option>
                                <option value="02" <? if(strcmp($row[day], "02") == 0){ echo ("selected"); } ?>>2</option>
                                <option value="03" <? if(strcmp($row[day], "03") == 0){ echo ("selected"); } ?>>3</option>
                                <option value="04" <? if(strcmp($row[day], "04") == 0){ echo ("selected"); } ?>>4</option>
                                <option value="05" <? if(strcmp($row[day], "05") == 0){ echo ("selected"); } ?>>5</option>
                                <option value="06" <? if(strcmp($row[day], "06") == 0){ echo ("selected"); } ?>>6</option>
                                <option value="07" <? if(strcmp($row[day], "07") == 0){ echo ("selected"); } ?>>7</option>
                                <option value="08" <? if(strcmp($row[day], "08") == 0){ echo ("selected"); } ?>>8</option>
                                <option value="09" <? if(strcmp($row[day], "09") == 0){ echo ("selected"); } ?>>9</option>
                                <option value="10" <? if(strcmp($row[day], "10") == 0){ echo ("selected"); } ?>>10</option>
                                <option value="11" <? if(strcmp($row[day], "11") == 0){ echo ("selected"); } ?>>11</option>
                                <option value="12" <? if(strcmp($row[day], "12") == 0){ echo ("selected"); } ?>>12</option>
                                <option value="13" <? if(strcmp($row[day], "13") == 0){ echo ("selected"); } ?>>13</option>
                                <option value="14" <? if(strcmp($row[day], "14") == 0){ echo ("selected"); } ?>>14</option>
                                <option value="15" <? if(strcmp($row[day], "15") == 0){ echo ("selected"); } ?>>15</option>
                                <option value="16" <? if(strcmp($row[day], "16") == 0){ echo ("selected"); } ?>>16</option>
                                <option value="17" <? if(strcmp($row[day], "17") == 0){ echo ("selected"); } ?>>17</option>
                                <option value="18" <? if(strcmp($row[day], "18") == 0){ echo ("selected"); } ?>>18</option>
                                <option value="19" <? if(strcmp($row[day], "19") == 0){ echo ("selected"); } ?>>19</option>
                                <option value="20" <? if(strcmp($row[day], "20") == 0){ echo ("selected"); } ?>>20</option>
                                <option value="21" <? if(strcmp($row[day], "21") == 0){ echo ("selected"); } ?>>21</option>
                                <option value="22" <? if(strcmp($row[day], "22") == 0){ echo ("selected"); } ?>>22</option>
                                <option value="23" <? if(strcmp($row[day], "23") == 0){ echo ("selected"); } ?>>23</option>
                                <option value="24" <? if(strcmp($row[day], "24") == 0){ echo ("selected"); } ?>>24</option>
                                <option value="25" <? if(strcmp($row[day], "25") == 0){ echo ("selected"); } ?>>25</option>
                                <option value="26" <? if(strcmp($row[day], "26") == 0){ echo ("selected"); } ?>>26</option>
                                <option value="27" <? if(strcmp($row[day], "27") == 0){ echo ("selected"); } ?>>27</option>
                                <option value="28" <? if(strcmp($row[day], "28") == 0){ echo ("selected"); } ?>>28</option>
                                <option value="29" <? if(strcmp($row[day], "29") == 0){ echo ("selected"); } ?>>29</option>
                                <option value="30" <? if(strcmp($row[day], "30") == 0){ echo ("selected"); } ?>>30</option>
                                <option value="31" <? if(strcmp($row[day], "31") == 0){ echo ("selected"); } ?>>31</option>
                            </select>
                            <select name="year">
				<? $year = date( "Y", strtotime("+6 months") ); ?>
                                <option value="<? echo($year); ?>" select="selected"><? echo($year); ?></option>
				<? $year = date( "Y", strtotime("-6 months") ); ?>
                                <option value="<? echo($year); ?>"><? echo($year); ?></option>
                            </select>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Start Time</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <select name="hour">
                                <option value="01" <? if(strcmp($row[hour], "01") == 0){ echo ("selected"); } ?>>1</option>
                                <option value="02" <? if(strcmp($row[hour], "02") == 0){ echo ("selected"); } ?>>2</option>
                                <option value="03" <? if(strcmp($row[hour], "03") == 0){ echo ("selected"); } ?>>3</option>
                                <option value="04" <? if(strcmp($row[hour], "04") == 0){ echo ("selected"); } ?>>4</option>
                                <option value="05" <? if(strcmp($row[hour], "05") == 0){ echo ("selected"); } ?>>5</option>
                                <option value="06" <? if(strcmp($row[hour], "06") == 0){ echo ("selected"); } ?>>6</option>
                                <option value="07" <? if(strcmp($row[hour], "07") == 0){ echo ("selected"); } ?>>7</option>
                                <option value="08" <? if(strcmp($row[hour], "08") == 0){ echo ("selected"); } ?>>8</option>
                                <option value="09" <? if(strcmp($row[hour], "09") == 0){ echo ("selected"); } ?>>9</option>
                                <option value="10" <? if(strcmp($row[hour], "10") == 0){ echo ("selected"); } ?>>10</option>
                                <option value="11" <? if(strcmp($row[hour], "11") == 0){ echo ("selected"); } ?>>11</option>
                                <option value="12" <? if(strcmp($row[hour], "12") == 0){ echo ("selected"); } ?>>12</option>
                            </select>
                            :
                            <select name="minute">
                                <option value="00" <? if(strcmp($row[minute], "00") == 0){ echo ("selected"); } ?>>00</option>
                                <option value="05" <? if(strcmp($row[minute], "05") == 0){ echo ("selected"); } ?>>05</option>
                                <option value="10" <? if(strcmp($row[minute], "10") == 0){ echo ("selected"); } ?>>10</option>
                                <option value="15" <? if(strcmp($row[minute], "15") == 0){ echo ("selected"); } ?>>15</option>
                                <option value="20" <? if(strcmp($row[minute], "20") == 0){ echo ("selected"); } ?>>20</option>
                                <option value="25" <? if(strcmp($row[minute], "25") == 0){ echo ("selected"); } ?>>25</option>
                                <option value="30" <? if(strcmp($row[minute], "30") == 0){ echo ("selected"); } ?>>30</option>
                                <option value="35" <? if(strcmp($row[minute], "35") == 0){ echo ("selected"); } ?>>35</option>
                                <option value="40" <? if(strcmp($row[minute], "40") == 0){ echo ("selected"); } ?>>40</option>
                                <option value="45" <? if(strcmp($row[minute], "45") == 0){ echo ("selected"); } ?>>45</option>
                                <option value="50" <? if(strcmp($row[minute], "50") == 0){ echo ("selected"); } ?>>50</option>
                                <option value="55" <? if(strcmp($row[minute], "55") == 0){ echo ("selected"); } ?>>55</option>
                            </select>
                            <select name="daypart">
                                <option value="0" <? if(strcmp($row[daypart], "0") == 0){ echo ("selected"); } ?>>AM</option>
                                <option value="1" <? if(strcmp($row[daypart], "1") == 0){ echo ("selected"); } ?>>PM</option>
                            </select>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Race Type</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <select name="type">
                                <option value="0">Type</option>
                                <option value="1" <? if($row[type] == 1){ echo ("selected"); } ?>>Triathlon</option>
                                <option value="2" <? if($row[type] == 2){ echo ("selected"); } ?>>Duathlon</option>
                                <option value="3" <? if($row[type] == 3){ echo ("selected"); } ?>>Other</option>
                                <option value="4" <? if($_POST[type] == 4){ echo ("selected"); } ?>>Swim-Run</option>
                            </select>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Bike Surface</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input type="radio" name="bike_surface" value="0" onclick="javascript:document.add_form.draft_legal.checked=false;document.add_form.draft_legal.disabled=false"<? if($row[bike_surface] == 0 || !($row[bike_surface])){ echo ("checked"); } ?>>Road
                            <input type="radio" name="bike_surface" value="1" onclick="javascript:document.add_form.draft_legal.checked=true;document.add_form.draft_legal.disabled=true" <? if($row[bike_surface] == 1){ echo ("checked"); } ?>>Offroad
                            <input type="radio" name="bike_surface" value="2" onclick="javascript:document.add_form.draft_legal.checked=true;document.add_form.draft_legal.disabled=true" <? if($row[bike_surface] == 2){ echo ("checked"); } ?>>Gravel
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Draft Legal (on-road only)</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input type="checkbox" name="draft_legal" value="1"<? if($row[draft_legal] == 1){ echo ("checked"); } ?>>Yes, draft legal. (Leave un-checked for non-drafting) 
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Kids' Race</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input type="checkbox" name="kids_race" value="1"<? if($row[kids_race] == 1){ echo ("checked"); } ?>>Yes, this is a kids' race. (Leave un-checked for a "normal" race) 
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Individual entry fee</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input value="<? echo stripslashes(htmlspecialchars($row[indivfee])); ?>" type="text" name="indivfee" class="txt shotext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Team entry fee</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input value="<? echo stripslashes(htmlspecialchars($row[teamfee])); ?>" type="text" name="teamfee" class="txt shotext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Registration fees disclosed?</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input type="checkbox" name="registration" value="1"<? if($row[registration] == 1){ echo ("checked"); } ?>><strong>Yes, registration fees are included or disclosed at the beginning of registration.</strong> (check this box if your entry fee <strong>*includes*</strong> any &amp; all registration/convenience fees; or if at a minimum all registration fees are disclosed at the beginning of registration).
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name"></div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            ***************************************************************
                            <br />
                            IMPORTANT: Fractional lengths must be entered as a decimal number<br />
                            Examples: 0.25, 1.2, 0.1, 13.2. If your race contains only two legs, simply
                            leave the third leg blank.
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">1st distance</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input value="<? echo stripslashes($row[swim]); ?>" type="text" name="swim" class="txt smltext" />
                            <select name="oneunit">
                            <option value="1" <? if($row[oneunit] == 1){ echo ("selected"); } ?>>miles</option>
                            <option value="4" <? if($row[oneunit] == 4){ echo ("selected"); } ?>>kilometers</option>
                            <option value="3" <? if($row[oneunit] == 3){ echo ("selected"); } ?>>yards</option>
                            <option value="2" <? if($row[oneunit] == 2){ echo ("selected"); } ?>>meters</option>
                            </select>
                            <select name="onetype">
                            <option value="1" <? if($row[onetype] == 1){ echo ("selected"); } ?>>Swim</option>
                            <option value="2" <? if($row[onetype] == 2){ echo ("selected"); } ?>>Bike</option>
                            <option value="3" <? if($row[onetype] == 3){ echo ("selected"); } ?>>Run</option>
                            <option value="4" <? if($row[onetype] == 4){ echo ("selected"); } ?>>Paddle</option>
                            <option value="5" <? if($row[onetype] == 5){ echo ("selected"); } ?>>Ski</option>
                            </select>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">2nd distance</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input value="<? echo stripslashes($row[bike]); ?>" type="text" name="bike" class="txt smltext" />
                            <select name="twounit">
                            <option value="1" <? if($row[twounit] == 1){ echo ("selected"); } ?>>miles</option>
                            <option value="4" <? if($row[twounit] == 4){ echo ("selected"); } ?>>kilometers</option>
                            <option value="3" <? if($row[twounit] == 3){ echo ("selected"); } ?>>yards</option>
                            <option value="2" <? if($row[twounit] == 2){ echo ("selected"); } ?>>meters</option>
                            </select>
                            <select name="twotype">
                            <option value="2" <? if($row[twotype] == 2){ echo ("selected"); } ?>>Bike</option>
                            <option value="1" <? if($row[twotype] == 1){ echo ("selected"); } ?>>Swim</option>
                            <option value="3" <? if($row[twotype] == 3){ echo ("selected"); } ?>>Run</option>
                            <option value="4" <? if($row[twotype] == 4){ echo ("selected"); } ?>>Paddle</option>
                            <option value="5" <? if($row[twotype] == 5){ echo ("selected"); } ?>>Ski</option>
                            </select>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">3rd distance</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input value="<? echo stripslashes($row[run]); ?>" type="text" name="run" class="txt smltext" />
                            <select name="threeunit">
                            <option value="1" <? if($row[threeunit] == 1){ echo ("selected"); } ?>>miles</option>
                            <option value="4" <? if($row[threeunit] == 4){ echo ("selected"); } ?>>kilometers</option>
                            <option value="3" <? if($row[threeunit] == 3){ echo ("selected"); } ?>>yards</option>
                            <option value="2" <? if($row[threeunit] == 2){ echo ("selected"); } ?>>meters</option>
                            </select>
                            <select name="threetype">
                            <option value="3" <? if($row[threetype] == 3){ echo ("selected"); } ?>>Run</option>
                            <option value="2" <? if($row[threetype] == 2){ echo ("selected"); } ?>>Bike</option>
                            <option value="1" <? if($row[threetype] == 1){ echo ("selected"); } ?>>Swim</option>
                            <option value="4" <? if($row[threetype] == 4){ echo ("selected"); } ?>>Paddle</option>
                            <option value="5" <? if($row[threetype] == 5){ echo ("selected"); } ?>>Ski</option>
                            </select>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name"></div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            **************************************************************
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">State</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <SELECT name="state">
                               <OPTION value="0">Choose a State/Province</OPTION>
                            <? //use loop for dropdown box
                            foreach($state_list as $key=>$value){
                                if(strcmp($row[state], $value) == 0){
                                    $str = " selected=\"selected\"";
                                }
                                echo "<option value=\"$value\"$str>$value</option>";
                                $str = "";
                            }
                            ?>
                            </SELECT>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">City</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input value="<? echo stripslashes(htmlspecialchars($row[city])); ?>" type="text" name="city" class="txt shotext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Address</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input value="<? echo stripslashes(htmlspecialchars($row[address])); ?>" type="text" name="address" class="txt lngtext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Phone Contact</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input value="<? echo stripslashes(htmlspecialchars($row[phone])); ?>" type="text" name="phone" class="txt shotext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">E-mail Contact</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input value="<? echo stripslashes(htmlspecialchars($row[email])); ?>" type="text" name="email" class="txt shotext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Course Info</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <textarea class="txt lngtext" name="courseinfo" rows="7" placeholder="Please insert a short paragraph describing the course."><? if($row[courseinfo]){ echo strip_tags(stripslashes($row[courseinfo])); } ?></textarea>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">More Info</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <textarea name="moreinfo" class="txt lngtext" rows="7" placeholder="Please insert a short paragraph describing information such as prizes, age groups, drafting rule, etc."><? if($row[moreinfo]){ echo strip_tags(stripslashes($row[moreinfo])); } ?></textarea>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Directions</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <textarea name="directions" class="txt lngtext" rows="7" placeholder="Please describe how to get to your race from your surrounding area."><? if($row[directions]){ echo strip_tags(stripslashes($row[directions])); } ?></textarea>
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Registration link</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input value="<? echo $row[register]; ?>" type="text" name="register" placeholder="http://" class="txt lngtext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Website</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input value="<? echo $row[website]; ?>" type="text" name="website" placeholder="http://" class="txt lngtext" />
                        </div>
                      </div>
                      <div class="drow">
                        <div class="dcell name">Results</div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input value="<? echo $row[results]; ?>" type="text" name="results" class="txt lngtext" />
                        </div>
                      </div>
                      <div class="drow actions">
                        <div class="dcell name"></div>
                        <div class="dcell divider"></div>
                        <div class="dcell value">
                            <input type="submit" name="save_changes" value="Save Your Race Info" class="btn" />
                            <input type="submit" name="add_race" value="Save As A New Race" class="btn" />
                            <input type="reset" value="Reset" class="btn" />
                            <input type="hidden" name="edit_race" value="1">
                            <input type="hidden" name="uid" value="<? echo($row[uid]); ?>">
                            <? // need to temporary set the field as being valid ?>
                            <input type="hidden" name="valid" value="1">
                            <input type="hidden" name="submitted_by" value="<? echo($row[submitted_by]); ?>">
                            <input type="hidden" name="edited_by" value="<? echo($useruid); ?>">
                        </div>
                      </div>
                    </div>

                </form>
 
                <? } else { 
                    if($confirm == 1){
                        $confirm = 0;
                        if($type == 1){ $typename = 'Triathlon'; }
                        if($type == 2){ $typename = 'Duathlon'; }
                        if($type == 3){ $typename = 'Other'; }
                        if($type == 4){ $typename = 'Swim-Run'; }
                        include("include_edit_confirm.php");
                    } 
                } ?>

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

              <div class="widget-column col-4-12 col-fixed">
                <? include("include_sidebar.php"); ?>
              </div>

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

