 var aa = "#FFFFFF";  
var ab = "#000000";  
var ac = "#007FFF";  
var ad = "#008000";  
var ae = "#FF0000";  
var af = "#FFE303";  
var ag = "#00FFFF";  
var ah = "#BEBEBE";  
var ai = "#00FF00";  
var aj = "#000080";  
var ak = "#800080";  
var al = "#C0C0C0";  
var am = "#800000";  
var an = "#808000";  
var ao = "#008080";  
var ap = "#FF6103";  
var aq = "#76EE00";  
var ar = "#FF00FF";  
var as = "#FF69B4";  
var at = "#CC00FF";  
 var au = new Array(0);  
au.push(ae);  
au.push(ac);  
au.push(ag);  
au.push(af);  
au.push(ar);  
au.push(as);  
au.push(ap);  
au.push(ak);  
au.push(ai);  
au.push(ao);  
au.push(at);  
au.push(aj);  
au.push(an);  
au.push(ad);  
au.push(am);  
au.push(ab);  
au.push(aa);  
au.push(ae);  
au.push(ac);  
au.push(ag);  
au.push(ai);  
 var av ;  
 var aw = new Array(0);  
var ax = new Array(0);  
var ay = 100;  
var az = new Array(0);  
 var ba = new Array(0);  
var bb = new Array(0);  
var bc = 100;  
 var bd = new Array(0);  
 function onLoad() {  
if (GBrowserIsCompatible()) {  
CustomGetTileUrl =  
function(a,b,c) {  
var be = new GPoint(a.x*256,(a.y+1)*256);  
var bf = new GPoint((a.x+1)*256,a.y*256);  
var bg = G_NORMAL_MAP.getProjection().fromPixelToLatLng(be,b,c);  
var bh = G_NORMAL_MAP.getProjection().fromPixelToLatLng(bf,b,c);  
var bi = bg.x+","+bg.y+","+bh.x+","+bh.y;  
var bj = "EPSG:4326";  
var bk = this.myBaseURL;  
bk+="&REQUEST=GetMap";  
bk+="&SERVICE=WMS";  
bk+="&reaspect=false&VERSION=1.1.1";  
bk+="&LAYERS="+this.myLayers;  
bk+="&STYLES=default";  
bk+="&FORMAT="+this.myFormat;  
bk+="&BGCOLOR=0xFFFFFF";  
bk+="&TRANSPARENT=TRUE";  
bk+="&SRS="+bj;  
bk+="&BBOX="+bi;  
bk+="&WIDTH=256";  
bk+="&HEIGHT=256";  
bk+="&GroupName="+this.myLayers;  
return bk;  
}  
var bl = new GTileLayer(new GCopyrightCollection(""),1,17);  
bl.myLayers='DRG';  
bl.myFormat='image/jpeg';  
bl.myBaseURL='http://www.terraserver-usa.com/ogcmap6.ashx?';  
bl.getTileUrl=CustomGetTileUrl;  
var bm = [bl];  
var bn = new GMapType(bm, G_SATELLITE_MAP.getProjection(), "Topo", G_SATELLITE_MAP);  
 av = new GMap2(document.getElementById("map"));  
av.addControl(new GLargeMapControl());  
av.setCenter(new GLatLng(mapCenterLat, mapCenterLng), initialMapScale);  
av.addControl(new GLargeMapControl());  
av.addControl(new GMapTypeControl());  
av.addControl(new GScaleControl());  
av.addControl(new AI());  
av.addMapType(bn);  
 AA("checkpoints.xml");  
for (var cs = 0; cs < numRoutes; cs++) {  
var bo = "team" + cs + ".xml";  
AC(bo, au[cs], cs, 2);  
}  
}  
} ;  
 function AA(xmlFileName) {  
GDownloadUrl(xmlFileName,  
function(data) {  
var bp = GXml.parse(data);  
var bq = bp.documentElement.getElementsByTagName("checkpoint");  
var br = 0;  
for (var cs = 0; cs < bq.length; cs++) {  
var bs = new GLatLng(parseFloat(bq[cs].getAttribute("lat")),  
parseFloat(bq[cs].getAttribute("lng")));  
if (cpDataContainsCPNums == 1) {  
br = bd.push(  
AB(parseInt(bq[cs].getAttribute("cpnum")),  
bs, bq[cs].getAttribute("clue")));  
} else {  
br = bd.push(  
AB(cs+1, bs, bq[cs].getAttribute("clue")));  
}  
av.addOverlay(bd[br-1]);  
}  
}  
);  
};  
 function AB(cpNum, ci, clue) {  
var bt = new GIcon();  
bt.image = "../../images/cp" + cpNum + ".png";  
bt.iconSize = new GSize(32, 32);  
bt.iconAnchor = new GPoint(16, 32);  
bt.infoWindowAnchor = new GPoint(16,30);  
 var bu = new GMarker(ci, bt);  
GEvent.addListener(bu, "click",  
function() {  
bu.openInfoWindowHtml("Checkpoint # " + cpNum + "<p>" +  
"clue = " + clue );  
}  
);  
return bu;  
};  
  function AC(xmlFileName, trackColor, tNum, trackWeight) {  
GDownloadUrl(xmlFileName,  
function(data) {  
var bp = GXml.parse(data);  
 var bw = bp.documentElement.getElementsByTagName("trackpoint");  
var bx = [];  
var by = tNum * ay;  
for (var cs = 0; cs < bw.length; cs++) {  
if (parseFloat(bw[cs].getAttribute("lat")) == 0) {  
aw[by] = (new GPolyline(bx, trackColor, trackWeight, "0.8"));  
by++;  
bx = [];  
} else {  
bx.push(new GLatLng(parseFloat(bw[cs].getAttribute("lat")),  
parseFloat(bw[cs].getAttribute("lng"))));  
}  
}  
aw[by] = (new GPolyline(bx, trackColor, trackWeight, "0.8"));  
by++;  
ax[tNum] = by;  
 az[tNum] = 0;  
 var cb = bp.documentElement.getElementsByTagName("timepoint");  
for (var cs = 0; cs < cb.length; cs++) {  
var cc = new GLatLng(parseFloat(cb[cs].getAttribute("lat")),  
parseFloat(cb[cs].getAttribute("lng")));  
ba[(tNum*bc) + cs] = (AH(cc,  
parseFloat(cb[cs].getAttribute("elaptime")),  
parseFloat(cb[cs].getAttribute("dist"))));  
av.addOverlay(ba[(tNum*bc) + cs]);  
av.removeOverlay(ba[(tNum*bc) + cs]);  
}  
bb[tNum] = cs;  
}  
);  
};  
 function AD(points) {  
var cd = "";  
var ce = 0;  
var cf = 0;  
var cg = 0;  
var ch = 0;  
 for(var cs = 0; cs < points.length; ++cs) {  
var ci = points[cs];  
 var cj = Math.floor(ci.lat() * 1e5);  
var ck = Math.floor(ci.lng() * 1e5);  
 cg = cj - ce;  
ch = ck - cf;  
 ce = cj;  
cf = ck;  
 cd += AF(cg) + AF(ch);  
}  
return cd;  
};  
 function AE(points) {  
var cl = "";  
for(var cs = 0; cs < points.length; ++cs) {  
var cm = 3;  
cl += AG(cm);  
}  
return cl;  
};  
 function AF(num) {  
var cn = num << 1;  
 if (num < 0) {  
cn = ~(cn);  
}  
 return(AG(cn));  
};  
 function AG(num) {  
var co = "";  
 while (num >= 0x20) {  
co += (String.fromCharCode((0x20 | (num & 0x1f)) + 63));  
num >>= 5;  
}  
 co += (String.fromCharCode(num + 63));  
return co;  
};  
  function AH(ci, hourNum, dist) {  
var cp = new GIcon();  
cp.image = "../../images/timemarker.png";  
cp.iconSize = new GSize(32, 32);  
cp.iconAnchor = new GPoint(16, 32);  
cp.infoWindowAnchor = new GPoint(16, 30);  
 var bu = new GMarker(ci, cp);  
GEvent.addListener(bu, "click",  
function() {  
bu.openInfoWindowHtml("Elapsed Time = " +  
((Math.round(hourNum/36))/100) + " hours" +  
"<p> Total Distance = " + ((Math.round(dist * 100))/100) +  
" meters (which = " +  
((Math.round(dist * 0.062))/100) + " miles)");  
}  
);  
return bu;  
};  
 function AI() {  
};  
 AI.prototype = new GControl();  
 function AJ(tNum) {  
var cs;  
if (az[tNum]) {  
for (cs = (tNum*ay); cs < ax[tNum]; cs++) {  
av.removeOverlay(aw[cs]);  
}  
for (cs = (tNum*bc); cs < (tNum*bc) + bb[tNum]; cs++) {  
av.removeOverlay(ba[cs]);  
}  
az[tNum] = 0;  
} else {  
for (cs = (tNum*ay); cs < ax[tNum]; cs++) {  
av.addOverlay(aw[cs]);  
}  
for (cs = (tNum*bc); cs < (tNum*bc) + bb[tNum]; cs++) {  
av.addOverlay(ba[cs]);  
}  
az[tNum] = 1;  
}  
};  
 AI.prototype.initialize = function(map) {  
var cs = 0;  
var ct = document.createElement("div");  
 if (numRoutes > 0) {  
var cu = document.createElement("div");  
this.setButtonStyle_(cu, au[0]);  
ct.appendChild(cu);  
cu.appendChild(document.createTextNode(teamNames[0]));  
GEvent.addDomListener(cu, "click", function() { AJ(0); });  
}  
 if (numRoutes > 1) {  
var cv = document.createElement("div");  
this.setButtonStyle_(cv, au[1]);  
ct.appendChild(cv);  
cv.appendChild(document.createTextNode(teamNames[1]));  
GEvent.addDomListener(cv, "click", function() { AJ(1); });  
}  
 if (numRoutes > 2) {  
var cw = document.createElement("div");  
this.setButtonStyle_(cw, au[2]);  
ct.appendChild(cw);  
cw.appendChild(document.createTextNode(teamNames[2]));  
GEvent.addDomListener(cw, "click", function() { AJ(2); });  
}  
 if (numRoutes > 3) {  
var cx = document.createElement("div");  
this.setButtonStyle_(cx, au[3]);  
ct.appendChild(cx);  
cx.appendChild(document.createTextNode(teamNames[3]));  
GEvent.addDomListener(cx, "click", function() { AJ(3); });  
}  
 if (numRoutes > 4) {  
var cy = document.createElement("div");  
this.setButtonStyle_(cy, au[4]);  
ct.appendChild(cy);  
cy.appendChild(document.createTextNode(teamNames[4]));  
GEvent.addDomListener(cy, "click", function() { AJ(4); });  
}  
 if (numRoutes > 5) {  
var cz = document.createElement("div");  
this.setButtonStyle_(cz, au[5]);  
ct.appendChild(cz);  
cz.appendChild(document.createTextNode(teamNames[5]));  
GEvent.addDomListener(cz, "click", function() { AJ(5); });  
}  
 if (numRoutes > 6) {  
var da = document.createElement("div");  
this.setButtonStyle_(da, au[6]);  
ct.appendChild(da);  
da.appendChild(document.createTextNode(teamNames[6]));  
GEvent.addDomListener(da, "click", function() { AJ(6); });  
}  
 if (numRoutes > 7) {  
var db = document.createElement("div");  
this.setButtonStyle_(db, au[7]);  
ct.appendChild(db);  
db.appendChild(document.createTextNode(teamNames[7]));  
GEvent.addDomListener(db, "click", function() { AJ(7); });  
}  
 if (numRoutes > 8) {  
var dc = document.createElement("div");  
this.setButtonStyle_(dc, au[8]);  
ct.appendChild(dc);  
dc.appendChild(document.createTextNode(teamNames[8]));  
GEvent.addDomListener(dc, "click", function() { AJ(8); });  
}  
 if (numRoutes > 9) {  
var dd = document.createElement("div");  
this.setButtonStyle_(dd, au[9]);  
ct.appendChild(dd);  
dd.appendChild(document.createTextNode(teamNames[9]));  
GEvent.addDomListener(dd, "click", function() { AJ(9); });  
}  
 if (numRoutes > 10) {  
var de = document.createElement("div");  
this.setButtonStyle_(de, au[10]);  
ct.appendChild(de);  
de.appendChild(document.createTextNode(teamNames[10]));  
GEvent.addDomListener(de, "click", function() { AJ(10); });  
}  
 if (numRoutes > 11) {  
var df = document.createElement("div");  
this.setButtonStyle_(df, au[11]);  
ct.appendChild(df);  
df.appendChild(document.createTextNode(teamNames[11]));  
GEvent.addDomListener(df, "click", function() { AJ(11); });  
}  
 if (numRoutes > 12) {  
var dg = document.createElement("div");  
this.setButtonStyle_(dg, au[12]);  
ct.appendChild(dg);  
dg.appendChild(document.createTextNode(teamNames[12]));  
GEvent.addDomListener(dg, "click", function() { AJ(12); });  
}  
 if (numRoutes > 13) {  
var dh = document.createElement("div");  
this.setButtonStyle_(dh, au[13]);  
ct.appendChild(dh);  
dh.appendChild(document.createTextNode(teamNames[13]));  
GEvent.addDomListener(dh, "click", function() { AJ(13); });  
}  
 if (numRoutes > 14) {  
var di = document.createElement("div");  
this.setButtonStyle_(di, au[14]);  
ct.appendChild(di);  
di.appendChild(document.createTextNode(teamNames[14]));  
GEvent.addDomListener(di, "click", function() { AJ(14); });  
}  
 if (numRoutes > 15) {  
var dj = document.createElement("div");  
this.setButtonStyle_(dj, au[15]);  
ct.appendChild(dj);  
dj.appendChild(document.createTextNode(teamNames[15]));  
GEvent.addDomListener(dj, "click", function() { AJ(15); });  
}  
 if (numRoutes > 16) {  
var dk = document.createElement("div");  
this.setButtonStyle_(dk, au[16]);  
ct.appendChild(dk);  
dk.appendChild(document.createTextNode(teamNames[16]));  
GEvent.addDomListener(dk, "click", function() { AJ(16); });  
}  
 if (numRoutes > 17) {  
var dl = document.createElement("div");  
this.setButtonStyle_(dl, au[17]);  
ct.appendChild(dl);  
dl.appendChild(document.createTextNode(teamNames[17]));  
GEvent.addDomListener(dl, "click", function() { AJ(17); });  
}  
 if (numRoutes > 18) {  
var dm = document.createElement("div");  
this.setButtonStyle_(dm, au[18]);  
ct.appendChild(dm);  
dm.appendChild(document.createTextNode(teamNames[18]));  
GEvent.addDomListener(dm, "click", function() { AJ(18); });  
}  
 if (numRoutes > 19) {  
var dn = document.createElement("div");  
this.setButtonStyle_(dn, au[19]);  
ct.appendChild(dn);  
dn.appendChild(document.createTextNode(teamNames[19]));  
GEvent.addDomListener(dn, "click", function() { AJ(19); });  
}  
 map.getContainer().appendChild(ct);  
return ct;  
};  
 AI.prototype.getDefaultPosition = function() {  
return new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(7, 7));  
};  
 AI.prototype.setButtonStyle_ = function(button, bgColor) {  
button.style.color = "#0000cc";  
button.style.backgroundColor = bgColor;  
button.style.font = "small Arial";  
button.style.border = "2px solid black";  
button.style.padding = "2px";  
button.style.marginBottom = "3px";  
button.style.textAlign = "center";  
button.style.width = "7em";  
button.style.cursor = "pointer";  
};  
  
