<html>
<title>Survey Traverse Calculation - RJM Programming - Copyright © 2013 rjmprogramming.com.au all rights reserved.</title>
<head>
<meta charset="utf-8">
<link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'>
<style>
table {
border: 1px solid black;
}

.lightgray {
background-color: lightgray;
}

.lightblue {
background-color: lightblue;
}

.white {
background-color: white;
}

.lightgreen {
background-color: lightgreen;
}

.yellow {
background-color: yellow;
}

.cyellow {
color: yellow;
}

.pink {
background-color: pink;
}
</style>
<script>
var edone=false, ndone=false;
var maxe=-1.0, mine=-1.0, maxn=-1.0, minn=-1.0;
var justen=-1;
var numlegs=0;
var firstBearing=0;
var currb = 0.0;
var currx = 0.0;
var curry = 0.0;
var lastBearing="-0";
var adjust=0;
var canvscale=1.0;
var lbbit = "";
var lbval = "";
var ballval = "";
var prmstr = window.location.search.substr(1).replace('numlegs=','');
var prmarr = prmstr.split ("&");
var params = {};
var parambits = {};
var enarr = {};
var enarrstr = "";
var eoff=0.0;
var noff=0.0;
var envials=[];
var pvials=[];
var cnumlegs = location.search.split('numlegs=')[1] ? decodeURIComponent(location.search.split('numlegs=')[1].split('&')[0]) : '';
if (window.localStorage) {
// 34,56,78,45 ... ,
// 34,56,"One",78,45,"Two" ... ,"
// "One",34,56,"Two",78,45 ... ",
var acontt=decodeURIComponent(('' + localStorage.getItem('en_st')).replace(/^null$/g,'')).replace(/\+/g,' ');
if (acontt != '') { localStorage.removeItem('en_st'); }
//alert(acontt);
var minicom=[];
var endelim=',';
if (acontt.indexOf(',"') != -1 && acontt.indexOf('",') != -1) {
if (eval('' + acontt.indexOf('",')) < eval('' + acontt.indexOf(',"'))) {
endelim='",';
} else {
endelim=',"';
}
} else if (acontt.indexOf(',"') != -1) {
endelim=',"';
} else if (acontt.indexOf('",') != -1) {
endelim='",';
}
var pfirst=true;
var pyoullneverfindthis='';
var jxv=0;
var xenvials=acontt.split(endelim);
xenvials.push('');
for (var ixv=0; ixv<xenvials.length; ixv++) {
if (xenvials[ixv] != '') {
if (endelim == ',"') {
pvials.push(xenvials[eval(1 + ixv)].split('"')[0]);
if (xenvials[ixv].indexOf('",') != -1) { xenvials[ixv]=xenvials[ixv].replace(xenvials[ixv].split('",')[0] + '",',''); }
minicom=xenvials[ixv].split(',');
for (jxv=0; jxv<minicom.length; jxv++) {
envials.push(minicom[jxv]);
}
} else if (endelim == '",') {
pvials.push(xenvials[ixv].split('"')[0]);
if (xenvials[eval(1 + ixv)].indexOf(',"') != -1) { xenvials[eval(1 + ixv)]=xenvials[eval(1 + ixv)].replace(',"' + xenvials[eval(1 + ixv)].split(',"')[0],''); }
minicom=xenvials[eval(1 + ixv)].split(',');
for (jxv=0; jxv<minicom.length; jxv++) {
envials.push(minicom[jxv]);
}
} else if (('' + xenvials[ixv]).trim() != '' && ('' + xenvials[ixv]).replace(/\ /g,'').replace(/\-/g,'').replace(/\./g,'').replace(/0/g,'').replace(/1/g,'').replace(/2/g,'').replace(/3/g,'').replace(/4/g,'').replace(/5/g,'').replace(/6/g,'').replace(/7/g,'').replace(/8/g,'').replace(/9/g,'') == '') {
//alert('envials.push(' + xenvials[ixv] + ');');
envials.push(xenvials[ixv]);
} else if (('' + xenvials[ixv]).replace(/\ /g,'').replace(/\-/g,'').replace(/\./g,'').replace(/0/g,'').replace(/1/g,'').replace(/2/g,'').replace(/3/g,'').replace(/4/g,'').replace(/5/g,'').replace(/6/g,'').replace(/7/g,'').replace(/8/g,'').replace(/9/g,'') != pyoullneverfindthis) {
//alert('pvials.push(' + xenvials[ixv].replace(/\&\;/g,"&").replace(/\&apos\;/g,"'").replace(/\"\;/g,'"') + ')');
pvials.push(xenvials[ixv].replace(/\&\;/g,"&").replace(/\&apos\;/g,"'").replace(/\"\;/g,'"'));
if (pfirst) {
pfirst=false;
pyoullneverfindthis='youllnever_find_this';
}
} else {
//alert('envials.push(' + xenvials[ixv] + ')');
envials.push(xenvials[ixv]);
}
pfirst=false;
}
}
}

if (prmstr.replace('?numlegs=','').indexOf("=") != (0 - 1)) {
for ( var i = 0; i < prmarr.length; i++) {
var tmparr = prmarr[i].split("=");
params[tmparr[0]] = tmparr[1];
//alert(tmparr[1]);
numlegs = -1;
parambits = tmparr[1].split(",");
}
}

function ifzeromakezero(innum,e_or_n) {
var cinnum = innum.toString();
if (cinnum.indexOf("e-") != (0 - 1)) {
if (e_or_n == 1) {
if (!edone) {
mine=0.0;
maxe=0.0;
} else {
if (mine > 0.0) { mine=0.0; }
if (maxe < 0.0) { maxe=0.0; }
}
edone=true;
} else if (e_or_n == 2) {
if (!ndone) {
minn=0.0;
maxn=0.0;
} else {
if (minn > 0.0) { minn=0.0; }
if (maxn < 0.0) { maxn=0.0; }
}
ndone=true;
}
return 0.000;
}
if (e_or_n == 1) {
if (!edone) {
mine=innum;
maxe=innum;
} else {
if (mine > innum) { mine=innum; }
if (maxe < innum) { maxe=innum; }
}
edone=true;
} else if (e_or_n == 2) {
if (!ndone) {
minn=innum;
maxn=innum;
} else {
if (minn > innum) { minn=innum; }
if (maxn < innum) { maxn=innum; }
}
ndone=true;
}
return innum;
}

function postspanscheck() {
var eles=document.getElementsByTagName('span');
for (var ieles=0; ieles<eles.length; ieles++) {
if (('' + eles[ieles].style.zIndex) != '') {
if (('' + eles[ieles].style.zIndex).indexOf('-') != -1) {
eles[ieles].style.zIndex=('' + eles[ieles].style.zIndex).replace('-','');
eles[ieles].style.opacity='1.0';
document.getElementById(eles[ieles].id.replace('S','')).style.opacity='0.0';
} else {
eles[ieles].style.zIndex=('-' + eles[ieles].style.zIndex);
eles[ieles].style.opacity='0.0';
document.getElementById(eles[ieles].id.replace('S','')).style.opacity='1.0';
}
}
}
setTimeout(postspanscheck, 15000);
}

function docan() {
var sofart='';
document.getElementById('dcanvas').innerHTML='<canvas style="transform-origin:0 0;transform:scale(' + canvscale + ');background-color:#f0f0f0;border:2px dashed red;" height=' + eval(500 + eval('' + maxn) - eval('' + minn)) + ' width=' + eval(700 + eval('' + maxe) - eval('' + mine)) + ' id=mycanvas></canvas>';
setTimeout(postspanscheck, 5000);
var ele=document.getElementById('mycanvas');
var context=document.getElementById('mycanvas').getContext('2d');
var iz=0, mto=true, grad;

// Red Orange Yellow Green Cyan Blue Violet
var pts = [[0, 0, "red"], [0, 0, "orange"], [0, 0, "yellow"], [0, 0, "green"], [0, 0, "cyan"], [0, 0, "blue"], [0, 0, "violet"]];

//var pts = [[0, 0, "red"], [0, 0, "green"], [0, 0, "blue"], [0, 0, "purple"], [0, 0, "olive"], [0, 0, "magenta"], [0, 0, "cyan"], [0, 0, "brown"], [0, 0, "black"], [0, 0, "pink"], [0, 0, "darkgreen"], [0, 0, "darkblue"], [0, 0, "darkorange"]];
var begin = pts[0];
var end = pts[1];

while (document.getElementById('E' + iz)) {
if (document.getElementById('E' + iz).value != '') {
if (mto) {
context.lineWidth = 6;
context.lineJoin = "round";
context.lineCap = "round";
//context.strokeStyle = "black";
context.beginPath();
begin=pts[eval(iz % pts.length)];
begin[0] = eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine));
begin[1] = eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn));
context.moveTo(eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)), eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn)));
if (document.getElementById('P' + iz).value.trim() != '' && sofart.indexOf(document.getElementById('P' + iz).value + "," + eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)) + "," + eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn))) == -1) {
sofart+=document.getElementById('P' + iz).value + "," + eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)) + "," + eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn));
context.strokeStyle='blue'; //element.colour;
context.font = "48px Verdana";
context.strokeText(document.getElementById('P' + iz).value,eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)), eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn)));
}
} else {
end=pts[eval(1 + eval(iz % 5))];
end[0] = eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine));
end[1] = eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn));
grad = context.createLinearGradient(begin[0], begin[1], end[0], end[1]);
grad.addColorStop(0, begin[2]);
grad.addColorStop(1, end[2]);
context.strokeStyle = grad;
context.lineTo(eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)), eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn)));
context.stroke();
if (document.getElementById('P' + iz).value.trim() != '' && sofart.indexOf(document.getElementById('P' + iz).value + "," + eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)) + "," + eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn))) == -1) {
sofart+=document.getElementById('P' + iz).value + "," + eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)) + "," + eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn));
context.strokeStyle='blue'; //element.colour;
context.font = "48px Verdana";
context.strokeText(document.getElementById('P' + iz).value,eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)), eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn)));
}
//context.strokeStyle = "black";
context.beginPath();
context.moveTo(eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)), eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn)));
begin=pts[eval(iz % pts.length)];
begin[0] = eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine));
begin[1] = eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn));
}
mto=false;
}
iz++;
}
}

function scaleit(sbyo) {
var sby='' + sbyo.value;
if (sby != '') {
document.getElementById('mycanvas').style.transformOrigin="0 0;";
if (sby.indexOf('/') != -1) {
eval("canvscale=eval(" + canvscale + " " + sby + ");");
} else if (sby.indexOf('x') != -1 || sby.indexOf('*') != -1) {
eval("canvscale=eval(" + canvscale + " " + sby.replace('x','*') + ");");
} else {
canvscale=eval('' + sby);
}
document.getElementById('mycanvas').style.transform="scale(" + canvscale + ");";
}
document.getElementById('scaleopt').innerHTML='Scale ' + canvscale;
sbyo.value='';
docan();
}

function postcheck() {
var sofart='';
var rectis, dothis=false, ieles=0;
var eles=document.getElementsByTagName('td');
for (ieles=0; ieles<eles.length; ieles++) {
if (('' + eles[ieles].getAttribute('data-title')).replace(/^null$/g,'') != '') {
rectis=eles[ieles].getBoundingClientRect();
if (document.getElementById('overlays')) {
dothis=true;
document.getElementById('overlays').innerHTML+='<span id=S' + eles[ieles].id + ' style="overflow:hidden;position:absolute;z-index:-78;opacity:0.3;top:' + rectis.top + 'px;left:' + rectis.left + 'px;width:' + rectis.width + 'px;height:' + rectis.height + 'px;">' + (('' + eles[ieles].getAttribute('data-title')).replace(':','°').replace(":","'") + '"') + '</span>';
}
}
}
eles=document.getElementsByTagName('input');
for (ieles=0; ieles<eles.length; ieles++) {
if (('' + eles[ieles].getAttribute('data-title')).replace(/^null$/g,'') != '') {
rectis=eles[ieles].getBoundingClientRect();
if (document.getElementById('overlays')) {
dothis=true;
document.getElementById('overlays').innerHTML+='<span id=S' + eles[ieles].id + ' style="overflow:hidden;position:absolute;z-index:-78;opacity:0.3;top:' + rectis.top + 'px;left:' + rectis.left + 'px;width:' + rectis.width + 'px;height:' + rectis.height + 'px;">' + (('' + eles[ieles].getAttribute('data-title')).replace(':','°').replace(":","'") + '"') + '</span>';
}
}
}
if (dothis) {
//alert('mine=' + mine + ' and maxe=' + maxe + ' and minn=' + minn + ' and maxn=' + maxn + ' <canvas height=' + eval(150 + eval('' + maxn) - eval('' + minn)) + ' width=' + eval(150 + eval('' + maxe) - eval('' + mine)) + ' id=mycanvas></canvas>');
var aregeographicals=true;
var iz=0;
var isdms=true;
var jdatac='', idatac='', idatacd='', ipeninfoc='', ipeninfocd='', iaregeographicalsc='', iaregeographicalscd='';
while (document.getElementById('E' + iz)) {
if (document.getElementById('E' + iz).value != '') {
if (Math.abs(eval('' + document.getElementById('E' + iz).value)) > 90.0) {
aregeographicals=false;
} else if ((document.getElementById('E' + iz).value + '0000').indexOf('.') != -1) {
if ((document.getElementById('E' + iz).value + '0000').split('.')[1].substring(0,1) >= '6') { isdms=false; }
if ((document.getElementById('E' + iz).value + '0000').split('.')[1].substring(2).substring(0,1) >= '6') { isdms=false; }
}
}
if (document.getElementById('N' + iz).value != '') {
if (Math.abs(eval('' + document.getElementById('N' + iz).value)) > 180.0) {
aregeographicals=false;
} else if ((document.getElementById('N' + iz).value + '0000').indexOf('.') != -1) {
if ((document.getElementById('N' + iz).value + '0000').split('.')[1].substring(0,1) >= '6') { isdms=false; }
if ((document.getElementById('N' + iz).value + '0000').split('.')[1].substring(2).substring(0,1) >= '6') { isdms=false; }
jdatac+=',[' + document.getElementById('E' + iz).value + "," + document.getElementById('N' + iz).value + ',~' + document.getElementById('P' + iz).value.replace(/\'/g,'`') + '~]';
idatac+=idatacd + ' [' + document.getElementById('E' + iz).value + "|" + document.getElementById('N' + iz).value + '|~' + document.getElementById('P' + iz).value.replace(/\'/g,'`').replace(/\,/g,';') + '~,2]';
idatacd=',';
ipeninfoc+=ipeninfocd + '' + document.getElementById('E' + iz).value + "|" + document.getElementById('N' + iz).value + '|127938_' + document.getElementById('P' + iz).value.replace(/\ /g,'_').replace(/\'/g,'`').replace(/\,/g,';').replace(/\,/g,';') + '';
ipeninfocd=',+';
iaregeographicalsc+=iaregeographicalscd + 'http.' + document.getElementById('P' + iz).value.replace(/\ /g,'_').replace(/\'/g,'`').replace(/\,/g,';') + '';
iaregeographicalscd=',';
}
}
iz++;
}
if (aregeographicals) {
//<input type=hidden id=iaregeographicals name=aregeographicals value='http.Ice,http.Lakagigar_Volcano,http.Bora_Bora'></input>
//<input type=hidden id=ipeninfo name=peninfo value='75.57|-92.28|127938_Ice,64.04|-18.15|127755_Lakagigar_Volcano,-16.30|151.44|127958.65039_Bora_Bora'></input>
//<input type=hidden id=idata name=data value=' [75.57|-92.28|~Ice~,2] , [64.04|-18.15|~Lakagigar Volcano~,2] , [-16.30|151.44|~Bora Bora~,2]'></input>
//<input type=hidden id=jdata name=data value=',[75.57,-92.28,~Ice~],[64.04,-18.15,~Lakagigar Volcano~],[-16.30,151.44,~Bora Bora~]'></input>
document.getElementById('iaregeographicals').value=iaregeographicalsc;
document.getElementById('ipeninfo').value=ipeninfoc;
document.getElementById('idata').value=idatac;
document.getElementById('jdata').value=jdatac;
document.getElementById('overlays').innerHTML+='<br><br><iframe src= id=mygeoframe name=mygeoframe height=800 width=800></iframe>';
if (eval(0 + eval('' + maxn) - eval('' + minn)) > 5 || eval(0 + eval('' + maxe) - eval('' + mine)) > 5) {
//alert(document.getElementById('geoform').outerHTML);
document.getElementById('geosb').click();
} else {
//alert(jdatac);
document.getElementById('mapsb').click();
}
} else {
document.getElementById('overlays').innerHTML+='<br><br><select onchange=scaleit(this);><option value=1.0>Scale 1.0</option><option value=" / 2.0">Scale / 2.0</option><option value=" x 2.0">Scale x 2.0</option><option value=" / 5.0">Scale / 5.0</option><option value=" x 5.0">Scale x 5.0</option><option value=" / 10.0">Scale / 10.0</option><option value=" x 10.0">Scale x 10.0</option><option value=" / 100.0">Scale / 100.0</option><option value=" x 100.0">Scale x 100.0</option><option id=scaleopt value="">Scale</option></select><br><br><div id=dcanvas><canvas style="transform-origin:0 0;transform:scale(1.0);background-color:#f0f0f0;border:2px dashed red;" height=' + eval(500 + eval('' + maxn) - eval('' + minn)) + ' width=' + eval(700 + eval('' + maxe) - eval('' + mine)) + ' id=mycanvas></canvas></div>';
setTimeout(postspanscheck, 5000);
var ele=document.getElementById('mycanvas');
var context=document.getElementById('mycanvas').getContext('2d');
var mto=true, grad;

// Red Orange Yellow Green Cyan Blue Violet
var pts = [[0, 0, "red"], [0, 0, "orange"], [0, 0, "yellow"], [0, 0, "green"], [0, 0, "cyan"], [0, 0, "blue"], [0, 0, "violet"]];

//var pts = [[0, 0, "red"], [0, 0, "green"], [0, 0, "blue"], [0, 0, "purple"], [0, 0, "olive"], [0, 0, "magenta"], [0, 0, "cyan"], [0, 0, "brown"], [0, 0, "black"], [0, 0, "pink"], [0, 0, "darkgreen"], [0, 0, "darkblue"], [0, 0, "darkorange"]];
var begin = pts[0];
var end = pts[1];

iz=0;

while (document.getElementById('E' + iz)) {
if (document.getElementById('E' + iz).value != '') {
if (mto) {
context.lineWidth = 6;
context.lineJoin = "round";
context.lineCap = "round";
//context.strokeStyle = "black";
context.beginPath();
begin=pts[eval(iz % pts.length)];
begin[0] = eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine));
begin[1] = eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn));
context.moveTo(eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)), eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn)));
if (document.getElementById('P' + iz).value.trim() != '' && sofart.indexOf(document.getElementById('P' + iz).value + "," + eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)) + "," + eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn))) == -1) {
sofart+=document.getElementById('P' + iz).value + "," + eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)) + "," + eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn));
context.strokeStyle='blue'; //element.colour;
context.font = "48px Verdana";
context.strokeText(document.getElementById('P' + iz).value,eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)), eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn)));
}
} else {
end=pts[eval(1 + eval(iz % 5))];
end[0] = eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine));
end[1] = eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn));
grad = context.createLinearGradient(begin[0], begin[1], end[0], end[1]);
grad.addColorStop(0, begin[2]);
grad.addColorStop(1, end[2]);
context.strokeStyle = grad;
context.lineTo(eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)), eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn)));
context.stroke();
//context.strokeStyle = "black";
if (document.getElementById('P' + iz).value.trim() != '' && sofart.indexOf(document.getElementById('P' + iz).value + "," + eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)) + "," + eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn))) == -1) {
sofart+=document.getElementById('P' + iz).value + "," + eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)) + "," + eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn));
context.strokeStyle='blue'; //element.colour;
context.font = "48px Verdana";
context.strokeText(document.getElementById('P' + iz).value,eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)), eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn)));
}
context.beginPath();
context.moveTo(eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine)), eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn)));
begin=pts[eval(iz % pts.length)];
begin[0] = eval(150 + eval('' + document.getElementById('E' + iz).value) - eval('' + mine));
begin[1] = eval(eval('' + maxn) + 150 - eval('' + document.getElementById('N' + iz).value) + 0 * eval('' + minn));
}
mto=false;
}
iz++;
}
}
}
}

function checkAtStart() { // check query string
if (numlegs != 0) {
//alert(params['traverse']);
processTraverse(params['traverse']);
} else {
if (cnumlegs != '') {
numlegs = '' + cnumlegs;
} else {
numlegs = prompt("Please tell me how many Traverse legs you have. If you have a set of co-ordinates number of Traverse legs is one less than this number of co-ordinate sets. If you are specifying a CSV filename to use for a set of co-ordinates that is allowed too.", "0");
}
if (('' + numlegs + '~').toLowerCase().indexOf('.csv~') != -1) {
document.getElementById('preifcsv').src='./SurveyTraverse.php?csvfile=' + encodeURIComponent(numlegs);
} else if (numlegs != "0" && numlegs != null) {
window.location = window.location + "?traverse=" + numlegs + ",0";
}
}
}

function fixthis(afix) {
var areal = 0.0;
var breal = 0.0;
var creal = 0.0;
var ien = 0;
areal = eval(afix);
//alert(enarrstr);
enarr = enarrstr.split(",");

for ( var j = 0; j <= numlegs; j++) {
document.getElementById('E' + j).value = ifzeromakezero(enarr[ien],1);
ien += 1;
document.getElementById('N' + j).value = ifzeromakezero(enarr[ien],2);
ien += 1;
breal = eval(document.getElementById('A' + j).value);
creal = eval(areal+breal);
while (creal >= 360.0) {
creal = eval(creal-360.0);
}
while (creal < 0.0) {
creal = eval(creal+360.0);
}
document.getElementById('A' + j).value = ifzeromakezero(creal,0);
var deg = eval(creal);
document.getElementById('A' + j).title = document.getElementById('A' + j).title + " ... DMS " + Math.floor(deg) + "°";
deg = deg - Math.floor(deg);
if (Math.floor((deg * 60.0)) < 10.0) document.getElementById('A' + j).title = document.getElementById('A' + j).title + "0";
document.getElementById('A' + j).title = document.getElementById('A' + j).title + Math.floor((deg * 60.0)) + "'";
deg = (deg * 60.0 - Math.floor((deg * 60.0))) * 60.0;
if (deg < 10) document.getElementById('A' + j).title = document.getElementById('A' + j).title + "0";
document.getElementById('A' + j).title = document.getElementById('A' + j).title + deg + '"';
}
//alert(afix + " " + areal);
adjust = -1;
document.getElementById('Ball').innerHTML = ""; //lbbit;
document.getElementById('lastBearing').value = ifzeromakezero(lbval,0);
analyze(document.getElementById('adjust'));
document.getElementById('adjust').value = 'Bowditch Adjust';
}

function analyze(but) {
justen=1;
var kjw=0, thisdiste=0.0, thisdistn=0.0, thisbrgis=0.0, lastb=0.0;
// alert(1);
if (adjust <= 0) {
// alert('' + Math.atan2(10.0,10.0) * (180.0 / Math.PI));
if (adjust == 0) {
// alert(3);
var kk;
enarrstr = "";
lbbit = document.getElementById('Ball').innerHTML;
lbval = document.getElementById('lastBearing').value;
for ( var jj = 0; jj < numlegs; jj++) {
kk = jj+1;
if (adjust == 0) {
if (document.getElementById('E' + jj).value.replace(/\./g,'').replace(/\-/g,'').replace(/0/g,'') == '') { justen--; }
if (document.getElementById('N' + jj).value.replace(/\./g,'').replace(/\-/g,'').replace(/0/g,'') == '') { justen--; }
enarrstr = enarrstr + document.getElementById('E' + jj).value + ",";
enarrstr = enarrstr + document.getElementById('N' + jj).value + ",";
if (kk == numlegs) {
if (adjust == 0) {
if (document.getElementById('E' + numlegs).value.replace(/\./g,'').replace(/\-/g,'').replace(/0/g,'') == '') { justen--; }
if (document.getElementById('N' + numlegs).value.replace(/\./g,'').replace(/\-/g,'').replace(/0/g,'') == '') { justen--; }
enarrstr = enarrstr + document.getElementById('E' + numlegs).value + ",";
enarrstr = enarrstr + document.getElementById('N' + numlegs).value + ",";
}
}
}
}
}
if (document.getElementById('firstBearing').value.replace(/\./g,'').replace(/\-/g,'').replace(/0/g,'') != '') { justen--; }
if (document.getElementById('lastBearing').value.replace(/\./g,'').replace(/\-/g,'').replace(/0/g,'') != '') { justen--; }
//alert('justen=' + justen);
document.getElementById('adjust').title = 'Bowditch Adjust';
document.getElementById('adjust').value = 'Adjust';


//alert(79);
if (eval('' + justen) > 0) {
//alert(89);
kjw=0;
for (jw = 0; jw < numlegs; jw++) {
kjw++;
thisdiste=eval('' + document.getElementById('E' + jw).value);
//alert('01 thisdiste=' + thisdiste + ' thisdistn=' + thisdistn + ' ' + document.getElementById('E' + jw).value + ' then ' + document.getElementById('E' + kjw).value);
thisdiste-=eval('' + document.getElementById('E' + kjw).value);
//alert('02 thisdiste=' + thisdiste + ' thisdistn=' + thisdistn);
thisdiste*=thisdiste;
//alert('03 thisdiste=' + thisdiste + ' thisdistn=' + thisdistn);
thisdistn=eval('' + document.getElementById('N' + jw).value);
//alert('04 thisdiste=' + thisdiste + ' thisdistn=' + thisdistn + ' ' + kjw + ':' + document.getElementById('N' + kjw).value);
thisdistn-=eval('' + document.getElementById('N' + kjw).value);
//alert('05 thisdiste=' + thisdiste + ' thisdistn=' + thisdistn);
thisdistn*=thisdistn;
//alert('06 thisdiste=' + thisdiste + ' thisdistn=' + thisdistn);
//document.getElementById('L' + jw).value='' + Math.pow( ( ((eval('' + document.getElementById('E' + jw).value)) - (eval('' + document.getElementById('E' + kjw).value))) * ((eval('' + document.getElementById('E' + jw).value)) - (eval('' + document.getElementById('E' + kjw).value))) + ((eval('' + document.getElementById('N' + jw).value)) - (eval('' + document.getElementById('N' + kjw).value))) * ((eval('' + document.getElementById('N' + jw).value)) - (eval('' + document.getElementById('N' + kjw).value))) ),0.5);
//document.getElementById('L' + jw).value='' + Math.pow( eval(thisdiste + thisdistn), 0.5);
document.getElementById('L' + jw).title='' + Math.pow( eval(thisdiste + thisdistn), 0.5);

thisbrgis=eval('' + Math.atan2(eval(eval('' + document.getElementById('E' + kjw).value) - eval('' + document.getElementById('E' + jw).value)), eval(eval('' + document.getElementById('N' + kjw).value) - eval('' + document.getElementById('N' + jw).value))) * (180.0 / Math.PI));
if (thisbrgis < 0) { thisbrgis+=360.0; }
//document.getElementById('B' + jw).innerHTML='' + thisbrgis;
document.getElementById('B' + jw).title='' + thisbrgis;

if (jw == 0) {
if (('' + thisbrgis).indexOf('.') == -1) {
document.getElementById('A' + jw).setAttribute('data-title', '' + '' + thisbrgis + '.00');
} else {
document.getElementById('A' + jw).setAttribute('data-title', '' + '' + thisbrgis);
}
lastb=eval('' + thisbrgis);
} else {
if (eval('' + thisbrgis) > eval('' + lastb)) {
//alert('thisbrgis=' + eval('' + thisbrgis) + ' and lastb=' + eval('' + lastb) + ' results in ' + eval(eval(180.0 + eval(eval('' + thisbrgis) - eval('' + lastb))) % 360.0));
lastb=eval(eval(180.0 + eval(eval('' + thisbrgis) - eval('' + lastb))) % 360.0);
} else {
lastb=eval(eval(540.0 + eval(eval('' + thisbrgis) - eval('' + lastb))) % 360.0);
}
if (('' + lastb).indexOf('.') == -1) {
document.getElementById('A' + jw).setAttribute('data-title', '' + lastb + '.00');
} else {
document.getElementById('A' + jw).setAttribute('data-title', '' + lastb);
}
}

lastb=eval('' + thisbrgis);

document.getElementById('E' + jw).title='' + '' + document.getElementById('E' + jw).value;
document.getElementById('N' + jw).title='' + '' + document.getElementById('N' + jw).value;
if (eval(1 + jw) == numlegs) {
document.getElementById('E' + kjw).title='' + document.getElementById('E' + kjw).value;
document.getElementById('N' + kjw).title='' + document.getElementById('N' + kjw).value;
if (('' + eval(eval(540.0 + eval(eval('0.000') - eval('' + thisbrgis))) % 360.0)).indexOf('.') != -1) {
document.getElementById('A' + kjw).setAttribute('data-title', '' + eval(eval(540.0 + eval(eval('0.000') - eval('' + thisbrgis))) % 360.0));
} else {
document.getElementById('A' + kjw).setAttribute('data-title', '' + eval(eval(540.0 + eval(eval('0.000') - eval('' + thisbrgis))) % 360.0) + '.00');
}
}
}
// alert(99);
}

var x360 = 0.0;
var areal = 0.0;
var breal = 0.0;
var deltae = 0.0;
var deltan = 0.0;
var badj = 0.0;
var thise="", thisn="", laste="", lastn="", lastb="", lpre=".0", vareal="", k;
laste = document.getElementById('E' + numlegs).value;
lastn = document.getElementById('N' + numlegs).value;
currb = eval(document.getElementById('firstBearing').value);
currx = eval(document.getElementById('E0').value);
curry = eval(document.getElementById('N0').value);
for ( var j = 0; j < numlegs; j++) {
k = j+1;
thise = document.getElementById('E' + k).value;
thisn = document.getElementById('N' + k).value;
areal = eval(currb);
//if (document.getElementById('A' + j).value.replace(/\./g,'').replace(/\-/g,'').replace(/0/g,'') != '') { justen--; alert('Ajusten=' + justen); }
//if (document.getElementById('L' + j).value.replace(/\./g,'').replace(/\-/g,'').replace(/0/g,'') != '') { justen--; alert('Ljusten=' + justen); }
breal = eval(document.getElementById('A' + j).value);
areal += breal;
currb = eval(areal);
x360 = eval(currb);
while (x360 >= 360.0) {
x360 = eval(x360-360.0);
}
document.getElementById('B' + j).innerHTML = ifzeromakezero(x360,0);
deltae = eval(Math.sin(currb * Math.PI / 180.0) * document.getElementById('L' + j).value);
deltan = eval(Math.cos(currb * Math.PI / 180.0) * document.getElementById('L' + j).value);
document.getElementById('dE' + j).innerHTML = ifzeromakezero(deltae,0);
document.getElementById('dN' + j).innerHTML = ifzeromakezero(deltan,0);
currx += deltae;
curry += deltan;
//alert(j);
document.getElementById('E' + k).value = ifzeromakezero(currx,1);
document.getElementById('N' + k).value = ifzeromakezero(curry,2);
//alert("k");
if (k == numlegs) {
eoff = ifzeromakezero(eval(-currx/numlegs),0);
noff = ifzeromakezero(eval(-curry/numlegs),0);
//alert("Eoff=" + eoff);
}
if (thise.replace("-0.000","").length != 0 && thisn.replace("-0.000","").length != 0) {
if (k == numlegs) {
if (adjust == 0) {
enarrstr = enarrstr + document.getElementById('E' + numlegs).value + ",";
enarrstr = enarrstr + document.getElementById('N' + numlegs).value + ",";
}
document.getElementById('Eall').innerHTML = ifzeromakezero(eval(thise-currx),0);
document.getElementById('Nall').innerHTML = ifzeromakezero(eval(thisn-curry),0);
} else {
document.getElementById('eE' + k).innerHTML = ifzeromakezero(eval(thise-currx),0);
document.getElementById('eN' + k).innerHTML = ifzeromakezero(eval(thisn-curry),0);
}
}
//alert(j);
areal = eval(currb);
areal += 180.0;
currb = eval(areal);
//alert("j");
}
//alert(currx + " " + curry);
//thise = laste;
//thisn = lastn;
//alert(laste + " " + lastn);
if (laste.replace("-0.000","").length != 0 && lastn.replace("-0.000","").length != 0) {
//alert(' ' + justen);
document.getElementById('Eall').innerHTML = ifzeromakezero(eval(laste-currx),0);
document.getElementById('Nall').innerHTML = ifzeromakezero(eval(lastn-curry),0);
}

//alert('+' + justen);
//if (adjust == 0) {
if (document.getElementById('A' + numlegs).value.replace("-0").length > 0) {
//alert(8);
if (document.getElementById('lastBearing').value.replace("-0").length > 0) {
//alert(9);
if (eval('' + justen) > 0) {
//alert(29);
kjw=0;
for (jw = 0; jw < numlegs; jw++) {
kjw++;
//alert('title');
if (eval(1 + jw) == numlegs) {
document.getElementById('E' + kjw).value=ifzeromakezero('' + document.getElementById('E' + kjw).title,1);
document.getElementById('N' + kjw).value=ifzeromakezero('' + document.getElementById('N' + kjw).title,2);
document.getElementById('A' + kjw).value='' + document.getElementById('A' + kjw).getAttribute('data-title');
document.getElementById('adjust').style.display='none';
}
document.getElementById('L' + jw).value='' + document.getElementById('L' + jw).title;
document.getElementById('A' + jw).value='' + document.getElementById('A' + jw).getAttribute('data-title');
document.getElementById('B' + jw).innerHTML='' + document.getElementById('B' + jw).title;
document.getElementById('B' + jw).title=bchange(document.getElementById('B' + jw).title, jw, numlegs);
document.getElementById('E' + jw).value=ifzeromakezero('' + document.getElementById('E' + jw).title,1);
document.getElementById('N' + jw).value=ifzeromakezero('' + document.getElementById('N' + jw).title,2);
}
//alert(39);
} else {
lastb = eval(document.getElementById('lastBearing').value);
areal = eval(currb);
breal = eval(document.getElementById('A' + numlegs).value);
areal -= breal;
//areal -= 180.0;
currb = eval(areal);
x360 = eval(currb);
while (x360 >= 360.0) {
x360 = eval(x360-360.0);
}
areal = eval(lastb-x360);
while (areal > 180.0) {
areal = eval(areal-360.0);
}
while (areal <= -180.0) {
areal = eval(areal+360.0);
}

badj = eval(numlegs);

var xoffp='';
var yoffp='';

if (document.getElementById('Eall').innerHTML.trim() == '') { xoffp='0'; }
if (document.getElementById('Nall').innerHTML.trim() == '') { yoffp='0'; }

var xoff = eval(xoffp + document.getElementById('Eall').innerHTML);
var yoff = eval(yoffp + document.getElementById('Nall').innerHTML);

if (xoff.length > 0 && yoff.length > 0) {
eoff = eval(xoff/badj);
noff = eval(yoff/badj);
}

badj = eval(badj+1);
vareal = areal.toString();
//alert("Vareal=" + vareal + " badj=" + badj);
if (vareal.indexOf(".") == (0 - 1)) vareal = vareal + ".0";
badj = eval(areal/badj);
vareal = badj.toString();
if (vareal.indexOf(".") == (0 - 1)) vareal = vareal + ".0";
//alert("vareal=" + vareal + " badj=" + badj);
if (adjust == 0) {
document.getElementById('Ball').innerHTML = ifzeromakezero(areal,0);
document.getElementById('Ball').innerHTML += " <input type='button' onclick='fixthis(" + '"' + vareal + '"' + ");' value='Adjust Angles'></input>";
document.getElementById('lastBearing').value = ifzeromakezero(areal,0);
}
}
}
//}
}
if (eval('' + justen) < 0) { adjust = 1; }
} else {
// alert("eoff=" + eoff + " noFF=" + noff);
//alert(10);
but.style.display = 'none';
var xxoff = eval(eoff);
var yyoff = eval(noff);
var eis=0.0, nis=0.0;
for ( var jj = 1; jj <= numlegs; jj++) {
eis = eval(document.getElementById('E' + jj).value);
nis = eval(document.getElementById('N' + jj).value);
document.getElementById('E' + jj).value = ifzeromakezero(eval(xxoff + eis),1);
if (document.getElementById('E' + jj).value.indexOf("e-") != (0 - 1)) document.getElementById('E' + jj).value = "0.000";
document.getElementById('N' + jj).value = ifzeromakezero(eval(yyoff + nis),2);
if (document.getElementById('N' + jj).value.indexOf("e-") != (0 - 1)) document.getElementById('N' + jj).value = "0.000";
//alert("xxoff=" + xxoff + " yyoff=" + yyoff);
xxoff += eval(eoff);
yyoff += eval(noff);
}


}
}

function bchange(inf, thisi, nlegs) {
var retval='';
var zz='';
var secsare=eval(eval('' + inf) * 3600.0);
var degsare=eval('' + Math.floor(secsare / 3600.0));
secsare=eval('' + inf);
secsare-=eval(degsare * 1.0); // -3.5
//alert(inf + ' interim secsare=' + secsare);
secsare=Math.abs(secsare);
var minsare=Math.floor(eval(secsare * 60.0));
secsare=eval('' + inf);
secsare-=eval(degsare * 1.0); // -3.5
secsare-=eval(minsare / 60.0); // -3.5
//alert(inf + ' final secsare=' + eval(secsare * 3600.0));
if (eval('' + eval(secsare * 3600.0)) < 10.0) { zz='0'; }
retval='' + degsare + ':' + ('0' + minsare).substring(eval(-2 + ('0' + minsare).length)) + ':' + zz + eval(secsare * 3600.0);
document.getElementById('B' + thisi).setAttribute('data-title','' + degsare + ':' + ('0' + minsare).substring(eval(-2 + ('0' + minsare).length)) + ':' + zz + eval(secsare * 3600.0));
if (thisi == 0) {
inf=document.getElementById('firstBearing').value;
secsare=eval(eval('' + inf) * 3600.0);
degsare=eval('' + Math.floor(secsare / 3600.0));
secsare=eval('' + inf);
secsare-=eval(degsare * 1.0); // -3.5
//alert(inf + ' interim secsare=' + secsare);
secsare=Math.abs(secsare);
minsare=Math.floor(eval(secsare * 60.0));
secsare=eval('' + inf);
secsare-=eval(degsare * 1.0); // -3.5
secsare-=eval(minsare / 60.0); // -3.5
//alert(inf + ' final secsare=' + eval(secsare * 3600.0));
zz='';
if (eval('' + eval(secsare * 3600.0)) < 10.0) { zz='0'; }
document.getElementById('firstBearing').setAttribute('data-title','' + degsare + ':' + ('0' + minsare).substring(eval(-2 + ('0' + minsare).length)) + ':' + zz + eval(secsare * 3600.0));
inf=document.getElementById('lastBearing').value;
secsare=eval(eval('' + inf) * 3600.0);
degsare=eval('' + Math.floor(secsare / 3600.0));
secsare=eval('' + inf);
secsare-=eval(degsare * 1.0); // -3.5
//alert(inf + ' interim secsare=' + secsare);
secsare=Math.abs(secsare);
minsare=Math.floor(eval(secsare * 60.0));
secsare=eval('' + inf);
secsare-=eval(degsare * 1.0); // -3.5
secsare-=eval(minsare / 60.0); // -3.5
//alert(inf + ' final secsare=' + eval(secsare * 3600.0));
zz='';
if (eval('' + eval(secsare * 3600.0)) < 10.0) { zz='0'; }
document.getElementById('lastBearing').setAttribute('data-title','' + degsare + ':' + ('0' + minsare).substring(eval(-2 + ('0' + minsare).length)) + ':' + zz + eval(secsare * 3600.0));
}
if (1 == 1) {
inf=document.getElementById('A' + thisi).value;
secsare=eval(eval('' + inf) * 3600.0);
degsare=eval('' + Math.floor(secsare / 3600.0));
secsare=eval('' + inf);
secsare-=eval(degsare * 1.0); // -3.5
//alert(inf + ' interim secsare=' + secsare);
secsare=Math.abs(secsare);
minsare=Math.floor(eval(secsare * 60.0));
secsare=eval('' + inf);
secsare-=eval(degsare * 1.0); // -3.5
secsare-=eval(minsare / 60.0); // -3.5
//alert(inf + ' final secsare=' + eval(secsare * 3600.0));
zz='';
if (eval('' + eval(secsare * 3600.0)) < 10.0) { zz='0'; }
document.getElementById('A' + thisi).setAttribute('data-title','' + degsare + ':' + ('0' + minsare).substring(eval(-2 + ('0' + minsare).length)) + ':' + zz + eval(secsare * 3600.0));
}
if (eval(eval('' + thisi) + 1) == eval('' + nlegs)) {
thisi++;
inf=document.getElementById('A' + thisi).value;
secsare=eval(eval('' + inf) * 3600.0);
degsare=eval('' + Math.floor(secsare / 3600.0));
secsare=eval('' + inf);
secsare-=eval(degsare * 1.0); // -3.5
//alert(inf + ' interim secsare=' + secsare);
secsare=Math.abs(secsare);
minsare=Math.floor(eval(secsare * 60.0));
secsare=eval('' + inf);
secsare-=eval(degsare * 1.0); // -3.5
secsare-=eval(minsare / 60.0); // -3.5
//alert(inf + ' final secsare=' + eval(secsare * 3600.0));
zz='';
if (eval('' + eval(secsare * 3600.0)) < 10.0) { zz='0'; }
document.getElementById('A' + thisi).setAttribute('data-title','' + degsare + ':' + ('0' + minsare).substring(eval(-2 + ('0' + minsare).length)) + ':' + zz + eval(secsare * 3600.0));
setTimeout(postcheck, 3700); // 500
}
return retval; //'' + degsare + ':' + ('0' + minsare).substring(eval(-2 + ('0' + minsare).length)) + ':' + zz + eval(secsare * 3600.0);
}

function anglechange(ame) {
var deg=0.0;
var mn=0;
var secs=0;
if (ame.value.indexOf(".") == (0 - 1)) {
mn = prompt("Enter the minutes value of your " + ame.value + " degree angle/bearing", "0");
if (mn == null) mn = "0";
if (mn.length == 1) mn = "0" + mn;
secs = prompt("Enter the seconds value of your " + ame.value + " degree, " + mn + " minutes angle/bearing", "0");
if (secs == null) secs = "0";
if (secs.indexOf(".") == 0) secs = "00" + secs;
if (secs.length == 1 || secs.indexOf(".") == 1) secs = "0" + secs;
if (secs.indexOf(".") == (0 - 1)) secs = secs + ".0";
if (ame.value.indexOf("-") == (0 - 1)) {
deg = eval(ame.value);
if (deg >= 360) {
while (deg >= 360) {
deg = deg - 360;
}
}
deg = eval(deg + (mn / 60.0));
deg = eval(deg + (secs / 3600.0));
ame.value = deg;
ame.title = ame.title + " ... DMS " + Math.floor(deg) + "°";
deg = deg - Math.floor(deg);
if (Math.floor((deg * 60.0)) < 10.0) ame.title = ame.title + "0";
ame.title = ame.title + Math.floor((deg * 60.0)) + "'";
deg = (deg * 60.0 - Math.floor((deg * 60.0))) * 60.0;
if (deg < 10) ame.title = ame.title + "0";
ame.title = ame.title + deg + '"';

} else {
deg = eval(ame.value);
//alert(ame.value + " " + deg);
deg = -deg;
//alert(ame.value + "+" + deg);
if (deg >= 360) {
while (deg >= 360) {
deg = deg - 360;
//alert(ame.value + ":" + deg);
}
}
deg = eval(deg + (mn / 60.0));
deg = eval(deg + (secs / 3600.0));
//deg = -deg;
deg = eval(360.0 - deg);
ame.value = deg;
ame.title = ame.title + " ... DMS " + Math.floor(deg) + "°";
deg = deg - Math.floor(deg);
if (Math.floor((deg * 60.0)) < 10.0) ame.title = ame.title + "0";
ame.title = ame.title + Math.floor((deg * 60.0)) + "'";
deg = (deg * 60.0 - Math.floor((deg * 60.0))) * 60.0;
if (deg < 10) ame.title = ame.title + "0";
ame.title = ame.title + deg + '"';

}

} else {
if (ame.value.indexOf("-") == (0 - 1)) {
deg = eval(ame.value);
if (deg >= 360) {
while (deg >= 360) {
deg = deg - 360;
}
ame.value = deg;
ame.title = ame.title + " ... DMS " + Math.floor(deg) + "°";
deg = deg - Math.floor(deg);
if (Math.floor((deg * 60.0)) < 10.0) ame.title = ame.title + "0";
ame.title = ame.title + Math.floor((deg * 60.0)) + "'";
deg = deg * 60.0 - Math.floor((deg * 60.0));
if (deg < 10) ame.title = ame.title + "0";
ame.title = ame.title + deg + '"';
} else {
deg = ame.value;
ame.title = ame.title + " " + Math.floor(deg) + "°";
deg = deg - Math.floor(deg);
if (Math.floor((deg * 60.0)) < 10.0) ame.title = ame.title + "0";
ame.title = ame.title + Math.floor((deg * 60.0)) + "'";
deg = (deg * 60.0 - Math.floor((deg * 60.0))) * 60.0;
if (deg < 10) ame.title = ame.title + "0";
ame.title = ame.title + deg + '"';
}
} else {
deg = eval(ame.value);
deg = -deg;
if (deg >= 360) {
while (deg >= 360) {
deg = deg - 360;
}
}
ame.value = eval(360.0 - deg);
deg = ame.value;
ame.title = ame.title + " ... DMS " + Math.floor(deg) + "°";
deg = deg - Math.floor(deg);
if (Math.floor((deg * 60.0)) < 10.0) ame.title = ame.title + "0";
ame.title = ame.title + Math.floor((deg * 60.0)) + "'";
deg = (deg * 60.0 - Math.floor((deg * 60.0))) * 60.0;
if (deg < 10) ame.title = ame.title + "0";
ame.title = ame.title + deg + '"';
}
}
}

function achange() {
}

function isNumeric(str) { // thanks to https://stackoverflow.com/questions/175739/built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number
if (typeof str != "string") return false // we only process strings!
return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
!isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail
}

function getthis(iois) {
var ik=0;
var totco=0;
var ccomma=',';
var legcnt=-1;
var lsst='', lsstd='';
var miniarr=[], minirec='', ethere=false, nthere=false, pthere=false, psuff='', psuffdef=' ';
if (iois != null) {
var aconto = (iois.contentWindow || iois.contentDocument);
if (aconto != null) {
if (aconto.document) { aconto = aconto.document; }
if (aconto.body != null) {
if (aconto.body.innerHTML.indexOf('<pre>') == 0 && aconto.body.innerHTML.indexOf(',') != -1) {
//alert('0:' + aconto.body.innerHTML);
var reclines=aconto.body.innerHTML.replace('<pre>','').replace('</pre>','').split('<br>');
for (var irecs=0; irecs<reclines.length; irecs++) {
miniarr=reclines[irecs].split(',');
minirec='';
ethere=false;
nthere=false;
pthere=false;
ccomma=',';
psuff=psuffdef.trim();
if (miniarr.length >= 2) {
if (!pthere && ('' + miniarr[0]).trim() != '' && !isNumeric('' + miniarr[0].replace(/\"/g,'').replace(/\'/g,''))) { if (psuffdef == " ") { psuffdef=','; } pthere=true; psuff=',' + miniarr[0]; }
if (!pthere && ('' + miniarr[1]).trim() != '' && !isNumeric('' + miniarr[1].replace(/\"/g,'').replace(/\'/g,''))) { if (psuffdef == " ") { psuffdef=','; } pthere=true; psuff=',' + miniarr[1]; }
if (isNumeric('' + miniarr[0].replace(/\"/g,'').replace(/\'/g,''))) { minirec+= '' + miniarr[0].replace(/\"/g,'').replace(/\'/g,''); ethere=true; }
if (isNumeric('' + miniarr[1].replace(/\"/g,'').replace(/\'/g,''))) {
if (ethere) {
minirec+= ',' + miniarr[1].replace(/\"/g,'').replace(/\'/g,''); nthere=true;
} else {
minirec+= '' + miniarr[1].replace(/\"/g,'').replace(/\'/g,''); ethere=true;
}
}
if (miniarr.length > 2) {
if (!pthere && ('' + miniarr[2]).trim() != '' && !isNumeric('' + miniarr[2].replace(/\"/g,'').replace(/\'/g,''))) { if (psuffdef == " ") { psuffdef=','; } pthere=true; psuff=''; for (ik=2; ik<miniarr.length; ik++) { psuff+=ccomma + miniarr[ik]; ccomma=','; } }
if (miniarr.length > 2 && ethere && !nthere) {
if (isNumeric('' + miniarr[2].replace(/\"/g,'').replace(/\'/g,''))) {
minirec+= ',' + miniarr[2].replace(/\"/g,'').replace(/\'/g,''); nthere=true;
}
}
}
if (nthere) { if (psuffdef.trim() == "") { psuffdef=""; psuff=""; } legcnt++; lsst+=lsstd + minirec + psuff; lsstd=','; }
}
}
if (lsst != '' && legcnt > 0) {
//alert(lsst.slice(-100));
localStorage.setItem('en_st', encodeURIComponent(lsst));
location.href=document.URL.split('#')[0].split('?')[0] + '?traverse=' + legcnt + ',0';
}
//alert(aconto.body.innerHTML);
}
}
}
}
}

function cadj() {
document.getElementById('adjust').click();
}

function processTraverse(ininfo) { // data items
for ( var i = 0; i < parambits.length; i++) {
if (numlegs == (0 - 1)) {
numlegs = parambits[i];
if (parambits.length > 1) firstBearing = parambits[i+1];
}
//alert(parambits[i]);
}
var zeroe="0.000";
var zeron="0.000";
var placec="";
var lightblue = "";
var clickadjust=false;
if (numlegs > 0) {
document.write("<h1>Survey Traverse Calculation</h1><input id='adjust' type='button' title='Analyze' onclick='analyze(this);' value='Analyze when Fully (or just E,N) Filled Out Below'></input> <a title='Restart' target='_blank' href='" + document.URL.split('#')[0].split('?')[0] + "'>Restart</a><br><br><table><tbody>");
document.write("<tr class='lightgray'><td title='Please enter Angles in Degrees'>Angles</td><td title='Please enter Bearings in Degrees'>Bearings</td><td>Lengths</td><td>Delta E</td><td>Delta N</td><td>E</td><td>N</td><td>Point</td></tr>");
document.write("<tr class='yellow'><td></td><td><input title='Entries with . are assumed as decimal degrees, else enter integer angle Degree value and will prompt for rest' onchange='anglechange(this);' type='text' id='firstBearing' value='" + firstBearing + "'></input></td><td></td><td></td><td></td><td></td><td></td><td><input class='lightgray' onclick='achange();' type='text' id='firstName'></input></td></tr>");
if (pvials.length > 0) { placec='' + pvials[0].replace(/\&\#44\;/g,",").replace(/\&comma\;/g,","); pvials.shift(); }
if (envials.length > 0) { clickadjust=true; zeroe='' + envials[0]; zeron='' + envials[1]; envials.shift(); envials.shift(); }
for ( var j = 0; j < numlegs; j++) {
document.write("<tr class='pink'><td><input title='Entries with . are assumed as decimal degrees, else enter integer angle Degree value and will prompt for rest' onchange='anglechange(this);' type='text' id='A" + j + "' value='0'></input></td><td id='dB" + j + "'></td><td></td><td><p class='cyellow' id='eE" + j + "'></p></td><td><p class='cyellow' id='eN" + j + "'></p></td><td><input " + lightblue + " onclick='achange();' type='text' id='E" + j + "' value='" + zeroe + "'></input></td><td><input " + lightblue + " onclick='achange();' type='text' id='N" + j + "' value='" + zeron + "'></input></td><td><input class='lightblue' onclick='achange();' type='text' id='P" + j + "' value=\"" + placec + "\"></input></td></tr>");
document.write("<tr class='yellow'><td></td><td id='B" + j + "'>0</td><td><input onclick='achange();' type='text' id='L" + j + "' value='0.000'></input></td><td id='dE" + j + "'>0.000</td><td id='dN" + j + "'>0.000</td><td></td><td></td><td></td></tr>");
zeroe = "";
zeron = "";
placec = "";
if (pvials.length > 0) { placec='' + pvials[0].replace(/\&\#44\;/g,",").replace(/\&comma\;/g,","); pvials.shift(); }
if (envials.length > 0) { clickadjust=true; zeroe='' + envials[0]; zeron='' + envials[1]; envials.shift(); envials.shift(); }
lightblue = " class='lightblue'";
}
if (zeroe == "") {
zeroe="-0.000";
}
if (zeron == "") {
zeron="-0.000";
}
document.write("<tr class='pink'><td><input class='lightgray' title='Entries with . are assumed as decimal degrees, else enter integer angle Degree value and will prompt for rest' onchange='anglechange(this);' type='text' id='A" + numlegs + "' value='-0'></input></td><td id='Ball' class='white'></td><td></td><td id='Eall' class='white'></td><td id='Nall' class='white'></td><td><input class='lightgreen' onclick='achange();' type='text' id='E" + numlegs + "' value='" + zeroe + "'></input></td><td><input class='lightgreen' onclick='achange();' type='text' id='N" + numlegs + "' value='" + zeron + "'></input></td><td><input class='lightblue' onclick='achange();' type='text' id='P" + numlegs + "' value=\"" + placec + "\"></input></td></tr>");
document.write("<tr class='yellow'><td></td><td><input class='lightgray' title='Entries with . are assumed as decimal degrees, else enter integer angle Degree value and will prompt for rest' onchange='anglechange(this);' type='text' id='lastBearing' value='" + lastBearing + "'></input></td><td></td><td></td><td></td><td></td><td></td><td><input class='lightgray' onclick='achange();' type='text' id='firstName'></input></td></tr>");
document.write("</tbody></table><div id=overlays></div><iframe src='//www.rjmprogramming.com.au/About_Us.html' style=display:none; id=preifcsv></iframe><iframe srcdoc='' style=display:none; onload='getthis(this);' id=ifcsv></iframe>");
if (clickadjust) { setTimeout(cadj, 1000); }
setTimeout(postcheck, 2000);
}
}

if (document.URL.replace('?numlegs=','').indexOf('?') != -1) {
checkAtStart();
} else {
setTimeout(checkAtStart, 2000);
}
</script>
<body>
<iframe src='//www.rjmprogramming.com.au/About_Us.html' style=display:none; id=preifcsv></iframe>
<iframe srcdoc='' style=display:none; onload='getthis(this);' id=ifcsv></iframe>
<form target=mygeoframe id=geoform action='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php' style='display:none;' method='POST'>
<input type=hidden id=ititle name=title value='My Land Survey Traverse'></input>
<input type=hidden name=aregexographicals value=y><input>
<input type=hidden id=iwidth name=width value='556'></input>
<input type=hidden id=iheight name=height value='346'></input>
<input type=hidden id=icountry name=country value='Places'></input>
<input type=hidden id=ipopularity name=popularity value=''></input>
<input type=hidden id=iaregeographicals name=aregeographicals value='http.Ice,http.Lakagigar_Volcano,http.Bora_Bora'></input>
<input type=hidden id=ipeninfo name=peninfo value='75.57|-92.28|127938_Ice,64.04|-18.15|127755_Lakagigar_Volcano,-16.30|151.44|127958.65039_Bora_Bora'></input>
<input type=hidden id=idata name=data value=' [75.57|-92.28|~Ice~,2] , [64.04|-18.15|~Lakagigar Volcano~,2] , [-16.30|151.44|~Bora Bora~,2]'></input>
<input type=hidden name=wouldlikeyoutoseekpermission value=y></input>
<input type=submit value='Do GeoChart' style='display:none;' id=geosb><input>
</form>
<form target=mygeoframe id=mapform action='//www.rjmprogramming.com.au/PHP/Map/map.php' style='display:none;' method='POST'>
<input type=hidden id=jtitle name=title value='My Land Survey Traverse'></input>
<input type=hidden id=jonclick name=onclick value='y'></input>
<input type=hidden id=jlabel name=label value="['Lat',"></input>
<input type=hidden id=jvalue name=value value="'Lon','Name']"></input>
<input type=hidden id=jdata name=data value=',[75.57,-92.28,~Ice~],[64.04,-18.15,~Lakagigar Volcano~],[-16.30,151.44,~Bora Bora~]'></input>
<input type=hidden name=wouldlikeyoutoseekpermission value=y></input>
<input type=submit value='Do Map' style='display:none;' id=mapsb><input>
</form>
</body>
</html>