<p>Please confirm your race information. If everything is correct, click the submit button. Otherwise, you may click the edit button to change your race information before submitting.</p>
<p><font color="red"><? echo $dupmsg; ?></font></p>

<p>
<?
$nametagmod = trim(strtolower(str_replace(" ","",$_POST[name])));
$nametagmod1 = $nametagmod . '1';
$nametagmod2 = $nametagmod . '2';
$nametagmod3 = $nametagmod . '3';
if($_FILES[imagefile][size][0] > 0){
    fopen("/srv/www/htdocs/trifind/racepics/$nametagmod1.img", "w");            
    move_uploaded_file($_FILES['imagefile']['tmp_name'][0],"/srv/www/htdocs/trifind/racepics/$nametagmod1.img");
    print "<img border=\"1\" bordercolor=\"#000\" src=\"phpthumb/phpThumb.php?src=../racepics/$nametagmod1.img&w=170&h=170\" />";
    print "&nbsp;&nbsp;&nbsp;&nbsp;";
}

if($_FILES[imagefile][size][1] > 0){
    fopen("/srv/www/htdocs/trifind/racepics/$nametagmod2.img", "w");            
    move_uploaded_file($_FILES['imagefile']['tmp_name'][1],"/srv/www/htdocs/trifind/racepics/$nametagmod2.img");
    print "<img border=\"1\" bordercolor=\"#000\" src=\"phpthumb/phpThumb.php?src=../racepics/$nametagmod2.img&w=170&h=170\" />";
    print "&nbsp;&nbsp;&nbsp;&nbsp;";
}

if($_FILES[imagefile][size][2] > 0){
    fopen("/srv/www/htdocs/trifind/racepics/$nametagmod3.img", "w");            
    move_uploaded_file($_FILES['imagefile']['tmp_name'][2],"/srv/www/htdocs/trifind/racepics/$nametagmod3.img");
    print "<img border=\"1\" bordercolor=\"#000\" src=\"phpthumb/phpThumb.php?src=../racepics/$nametagmod3.img&w=170&h=170\" />";            
}?>
</p>

<div class="dtable form">
  <div class="drow">
    <div class="dcell name">Race Name</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo stripslashes($_POST[name]); ?>    
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Date</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo  "$month/$day/$year"; ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Race Type</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo $typename; ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Bike Surface</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <?
        if ($bike_surface == 1) { $bike_surface_name = "Offroad"; } 
        elseif ($bike_surface == 2) { $bike_surface_name = "Gravel"; }
        else { $bike_surface_name = "Road"; }
        ?>
        <? echo $bike_surface_name; ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Drafting rules</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? //Determine draft rules
        if ($draft_legal == 1) { $draft_legal_name = "Draft-legal"; } 
        else { $draft_legal_name = "Non-drafting"; }
        ?>
        <? echo $draft_legal_name; ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Kid's race?</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? //Determine kids race
        if ($kids_race == 1) { $kids_race_name = "This is a kids' race"; } 
        else { $kids_race_name = "This is NOT a kids' race"; }
        ?>
        <? echo $kids_race_name; ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Course</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <?
        if($oneunit == 1){ $oneunitword = "mile"; }
        if($oneunit == 2){ $oneunitword = "meter"; }
        if($oneunit == 3){ $oneunitword = "yard"; }
        if($oneunit == 4){ $oneunitword = "kilometers"; }

        if($twounit == 1){ $twounitword = "mile"; }
        if($twounit == 2){ $twounitword = "meter"; }
        if($twounit == 3){ $twounitword = "yard"; }
        if($twounit == 4){ $twounitword = "kilometers"; }

        if($threeunit == 1){ $threeunitword = "mile"; }
        if($threeunit == 2){ $threeunitword = "meter"; }
        if($threeunit == 3){ $threeunitword = "yard"; }
        if($threeunit == 4){ $threeunitword = "kilometers"; }

        if($onetype == 1){ $onetypeword = "swim"; }
        if($onetype == 2){ $onetypeword = "bike"; }
        if($onetype == 3){ $onetypeword = "run"; }
        if($onetype == 4){ $onetypeword = "paddle"; }
        if($onetype == 5){ $onetypeword = "ski"; }

        if($twotype == 1){ $twotypeword = "swim"; }
        if($twotype == 2){ $twotypeword = "bike"; }
        if($twotype == 3){ $twotypeword = "run"; }
        if($twotype == 4){ $twotypeword = "paddle"; }
        if($twotype == 5){ $twotypeword = "paddle"; }

        if($threetype == 1){ $threetypeword = "swim"; }
        if($threetype == 2){ $threetypeword = "bike"; }
        if($threetype == 3){ $threetypeword = "run"; }
        if($threetype == 4){ $threetypeword = "paddle"; }
        if($threetype == 5){ $threetypeword = "ski"; }

        ?>
        <? 
        echo "$swim $oneunitword $onetypeword, $bike $twounitword $twotypeword";
        if ($run != 0) { echo ", $run $threeunitword $threetypeword"; }
        ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Start</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo "$hour:$minute"; ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Location</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo stripslashes($city); echo ", $state"; ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Address</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo stripslashes($address); ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Contact</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo stripslashes($phone); echo "<br />"; echo stripslashes($email); ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Individual Price</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo stripslashes($indivfee); ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Team Price</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo stripslashes($teamfee); ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Registration/convenience fees included?</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? //Determine draft rules
        if ($registration == 1) { $registration_name = "ALL registration/convenience fees ARE included in price."; } 
        else { $registration_name = "Not specified whether any/all registration fees are included in price."; }
        ?>
        <? echo $registration_name; ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Course Info</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo stripslashes($courseinfo); ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">More</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo stripslashes($moreinfo); ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Directions</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo stripslashes($directions); ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Register</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo "<a target=\"_blank\" href=\"$register\">Click here</a>"; ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Website</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo "<a target=\"_blank\" href=\"$website\">$name</a>"; ?>
    </div>
  </div>
  <div class="drow">
    <div class="dcell name">Results</div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <? echo "<a target=\"_blank\" href=\"$results\">$results</a>"; ?>
    </div>
  </div>
  <div class="drow actions">
    <div class="dcell name"></div>
    <div class="dcell divider"></div>
    <div class="dcell value">
        <form action="add.php" method="post">
            <input type="hidden" name="picname1" value="<? echo $nametagmod1; ?>">
            <input type="hidden" name="picname2" value="<? echo $nametagmod2; ?>">
            <input type="hidden" name="picname3" value="<? echo $nametagmod3; ?>">
            <input type="hidden" name="name" value="<? echo stripslashes(htmlspecialchars($_POST[name])); ?>">
            <input type="hidden" name="password" value="<? echo $_POST[password]; ?>">
            <input type="hidden" name="month" value="<? echo $_POST[month]; ?>">
            <input type="hidden" name="day" value="<? echo $_POST[day]; ?>">
            <input type="hidden" name="daypart" value="<? echo $_POST[daypart]; ?>">
            <input type="hidden" name="hour" value="<? echo $_POST[hour]; ?>">
            <input type="hidden" name="minute" value="<? echo $_POST[minute]; ?>">
            <input type="hidden" name="year" value="<? echo $_POST[year]; ?>">
            <input type="hidden" name="type" value="<? echo $_POST[type]; ?>">
            <input type="hidden" name="bike_surface" value="<? echo $_POST[bike_surface]; ?>">
            <input type="hidden" name="draft_legal" value="<? echo $draft_legal; ?>">
            <input type="hidden" name="kids_race" value="<? echo $kids_race; ?>">
            <input type="hidden" name="indivfee" value="<? echo stripslashes(htmlspecialchars($_POST[indivfee])); ?>">
            <input type="hidden" name="teamfee" value="<? echo stripslashes(htmlspecialchars($_POST[teamfee])); ?>">
            <input type="hidden" name="registration" value="<? echo $registration; ?>">
            <input type="hidden" name="swim" value="<? echo stripslashes(htmlspecialchars($_POST[swim])); ?>">
            <input type="hidden" name="bike" value="<? echo stripslashes(htmlspecialchars($_POST[bike])); ?>">
            <input type="hidden" name="run" value="<? echo stripslashes(htmlspecialchars($_POST[run])); ?>">
            <input type="hidden" name="oneunit" value="<? echo $_POST[oneunit]; ?>">
            <input type="hidden" name="twounit" value="<? echo $_POST[twounit]; ?>">
            <input type="hidden" name="threeunit" value="<? echo $_POST[threeunit]; ?>">
            <input type="hidden" name="onetype" value="<? echo $_POST[onetype]; ?>">
            <input type="hidden" name="twotype" value="<? echo $_POST[twotype]; ?>">
            <input type="hidden" name="threetype" value="<? echo $_POST[threetype]; ?>">
            <input type="hidden" name="state" value="<? echo $_POST[state]; ?>">
            <input type="hidden" name="city" value="<? echo stripslashes(htmlspecialchars($_POST[city])); ?>">
            <input type="hidden" name="address" value="<? echo stripslashes(htmlspecialchars($_POST[address])); ?>">
            <input type="hidden" name="phone" value="<? echo stripslashes(htmlspecialchars($_POST[phone])); ?>">
            <input type="hidden" name="email" value="<? echo stripslashes(htmlspecialchars($_POST[email])); ?>">
            <input type="hidden" name="courseinfo" value="<? echo stripslashes(htmlspecialchars($_POST[courseinfo])); ?>">
            <input type="hidden" name="moreinfo" value="<? echo stripslashes(htmlspecialchars($_POST[moreinfo])); ?>">
            <input type="hidden" name="directions" value="<? echo stripslashes(htmlspecialchars($_POST[directions])); ?>">
            <input type="hidden" name="register" value="<? echo $_POST[register]; ?>">
            <input type="hidden" name="website" value="<? echo $_POST[website]; ?>">
            <input type="hidden" name="results" value="<? echo $_POST[results]; ?>">
            <input type="hidden" name="sixresults" value="<? echo $_POST[sixresults]; ?>">
            <input type="hidden" name="addrace" value="1">
            <input type="hidden" name="confirm1" value="1">
            <input type="hidden" name="submitted_by" value="<?echo($useruid);?>" />
            <input type="submit" name="submit" value="Submit Race" class="btn float-left" style="margin-right: 5px" />
        </form>
        <form action="add.php" method="post">
            <input type="hidden" name="name" value="<? echo stripslashes(htmlspecialchars($name)); ?>">
            <input type="hidden" name="password" value="<? echo $_POST[password]; ?>">
            <input type="hidden" name="month" value="<? echo $month; ?>">
            <input type="hidden" name="day" value="<? echo $day; ?>">
            <input type="hidden" name="daypart" value="<? echo $daypart; ?>">
            <? if($daypart == 1){ $hour = sprintf('%02d', $hour - 12); } ?>
            <input type="hidden" name="hour" value="<? echo $hour; ?>">
            <input type="hidden" name="minute" value="<? echo $minute; ?>">
            <input type="hidden" name="year" value="<? echo $year; ?>">
            <input type="hidden" name="type" value="<? echo $type; ?>">
            <input type="hidden" name="bike_surface" value="<? echo $bike_surface; ?>">
            <input type="hidden" name="draft_legal" value="<? echo $draft_legal; ?>">
            <input type="hidden" name="kids_race" value="<? echo $kids_race; ?>">
            <input type="hidden" name="indivfee" value="<? echo stripslashes(htmlspecialchars($indivfee)); ?>">
            <input type="hidden" name="teamfee" value="<? echo stripslashes(htmlspecialchars($teamfee)); ?>">
            <input type="hidden" name="registration" value="<? echo $registration; ?>">
            <input type="hidden" name="swim" value="<? echo stripslashes(htmlspecialchars($swim)); ?>">
            <input type="hidden" name="bike" value="<? echo stripslashes(htmlspecialchars($bike)); ?>">
            <input type="hidden" name="run" value="<? echo stripslashes(htmlspecialchars($run)); ?>">
            <input type="hidden" name="oneunit" value="<? echo $oneunit; ?>">
            <input type="hidden" name="twounit" value="<? echo $twounit; ?>">
            <input type="hidden" name="threeunit" value="<? echo $threeunit; ?>">
            <input type="hidden" name="onetype" value="<? echo $onetype; ?>">
            <input type="hidden" name="twotype" value="<? echo $twotype; ?>">
            <input type="hidden" name="threetype" value="<? echo $threetype; ?>">
            <input type="hidden" name="state" value="<? echo $state; ?>">
            <input type="hidden" name="city" value="<? echo stripslashes(htmlspecialchars($city)); ?>">
            <input type="hidden" name="address" value="<? echo stripslashes(htmlspecialchars($address)); ?>">
            <input type="hidden" name="phone" value="<? echo stripslashes(htmlspecialchars($phone)); ?>">
            <input type="hidden" name="email" value="<? echo stripslashes(htmlspecialchars($email)); ?>">
            <input type="hidden" name="courseinfo" value="<? echo stripslashes(htmlspecialchars($courseinfo)); ?>">
            <input type="hidden" name="moreinfo" value="<? echo stripslashes(htmlspecialchars($moreinfo)); ?>">
            <input type="hidden" name="directions" value="<? echo stripslashes(htmlspecialchars($directions)); ?>">
            <input type="hidden" name="register" value="<? echo $register; ?>">
            <input type="hidden" name="website" value="<? echo $website; ?>">
            <input type="hidden" name="results" value="<? echo $results; ?>">
            <input type="hidden" name="sixresults" value="<? echo $sixresults; ?>">
            <input type="submit" name="submit" value="Edit Information" class="btn float-left" />
            <input type="hidden" name="picname1" value="<? echo $nametagmod1; ?>" />
            <input type="hidden" name="picname2" value="<? echo $nametagmod2; ?>" />
            <input type="hidden" name="picname3" value="<? echo $nametagmod3; ?>" />
            <input type="hidden" name="deletepics" value="1" />
        </form>
    </div>
  </div>
</div>
