
function xferyesno(radioname,alrt)
{
  var rdv = eval("theform."+radioname+"radio");
  var ist = rdv[0].checked;
  var isf = rdv[1].checked;
  var hv = eval("theform."+radioname);
  if (ist) {hv . value = "true"; return 1} else
  if (isf) {hv . value = "false"; return 1} else
  alert("You didn't answer: \""+alrt+'"');
  return 0;

} 


function xferradio(radioname)
{
  var rdv = document.getElementsByName(radioname+"radio");
  var ln = rdv.length;
  var i = 0;
  var v = -1;
  for (i=0;i<ln;i++)
     {
	 if (rdv[i].checked) v = i;
	 }
  var hv = document.getElementsByName(radioname)[0];
  hv . value = v;
  return 1;
}



function checktext(inputname,alrt)
{
  var vl = eval("theform."+inputname+'.value');
  if ((vl.search(","))<0) return 1;
  alert("No commas are allowed in the answer to: \""+alrt+'"');
  return 0;
} 



function submitonly()
{
var frm = document.getElementsByName("theform")[0];
frm.submit();
}

// note: popwin,popwin1 also appear in container*php
var winprops = "width=650,height=500,scrollbars=1,resizable=1,toolbars=1";

function popwin1() {
	poppedwin.focus();
}

function popwin(url)
{
	 poppedwin = window.open(url,"poppedwin",winprops);
     setTimeout('popwin1()',10);
}


var exwinprops = "width=850,height=500,scrollbars=1,resizable=1,toolbar=1";

function popexwin1() {
	examplewin.focus();
}

function popexwin(url)
{
	 examplewin = window.open(url,"exwin");
     setTimeout('popexwin1()',10);
}


// the wgs84 ellispoid parameters

var equatorialRadius = 6378137;
var eccSquared =  0.00669438;
var rtod = 180.0/Math.PI;

function UTMtoLL(UTMEasting, UTMNorthing,ZoneNumber,NorthernHemisphere)
{
  var Lat,Long,k0,a,eccPrimeSquared,e1,N1,T1,C1,R1,D,M,LongOrigin,
      mu,phi1,phi1Rad,x,y,ln;
//converts UTM coords to lat/long.  Equations from USGS Bulletin 1532 
//East Longitudes are positive, West longitudes are negative. 
//North latitudes are positive, South latitudes are negative
//Lat and Long are in decimal degrees. 
	//Written by Chuck Gantz- chuck.gantz@globalstar.com

	k0 = 0.9996;
	a = equatorialRadius;
	e1 = (1-Math.sqrt(1-eccSquared))/(1+Math.sqrt(1-eccSquared));

	x = UTMEasting - 500000.0; //remove 500,000 meter offset for longitude
	y = UTMNorthing;

	if(!NorthernHemisphere)
		y = y - 10000000.0;//remove 10,000,000 meter offset used for southern hemisphere

	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*rtod;

	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 * rtod;
	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 * rtod;
	rs = new Object;
	rs . longitude = Long;
	rs . latitude = Lat;
	return rs;

}

var newwinprops = "width=800,height=600,location=0,toolbar=0,menubar=0,scrollbars=1,resizable=1,status=0";
	var newwinname = '_blank';

	function launchNew(url) {
		newwin =window.open(url,newwinname,newwinprops);
		setTimeout('newwin.focus();',200);
	}

// The "back" and "forward" buttons don't work as expected with a *Map and can get the user in trouble.
// So, it is necessary to launch the map in a window without these buttons.
// This is the code that pops a new window without various controls.
// Use this scheme if you want to directly link to the map from another webpage.
// ALWAYS launch in a window without controls.

var mapwinprops = "width=800,height=600,location=0,toolbar=0,menubar=0,scrollbars=1,resizable=1,status=0";
	var mapwinname = '_blank';

	function launchMapWindow(url) {
		mapwin =window.open(url,mapwinname,mapwinprops);
// The following line forces the map window to pop in the foreground
		setTimeout('mapwin.focus();',200);
	}

var projectwinprops = "width=800,height=600,location=0,toolbar=0,menubar=0,scrollbars=1,resizable=1,status=yes";
	var projectwinname = 'mapperproject';

	function launchProjectWindow(url) {
		projectwin =window.open(url,projectwinname,projectwinprops);
// The following line forces the map window to pop in the foreground
		setTimeout('projectwin.focus();',200);
	}


