<?PHP 

include("config.php");

if(!is_logged_in($user)){ 
  header('Location:https://slowtwitch.com/calendar/');
  exit(); 
}

$username = base64_decode($_SESSION['user']);
$testresults = mysql_query("SELECT user_id FROM ".$prefix."User WHERE user_username='$username'") or die(mysql_error());
$testrow = mysql_fetch_array($testresults);
$useruid = $testrow[user_id];

// set the page title
$pagetitle = "Add a Triathlon";

// set meta tags
$meta_keywords = "add triathlon";
$meta_description = "Do you want to include your triathlon in our online multisport calendar? Then use this form to send us your race information, and we will add it to our website.";

?>

<?  
if($_POST[addrace] == 1){
  include("add_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 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">
                <?
                if( $_GET[confirmed] == "yes" ) { ?>
                <h1>Thank you</h1>
                <? echo "<p>Thank you. Your race should be added within 24 hours. You will now be redirected back to the add page.</p>";
                } else if ($confirm == 1){ ?>
                <h1>Add a Race: Step 2 of 2</h1>
                <? }else if( ($confirm !=1) && ($_POST[confirm1] != 1)){ ?>
                <h1>Add a Race: Step 1 of 2</h1>
                <? }else if( ($_POST[addrace] == 1) && (!$errmsg) && ($_POST[confirm1] == 1)){ ?>
                <h1>Thank you</h1>
                <? } 
                 if(($confirm != 1) && ($_POST[confirm1] != 1) && $_GET[confirmed] != "yes"){ ?>
                <p>If you would like to add your triathlon to our website, simply fill out the form below. Be sure to fill out every field. After filling out each field, click submit. <font color="red">You will then be prompted to confirm your race information before the information is sent to us.</font> <!--Pictures are optional, and you can upload a maximum of 3 photos. The maximum file size for each picture is 600k.--></p>
                <? } ?>
                <? include("../runshops/include_region_list.php"); ?>

                <? if( $_GET[confirmed] != "yes" && (($_POST[addrace] != 1) || ($errmsg) || (($confirm != 1) && ($_POST[confirm1] != 1))) ){ ?>
                <form enctype="multipart/form-data" name="add_form" action="add.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($_POST[name]); ?>" type="text" name="name" class="txt lngtext" />
                        </div>
                      </div>
                      <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($_POST[month], "01") == 0){ echo ("selected"); } ?>>January</option>
                                <option value="02" <? if(strcmp($_POST[month], "02") == 0){ echo ("selected"); } ?>>February</option>
                                <option value="03" <? if(strcmp($_POST[month], "03") == 0){ echo ("selected"); } ?>>March</option>
                                <option value="04" <? if(strcmp($_POST[month], "04") == 0){ echo ("selected"); } ?>>April</option>
                                <option value="05" <? if(strcmp($_POST[month], "05") == 0){ echo ("selected"); } ?>>May</option>
                                <option value="06" <? if(strcmp($_POST[month], "06") == 0){ echo ("selected"); } ?>>June</option>
                                <option value="07" <? if(strcmp($_POST[month], "07") == 0){ echo ("selected"); } ?>>July</option>
                                <option value="08" <? if(strcmp($_POST[month], "08") == 0){ echo ("selected"); } ?>>August</option>
                                <option value="09" <? if(strcmp($_POST[month], "09") == 0){ echo ("selected"); } ?>>September</option>
                                <option value="10" <? if(strcmp($_POST[month], "10") == 0){ echo ("selected"); } ?>>October</option>
                                <option value="11" <? if(strcmp($_POST[month], "11") == 0){ echo ("selected"); } ?>>November</option>
                                <option value="12" <? if(strcmp($_POST[month], "12") == 0){ echo ("selected"); } ?>>December</option>
                            </select>
                            <select name="day">
                                <option value="0">Day</option>
                                <option value="01" <? if(strcmp($_POST[day], "01") == 0){ echo ("selected"); } ?>>1</option>
                                <option value="02" <? if(strcmp($_POST[day], "02") == 0){ echo ("selected"); } ?>>2</option>
                                <option value="03" <? if(strcmp($_POST[day], "03") == 0){ echo ("selected"); } ?>>3</option>
                                <option value="04" <? if(strcmp($_POST[day], "04") == 0){ echo ("selected"); } ?>>4</option>
                                <option value="05" <? if(strcmp($_POST[day], "05") == 0){ echo ("selected"); } ?>>5</option>
                                <option value="06" <? if(strcmp($_POST[day], "06") == 0){ echo ("selected"); } ?>>6</option>
                                <option value="07" <? if(strcmp($_POST[day], "07") == 0){ echo ("selected"); } ?>>7</option>
                                <option value="08" <? if(strcmp($_POST[day], "08") == 0){ echo ("selected"); } ?>>8</option>
                                <option value="09" <? if(strcmp($_POST[day], "09") == 0){ echo ("selected"); } ?>>9</option>
                                <option value="10" <? if(strcmp($_POST[day], "10") == 0){ echo ("selected"); } ?>>10</option>
                                <option value="11" <? if(strcmp($_POST[day], "11") == 0){ echo ("selected"); } ?>>11</option>
                                <option value="12" <? if(strcmp($_POST[day], "12") == 0){ echo ("selected"); } ?>>12</option>
                                <option value="13" <? if(strcmp($_POST[day], "13") == 0){ echo ("selected"); } ?>>13</option>
                                <option value="14" <? if(strcmp($_POST[day], "14") == 0){ echo ("selected"); } ?>>14</option>
                                <option value="15" <? if(strcmp($_POST[day], "15") == 0){ echo ("selected"); } ?>>15</option>
                                <option value="16" <? if(strcmp($_POST[day], "16") == 0){ echo ("selected"); } ?>>16</option>
                                <option value="17" <? if(strcmp($_POST[day], "17") == 0){ echo ("selected"); } ?>>17</option>
                                <option value="18" <? if(strcmp($_POST[day], "18") == 0){ echo ("selected"); } ?>>18</option>
                                <option value="19" <? if(strcmp($_POST[day], "19") == 0){ echo ("selected"); } ?>>19</option>
                                <option value="20" <? if(strcmp($_POST[day], "20") == 0){ echo ("selected"); } ?>>20</option>
                                <option value="21" <? if(strcmp($_POST[day], "21") == 0){ echo ("selected"); } ?>>21</option>
                                <option value="22" <? if(strcmp($_POST[day], "22") == 0){ echo ("selected"); } ?>>22</option>
                                <option value="23" <? if(strcmp($_POST[day], "23") == 0){ echo ("selected"); } ?>>23</option>
                                <option value="24" <? if(strcmp($_POST[day], "24") == 0){ echo ("selected"); } ?>>24</option>
                                <option value="25" <? if(strcmp($_POST[day], "25") == 0){ echo ("selected"); } ?>>25</option>
                                <option value="26" <? if(strcmp($_POST[day], "26") == 0){ echo ("selected"); } ?>>26</option>
                                <option value="27" <? if(strcmp($_POST[day], "27") == 0){ echo ("selected"); } ?>>27</option>
                                <option value="28" <? if(strcmp($_POST[day], "28") == 0){ echo ("selected"); } ?>>28</option>
                                <option value="29" <? if(strcmp($_POST[day], "29") == 0){ echo ("selected"); } ?>>29</option>
                                <option value="30" <? if(strcmp($_POST[day], "30") == 0){ echo ("selected"); } ?>>30</option>
                                <option value="31" <? if(strcmp($_POST[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($_POST[hour], "01") == 0){ echo ("selected"); } ?>>1</option>
                                <option value="02" <? if(strcmp($_POST[hour], "02") == 0){ echo ("selected"); } ?>>2</option>
                                <option value="03" <? if(strcmp($_POST[hour], "03") == 0){ echo ("selected"); } ?>>3</option>
                                <option value="04" <? if(strcmp($_POST[hour], "04") == 0){ echo ("selected"); } ?>>4</option>
                                <option value="05" <? if(strcmp($_POST[hour], "05") == 0){ echo ("selected"); } ?>>5</option>
                                <option value="06" <? if(strcmp($_POST[hour], "06") == 0){ echo ("selected"); } ?>>6</option>
                                <option value="07" <? if(strcmp($_POST[hour], "07") == 0){ echo ("selected"); } ?>>7</option>
                                <option value="08" <? if(strcmp($_POST[hour], "08") == 0){ echo ("selected"); } ?>>8</option>
                                <option value="09" <? if(strcmp($_POST[hour], "09") == 0){ echo ("selected"); } ?>>9</option>
                                <option value="10" <? if(strcmp($_POST[hour], "10") == 0){ echo ("selected"); } ?>>10</option>
                                <option value="11" <? if(strcmp($_POST[hour], "11") == 0){ echo ("selected"); } ?>>11</option>
                                <option value="12" <? if(strcmp($_POST[hour], "12") == 0){ echo ("selected"); } ?>>12</option>
                            </select>
                            :
                            <select name="minute">
                                <option value="00" <? if(strcmp($_POST[minute], "00") == 0){ echo ("selected"); } ?>>00</option>
                                <option value="05" <? if(strcmp($_POST[minute], "05") == 0){ echo ("selected"); } ?>>05</option>
                                <option value="10" <? if(strcmp($_POST[minute], "10") == 0){ echo ("selected"); } ?>>10</option>
                                <option value="15" <? if(strcmp($_POST[minute], "15") == 0){ echo ("selected"); } ?>>15</option>
                                <option value="20" <? if(strcmp($_POST[minute], "20") == 0){ echo ("selected"); } ?>>20</option>
                                <option value="25" <? if(strcmp($_POST[minute], "25") == 0){ echo ("selected"); } ?>>25</option>
                                <option value="30" <? if(strcmp($_POST[minute], "30") == 0){ echo ("selected"); } ?>>30</option>
                                <option value="35" <? if(strcmp($_POST[minute], "35") == 0){ echo ("selected"); } ?>>35</option>
                                <option value="40" <? if(strcmp($_POST[minute], "40") == 0){ echo ("selected"); } ?>>40</option>
                                <option value="45" <? if(strcmp($_POST[minute], "45") == 0){ echo ("selected"); } ?>>45</option>
                                <option value="50" <? if(strcmp($_POST[minute], "50") == 0){ echo ("selected"); } ?>>50</option>
                                <option value="55" <? if(strcmp($_POST[minute], "55") == 0){ echo ("selected"); } ?>>55</option>
                            </select>
                            <select name="daypart">
                                <option value="0" <? if(strcmp($_POST[daypart], "0") == 0){ echo ("selected"); } ?>>AM</option>
                                <option value="1" <? if(strcmp($_POST[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($_POST[type] == 1){ echo ("selected"); } ?>>Triathlon</option>
                                <option value="2" <? if($_POST[type] == 2){ echo ("selected"); } ?>>Duathlon</option>
                                <option value="3" <? if($_POST[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($_POST[bike_surface] == 0 || !($_POST[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($_POST[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($_POST[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($_POST[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($_POST[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($_POST[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($_POST[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($_POST[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($_POST[swim]); ?>" type="text" name="swim" class="txt smltext" />
                            <select name="oneunit">
                            <option value="1" <? if($_POST[oneunit] == 1){ echo ("selected"); } ?>>miles</option>
                            <option value="4" <? if($_POST[oneunit] == 4){ echo ("selected"); } ?>>kilometers</option>
                            <option value="3" <? if($_POST[oneunit] == 3){ echo ("selected"); } ?>>yards</option>
                            <option value="2" <? if($_POST[oneunit] == 2){ echo ("selected"); } ?>>meters</option>
                            </select>
                            <select name="onetype">
                            <option value="1" <? if($_POST[onetype] == 1){ echo ("selected"); } ?>>Swim</option>
                            <option value="2" <? if($_POST[onetype] == 2){ echo ("selected"); } ?>>Bike</option>
                            <option value="3" <? if($_POST[onetype] == 3){ echo ("selected"); } ?>>Run</option>
                            <option value="4" <? if($_POST[onetype] == 4){ echo ("selected"); } ?>>Paddle</option>
                            <option value="5" <? if($_POST[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($_POST[bike]); ?>" type="text" name="bike" class="txt smltext" />
                            <select name="twounit">
                            <option value="1" <? if($_POST[twounit] == 1){ echo ("selected"); } ?>>miles</option>
                            <option value="4" <? if($_POST[twounit] == 4){ echo ("selected"); } ?>>kilometers</option>
                            <option value="3" <? if($_POST[twounit] == 3){ echo ("selected"); } ?>>yards</option>
                            <option value="2" <? if($_POST[twounit] == 2){ echo ("selected"); } ?>>meters</option>
                            </select>
                            <select name="twotype">
                            <option value="2" <? if($_POST[twotype] == 2){ echo ("selected"); } ?>>Bike</option>
                            <option value="1" <? if($_POST[twotype] == 1){ echo ("selected"); } ?>>Swim</option>
                            <option value="3" <? if($_POST[twotype] == 3){ echo ("selected"); } ?>>Run</option>
                            <option value="4" <? if($_POST[twotype] == 4){ echo ("selected"); } ?>>Paddle</option>
                            <option value="5" <? if($_POST[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($_POST[run]); ?>" type="text" name="run" class="txt smltext" />
                            <select name="threeunit">
                            <option value="1" <? if($_POST[threeunit] == 1){ echo ("selected"); } ?>>miles</option>
                            <option value="4" <? if($_POST[threeunit] == 4){ echo ("selected"); } ?>>kilometers</option>
                            <option value="3" <? if($_POST[threeunit] == 3){ echo ("selected"); } ?>>yards</option>
                            <option value="2" <? if($_POST[threeunit] == 2){ echo ("selected"); } ?>>meters</option>
                            </select>
                            <select name="threetype">
                            <option value="3" <? if($_POST[threetype] == 3){ echo ("selected"); } ?>>Run</option>
                            <option value="2" <? if($_POST[threetype] == 2){ echo ("selected"); } ?>>Bike</option>
                            <option value="1" <? if($_POST[threetype] == 1){ echo ("selected"); } ?>>Swim</option>
                            <option value="4" <? if($_POST[threetype] == 4){ echo ("selected"); } ?>>Paddle</option>
                            <option value="5" <? if($_POST[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($_POST[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($_POST[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($_POST[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($_POST[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($_POST[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($_POST[courseinfo]){ echo strip_tags(stripslashes($_POST[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($_POST[moreinfo]){ echo strip_tags(stripslashes($_POST[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($_POST[directions]){ echo strip_tags(stripslashes($_POST[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 $_POST[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 $_POST[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 $_POST[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" value="Submit" class="btn" />
                          <input type="hidden" name="addrace" value="1" />
                        </div>
                      </div>
                    </div>
                </form>

                <?
                if($_POST[deletepics] == 1){
                    //delete pictures uploaded
                    $file1 = $_POST[picname1];
                    $file2 = $_POST[picname2];
                    $file3 = $_POST[picname3];
                    $file1 = stripslashes(str_replace("\"", "", $file1));
                    $file2 = stripslashes(str_replace("\"", "", $file2));
                    $file3 = stripslashes(str_replace("\"", "", $file3));
                    $file1 = "/srv/www/htdocs/trifind/racepics/$file1.img";
                    $file2 = "/srv/www/htdocs/trifind/racepics/$file2.img";
                    $file3 = "/srv/www/htdocs/trifind/racepics/$file3.img";
                    if(file_exists($file1)){ unlink($file1); }
                    if(file_exists($file2)){ unlink($file2); }
                    if(file_exists($file3)){ unlink($file3); }
                }?>
                 
                <? } else { 
                    if(($_POST[addrace] == 1) && (!$errmsg) && ($_POST[confirm1] == 1)){
                        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\">";
                    }

                    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_add_confirm.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>
