var atsym = '@';
var WindowObjectReference;
function mailto(n) {
openPopup('vht_mail_form.php?to=' + n);
}
function openPopup(page,name,width,height) {
if(WindowObjectReference == null || WindowObjectReference.closed)
{
var w = (width>0) ? width : window.outerWidth * .9;
var h = (height>0) ? height : window.outerHeight;
WindowObjectReference = window.open(page,"WindowObjectReference",
"resizable=yes,scrollbars=yes,status=yes,width=" + w + ",height=" + h);
}
else
{
WindowObjectReference.focus();
};
}
function LabeledMarker(latlng, options){
this.latlng = latlng;
this.labelText = options.labelText || "";
this.labelClass = options.labelClass || "markerLabel";
this.labelOffset = options.labelOffset || new GSize(0, 0);
this.clickable = options.clickable
if (options.draggable) {
options.draggable = false;
}
GMarker.apply(this, arguments);
}
LabeledMarker.prototype = new GMarker(new GLatLng(0, 0));
LabeledMarker.prototype.initialize = function(map) {
GMarker.prototype.initialize.apply(this, arguments);
var div = document.createElement("div");
div.className = this.labelClass;
div.innerHTML = this.labelText;
div.style.position = "absolute";
map.getPane(G_MAP_MARKER_PANE).appendChild(div);
if (this.clickable) {
var eventPassthrus = ['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout'];
for(var i = 0; i < eventPassthrus.length; i++) {
var name = eventPassthrus[i];
GEvent.addDomListener(div, name, newEventPassthru(this, name));
}
div.style.cursor = "pointer";
}
this.map = map;
this.div = div;
}
function newEventPassthru(obj, event) {
return function() {
GEvent.trigger(obj, event);
};
}
LabeledMarker.prototype.redraw = function(force) {
GMarker.prototype.redraw.apply(this, arguments);
if (!force) return;
var p = this.map.fromLatLngToDivPixel(this.latlng);
var z = GOverlay.getZIndex(this.latlng.lat());
this.div.style.left = (p.x + this.labelOffset.width) + "px";
this.div.style.top = (p.y + this.labelOffset.height) + "px";
this.div.style.zIndex = z + 1;
}
LabeledMarker.prototype.remove = function() {
GEvent.clearInstanceListeners(this.div);
this.div.parentNode.removeChild(this.div);
this.div = null;
GMarker.prototype.remove.apply(this, arguments);
}
function say(a) {GLog.write(a)}
var HTrailLists = [];
var map = '';
var Hiframe = '';
var HmapId = 'HmapDiv';
var HonLoadListB = new Array;
var HonLoadListA = new Array;
var HonUnloadList = new Array;
var HMapTypes = new Array();
var HMapWidth = '400px';
var HMapHeight = '300px';
var HFlag = '!';
var HShowSizeControl = 0;
var MapFile = "{$_SERVER['PHP_SELF']}";
var HNumM = new Array;
HonLoadListA[0]= new Function ("HLoadMap()");
HonUnloadList[0]= new Function ("GUnload()");
function HOnLoadJ(n, f) { 
var m = n + "()";
if (f) HonLoadListB[HonLoadListB.length] = new Function (m);
else HonLoadListA[HonLoadListA.length] = new Function (m);
}
function HOnUnload(n) { 
var m = n + "()";
HonUnloadList[HonUnloadList.length] = new Function (m);
}
function HShowCopyrightJ(m) {
alert(m);
}
function HMakeTrailInfoJ(info) {
HTrailInfo = info;
}
function HMakeMarkerJ(num,y,x,type,msg){
if(y!=0) {
if (!type) type = HInfoMarker;
var np = new GMarker(new GPoint(x, y),{icon: type, draggable: true, dragCrossMove: false, bouncy: false});
np.disableDragging();
var but = '';
if (msg!='') GEvent.addListener(np, "click", function(overlay,point) {if(!HeditTr)HMarkerClick(np,num,msg,but,point)});
HOverlayList[num] = np;
GEvent.addListener(np, "mouseover", function(overlay,point) {HMove(num)});
GEvent.addListener(np, "mouseout", function(overlay,point) {HMouseOutMk(num)});
}
HsegNum = num;
}
function HMakeSegJ(num,pathpoints,color,opacity,width,info) {
width = width || 5;
opacity = opacity || 1;
var p = HPts(pathpoints);
if (p[1][0] != undefined) {
HWP[num] = p[1];
HWPId[num] = p[2];
}
var p = p[0];
HOverlayList[num] = new GPolyline(p, "#" + color,width,opacity);
GEvent.addListener(HOverlayList[num], "click", function(point) {HTrailClick(point,num,info)})
GEvent.addListener(HOverlayList[num], "mouseover", function() {})
HPrev = num;
HsegNum = num;
}
function HMakePolygonJ(num,pathpoints,color,opacity,width,fillColor,fillOpacity,info) {
width = width || 5;
opacity = opacity || 1;
var p = HPts(pathpoints);
if (p[1][0] != undefined) {
HWP[num] = p[1];
HWPId[num] = p[2];
}
var p = p[0];
var len = p.length - 1;
if (p[0] != p[len-1] || p[1] != p[len]) { 
p[len+1] = p[0];
p[len+2] = p[1];
}
HOverlayList[num] = new GPolygon(p, "#" + color,width,opacity,"#" + fillColor,fillOpacity);
if (info != '') GEvent.addListener(HOverlayList[num], "click", function(point) {
if (HClickProc) map.openInfoWindowHtml(point,'<div style="white-space: nowrap;">' +  info + '<\/div>');
else HAddSegPoint(point);
})
GEvent.addListener(HOverlayList[num], "mouseover", function() {})
HPrev = num;
HsegNum = num;
}
function HMakeEncodedSegJ(num,pathpoints,levels,color,opacity,width,info) {
width = width || 5;
opacity = opacity || 1;
color = '#' + color;
HOverlayList[num] = new GPolyline.fromEncoded({
color: color,
weight: width,
opacity: opacity,
points: pathpoints,
levels: levels,
zoomFactor: 32,
numLevels: 4
});
GEvent.addListener(HOverlayList[num], "click", function(point) {HTrailClick(point,num,info)})
GEvent.addListener(HOverlayList[num], "mouseover", function() {})
HPrev = num;
HsegNum = num;
}
function HWindowSize(what) {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
if (what == 'width') return myWidth;
else return myHeight;
}
function HLoadMap() {
var mapdiv = document.getElementById(HmapId);
if (typeof(GIcon) == 'undefined') mapdiv.innerHTML = "<span style='color:red'>Sorry, there seems to be no connection to Google Maps.</span>";
else if (GBrowserIsCompatible() && mapdiv) {
HAddTopo();
if (HMapWidth != '') mapdiv.style.width = HMapWidth;
if (HMapHeight.substr(HMapHeight.length -1) == '%') HMapHeight = HWindowSize() * .01 * HMapHeight.substring(0,HMapHeight.length -1) + 'px';
if (HMapHeight != '') mapdiv.style.height = HMapHeight;
map = new GMap2(mapdiv, { mapTypes: HMapTypes });
map.setCenter(new GLatLng(HMCLatIni, HMCLonIni), HZoomIni);
var HMTypeIniL = HMTypeIni.toLowerCase();
if (HMTypeIniL == 'map') HMTypeIni = G_NORMAL_MAP;
if (HMTypeIniL == 'terrain') HMTypeIni = G_PHYSICAL_MAP;
if (HMTypeIniL == 'hybrid') HMTypeIni = G_HYBRID_MAP;
if (HMTypeIniL == 'topo') HMTypeIni = WMS_TOPO_MAP;
if (HMTypeIniL == 'topo - ms') HMTypeIni = WMS_TOPO_MAP;
if (HMTypeIniL == 'topo-ms') HMTypeIni = WMS_TOPO_MAP;
if (HMTypeIniL == 'satellite') HMTypeIni = G_SATELLITE_MAP;
if (HMTypeIniL == 'satellite - ms') HMTypeIni = WMS_DOQ_MAP;
if (HMTypeIniL == 'satellite-ms') HMTypeIni = WMS_DOQ_MAP;
map.setMapType(HMTypeIni);
HAddControls();
HFixCheckBox();
}
}
function HRemove(e) {
if (!e) e = window.document.body;
var id = e.id;
if (id != undefined && id != ''){
if (id == 'HmapDiv') return;
if (id == 'HmapDivCaption') {
e.style.display = 'block';
return;
}
if (e.style) e.style.display = 'none';
}
var kids = e.childNodes;
if (kids.length > 0) for (var i = 0; i < kids.length; i++) if (kids[i]) HRemove(kids[i]);
}
function HPortrait() {
map.getContainer().style.height = '900px';
map.getContainer().style.width = '700px';
}
function HLandscape() {
map.getContainer().style.height = '700px';
map.getContainer().style.width = '1000px';
}
function HNewCaption(t) {
var tx = t.value;
document.getElementById('HmapDivCaption').innerHTML = tx;
}
var o = ''
function HshowProfile(page, name) {
if (!name) name = '';
openPopup(page, name, 920, 600);
}
function HMarkerClick(np,num,msg,but,point) {
if (HeditTr) HMove(num);
else if (HClickProc) np.openInfoWindowHtml('<div style="white-space: nowrap;">' +  msg + but + '<\/div>');
else HAddSegPoint(point);
}
function HTrailClick(point,num,info) {
if (num == 0) {
HPLine.enableEditing();
return;
}
if (HeditTr) HEdit(num)
else if (info != '')
if (HClickProc) map.openInfoWindowHtml(point,'<div style="white-space: nowrap;">' +  info + '<\/div>');
else HAddSegPoint(point);
}
function Hsh(n) { 
sym = document.getElementById('HE' + n);
d = document.getElementById('Hdd' + n).style;
if (sym.alt == '-') {
sym.src = 'icons/box+.gif';
sym.alt = '+';
d.display = 'none';
}
else {
sym.src = 'icons/box-.gif';
sym.alt = '-';
d.display = 'block';
}
}
var Hhttp_request = false;
function HmakePOSTRequest(url, parameters) {
Hhttp_request = false;
if (window.XMLHttpRequest) {
Hhttp_request = new XMLHttpRequest();
if (Hhttp_request.overrideMimeType) {
Hhttp_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) {
try {
Hhttp_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
Hhttp_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!Hhttp_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
Hhttp_request.onreadystatechange = HalertContents;
Hhttp_request.open('POST', url, true);
Hhttp_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
Hhttp_request.setRequestHeader("Content-length", parameters.length);
Hhttp_request.setRequestHeader("Connection", "close");
Hhttp_request.send(parameters);
}
function HalertContents() {
if (Hhttp_request.readyState == 4) {
if (Hhttp_request.status == 200) {
result = Hhttp_request.responseText;
document.getElementById('HMailResponse').innerHTML = result;
} else {
alert('There was a problem with the request.');
}
}
}
function HAjaxPost(urla,ids) {
var url = arguments[0];
var poststr = '';
for (var i = 1;i < arguments.length; i++) {
poststr += arguments[i] + '=' + encodeURIComponent(document.getElementById(arguments[i]).value ) + "&";
}
HmakePOSTRequest(url, poststr);
}
function WMSCreateMap( name, copyright, baseUrl, layer, minResolution, maxResolution, urlArg ) {
var tileLayer = new GTileLayer( new GCopyrightCollection( copyright ), minResolution, maxResolution );
tileLayer.baseUrl = baseUrl;
tileLayer.layer = layer;
tileLayer.getTileUrl = WMSGetTileUrl;
tileLayer.getCopyright = function () { return copyright; };
var tileLayers = [ tileLayer ];
return new GMapType( tileLayers, G_SATELLITE_MAP.getProjection(), name, {urlArg: 'o' } );
}
function WMSGetTileUrl( tile, zoom ) {
var southWestPixel = new GPoint( tile.x * 256, ( tile.y + 1 ) * 256);
var northEastPixel = new GPoint( ( tile.x + 1 ) * 256, tile.y * 256);
var southWestCoords = G_NORMAL_MAP.getProjection().fromPixelToLatLng( southWestPixel, zoom );
var northEastCoords = G_NORMAL_MAP.getProjection().fromPixelToLatLng( northEastPixel, zoom );
var bbox = southWestCoords.lng() + ',' + southWestCoords.lat() + ',' + northEastCoords.lng() + ',' + northEastCoords.lat();
return this.baseUrl + '?VERSION=1.1.1&REQUEST=GetMap&LAYERS=' + this.layer + '&STYLES=&SRS=EPSG:4326&BBOX=' + bbox + '&WIDTH=256&HEIGHT=256&FORMAT=image/jpeg&BGCOLOR=0xCCCCCC&EXCEPTIONS=INIMAGE';
}
var WMS_TOPO_MAP;
var WMS_DOQ_MAP;
function HAddTopo(){
WMS_TOPO_MAP = WMSCreateMap( 'Topo - MS', 'Imagery by USGS / Web Service by TerraServer',
'http://msrmaps.com/ogcmap6.ashx', 'DRG', 4, 17, 't' );
WMS_DOQ_MAP = WMSCreateMap( 'Satellite - MS', 'Imagery by USGS / Web Service by TerraServer',
'http://msrmaps.com/ogcmap6.ashx', 'DOQ', 4, 18, 'o' );
HMapTypes.push(G_NORMAL_MAP);
HMapTypes.push(G_PHYSICAL_MAP);
HMapTypes.push(G_HYBRID_MAP);
HMapTypes.push(G_SATELLITE_3D_MAP);
HMapTypes.push(WMS_TOPO_MAP);
HMapTypes.push(G_SATELLITE_MAP);
HMapTypes.push(WMS_DOQ_MAP);
}
function HAddControls() {
map.addControl(new GLargeMapControl3D());
map.addControl(new GMapTypeControl());
scale = new GScaleControl();
scale.printable=function(){return true};
map.addControl(scale);
if (typeof(HShowSizeControl) != undefined && typeof(HSizeControl) == 'function') map.addControl(new HSizeControl(null, 'icons'));
}
function HOnLoadList() {
for (var i=0; i < HonLoadListB.length; i++) {
HonLoadListB[i]();
}
for (var i=0; i < HonLoadListA.length; i++) {
HonLoadListA[i]();
}
}
window.onload = HOnLoadList;
window.onunload = HonUnloadList;
function HFixCheckBox(){
var b = document.getElementById('HDet');
if (b) b.checked = 0;
var b = document.getElementById('HMiles');
if (b) b.checked = 1;
}
function createMarker(pointData) {
var latlng = new GLatLng(pointData.latitude, pointData.longitude);
var icon = new GIcon();
icon.iconAnchor = new GPoint(16, 16);
icon.infoWindowAnchor = new GPoint(25, 7);
opts = {
"icon": icon,
"labelText": pointData.abbr,
"labelOffset": new GSize(-16, -16)
};
var marker = new LabeledMarker(latlng, opts);
return marker;
}
function Hjscss(a,o,c1,c2) {
switch (a){
case 'swap':
o.className=!Hjscss('check',o,c1)?o.className.replace(c2,c1): o.className.replace(c1,c2);
break;
case 'add':
if(!Hjscss('check',o,c1)){o.className+=o.className?' '+c1:c1;}
break;
case 'remove':
var rep=o.className.match(' '+c1)?' '+c1:c1;
o.className=o.className.replace(rep,'');
break;
case 'check':
return new RegExp('\\b'+c1+'\\b').test(o.className)
break;
}
}
var HNNum = 0;
var HOverlayList = [];
var HTrails = [];
var HMarkerMsg = [];
var HOverlayDisplay = [];
var HPoiList = [];
var HTrailInfo = '';
var HLastClickPoint= '';
function HPts(a1,a2) { 
var r = new Array;
var p = new Array;
var wp = new Array;
var n = new Array;
var np = 0;
var nwp = 0;
if (!a2) {
a = a1.split(",");
for(i=0;i<a.length;i++){
if(isNaN(a[i])) {
wp[nwp]=np;
n[nwp] = a[i];
nwp++;
continue;
}
p[np] = new GLatLng(parseFloat(a[i]), parseFloat(a[++i]));
np++;
}
}
else for(i=0;i<arguments.length;i++){
if(isNaN(arguments[i])) continue;
p[np] = new GLatLng(parseFloat(arguments[i]), parseFloat(arguments[++i]));
np++;
}
r[0] = p;
r[1] = wp;
r[2] = n;
return r;
}
function HAddSeg(path,seg,lhtml) {
lhtml = lhtml || 1;
var t = '';
var told = '';
HFlag = "!";
for (var i=0;i<path.length;i++) {
told = t;
t += '["' + path[i] + '"]';
f = 'HTrailLists' + t;
try {
eval (f  + " += ['" + HFlag + "']")
}
catch(e) {
eval ('HTrailLists' + told + "= []")
eval (f  + " += ['" + HFlag + "']")
}
}
f[f.length] = seg;
HTrails[seg] = path[path.length-1];
}
function HAddOverlays(off) {
if (off == undefined) off = 1;
for(var i in HOverlayList){
HOverlayDisplay[i]=0;
if(!off) map.addOverlay(HOverlayList[i]);
if(HMarkerMsg[i])HAddMsg(i);
}
}
function HShowAll(start) {
for (var trail in HOverlayList) {
if (!HOverlayDisplay[trail]) map.addOverlay(HOverlayList[trail]);
HOverlayDisplay[trail] = 1;
}
var c = document.getElementsByName('showt');
for (var i=0;i<c.length;i++) {
c.item(i).checked = 1;
}
for (var p in HPoiList) {
if (!HOverlayDisplay[p]) map.addOverlay(HPoiList[p]);
HOverlayDisplay[p] = 1;
}
if (start == 1) {
for (var i=0;i<c.length;i++) {
if (c.item(i).className == 'cb_POI') c.item(i).click();
}
}
}
var HInfoMarker = new GIcon();
HInfoMarker.image = "./icons/marker_i.png";
HInfoMarker.shadow = "./icons/shadow50.png";
HInfoMarker.transparent = "./icons/marker_transparent.png";
HInfoMarker.imageMap = [1,8, 4,4, 1,8, 1,14, 18,4, 20,8, 20,13, 12,24, 8,24, 1,13];
HInfoMarker.iconSize = new GSize(20, 34);
HInfoMarker.shadowSize = new GSize(37, 34);
HInfoMarker.iconAnchor = new GPoint(10, 34);
HInfoMarker.infoWindowAnchor = new GPoint(10, 10);
var HParkingMarker = new GIcon();
HParkingMarker.image = "./icons/p_green.png";
HParkingMarker.shadow = "./icons/p_shadow.png";
HParkingMarker.transparent = "./icons/marker_transparent.png";
HParkingMarker.imageMap = [1,8, 4,4, 1,8, 1,14, 18,4, 20,8, 20,13, 12,24, 8,24, 1,13];
HParkingMarker.iconSize = new GSize(20, 20);
HParkingMarker.shadowSize = new GSize(30, 20);
HParkingMarker.iconAnchor = new GPoint(10, 20);
HParkingMarker.infoWindowAnchor = new GPoint(10, 10);
var HNoParkingMarker = new GIcon();
HNoParkingMarker.image = "./icons/p_green-no.png";
HNoParkingMarker.shadow = "./icons/p_shadow.png";
HNoParkingMarker.transparent = "./icons/marker_transparent.png";
HNoParkingMarker.imageMap = [1,8, 4,4, 1,8, 1,14, 18,4, 20,8, 20,13, 12,24, 8,24, 1,13];
HNoParkingMarker.iconSize = new GSize(20, 20);
HNoParkingMarker.shadowSize = new GSize(30, 20);
HNoParkingMarker.iconAnchor = new GPoint(10, 20);
HNoParkingMarker.infoWindowAnchor = new GPoint(10, 10);
var HxMarker = new GIcon();
HxMarker.image = "./icons/marker_x_yellow.png";
HxMarker.iconSize = new GSize(20, 20);
HxMarker.iconAnchor = new GPoint(10, 10);
HxMarker.infoWindowAnchor = new GPoint(10, 10);
var HSqMarker = new GIcon();
HSqMarker.image = "./icons/rmarker_blank.png";
HSqMarker.shadow = "./icons/rmarker_shadow.png";
HSqMarker.transparent = "./icons/rmarker_transparent.png";
HSqMarker.imageMap = [3,1, 27,1, 27,20, 3,20];
HSqMarker.iconSize = new GSize(28, 28);
HSqMarker.shadowSize = new GSize(40, 28);
HSqMarker.iconAnchor = new GPoint(10, 28);
HSqMarker.infoWindowAnchor = new GPoint(10, 10);
function HCreateMarker(name,image,base) {
if(base == null || base == '') base = "HInfoMarker";
eval(name + " = new GIcon(" + base + ");");
eval(name + ".image = './icons/" + image + "';");
}
HCreateMarker("HTrailMarker","marker_t.png");
HCreateMarker("HOtherMarker","marker_o.png");
HCreateMarker("HParkMarker","marker_p.png");
HCreateMarker("HSponsorMarker","marker_s.png");
HCreateMarker("HHikeMarker","marker_h.png");
HCreateMarker("HParkingMarker","p_green.png",'HParkingMarker');
HCreateMarker("HNoParkingMarker","p_green-no.png",'HNoParkingMarker');
HCreateMarker("HRedXMarker","flat_x_red.png",'HxMarker');
HCreateMarker("HYellowXMarker","flat_x_yellow.png",'HxMarker');
HCreateMarker("HEMarker","iconE.png");
HCreateMarker("HWPMarker","marker_w.png");
HCreateMarker("HQmMarker","marker_qm.png");
HCreateMarker("HStopMarker","marker_stop.png");
HCreateMarker("HCautionMarker","marker_caution.png");
HCreateMarker("HGreenMarker","marker_green.png");
HCreateMarker("HWaterTrailMarker","marker_t_light_blue.png");
HCreateMarker("HLaunchMarker","marker_l_light_blue.png");
HCreateMarker("HCrossMarker","marker_intersection.png");
HCreateMarker("HRightMarker","marker_right.png");
HCreateMarker("HLeftMarker","marker_left.png");
HCreateMarker("HTeeMarker","marker_tee.png");
HCreateMarker("HStraightMarker","marker_straight.png");
var baseIcon = new GIcon();
baseIcon.shadow = "./icons/shadow50.png";
baseIcon.transparent = "./icons/marker_transparent.png";
baseIcon.imageMap = [1,8, 4,4, 1,8, 1,14, 18,4, 20,8, 20,13, 12,24, 8,24, 1,13];
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);
var HLastIndex = -1;
function HCreateNumMarker(point, index, preload) {
if (index==='') index = HLastIndex++;
if (index > 99) {
if (index % 100 == 0) index = '00'
else index = index % 100
}
if (index > 10) {
var u = index % 10
if (u != 0) index = u
}
var image = "./icons/icon" + index + ".png";
var marker;
if (!preload) {
var icon = new GIcon(baseIcon);
icon.image = image
HLastIndex = index;
marker = new GMarker(point, {icon: icon, clickable: false});
HNumM[index] = marker;
HCreateNumMarker(point, index+1, 1);
}
else {
document.getElementById('HPreLoad').src = image
marker = '';
}
return marker;
}
function HPrintShow(){
Hjscss('remove',document.getElementById("HRemoveMe"),'HHide');
Hjscss('remove',document.getElementById("HmapDivCaption"),'HHide');
Hjscss('add',document.getElementById("HPrintB"),'HHide');
HLandscape();
Hjscss('add',document.getElementById("HPrintIt"),'HSolidBorder');
}
function HPrintHide(){
Hjscss('add',document.getElementById("HRemoveMe"),'HHide');
Hjscss('add',document.getElementById("HmapDivCaption"),'HHide');
Hjscss('remove',document.getElementById("HPrintB"),'HHide');
Hjscss('remove',document.getElementById("HPrintIt"),'HSolidBorder');
}
function HAddElement(t,p) { 
var nel = document.createElement(t);
for (var i = 2; i < arguments.length; i+=2) {
nel.setAttribute(arguments[i],arguments[i+1]);
}
var pn = document.getElementById(p);
pn.appendChild (nel);
}
function HAddTextNode(p,t) {
var t = document.createTextNode(t);
var p = document.getElementById(p);
p.appendChild(t);
}
function HonLoadPed() {
GEvent.addListener(map, "click", function(overlay, point) {HAddSegPoint(point)});
GEvent.addListener(map, "mousemove", function(point) {HmouseMove(point)});
GEvent.addListener(map, "singlerightclick", function(point,scr,overlay) {alert(point + ', src=' + src)});   
}
HOnLoadJ('HonLoadPed');
HPedDisp = 0;
var HWPD = 0;
var HWPNum = 1;
var HWPNumMk = [];
var HEMark;
var HWPMk = [];
var HTDist = '';
var HWPN = '';
var HPList = [];
var HPLpt = 1;
var HPedSeg = [];
HPedSeg[0] = 0;
var HTDistMv = 0;
var HWPList = []; 
var HWPDist = [];
HWPDist[0] = 0;
var HToAddress = "";
var HRecord = 0;
var HWPRecord = 0;
var HMFac = 0.621371192;
var HShowDetails = 0;
var HShowElevation = 0;
var HFDeg = 0; 
var HElId = 0;
var HRId = 0;
var Hfirstwp = 'Start';
var HAJAXn = 0;
var HTMark = '';
var HeditTr = 0;
var HMoveN;
var HMoveS;
var HMWPm;
var HMWPp = 1;
var HEPoly = '';
var HLastWP = '';
var Hpp = new GPoint(0,0);
var Hzero = Hpp;
var Htotd = 0;
var Hddd = 0;
var HEditSeg;
function HReshow() {
HElId = 0;
HRId = 0;
HPLpt = 1;
var pts = HPList;
var wps = HWPList;
HUndoPed(1);
HWPNum = 1;
var oHR = HRecord;
HRecord = 1;
var j = 0;
for(var i=0;i<pts.length;i++) {
HAddSegPoint(pts[i]);
if (wps[i] != null) {
HAddWayPoint(wps[i]);
j++;
}
}
HEndAdd();
var exim = document.getElementById('HExIm')
if (exim) exim.className = (HShowDetails) ? 'HShow' : 'HHide';
HRecord = oHR;
}
function HTMOver(num, rid) {
HTMOut(rid);
if (HPList[num]) {
HTMark = new GMarker(HPList[num], HWPMarker);
map.addOverlay(HTMark);
}
document.getElementById(rid).style.color = 'red';
var d = document.getElementById('HPwpDispData');
var dd = document.getElementById(rid).firstChild.innerHTML.replace(' ', '');
if (dd == '') dd = '-';
if (d) d.innerHTML = dd;
}
function HTMOut(rid){
map.removeOverlay(HTMark);
document.getElementById(rid).style.color = 'black';
}
function HmouseMove(p) {
var distbox = document.getElementById('Hddd');
if (Hpp == Hzero) {
}
else {
Hddd = HMFac * Hpp.distanceFrom(p) * .001;
distbox.innerHTML = Hddd.toFixed(4)  + 'mi (' + parseInt(Hddd * 5280, 10) + "'), " + (Htotd + Hddd).toFixed(4);
}
}
function HChangeWP(rn) {
var col = (HShowDetails) ? 4 : 0
var rid = parseInt(rn, 10);
rid = 'R' + rid
var row = document.getElementById(rid);
var cn = row.getElementsByTagName('td');
HWPList[rn] = cn[col].firstChild.value;
}
function HAddSegPoint(point){
if (!point) return;
if (!isNaN(point.lat())) {
}
if (HRecord) {
HElId++;
HRId++;
var rid = 'R' + HRId;
HPList[HPLpt] = point;
var x = point.lng().toString().substr(0,9);  
var y = point.lat().toString().substr(0,8);
if (HPLpt == 1) { 
var fwp = HWPList[0] || Hfirstwp;
HWPNumMk[0] = point;
HWPMk[0] = HCreateNumMarker(HPList[1],0);
map.addOverlay(HWPMk[0]);
if (HShowDetails) {
HAddElement('tr','HTB','id',rid, 'onmouseover', 'HTMOver("' + HPLpt +'","' +  rid + '")', 'onmouseout', 'HTMOut("' +  rid + '")' );
HAddElement('td',rid,'id',0 + rid);
HAddTextNode(0 + rid,HDeg2DMS(y,1) + ", " + HDeg2DMS(x,1));
HAddElement('td',rid,'id','HE' + HElId,'name','HEl','class','Hml');
HAddElement('td',rid,'id',1 + rid,'class','Hml');
HAddTextNode(1 + rid,'0');
HAddElement('td',rid,'name','HDis','id',2 + rid);
HAddTextNode(2 + rid,'0');
var tds = document.getElementById(2 + rid);
tds.setAttribute('id','HDis');
HAddElement('td',rid,'id',3 + rid);
HAddElement('input',3 + rid, 'value', fwp, 'onchange', 'HChangeWP("' + HPLpt + '")');
HAddElement('td',rid,'id',4 + rid, 'value', 'E', 'onclick', 'HDelWP("' + (HPLpt - 1) + '")');
HAddTextNode(4 + rid,'Delete');
}
else {
HAddElement('tr','HTB','id',rid, 'onmouseover', 'HTMOver("' + HPLpt +'","' +  rid + '")', 'onmouseout', 'HTMOut("' +  rid + '")' );
HAddElement('td',rid,'name','HDis','id',2 + rid);
HAddElement('input',2 + rid, 'value', fwp, 'onchange', 'HChangeWP("' + HPLpt + '")');
var tds = document.getElementById(2 + rid);
tds.setAttribute('id','HDis');
HAddElement('td',rid,'id',3 + rid);
HAddTextNode(3 + rid,'0');
HAddElement('td',rid,'id',4 + rid);
HAddTextNode(4 + rid,'0');
}
}
else {
var ddm = point.distanceFrom(HPList[HPLpt-1]) * .001;
HWPD += ddm;
HPedSeg[HPLpt] = ddm;
HTDistMv += ddm;
if (HShowDetails) {
HAddElement('tr','HTB','id',rid, 'onmouseover', 'HTMOver("' + HPLpt +'","' +  rid + '")', 'onmouseout', 'HTMOut("' +  rid + '")' );
HAddElement('td',rid,'id',0 + rid);
HAddTextNode(0 + rid,HDeg2DMS(y,1) + ", " + HDeg2DMS(x,1));
HAddElement('td',rid,'id','HE' + HElId,'name','HEl','class','Hml');
HAddElement('td',rid,'id',1 + rid,'class','Hml');
HAddTextNode(1 + rid,(HMFac*ddm).toFixed(2));
HAddElement('td',rid,'name','HDis','id',2 + rid);
HAddTextNode(2 + rid,(HMFac*HTDistMv).toFixed(2));
var tds = document.getElementById(2 + rid);
tds.setAttribute('id','HDis');
HAddElement('td',rid,'id',3 + rid);
HAddElement('input',3 + rid, 'value', 'E', 'onchange', 'HChangeWP("' + HPLpt + '")');
HAddElement('td',rid,'id',4 + rid, 'value', 'E', 'onclick', 'HDelWP("' + (HPLpt - 1) + '")');
HAddTextNode(4 + rid,'Delete');
if (HRId > 1) {
var pr = HRId - 1;
var tds = document.getElementById("R" + pr).childNodes;
var inp = tds[4].childNodes;
if (inp[0].value == 'E') {
inp[0].value = '';
}
}
}
else {
HRId--;
var tds = document.getElementById("R" + HRId).childNodes
var inp = tds[0].childNodes;
if (inp[0].value == 'E') {
var t = document.getElementById('HTB');
var r = document.getElementById("R" + HRId);
t.removeChild(r);
}
HAddElement('tr','HTB','id',rid, 'onmouseover', 'HTMOver("' + HPLpt +'","' +  rid + '")', 'onmouseout', 'HTMOut("' +  rid + '")' );
HAddElement('td',rid,'name','HDis','id',2 + rid);
HAddElement('input',2 + rid, 'value', 'E', 'onchange', 'HChangeWP("' + HPLpt + '")');
var tds = document.getElementById(2 + rid);
tds.setAttribute('id','HDis');
HAddElement('td',rid,'id',3 + rid);
HAddTextNode(3 + rid,(HMFac*HWPD).toFixed(2));
HAddElement('td',rid,'id',4 + rid);
HAddTextNode(4 + rid,(HMFac*HTDistMv).toFixed(2));
HRId++;
}
}
HPLpt++;
}
Hpp = point;
Htotd += Hddd;
}
function HDelWP(n) {
n = parseInt(n);
HEditSeg.deleteVertex(n);
HPList[n+1] = null;
var rnum = n + 1;
var rid = 'R' + rnum;
document.getElementById(0 + rid).innerHTML = '';
document.getElementById(4 + rid).innerHTML = '';
document.getElementById(4 + rid).removeEventListener('onclick',HDelWP,false);
document.getElementById('HPwpDispData').innerHTML = '-';
}
function HEndAdd() {
HOverlayList[HsegNum] = new GPolyline(HPList, "#FF0000", 5);
map.addOverlay(HOverlayList[HsegNum]);
GEvent.addListener(HOverlayList[HsegNum], "click", function(point) {HTrailClick(point,HsegNum,'')})
HsegNum++;
if (HEMark) map.removeOverlay(HEMark);
if (HPList.length > 0) {
HEMark = HCreateNumMarker(HPList[HPLpt-1],HWPNum);
map.addOverlay(HEMark);
}
var col = (HShowDetails) ? 4 : 0;
var pr = HPLpt - 1;
if (document.getElementById("R" + pr)) {
var tds = document.getElementById("R" + pr).childNodes;
var inp = tds[col].childNodes;
if (inp[0].value == 'E') inp[0].value = (HLastWP == '') ? 'End' : HLastWP;
if (HShowDetails) {
}
}
}
function HAddElevs() {
var b = document.getElementById('HTB');
var rows = b.childNodes;
var latlon = HToText(1).split(',');
var n = 0;
for (var i = 0; i < rows.length; i++) {
if (isNaN(latlon[n])) {
n++;
i--;
continue;
}
var cells = rows[i].childNodes;
if ( cells[1].innerHTML == '') HGetElevation(latlon[n],latlon[n+1],cells[1].id, 'HEl');
n += 2;
}
}
function HAddWayPoint(n,line) {
if (n) while (n[0] == ' ') n = n.substr(1);
else n = '';
if (n[0] == '"' || n[0] == "'") {
if (n[n.length-1] == n[0]) {
n = n.substr(1,n.length - 2);
}
}
if (line) var rid = 'R' + line;
else var rid = 'R' + HRId;
HWPList[HPLpt-1] = n;
if (HPList[HPLpt-1] != undefined){
HWPNumMk[HWPNum] = new GLatLng(HPList[HPLpt-1].lat(),HPList[HPLpt-1].lng());
HWPMk[HWPNum] = HCreateNumMarker(HPList[HPLpt-1],HWPNum);
if (HEMark) map.removeOverlay(HEMark);
map.addOverlay(HWPMk[HWPNum]);
HWPDist[HWPNum] = HMFac*HTDistMv;
if (HShowDetails) {
var tds = document.getElementById("R" + HRId).childNodes;
tds[4].childNodes[0].value = n
}
else {
var tds = document.getElementById("R" + HRId).childNodes;
tds[0].childNodes[0].value = n
}
HWPD = 0;
HWPNum++;
}
}
function HUndoPed(all) {
if (all || HPLpt < 1) {
if (HEMark) map.removeOverlay(HEMark);
for (var i=0;i<HWPMk.length;i++) {
map.removeOverlay(HWPMk[i]);
}
var b = document.getElementById("Hrec_tab");
if (b) {
var th = b.getElementsByTagName("thead");
var rs = th[0].childNodes;
if (rs.length > 0) for (var i=rs.length-1;i>-1;i--) {
th[0].removeChild(rs[i]);
}
var th = document.getElementById("HTB");
var rs = th.childNodes;
if (rs.length > 0) for (var i=rs.length-1;i>-1;i--) {
th.removeChild(rs[i]);
}
var th = document.getElementById("HTF");
var rs = th.childNodes;
if (rs.length > 0) for (var i=rs.length-1;i>-1;i--) {
th.removeChild(rs[i]);
}
}
HWPD = 0;
HWPNum = 1;
HWPNumMk = [];
HWPMk = [];
HTDist = '';
HWPN = '';
HRId = 0;
HPList = [];
HPLpt = 1;
HPedSeg = [];
HPedSeg[0] = 0;
HTDistMv = 0;
HWPList = [];
if (HMWPm) map.removeOverlay(HMWPm);
HMWPm = null;
HMWPp = 1;
b = document.getElementById('Hrtd');
if (HShowDetails) {
HMakeHeadRow("Latitude, Longitude","\u00a0  Elev. ","\u00a0   Seg.","\u00a0 Tot. ","\u00a0 Way Point ");
if (b) {
var o = "<button onclick='HAddElevs()'>Add Elevations<\/button> &nbsp;<button id=HShGrB onclick='HShowGraph()'>Show Graph<\/button> <input type=radio name=Hdms id=HDFcb onclick='HDMS(0)' checked>&deg;<input type=radio name=Hdms onclick='HDMS(1)'>&deg; '<input type=radio name=Hdms onclick='HDMS(2)'>&deg; '";
o += "\n<br>Track Way Points: <button id=HMWPcbd onclick='HMWP(-1)'>&lt;</button><button id=HMWPcb onclick='HMWP(0)'>WP</button><button id=HMWPcbu onclick=HMWP(1)>&gt;</button>";
o += "\n<table id=HPwpDisp style=color:red align=center><tr><td id=HPwpDispData>-</td></tr><tr><td></td></tr></table>";
b.innerHTML = o;
document.getElementById('HMWPcbd').disabled = true;
document.getElementById('HMWPcbu').disabled = true;
}
}
else {
HMakeHeadRow("Way Point","Seg.","Tot.");
if (b) b.innerHTML = " ";
}
HMakeHeadRow(" ");
} 
}
function HMakeHeadRow() {
var hr = document.createElement('tr');
for (var i = 0; i < arguments.length; i++) {
var h = document.createElement('th');
var t = document.createTextNode(arguments[i]);
h.style.textAlign = 'center';
h.appendChild (t);
hr.appendChild (h);
}
var p = document.getElementById('Hrec_tab');
if (p) {
var th = p.firstChild;
th.appendChild(hr);
}
}
function HShowGraph() {
if(HShowDetails) {
var d = document.getElementsByName('HDis');
var x = '';
for (var i = 0; i < d.length; i++) {
x += "," + d[i].innerHTML;
}
x = x.substr(1);
var y = '';
var d = document.getElementsByName('HEl');
for (var i = 0; i < d.length; i++) {
y += "," + d[i].innerHTML;
}
y = y.substr(1);
var wpd = ''
var wpn = ''
var t = document.getElementById('HTB');
var ra = t.getElementsByTagName('tr');
var c = 0;
for (var i = 0; i<ra.length;i++) {
var cn = ra[i].getElementsByTagName('td');
if (cn[4] && cn[4].firstChild.value != '') {
wpd += "," + cn[3].innerHTML;
wpn += "," + cn[4].firstChild.value;
c++;
}
}
wpd = wpd.substr(1);
wpn = wpn.substr(1);
wpd = wpd.replace(/ */g,'');
var w = 0;
var h = 0;
var d = document.getElementById('HPImg');
if (d) {
w = d.width;
h = d.height;
}
if (!w || w == undefined || w == 0) w = 900;
if (!h || h == undefined || h == 0) h = 400;
var url = 'jhm_draw_graph.php';
ne = document.getElementById('HPImg_i');
if (ne) ne.parentNode.removeChild(ne);
var jsel = document.createElement('IMG');
jsel.type = 'image/gif';
jsel.type = 'text/html';
jsel.height = h;
jsel.width = w;
jsel.id = 'HPImg_i';
jsel.src = url  + '?x=' + x + '&y=' + y + '&wpd=' + wpd + '&wpn=' + wpn + '&h=' + h + '&w=' + w;
jsel.alt = "Graph of Elevations";
d.appendChild (jsel);
}
}
function HTogRecord(button) {
if (button == 'HRecBut') {
HRecord = !HRecord;
HClickProc = !HClickProc;
}
var rb = document.getElementById(button);
if (HRecord) rb.innerHTML = 'Stop';
else rb.innerHTML = 'Start';
}
function HGetWayPoints() {
var wpl = [];
var t = document.getElementById('HTB');
var ra = t.getElementsByTagName('tr');
for (var i = 0; i<ra.length;i++) {
var cn = ra[i].getElementsByTagName('td');
if (cn[4] && cn[4].firstChild.value != '') {
wpl[i] = cn[4].firstChild.value;
}
}
return wpl;
}
function HToText(email) {
var o = '';
var fsep = ',';
var ssep = ', ';
var wwp = document.getElementById('HWithWP').checked;
var wwpq = document.getElementById('HWithWPq').checked;
var wpl = []
if (wwp || wwpq) wpl = HGetWayPoints();
for(var i=1;i < HPList.length;i++) {
if (HPList[i] == null) continue;
var x = parseFloat(HPList[i].lng());   
var y = parseFloat(HPList[i].lat());
var t = (wpl[i-1]) ? wpl[i-1].replace("'","\\'") : null;
o += (email) ? y + ',' + x : HDeg2DMS(y.toFixed(5)) + fsep + HDeg2DMS(x.toFixed(5));
if (t != null) {
if (i == 1) {
o += (wwp) ? ',"' + t + '"': '';
o = (wwpq) ? "'" + t + "'," + o : o;
}
else {
o += (wwp) ? ',"' + t + '"': '';
o += (wwpq) ? ",'" + t + "'": '';
}
}
o += ssep;
}
o = o.substr(0,o.length-2);
if (email) return o;
else {
var b = document.getElementById("HToTextId");
b.value = o;
}
}
function HCloseEmail() {
var b = document.getElementById('HMailBox');
var p = b.parentNode;
p.removeChild(b);
}
function HToEmail(toadr) {
if (!toadr) toadr = '';
var latlon = HToText(1);
var o = '';
o += "<br>Response: <div id=HMailResponse></div>"
o += "\n<div id=HMailBox style='border:solid red'>";
o += "\n<span class=centered>Email Selected Path</span>";
if (latlon.length == 0) o+= "\n<div style='color:red'>Select a path by clicking \"Start\" then clicking on the map. Then click \"Email Path\" again.</div>";
o += "\n<input type=hidden id=Hlatlon name=Hlatlon value=\"" + latlon + "\">";
o += "\n<input type=hidden id=Hhtmlreturn name=Hhtmlreturn value=\"" + MapFile + "\">";
o += "\n<br>To: <input type=text id=Hto name=Hto size=50 maxlength=200 value=" + toadr + ">(Full email address(es), separated by commas.)";
o += "\n<br>From: <input type=text id=Hfrom name=Hfrom size=50 maxlength=200>(Your email address for CC.)";
o += "\n<br>Subject: <input type=text id=Hsubject name=Hsubject size=50 maxlength=200 value='Request for map update'>";
o += "\n<br><br>Group:";
o += "\n<select id=Hgroup name=Hgroup>\n<option selected>Other (use comments)</option>";
for (var j in Hl1) {
o += "\n<option>" + Hl1[j] + "</option>";;
}
o += "\n</select>";
o += "\n<br>Trail Name:";
o += "<input type=text id=Htrailname name=Htrailname>";
o += "\n<br><br><label>Color:";
o += "<select id=Hcolor name=Hcolor>";
o += "\n<option value='other' selected>Other (use comments)</option>";
o += "<option value=#000000>Black</option>";
o += "<option value=#804000>Brown</option>";
o += "<option value=#ff0000>Red</option>";
o += "<option value=#ff8040>Orange</option>";
o += "<option value=#ffff00>Yellow</option>";
o += "<option value=#00ff00>Green</option>";
o += "<option value=#0000ff>Blue</option>";
o += "<option value=#800080>Violet</option>";
o += "<option value=#808080>Grey</option>";
o += "<option value=#ffffff>White</option>";
o += "\n</select></label>";
o += "\n<br>Transparency: ";
o += "\n<select id=Hopacity name=Hopacity>";
o += "\n<option value=.1>10% (very faint)</option>";
o += "<option value=.2>20%</option>";
o += "<option value=.3>30%</option>";
o += "<option value=.4>40%</option>";
o += "<option value=.5>50%</option>";
o += "<option value=.6>60%</option>";
o += "<option value=.7 selected>70%</option>";
o += "<option value=.8>80%</option>";
o += "<option value=.9>90%</option>";
o += "<option value=1>100% (covers anything)</option>";
o += "\n</select>";
o += "\n<br>Width (pixels): ";
o += "\n<select id=Hwidth name=Hwidth>";
o += "\n<option value=1>1</option>";
o += "<option value=2>2</option>";
o += "<option value=3 selected>3 (footpath)</option>";
o += "<option value=4>4</option>";
o += "<option value=5>5</option>";
o += "<option value=6>6</option>";
o += "<option value=7>7</option>";
o += "<option value=8>8</option>";
o += "<option value=9>9 (improved multiuse)</option>";
o += "\n</select>";
o += "\n<br><br>InfoWindow (Shown when trail is clicked. Optional):<br><textarea id=HinfoWindow name=HinfoWindow rows=5 cols=40></textarea>";
o += "\n<br><br>Comments: <textarea id=Hcomments name=Hcomments rows=5 cols=80></textarea>";
o += "\n<br>Your Name:";
o += "\n<input type=text id=Hsender name=Hsender size=50>";
o += "\n<button name='button' onclick='HAjaxPost(\"jhm_mailsender.php\",";
o += "\"Hlatlon\",\"Hhtmlreturn\",\"Hto\",\"Hfrom\",\"Hsubject\",\"Hgroup\",\"Htrailname\",\"Hcolor\",";
o += "\"Hopacity\",\"Hwidth\",\"HinfoWindow\",\"Hcomments\",\"Hsender\");HCloseEmail();'>";
o += "Send</button>"
o += "\n<button onclick=HEmailCan()>Cancel</button>";
o += "\n</div>";
var ms = document.getElementById('HMailDiv');
if (ms) ms.innerHTML = o;
ms = document.getElementById('HEmail');
ms.className = 'HShow';
}
function HEmailCan() {
ms = document.getElementById('HEmail');
ms.className = 'HHide';
}
function HToLL(o,wp) {  
var pts_supplied = 0;
if (!o || o == '') {
var b = document.getElementById("HToTextId");
var o = b.value;
o = o.toLowerCase();
o = o.replace(/,?\n/g,", ");
}
else pts_supplied = 1;
var hrec = HRecord;
HRecord = 1;
var wpa = new Array();
if(wp) {
for(;wp != '';) {
var pc = wp.indexOf(',');
if (pc == -1) break;
var y = wp.substr(0, pc);
wp = wp.substr(pc+1);
pc = wp.indexOf(',');
if (pc == -1) {
var x = wp;
wp = '';
}
else {
var x = wp.substr(0, pc);
wp = wp.substr(pc+1);
}
x = x.replace(/[+ ]g/, '');
y = y.replace(/[+ ]g/, '');
wpa.push(new GLatLng(y,x));
}
}
var firstwp = '';
for(var i=0;o != '';i++) {
o = trim(o);
pc = o.indexOf(',');
if (pc == -1) pc = o.indexOf("\t");
if (pc == -1) {
if (o.indexOf("w") > 1) pc = o.indexOf("w") - 1; 
else if (o.indexOf("x:") > -1) {   
var px = o.indexOf("x:");
var py = o.indexOf("y:");
if (py > -1) {
if (py > px) {
var lat = o.substr(py + 3);
var lon = o.substring(px +3,py);
pc = (o + ' ').indexOf(' ',py + 3);
o = lat + ',' + lon + ',' + o.substr(pc)
pc = o.indexOf(',');
}
}
}
}
if (pc == -1) {
if (o != '') HAddWayPoint(o);
break;
}
var first = o.substr(0, pc);
if (first.indexOf("w") > -1 || first.indexOf("e") > -1 ) {
o = o.substr(pc+1);
pc = o.indexOf(',');
if (pc == -1) pc = o.indexOf("\n");
if (pc == -1) pc = o.indexOf("\t");
if (pc == -1) {
var pn = o.indexOf('n');
if (pn < 1) pc = o.indexOf(" ");
}
var sec = o.substr(0, pc);
if (sec == '') {
sec = o;
o = '';
}
o = o.substr(pc+1);
o = (o == '') ? sec + ',' + first : sec + ',' + first + ',' + o;
first = sec;
pc = o.indexOf(',');
}
y = HLL(first);
o = o.substr(pc+1);
if (firstwp != '') {
HAddWayPoint(firstwp);
firstwp = '';
}
if (isNaN(y)) {
if (i == 0) firstwp = y;
else HAddWayPoint(y);
}
else {
var pc = o.indexOf(',');
if (pc == -1) {
x = HLL(o);
o = '';
}
else {
x = HLL(o.substr(0, pc));
o = o.substr(pc+1);
}
if(!isNaN(x)) {
HLastWP = '';
var point = new GLatLng(y,x);
HAddSegPoint(point);
}
else HLastWP = x;
}
if(wpa) for (var i = 0; i<wpa.length; i++) {
if(wpa[i].equals(point)) HAddWayPoint();
}
}
if (HLastWP[0] == "'") HLastWP = HLastWP.substr(1);
if (HLastWP[HLastWP.length-1] == "'") HLastWP = HLastWP.substr(0,HLastWP.length-1);
HEndAdd();
HRecord = hrec;
}
function trim (str) {  
var str = str.replace(/^\s\s*/, '');
var ws = /\s/;
var i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
}
function HLL(n) {   
var qp = /^\s*(['"]?)/;
var q = n.match(qp);
if (q[1] != '') return n; 
n = n.replace(/^[+\s]*/, ''); 
n = n.replace(/\u00B0/g, 'd'); 
var d = /\s*([\.\d\-\s'"do]*)([NESW]?)([\.\d\-\s'"d]*)/i;
var f = n.match(d);
var c = f[2].toLowerCase();
n = f[1] + ' ' + f[3];      
var sng = (c == 's' || c == 'w') ? -1 : 1; 
var m = /([^\-]*)(\-?)(.*)/;  
var ms = n.match(m);
sng = (ms[2] == '-') ? -sng : sng;  
n = ms[1] + ' ' + ms[3];       
var dms = /\s*([\d\.]*)[\sodO\u00B0]*([\d\.]*)[\s'\u8217]*([\d\.]*)[\s"\u8221]*/ 
var t = n.match(dms);
var s = (t[3] != '') ? parseFloat(t[3])/3600 : 0; 
var m = (t[2] != '') ? parseFloat(t[2])/60 : 0;
var d = (t[1] != '') ? parseFloat(t[1]) : 0;
var a = d + m + s;  
return sng * a;     
}
function HLLm() {   
var ret = new Array();
for(var i=0; i<arguments.length; i++)
ret[i] = HLL(arguments[i]);
return ret;
}
function HKmMi(n) {
HMFac = n;
HReshow(1);
}
function HDeg2DMS(d,mark) {
var mk = "\u00B0";
if (HFDeg == 0) return parseFloat(d).toFixed(5);
var sg = d / Math.abs(d);
var sng = (sg == 1) ? "": "-";
d = Math.abs(d);
var deg = Math.floor(d);
var f = d - deg;
var m  = f * 60;
if (HFDeg == 1) {
m = m.toFixed(4);
return sng + deg + mk + " " + m  + "'"
}
var min  = Math.floor(m);
f = m - min;
var sec = (f * 60).toFixed(3);
return sng + deg + mk + " " + min + "' " + sec + '"';
}
function HDetail(n) {
var oHSD = HShowDetails;
if (n==-1)HShowDetails = !HShowDetails;
else HShowDetails = n;
var hdet = document.getElementById('HDet')
document.getElementById('HDet').checked = HShowDetails;
if (oHSD != HShowDetails) {
if (HShowDetails) {
var t = document.getElementById('HTB');
var ra = t.getElementsByTagName('tr');
for (var i = 0; i<ra.length;i++) {
var cn = ra[i].getElementsByTagName('td');
if (cn[4] && cn[4].firstChild.value != '') {
HWPList[i] = cn[4].firstChild.value;
}
}
}
}
HReshow();
}
function HDMS(n) {
var oHFDeg = HFDeg;
HFDeg = n;
if (oHFDeg != HFDeg) HReshow();
}
function HPedShow () {
Hjscss('remove',document.getElementById("HPedDiv"),'HHide');
Hjscss('add',document.getElementById("HPedBut"),'HHide');
}
function HPedHide () {
Hjscss('add',document.getElementById("HPedDiv"),'HHide');
Hjscss('remove',document.getElementById("HPedBut"),'HHide');
}
function HPedometerDisplayJ(toAddress,prompt,style,aclass,footer) {
if (!toAddress) toAddress = "";
HPedDisp = 1;
var o = "";
o += "\n<button class='" + aclass + "' id=HPedBut onclick='HPedShow();'";
o += "title='Click to expose the Pedometer to draw and measure a trail'>Pedometer</button>";
o += "\n<div id=HPedDiv class=HHide>";
o += "\n<button onclick='HPedHide();' class='" + aclass + "' ";
o += "title='Click to close the Pedometer'>Hide Pedometer</button>";
o += "\n<img id=HPreLoad style='display:none' src='icons/icon0.png' alt='0' />";
o += "\n<table class=HPedClass align=center " + style + ">";
o += (document.getElementById('HPImg')) ? "" : "<tr><td><div id='HPImg'></div></td></tr>";
o += "\n<tr><td><table align=center><tr><td>";
o += "\n<div id=Hddd>0mi (0), 0</div>";
o += "\n" + prompt;
o += "<br>";
o += "\n<button id=HDrawN onclick='HDraw(0)' title='Click to draw a new trail of your own.'>Draw New</button>";
o += "\n<button id=HEditE onclick='HEditT()' title='Click to edit an existing trail line.'>Edit Existing</button>";
o += "\n<button id=HEditLE onclick='HList()' title='Click to list an existing trail line.'>List Existing</button>";
o += "\n<button onclick='HUndoPed(1)' title='Click to erase the trail info below.'>Clear All<\/button>";
o += "\n<br>Units: <span  title='Click to display in metric units.'><input type=radio name=Hu onclick='HKmMi(1)'>Km &amp; m</span>";
o += "\n<span title='Click to display in \"English\" units.'><input type=radio id='HMiles' name=Hu checked='checked' onclick='HKmMi(0.621371192)'>Mi &amp; ft</span>";
o += "\n<br><span title='Check to display all the intermeadiate points.'><input id=HDet type=checkbox name=Hd onclick='HDetail(-1)'>Details (for Elevations and Graph)</span>";
o += "</tr></table>\n<tr><td>";
o += "</td></tr><tr><td><\/div><div>";
o += "\n<div id=Hrtd class=centered></div>"
o += "<table id='Hrec_tab' align=center style='text-align:right'><thead>";
o += "\n<\/thead><tbody id='HTB'><\/tbody><tfoot><tr id='HTF'></tr></tfoot><\/table></div>";
o += "<button onclick='HToEmail(\"" + toAddress + "\")' class=centered title='Click to create an email with this and other information.'>Email Path<\/button>";
o += "\n<\/td><\/tr>";
o += "\n<tr id=HEmail class=HHide><td colspan=0>";
o += "\n<div id=HMailDiv></div></td></tr>";
o += "\n<tr><td class=centered><div id=HExIm class=HHide><button onclick='HToText()' title='Export the points to the box.'>LatLon to text<\/button>";
o += "\n<span title='Check to include the waypoint names.'><input type=checkbox id=HWithWP zchecked=checked>with WayPoints</span><br>";
o += "\n<span title='Check to include the waypoint names.'><input type=checkbox id=HWithWPq checked=checked>with 'WayPoints'</span><br>";
o += "\n<textarea id=HToTextId rows=6><\/textarea><br>";
o += "\n<button onclick='HToLL()' title='Import points from the box.'>Text to LatLon<\/button>";
o += "\n</div><\/td><\/tr>";
if (footer) o += "<tr><td>" + footer + "</td></tr>";
o += "<\/table>";
o += "</div>";
o += "\n<script type=text/javascript>HUndoPed(1)</" + "script>";
document.write (o);
document.close();
document.getElementById('HEditE').disabled = false;
document.getElementById('HDrawN').disabled = false;
}
function HGetElevation(y,x,id,n){
HShowElevation = 1;
if(n==null) n = id;
var u = (HMFac == 1) ? 'METERS' : 'FEET';
var p = (HMFac == 1) ? 1 : 0;
var url = 'jhm_ll_to_el.php';
var jsel = document.createElement('SCRIPT');
jsel.setAttribute("type","text/javascript");
jsel.setAttribute("id","AJAX" + (HAJAXn++));
jsel.setAttribute("src",url + '?x=' + parseFloat(x).toFixed(5) + '&y=' + parseFloat(y).toFixed(5) + '&i=' + id + '&n=' + n + '&u=' + u + '&p=' + p);
sp2 = document.body.firstChild;
document.body.insertBefore(jsel, sp2);
}
function HMWP(d) {
if (d == 0) {
if (HMWPm) {
map.removeOverlay(HMWPm);
HMWPm = null;
document.getElementById('R' + HMWPp).style.color = null;
}
else if (HPList[1]) {
HMWPm = new GMarker(HPList[1], HWPMarker);
map.addOverlay(HMWPm);
document.getElementById('R1').style.color = 'red';
HMWPp = 1;
document.getElementById('HMWPcbd').disabled = false;
document.getElementById('HMWPcbu').disabled = false;
}
}
else if (HMWPm) {
document.getElementById('R' + HMWPp).style.color = null;
do {HMWPp += d;} while (HPList[HMWPp] == null && HMWPp > 0 && HMWPp < HPList.length);
if (HMWPp < 1) HMWPp = 1;
if (HMWPp > HPList.length - 1) HMWPp = HPList.length - 1;
HMWPm.setLatLng(HPList[HMWPp])
document.getElementById('R' + HMWPp).style.color = 'red';
var dd = document.getElementById('R' + HMWPp).firstChild.innerHTML.replace(' ', '');
if (dd == '') dd = ' ';
document.getElementById('HPwpDispData').innerHTML = dd;
}
}
function HDraw() {
var b = document.getElementById('HDrawN');
var n = b.innerHTML == 'Draw New';
if (n) {
HEPoly = new GPolyline([], "#ff00ff",5,.50);
map.addOverlay(HEPoly)
HEPoly.enableDrawing()
GEvent.addListener(HEPoly, "endline", function() {HEdit(-1)})
}
b.innerHTML = (n) ? 'End Draw' : 'Draw New'
document.getElementById('HEditE').disabled = true;
if (!n) HEdit(0);
}
function HEditT(narg) {
var b = document.getElementById('HEditE');
var n = narg || b.innerHTML == 'Edit Existing';
b.innerHTML = (n) ? 'End Edit' : 'Edit Existing'
if (!n)
HEdit(0);
HeditTr = n;
document.getElementById('HDrawN').disabled = (n) ? true : false;
}
function HList() {
HEdit(0);
HMoveEnd();
}
function HMove(n) {
if (HeditTr && n) {
var marker = HOverlayList[n];
HMoveN = n;
HMoveS = marker.getLatLng();
marker.enableDragging();
marker.dragCrossMove = false;
}
}
function HMouseOutMk(n){
if (HMoveN) HOverlayList[HMoveN].disableDragging();
}
function HMoveEnd() {
HOverlayList[HMoveN].disableDragging();
HRecord = true;
HAddSegPoint(HMoveS);
HAddSegPoint(HOverlayList[HMoveN].getLatLng());
HEndAdd();
HMoveS = null;
HRecord = false;
}
function HEdit(n) {
if (n == -1) HEditSeg = HEPoly;
else if (n != 0) HEditSeg = HOverlayList[n];
if (n != 0) {
var elist = [];
for (var i = 0; i < HEditSeg.getVertexCount(); i++) {
elist[i] = HEditSeg.getVertex(i);
}
if (n == -1) map.removeOverlay(HEPoly);
HEPoly = new GPolyline(elist, "#00ffff",5,.50);
map.addOverlay(HEPoly);
HEPoly.enableEditing();
GEvent.addListener(HEPoly, "endline", function() {HEdit(0)})
}
else if(HEPoly) { 
HEPoly.disableEditing();
var r_prev = HRecord;
HRecord = 1;
for (var i = 0; i < HEPoly.getVertexCount(); i++) {
HAddSegPoint(HEPoly.getVertex(i));
}
HEndAdd();
map.removeOverlay(HEPoly);
HRecord = r_prev;
document.getElementById('HEditE').disabled = false;
}
}
var HSC=1.2
var HIP="";var HSP="";
HSizeControl.prototype = new GControl()
function HSizeControl(q,p){q=(typeof(q)==undefined||q==""||q==null)?'LARGE':q;HSP=(q=="LARGE")?new GSize(80,7):(q="SMALL")?new GSize(50,9):q;if(typeof(p)==undefined)p=HIP;HIP=p;if(HIP!=''&&HIP[HIP.length-1]!="/")HIP+="/"}
HSizeControl.prototype.initialize = function(m){
var c=document.createElement("div")
var a=document.createElement("div")
c.appendChild(a)
var b=document.createElement("img")
b.style.cursor='pointer'
b.src=HIP+'hscwidths.png'
b.alt='N'
b.title='Narower Map'
a.appendChild(b)
GEvent.addDomListener(a,"click",function(){var c=m.getCenter();m.getContainer().style.width=parseInt(m.getContainer().style.width)/HSC+'px';m.checkResize();m.setCenter(c);})
a=document.createElement("div")
c.appendChild(a)
b=document.createElement("img")
b.src=HIP+'hscwidthl.png'
b.alt='W'
b.style.position='absolute'
b.style.top='20px'
b.style.left='0px'
b.style.cursor='pointer'
b.title='Wider Map'
a.appendChild(b)
GEvent.addDomListener(b,"click",function(){var c=m.getCenter();m.getContainer().style.width=HSC*parseInt(m.getContainer().style.width)+'px';m.checkResize();m.setCenter(c);})
a=document.createElement("div")
c.appendChild(a)
b=document.createElement("img")
b.src=HIP+'hscheights.png'
b.alt='S'
b.style.position='absolute'
b.style.top='0px'
b.style.left='20px'
b.style.cursor='pointer'
b.title='Shorter Map'
a.appendChild(b)
GEvent.addDomListener(b,"click",function(){var c=m.getCenter();m.getContainer().style.height=parseInt(m.getContainer().style.height)/HSC+'px';m.checkResize();m.setCenter(c);})
a=document.createElement("div")
c.appendChild(a)
b=document.createElement("img")
b.src=HIP+'hscheightl.png'
b.alt='T'
b.style.position='absolute'
b.style.top='20px'
b.style.left='20px'
b.style.cursor='pointer'
b.title='Taller Map'
a.appendChild(b)
GEvent.addDomListener(a,"click",function(){var c=m.getCenter();m.getContainer().style.height=HSC*parseInt(m.getContainer().style.height)+'px';m.checkResize();m.setCenter(c);})
m.getContainer().appendChild(c)
return c
}
HSizeControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_LEFT,HSP);}
function HSizeStep(n){var o=HSC;if(n>1)HSC=n;return o}
