<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Running Pace/Distance Calculator"
description="A calculator that runners can use to calculate distance ran, pace, and expected completion time."
author="Reid Kaiser"
author_email="rkaiser@codekaiser.com"
screenshot="http://hosting.gmodules.com/ig/gadgets/file/105249630059693176889/PaceCalc.png"
thumbnail="http://hosting.gmodules.com/ig/gadgets/file/105249630059693176889/PaceCalcThumb.png"
author_location="Colorado"
author_affiliation="CodeKaiser"
title_url="" 
scrolling="true" height="300" width="250"/>

<Content type="html">
<![CDATA[
<head>
<style type="text/css">
td {font-size: 10px; }
input { width: 25px; height: 15px; font-size: 10px;}
#calc .button { font-size: 10px; width: 50px; height: 25px;}
select { font-size: 10px;}
table.alerts{ text-align: center;font-family: Verdana;font-weight: normal;font-size: 11px;color: #404040;width: 200px;height: 250px;background-color: #fafafa;border: 1px #d79900 solid;border-collapse: collapse;border-spacing: 0px;}
.alertHd{ border-bottom: 2px solid #d79900;background-color: #fff2ba;text-align: center;font-family: Verdana;font-weight: bold;font-size: 11px;color: #404040;}
.alertBod p{ text-align: left;font-family: Verdana, sans-serif, Arial;font-weight: normal;font-size: 11px;line-height: 12px;color: #404040;background-color: #fafafa;text-indent: -8px;margin-left: 10px;margin-right: 10px;margin-top: 5px;margin-bottom: 5px;} 
span.{
        text-align: left;
text-indent: -8px;
        color: red;
	font-style:italic;
        margin-left: 10px;margin-right: 10px;
}
</style>

<script language="JavaScript" type="text/javascript">
<!-- Begin
var TIME = 1;
var DISTANCE = 2;
var PACE = 3;
var MILES = 0;
var KILOMETERS = 1;
var TRUE = 1;
var FALSE = 0;
function calcIT() 
{min=document.calc.timeM.value;sec=document.calc.timeS.value;time = (min * 1) + (sec / 60);distance = document.calc.distance.value;minP = document.calc.paceM.value;secP = document.calc.paceS.value;pace = (minP * 1) + (secP / 60);result = document.calc.calcWhat.options[document.calc.calcWhat.selectedIndex].value;if (result == TIME) {distConversion(TRUE);paceConversion(TRUE);time = distance * pace;min = document.calc.timeM.value = Math.floor(time);document.calc.timeS.value = Math.round(60 * (time - min)); }else if (result == DISTANCE) {paceConversion(TRUE);distance = time / pace;distConversion(FALSE);document.calc.distance.value = decimalPlaces(distance, 2);}else if (result == PACE) {distConversion(TRUE);pace = time / distance;paceConversion(FALSE);minP = Math.floor(pace);secP = Math.round(60 * (pace - minP));if (secP == 60) {minP++;secP = 0;}document.calc.paceM.value = minP;document.calc.paceS.value = secP; }}
function distConversion(toMeters) 
{if (document.calc.optDist[MILES].checked) {distance = (toMeters) ? (distance * 1609) : (distance / 1609); }else if (document.calc.optDist[KILOMETERS].checked) {distance = (toMeters) ? (distance * 1000) : (distance / 1000); }}
function paceConversion(toMeters) 
{if (document.calc.optPace[MILES].checked) {pace = (toMeters) ? (pace / 1609) : (pace * 1609); }else if (document.calc.optPace[KILOMETERS].checked) {pace = (toMeters) ? (pace / 1000) : (pace * 1000); }}
function decimalPlaces(val, places) 
{factor = 1;for (i = 0; i < places; i++) {factor *= 10;}val *= factor;val = Math.round(val);val /= factor;return val;}
function checkcalc() 
{choice = document.calc.calcWhat.selectedIndex;
if (choice == 0) 
{document.getElementById("instructions").innerText = "Please select what you would like to calculate: time, distance, or pace.";}
if (choice == 1) 
{document.calc.timeM.value='';document.calc.timeS.value='';document.getElementById("instructions").innerText = "To calculate your time, enter the race distance and your target pace.";}
if (choice == 2) {document.calc.distance.value='';document.getElementById("instructions").innerText = "To calculate your distance, enter the time elapsed and your pace.";}
if (choice == 3) {document.calc.paceM.value='';document.calc.paceS.value='';document.getElementById("instructions").innerText = "To calculate your pace, enter the race time and the distance."; }}
// End -->
</script>
</head>
<body> 
<center>
 <form name="calc" id="calc"> 
<table class="alerts"> 
<tr> <td width="250" valign="top" class="content"> 
<div align="center"> 
<table> 
<tr><td class="alertHd">Running Calculator</td></tr> 
<tr><td class="alertBod">
<select name="calcWhat" onchange="checkcalc();" size="1"> 
<option value="0" selected>- Choose - </option> 
<option value="1">Time </option> 
<option value="2">Distance </option> 
<option value="3">Pace </option> </select> </td></tr> 
<tr><td class="alertBod">Time:<input type="text" name="timeM" size="5" maxlength="5">min<input type="text" name="timeS" size="5">sec</td></tr> 
<tr><td class="alertBod">Distance:<input type="text" name="distance" size="5"></td></tr> 
<tr><td class="alertBod">(Measure in:<input type="radio" name="optDist" value="miles" checked>Miles<input type="radio" name="optDist" value="kilometers">K) </td></tr> 
<tr><td class="alertBod">Pace time:<input type="text" name="paceM" size="5">min<input type="text" name="paceS" size="5">sec</td></tr> 
<tr><td class="alertBod">(Pace distance:<input type="radio" name="optPace" value="miles" checked>Miles<input type="radio" name="optPace" value="kilometers">K)</td></tr> 
</div> </td> </tr> 
<tr> <td align="center"><input type="button" value="calculate" onclick="calcIT()" class="button"></td> </tr> 
<tr><td><span id="instructions" class="instr"></span></td></tr>
</table> 
</form>

<div align="center"> 
Brought to you by<br>
<a href="http://www.wishforwhat.com" target=_blank>www.wishforwhat.com</a>
</div>

</center>
</body>


]]></Content>
</Module>
















































