<!doctype html>
<html>
<head>
<title>Missing Two - RJM Programming - December, 2018 ... Thanks to https://www.igismap.com/formula-to-find-bearing-or-heading-angle-between-two-points-latitude-longitude/</title>
<meta id="myviewport" name="viewport" content="width=device-width, initial-scale=1, minimum-scale=0.1, maximum-scale=8, user-scalable=yes" >
<style>
summary { background-color: #f0f0f0; }

.ph::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
color: red;
opacity: 1; /* Firefox */
font-size: 8px;
}

.ph:-ms-input-placeholder { /* Internet Explorer 10-11 */
color: red;
font-size: 8px;
}

.ph::-ms-input-placeholder { /* Microsoft Edge */
color: red;
font-size: 8px;
}
</style>
<script type='text/javascript'>
var dmore='none';
var trfoota="<td id=posttdmid style='vertical-align:top;><input id=goagain style='display:none;background-color:lightgreen;font-size:24px;' onclick=\"nextplease(); this.style.display='none';\" type=button value='Go Again'></input></td>";
var tdfoota="";
var xipn=location.search.split('ipn=')[1] ? ('' + decodeURIComponent(location.search.split('ipn=')[1].split('&')[0]).replace(/\+/g,' ')) : ''; //document.getElementById('tplacen').value;

var wasthisso='' + (screen.msOrientation || screen.mozOrientation || (screen.orientation || {}).type); //"portrait";
var wasangle=eval(180 - eval('' + window.orientation));

if ((navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) || document.URL.indexOf('alert=') != -1) && document.URL.toLowerCase().indexOf('https:') != 0) {
location.href=(document.URL.replace('http:','https:') + '&random=' + Math.floor(Math.random() * 174765654)).replace('.html&','.html?');
}
if ((navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) || document.URL.indexOf('update=') != -1) && document.URL.toLowerCase().indexOf('https:') != 0) {
location.href=(document.URL.replace('http:','https:') + '&random=' + Math.floor(Math.random() * 174765654)).replace('.html&','.html?');
}


// Thanks to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await and
// https://gist.github.com/Ajasra/ddd616505013a4309c0dda8a8ba626cb

async function myfunction() {
console.log('Inside of myfunction');
//alert(0);
if (window.DeviceOrientationEvent && typeof(DeviceOrientationEvent.requestPermission) === "function") {
//alert(4);
const permissionState = await DeviceOrientationEvent.requestPermission().then(response => {
if (response === 'granted') {
if (1 == 2) { alert('GrAnted'); }
//window.addEventListener('deviceorientation', OrientationHandler, true);
setTimeout(fallow, 2000);
dorh();
} else { console.log('prompt'); return false; } //} else if (result.state === 'prompt') {
//if (1 == 2) { alert("Need prompt!"); }
//} else {
//if (1 == 2) { alert("Not Supported!"); }
//}
}).catch(console.error);

//if (permissionState === "granted") {
// alert('granted');
//} else {
// alert('denied');
//}
} else if (window.DeviceOrientationEvent) {
//alert(44);
dmore='none';
setTimeout(fallow, 2000); //document.getElementById('ballow').style.display='block';
dorh();
} else {
dmore='none';
setTimeout(fallow, 2000);
}

if (window.DeviceMotionEvent && typeof(DeviceMotionEvent.requestPermission) === "function") {
//alert(24);
const permissionStateM = await DeviceMotionEvent.requestPermission().then(response => {
if (response === 'granted') {
if (1 == 2) { alert('GranTed'); }
window.addEventListener('devicemotion', function(event) {
lalpha='' + event.rotationRate.alpha;
});
//window.addEventListener('deviceorientation', OrientationHandler, true);
} else { console.log('prompt'); return false; } //} else if (result.state === 'prompt') {
//if (1 == 2) { alert("NeeD prompt!"); }
//} else {
//if (1 == 2) { alert("NoT Supported!"); }
//}
}).catch(console.error);

//if (permissionStateM === "granted") {
// alert('Granted');
//} else {
// alert('Denied');
//}
} else if (window.DeviceMotionEvent) {
//alert(244);
window.addEventListener('devicemotion', function(event) {
lalpha='' + event.rotationRate.alpha;
});
}


}

// Here we wait for the myfunction to finish
// and then returns a promise that'll be waited for aswell
// It's useless to wait the myfunction to finish before to return
// we can simply returns a promise that will be resolved later

// Also point that we don't use async keyword on the function because
// we can simply returns the promise returned by myfunction
function start() {
return myfunction();
}

// Call start
(async() => {
console.log('before start');

await start();

console.log('after start');
})();

var degtorad = Math.PI / 180; // Degree-to-Radian conversion ... thanks to https://www.w3.org/TR/orientation-event/#worked-example

var eles=['latf','longf','brg','dist','latt','longt'];
var cwhat=[false,false,false,false,true,true];
var decided=false;
var isokformore='';
var wasthisso="portrait";
var jsokformore='';
var trid='trgraphics';
var elev=2.0;
var dorbrg=-1.0, tiltLeftToRight=-1.0, tiltFrontToBack=-1.0, datstart=true, initial_yaw=0.0, initial_pitch=-1.0, initial_roll=-1.0, lalpha=0.0, lastalpha='';
var dok=true;
var viastart=false;
var dcnt=0;
var gllentry='';
var gllonesuffix='f';
var faux=false;
var cfok=true;
var lastclick='';
var fplacen=location.search.split('fplacen=')[1] ? (' ' + decodeURIComponent(location.search.split('fplacen=')[1].split('&')[0]).replace(/\+/g,' ')) : '';
var tplacen=location.search.split('tplacen=')[1] ? (' ' + decodeURIComponent(location.search.split('tplacen=')[1].split('&')[0]).replace(/\+/g,' ')) : '';
var fromto=location.search.split('tplacen=')[1] ? (location.search.split('fplacen=')[1] ? 'to' : 'from') : 'from';
var tdid='tdfrom';
var divid='dfrom';
var gc='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=Earth%20Places&aregexographicals=y&aregeographicals=HTTP.From%2Chttp.To' +
'&peninfo=latfrom|longfrom|127968_From,latto|longto|128205_To,nearestlat|nearestlong|nearestplace' +
'&width=417&height=260&country=Places&popularity=' +
'&data=%20[latfrom|longfrom|~From~,2]%20,%20[latto|longto|~To~,2]%20,%20[nearestlat|nearestlong|~nearestplace~,2]';
var mu="//www.rjmprogramming.com.au/PHP/Map/map.php?title=London&onclick=y&label=['Lat',&value='Lon','Name']&data=,[51.5072,-0.1275,~London~]";
var origmu=mu;
var tpurl="https://www.google.com/maps/dir/Sydney+NSW,+Australia/Brisbane+QLD,+Australia";
var origtpurl=tpurl;
var accomurl='//www.google.com/search?q=accommodation+in+Springwood,+New+South+Wales&rlz=1C5CHFA_enAU832AU832&sxsrf=AOaemvKkE3W-5RrqTUzo4tGtosOlwjOXFA:1631413859134&source=lnms&tbm=isch&sa=X&ved=2ahUKEwiHjbicsvjyAhWIyzgGHb-bDkcQ_AUoA3oECAEQBQ&biw=1439&bih=729';

var documentURL=document.URL;

setTimeout(bthe, 3000);

function fallow() {
document.getElementById('ballow').style.display=dmore; //'none';
}

function compassHeading( alpha, beta, gamma ) { // thanks to https://www.w3.org/TR/orientation-event/#worked-example

var _x = beta ? beta * degtorad : 0; // beta value
var _y = gamma ? gamma * degtorad : 0; // gamma value
var _z = alpha ? alpha * degtorad : 0; // alpha value

var cX = Math.cos( _x );
var cY = Math.cos( _y );
var cZ = Math.cos( _z );
var sX = Math.sin( _x );
var sY = Math.sin( _y );
var sZ = Math.sin( _z );

// Calculate Vx and Vy components
var Vx = - cZ * sY - sZ * sX * cY;
var Vy = - sZ * sY + cZ * sX * cY;

// Calculate compass heading
var compassHeading = Math.atan( Vx / Vy );

// Convert compass heading to use whole unit circle
if( Vy < 0 ) {
compassHeading += Math.PI;
} else if( Vx < 0 ) {
compassHeading += 2 * Math.PI;
}

return compassHeading * ( 180 / Math.PI ); // Compass Heading (in degrees)

}

function bthe() {
if (documentURL.indexOf('?') != -1) {
isokformore='?' + documentURL.split('?')[1].split('#')[0];
}
}

function great_circle_distance(talis, gnolis, latis, longis) {
var ourdist=0.0;
var rgnol=eval((gnolis) * Math.PI / 180.0);
var rtal=eval((talis) * Math.PI / 180.0);
var rlong=eval((longis) * Math.PI / 180.0);
var rlat=eval((latis) * Math.PI / 180.0);
var deltalong = Math.abs(eval(((gnolis)-(longis)) * Math.PI / 180.0));
var acof = eval(Math.sin(rtal) * Math.sin(rlat)) + (Math.cos(rtal) * Math.cos(rlat) * Math.cos(deltalong)); // via http://en.wikipedia.org/wiki/Great-circle_distance ... thanks
ourdist = eval(Math.round((Math.acos(acof) * 6371000.0) + 0.00001) * 100) / 100;
return ourdist;
}

function nextplease() {
var i;
console.log('nextplease 1');
if ((isokformore + jsokformore) != '' && 1 == 1) {
console.log('nextplease 11');
if (1 == 1) {
window.open(document.URL.split('?')[0].split('?')[0], '_blank');
} else {
document.getElementById('outofthisworld').value='slong';
window.scrollTo(0,0); //location.href='#dtop';
}
} else {
console.log('nextplease 111');

for (i=0; i<eles.length; i++) {
document.getElementById(eles[i]).value='0.0000000';
document.getElementById(eles[i]).style.backgroundColor='white';
}
eles=['latf','longf','brg','dist','latt','longt'];
cwhat=[false,false,false,false,true,true];
decided=false;
}
console.log('nextplease 2');
}

function calcit() {
var i, ourbrg=0.0, ourdist=0.0, j;
if (jsokformore != '') {
document.getElementById('latf').type='text';
document.getElementById('longf').type='text';
document.getElementById('latt').type='text';
document.getElementById('longt').type='text';
document.getElementById('brg').type='text';
document.getElementById('dist').type='text';
} else {
if ((isokformore + jsokformore) != '') {
document.getElementById('outofthisworld').value='ifill';
} else {
if (!cwhat[0] && !cwhat[1] && !cwhat[2] && !cwhat[3] && !cwhat[4] && !cwhat[5]) {
if (Math.abs(eval('' + document.getElementById(eles[4]).value)) < 0.00000004 && Math.abs(eval('' + document.getElementById(eles[5]).value)) < 0.00000004) {
cwhat[4]=true;
cwhat[5]=true;
} else if (Math.abs(eval('' + document.getElementById(eles[2]).value)) < 0.00000004 && Math.abs(eval('' + document.getElementById(eles[3]).value)) < 0.00000004) {
cwhat[2]=true;
cwhat[3]=true;
}
}
//alert(('' + cwhat[0]) + ('' + cwhat[1]) + ('' + cwhat[2]) + ('' + cwhat[3]) + ('' + cwhat[4]) + ('' + cwhat[5]));
if (jsokformore != '' || (cwhat[0] && cwhat[1] || (!cwhat[0] && !cwhat[1] && !cwhat[2] && !cwhat[3] && !cwhat[4] && !cwhat[5]))) {
isokformore=' ';
if (('' + document.getElementById('mysel').value) == '1') {
ourbrg=eval(eval(540.0 + 180.0 + eval('' + document.getElementById(eles[2]).value)) % 360.0);
} else {
ourbrg=eval('' + document.getElementById(eles[2]).value);
}
for (j=eval(('' + document.getElementById('mysel').value)); j>=1; j--) {
ourdist=eval('' + document.getElementById(eles[3]).value);

document.getElementById(eles[0]).value='' +
eval(eval(eval(180.0 / Math.PI) * Math.asin(
eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.cos(eval(eval('' + ourdist) / 6371000.0)))) +
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.sin(eval(eval('' + ourdist) / 6371000.0))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + ourbrg)))))));

document.getElementById(eles[1]).value=eval(eval(180.0 / Math.PI) * eval(eval(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[5]).value)) +
Math.atan2(
eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + ourbrg)) *
eval('' + Math.sin(eval(eval('' + ourdist) / 6371000.0)))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value)))),
eval(eval('' + Math.cos(eval(eval('' + ourdist) / 6371000.0))) -
eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value)))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value)))))));

if (document.getElementById(eles[0]).value.indexOf('e-') != -1) { document.getElementById(eles[0]).value='0.0000000'; }
if (document.getElementById(eles[1]).value.indexOf('e-') != -1) { document.getElementById(eles[1]).value='0.0000000'; }

if (j != 1) {
ourbrg=eval(eval(360.0 + eval(eval(eval(180.0 / Math.PI) * Math.atan2(
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval(eval('' + document.getElementById(eles[5]).value) - eval('' + document.getElementById(eles[1]).value))))),
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value)))) -
eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval(eval('' + document.getElementById(eles[5]).value) - eval('' + document.getElementById(eles[1]).value)))))
)))) % 360.0);
//ourbrg=eval(eval(540.0 + eval('' + document.getElementById(eles[2]).value)) % 360.0);
document.getElementById(eles[2]).value='' + ourbrg;
document.getElementById('mysel').value='1';
//alert(ourbrg);
}


}

document.getElementById(eles[0]).style.backgroundColor='lightgreen';
document.getElementById(eles[1]).style.backgroundColor='lightgreen';
document.getElementById('goagain').style.display='block'; // setTimeout(nextplease,10000);

} else if (cwhat[2] && cwhat[3]) {
isokformore=' ';

ourdist=great_circle_distance(document.getElementById(eles[0]).value,document.getElementById(eles[1]).value,document.getElementById(eles[4]).value,document.getElementById(eles[5]).value);
document.getElementById(eles[3]).value='' + ourdist;


//Let ‘R’ be the radius of Earth,
//‘L’ be the longitude,
//‘θ’ be latitude,
//‘β‘ be Bearing.

//Bearing from point A to B, can be calculated as,

//β = atan2(X,Y),

//where, X and Y are two quantities and can be calculated as:

//X = cos θb * sin ∆L

//Y = cos θa * sin θb – sin θa * cos θb * cos ∆L

ourbrg=eval(eval(360.0 + eval(eval(eval(180.0 / Math.PI) * Math.atan2(
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval(eval('' + document.getElementById(eles[5]).value) - eval('' + document.getElementById(eles[1]).value))))),
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value)))) -
eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval(eval('' + document.getElementById(eles[5]).value) - eval('' + document.getElementById(eles[1]).value)))))
)))) % 360.0);

document.getElementById('mysel').value='2';
document.getElementById(eles[2]).value='' + ourbrg;
document.getElementById(eles[2]).style.backgroundColor='lightgreen';
document.getElementById(eles[3]).style.backgroundColor='lightgreen';
document.getElementById('goagain').style.display='block'; // setTimeout(nextplease,10000);

} else if (cwhat[4] && cwhat[5]) {
isokformore=' ';

if (('' + document.getElementById('mysel').value) == '2') {
ourbrg=eval(eval(540.0 + 180.0 + eval('' + document.getElementById(eles[2]).value)) % 360.0);
} else {
ourbrg=eval('' + document.getElementById(eles[2]).value);
}
for (j=eval(3 - eval(('' + document.getElementById('mysel').value))); j>=1; j--) {
ourdist=eval('' + document.getElementById(eles[3]).value);


//Let first point latitude be la1,
///longitude as lo1,
//d be distance,
//R as radius of Earth,
//Ad be the angular distance i.e d/R and
//θ be the bearing,

//Here is the formula to find the second point, when first point, bearing and distance is known:

//latitude of second point = la2 = asin(sin la1 * cos Ad + cos la1 * sin Ad * cos θ), and
//longitude of second point = lo2 = lo1 + atan2(sin θ * sin Ad * cos la1 , cos Ad – sin la1 * sin la2)

document.getElementById(eles[4]).value='' +
eval(eval(eval(180.0 / Math.PI) * Math.asin(
Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value)) *
Math.cos(eval(eval('' + ourdist) / 6371000.0)) +
Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value)) *
Math.sin(eval(eval('' + ourdist) / 6371000.0)) *
Math.cos(eval(Math.PI / 180.0) * eval('' + ourbrg)))));

//Let first point latitude be la1,
//longitude as lo1,
//d be distance,
//R as radius of Earth,
//Ad be the angular distance i.e d/R and
//θ be the bearing,
// longitude of second point = lo2 = lo1 + atan2(sin θ * sin Ad * cos la1 , cos Ad – sin la1 * sin la2)

document.getElementById(eles[5]).value=eval(eval(180.0 / Math.PI) * eval(eval(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[1]).value)) +
Math.atan2(
eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + ourbrg)) *
eval('' + Math.sin(eval(eval('' + ourdist) / 6371000.0)))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value)))),
eval(eval('' + Math.cos(eval(eval('' + ourdist) / 6371000.0))) -
eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value)))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value)))))));


if (j != 1) {
ourbrg=eval(eval(360.0 + eval(eval(eval(180.0 / Math.PI) * Math.atan2(
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval(eval('' + document.getElementById(eles[1]).value) - eval('' + document.getElementById(eles[5]).value))))),
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value)))) -
eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval(eval('' + document.getElementById(eles[1]).value) - eval('' + document.getElementById(eles[5]).value)))))
)))) % 360.0);
//ourbrg=eval(eval(540.0 + eval('' + document.getElementById(eles[2]).value)) % 360.0);
document.getElementById(eles[2]).value='' + ourbrg;
document.getElementById('mysel').value='2';
//alert(ourbrg);
}



}

if (document.getElementById(eles[4]).value.indexOf('e-') != -1) { document.getElementById(eles[4]).value='0.0000000'; }
if (document.getElementById(eles[5]).value.indexOf('e-') != -1) { document.getElementById(eles[5]).value='0.0000000'; }

document.getElementById(eles[4]).style.backgroundColor='lightgreen';
document.getElementById(eles[5]).style.backgroundColor='lightgreen';
document.getElementById('goagain').style.display='block'; // setTimeout(nextplease,10000);

} else {
alert('Oops! Cannot calculate this mix, sorry.');
nextplease();
}

if ((isokformore + jsokformore) != '') {
document.getElementById('slong').style.cursor='pointer';
document.getElementById('slong').style.textDecoration='underline';
document.getElementById('slong').title='Click for another leg of a trip, perhaps?';
document.getElementById('slong').innerHTML='+';
isokformore='?latf=' + encodeURIComponent(document.getElementById('latt').value) + '&longf=' + encodeURIComponent(document.getElementById('longt').value);
window.scrollTo(0,0); //location.href='#dtop';
setTimeout(bthen, 3000);
} else {
window.scrollTo(0,0); //location.href='#dtop';
setTimeout(bthen, 3000);
}
}
}
}

// 38.627089
// -90.200203
// 96.51262423499941 279.26239975009173
// 382900

function mapit(ao) {
if ((isokformore + jsokformore) != '' && !faux) {
console.log('ao.id=' + ao.id);
//alert(isokformore + ' ... ' + top.document.getElementById('ltt').value);
if (ao.id.toLowerCase().indexOf('from') != -1) {
document.getElementById('outofthisworld').value=ao.id + '|' + top.document.getElementById('ltf').value + ',' + top.document.getElementById('lgf').value;
top.document.getElementById('outofthisworld').value=ao.id + '|' + top.document.getElementById('ltf').value + ',' + top.document.getElementById('lgf').value;
} else if (ao.id.toLowerCase().indexOf('to') != -1) {
document.getElementById('outofthisworld').value=ao.id + '|' + top.document.getElementById('ltt').value + ',' + top.document.getElementById('lgt').value;
top.document.getElementById('outofthisworld').value=ao.id + '|' + top.document.getElementById('ltt').value + ',' + top.document.getElementById('lgt').value;
} else {
document.getElementById('outofthisworld').value=ao.id;
}
} else {
trid='trgraphics';
tdid='td' + ao.id.replace('td','').replace('a','');
divid='d' + ao.id.replace('td','').replace('a','');
var htt='http:';
if (document.URL.toLowerCase().indexOf('https:') == 0) { htt='https:'; }
console.log('tdid=' + tdid);
if (tdid == 'tdfrom') {
if (('' + document.getElementById(ao.id.replace('td','a')).href).replace('undefined','') == '') {
document.getElementById(ao.id.replace('td','a')).setAttribute('data-href',htt + '//www.rjmprogramming.com.au/PHP/tz_places.php?place=&latitude=' + encodeURIComponent(document.getElementById('latf').value) + '&longitude=' + encodeURIComponent(document.getElementById('longf').value));
//document.getElementById(ao.id.replace('td','a')).target='_blank';
//alert(document.getElementById(ao.id.replace('td','a')).href);
//} else {
//alert(('' + document.getElementById(ao.id.replace('td','a')).href));
}
if (1 == 1) {
if (!faux) { top.document.getElementById('nearestif').src='//www.rjmprogramming.com.au/PHP/tz_places.php?place=&latitude=' + encodeURIComponent(document.getElementById('latf').value) + '&longitude=' + encodeURIComponent(document.getElementById('longf').value); }
} else {
top.document.getElementById('latitude').value=document.getElementById('latf').value;
top.document.getElementById('longitude').value=document.getElementById('longf').value;
if (!faux) { top.document.getElementById('inearest').click(); }
}
} else if (tdid == 'tdto') {
if (('' + document.getElementById(ao.id.replace('td','a')).href).replace('undefined','') == '') {
document.getElementById(ao.id.replace('td','a')).setAttribute('data-href',htt + '//www.rjmprogramming.com.au/PHP/tz_places.php?place=&latitude=' + encodeURIComponent(document.getElementById('latt').value) + '&longitude=' + encodeURIComponent(document.getElementById('longt').value));
//document.getElementById(ao.id.replace('td','a')).target='_blank';
//alert(document.getElementById(ao.id.replace('td','a')).href);
//} else {
//alert(('' + document.getElementById(ao.id.replace('td','a')).href));
}
if (1 == 1) {
if (!faux) { top.document.getElementById('nearestif').src='//www.rjmprogramming.com.au/PHP/tz_places.php?place=&latitude=' + encodeURIComponent(document.getElementById('latt').value) + '&longitude=' + encodeURIComponent(document.getElementById('longt').value); }
} else {
top.document.getElementById('latitude').value=document.getElementById('latt').value;
top.document.getElementById('longitude').value=document.getElementById('longt').value;
if (!faux) { top.document.getElementById('inearest').click(); }
}
}
}
window.scrollTo(0,document.body.scrollHeight); //location.href='#ifill';
faux=false;
}

function athen() {
if (top.document.getElementById('dto')) {
if (top.document.getElementById('dto').innerHTML.indexOf(' size="3"') != -1) {
top.document.getElementById('dto').innerHTML=top.document.getElementById('dto').innerHTML.replace(' size="3"', ' size="4"');
}
}
if (top.document.getElementById('dfrom')) {
if (top.document.getElementById('dfrom').innerHTML.indexOf(' size="3"') != -1) {
top.document.getElementById('dfrom').innerHTML=top.document.getElementById('dfrom').innerHTML.replace(' size="3"', ' size="4"');
}
}
window.scrollTo(0,document.body.scrollHeight); //location.href='#ifill';
}

function bthen() {
if (top.document.getElementById('dto')) {
if (top.document.getElementById('dto').innerHTML.indexOf(' size="3"') != -1) {
top.document.getElementById('dto').innerHTML=top.document.getElementById('dto').innerHTML.replace(' size="3"', ' size="4"');
}
}
if (top.document.getElementById('dfrom')) {
if (top.document.getElementById('dfrom').innerHTML.indexOf(' size="3"') != -1) {
top.document.getElementById('dfrom').innerHTML=top.document.getElementById('dfrom').innerHTML.replace(' size="3"', ' size="4"');
}
}
top.window.scrollTo(0,0); //location.href='#ifill';
}

function checknp(oiis) {
var i, j, k, plist='', ogc='';
// www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php
//?title=Earth%20Places
//&aregexographicals=y
//&aregeographicals=HTTP.From%2Chttp.To%2Chttp.Lome
//&peninfo=75.57|-92.28|127968_From,64.04|-18.15|128205_To,-16.30|151.44|Lome
//&width=417
//&height=260
//&country=Places
//&popularity=
//&data=%20[75.57|-92.28|~From~,2]%20,%20[64.04|-18.15|~To~,2]%20,%20[-16.30|151.44|~Lome~,2]

// <select size="4" id="snearest" style="background-color:olive;" onchange=" alert(this.options[this.selectedIndex].title + String.fromCharCode(32) + this.options[this.selectedIndex].text); "><option title="" value="">Please see Nearest TimeZone Places below ...</option>
// <option data-ll="(5.55,-0.21667)" title="Nearest" value="Africa/Accra">Africa/Accra in Ghana is 617.6km (+0) from (0.0000000,0.0000000)</option>
// <option data-ll="(6.13333,1.21666)" title="Next Nearest" value="Africa/Lome">Africa/Lome in Togo is 695.234km (+0) from (0.0000000,0.0000000)</option>
// <option data-ll="(5.31666,-4.03334)" title="Third Nearest" value="Africa/Abidjan">Africa/Abidjan in Cote d'Ivoire is 741.662km (+0) from (0.0000000,0.0000000)</option>
// </select>

// www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=Earth%20Places&aregexographicals=y&aregeographicals=HTTP.From%2Chttp.To%2Chttp.Lome&peninfo=75.57|-92.28|127968_From,64.04|-18.15|128205_To,-16.30|151.44|Lome&width=417&height=260&country=Places&popularity=&data=%20[75.57|-92.28|~From~,2]%20,%20[64.04|-18.15|~To~,2]%20,%20[-16.30|151.44|~Lome~,2]
var altolat='', altolong='';


if (document.getElementById('nearest')) {
//alert('hereIS');
if (document.getElementById('nearest').innerHTML != '' && document.getElementById('nearest').innerHTML.trim() == document.getElementById('nearest').innerHTML) {
//alert(top.document.getElementById('outofthisworld').value);
document.getElementById('nearest').innerHTML+=' ';
setTimeout(athen, 3000);
if (top.document.getElementById('outofthisworld').value.indexOf('|') != -1) {
if (top.document.getElementById('outofthisworld').value.split('|')[1] != '') {
altolat=top.document.getElementById('outofthisworld').value.split('|')[1].split(',')[0];
altolong=top.document.getElementById('outofthisworld').value.split('|')[1].split(',')[1];
//alert(top.document.getElementById('outofthisworld').value);
tdid='td' + top.document.getElementById('outofthisworld').value.split('|')[0].replace('a','');
divid='d' + top.document.getElementById('outofthisworld').value.split('|')[0].replace('a','');
top.document.getElementById('outofthisworld').value=top.document.getElementById('outofthisworld').value.split('|')[0];
}
}
document.getElementById(divid).style.display='table-cell';
document.getElementById(divid).innerHTML=document.getElementById('nearest').innerHTML.replace('position:','background-color:lightblue;').replace('absolute;','').replace('top:','').replace('left:','').replace('70px;','').replace('350px;','');
//var dbits=document.getElementById(divid).innerHTML=document.getElementById('nearest').innerHTML.split(' data-ll=');
//var vbits=document.getElementById(divid).innerHTML=document.getElementById('nearest').innerHTML.replace(' value=',' Value=').split(' value=');
//alert(top.document.getElementById('nearest').innerHTML);
var dbits=top.document.getElementById('nearest').innerHTML.split(' data-ll=');
var vbits=top.document.getElementById('nearest').innerHTML.replace(' value=',' Value=').split(' value=');
if (dbits.length > 1) {
ogc='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=Earth%20Places&aregexographicals=y&aregeographicals=HTTP.From%2Chttp.To' +
'&peninfo=latfrom|longfrom|127968_From,latto|longto|128205_To,nearestlat|nearestlong|nearestplace' +
'&width=417&height=260&country=Places&popularity=' +
'&data=%20[latfrom|longfrom|~From~,2]%20,%20[latto|longto|~To~,2]%20,%20[nearestlat|nearestlong|~nearestplace~,2]';
if (tdid.toLowerCase().indexOf('from') != -1) {
//alert(altolat + ' ... ' + altolong + ' ___ ' + document.getElementById(divid).innerHTML);
if (altolat != '' && altolong != '') {
ogc=ogc.replace('latfrom', altolat).replace('latfrom', altolat);
ogc=ogc.replace('longfrom', altolong).replace('longfrom', altolong);
} else {
ogc=ogc.replace('latfrom', document.getElementById('latf').value).replace('latfrom', document.getElementById('latf').value);
ogc=ogc.replace('longfrom', document.getElementById('longf').value).replace('longfrom', document.getElementById('longf').value);
}
plist='';
for (i=1; i<vbits.length; i++) {
plist+='%2Chttp.' + encodeURIComponent(vbits[i].substring(1).split(vbits[i].substring(0,1))[0].split('/')[eval(-1 + vbits[i].substring(1).split(vbits[i].substring(0,1))[0].split('/').length)].replace(/\_/g,' '));
}
ogc=ogc.replace('%2Chttp.To', plist);
plist='';
for (i=1; i<dbits.length; i++) {
plist+='%20,%20[' + dbits[i].substring(2).split(dbits[i].substring(0,1))[0].replace(')','').split(',')[0] + '|' + dbits[i].substring(2).split(dbits[i].substring(0,1))[0].replace(')','').split(',')[1] + '|~' + encodeURIComponent(vbits[i].substring(1).split(vbits[i].substring(0,1))[0].split('/')[eval(-1 + vbits[i].substring(1).split(vbits[i].substring(0,1))[0].split('/').length)].replace(/\_/g,' ')) + '~]';
}
ogc=ogc.replace('%20,%20[latto|longto|~To~,2]%20,%20[nearestlat|nearestlong|~nearestplace~,2]', plist);
plist='';
for (i=1; i<dbits.length; i++) {
plist+=',' + dbits[i].substring(2).split(dbits[i].substring(0,1))[0].replace(')','').split(',')[0] + '|' + dbits[i].substring(2).split(dbits[i].substring(0,1))[0].replace(')','').split(',')[1] + '|' + encodeURIComponent(vbits[i].substring(1).split(vbits[i].substring(0,1))[0].split('/')[eval(-1 + vbits[i].substring(1).split(vbits[i].substring(0,1))[0].split('/').length)].replace(/\_/g,' ')) + '';
}
ogc=ogc.replace(',latto|longto|128205_To,nearestlat|nearestlong|nearestplace', plist);
} else if (tdid.toLowerCase().indexOf('to') != -1) {
ogc='//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=Earth%20Places&aregexographicals=y&aregeographicals=HTTP.To%2Chttp.From' +
'&peninfo=latto|longto|128205_To,latfrom|longfrom|127968_From,nearestlat|nearestlong|nearestplace' +
'&width=417&height=260&country=Places&popularity=' +
'&data=%20[latto|longto|~To~,2]%20,%20[latfrom|longfrom|~From~,2]%20,%20[nearestlat|nearestlong|~nearestplace~,2]';
if (altolat != '' && altolong != '') {
ogc=ogc.replace('latto', altolat).replace('latto', altolat);
ogc=ogc.replace('longto', altolong).replace('longto', altolong);
//alert(altolat + ' .#. ' + altolong + ' ___ ' + ogc);
} else {
ogc=ogc.replace('latto', document.getElementById('latt').value).replace('latto', document.getElementById('latt').value);
ogc=ogc.replace('longto', document.getElementById('longt').value).replace('longto', document.getElementById('longt').value);
}
plist='';
for (i=1; i<vbits.length; i++) {
plist+='%2Chttp.' + encodeURIComponent(vbits[i].substring(1).split(vbits[i].substring(0,1))[0].split('/')[eval(-1 + vbits[i].substring(1).split(vbits[i].substring(0,1))[0].split('/').length)].replace(/\_/g,' '));
}
//alert(plist + ' ... ' + ogc.replace('%2Chttp.From', plist) + ' via ' + ogc);
ogc=ogc.replace('%2Chttp.From', plist);
plist='';
for (i=1; i<dbits.length; i++) {
plist+='%20,%20[' + dbits[i].substring(2).split(dbits[i].substring(0,1))[0].replace(')','').split(',')[0] + '|' + dbits[i].substring(2).split(dbits[i].substring(0,1))[0].replace(')','').split(',')[1] + '|~' + encodeURIComponent(vbits[i].substring(1).split(vbits[i].substring(0,1))[0].split('/')[eval(-1 + vbits[i].substring(1).split(vbits[i].substring(0,1))[0].split('/').length)].replace(/\_/g,' ')) + '~]';
}
//alert(plist + ' ... ' + ogc.replace('%20,%20[latfrom|longfrom|~From~,2]%20,%20[nearestlat|nearestlong|~nearestplace~,2]', plist) + ' via ' + ogc);
ogc=ogc.replace('%20,%20[latfrom|longfrom|~From~,2]%20,%20[nearestlat|nearestlong|~nearestplace~,2]', plist);
plist='';
for (i=1; i<dbits.length; i++) {
plist+=',' + dbits[i].substring(2).split(dbits[i].substring(0,1))[0].replace(')','').split(',')[0] + '|' + dbits[i].substring(2).split(dbits[i].substring(0,1))[0].replace(')','').split(',')[1] + '|' + encodeURIComponent(vbits[i].substring(1).split(vbits[i].substring(0,1))[0].split('/')[eval(-1 + vbits[i].substring(1).split(vbits[i].substring(0,1))[0].split('/').length)].replace(/\_/g,' ')) + '';
}
//alert(plist + ' ... ' + ogc.replace(',latfrom|longfrom|127968_From,nearestlat|nearestlong|nearestplace', plist) + ' via ' + ogc);
ogc=ogc.replace(',latfrom|longfrom|127968_From,nearestlat|nearestlong|nearestplace', plist);

}
document.getElementById(trid).style.display='table-row';
if (document.getElementById(tdid).innerHTML.indexOf(ogc) == -1 && ogc.indexOf('nearestlat') == -1) {
document.getElementById(tdid).innerHTML+='<iframe style=display:inline-block;height:300px;width:450px; src="' + ogc + '"></iframe>';
}
} else if (tdid.toLowerCase().indexOf('from') != -1) {
document.getElementById(trid).style.display='table-row';
if (altolat == '') { altolat=top.document.getElementById('ltf').value; }
if (altolong == '') { altolong=top.document.getElementById('lgf').value; }
document.getElementById(tdid).innerHTML+='<iframe style=display:inline-block;height:300px;width:450px; src="' + '//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=Earth%20Places&aregexographicals=y&aregeographicals=HTTP.From' +
'&peninfo=' + altolat + '|' + altolong + '|127968_From' +
'&width=417&height=260&country=Places&popularity=' +
'&data=%20[' + altolat + '|' + altolong + '|~From~,2]' + '"></iframe>';
} else if (tdid.toLowerCase().indexOf('to') != -1) {
document.getElementById(trid).style.display='table-row';
if (altolat == '') { altolat=top.document.getElementById('ltt').value; }
if (altolong == '') { altolong=top.document.getElementById('lgt').value; }
document.getElementById(tdid).innerHTML+='<iframe style=display:inline-block;height:300px;width:450px; src="' + '//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=Earth%20Places&aregexographicals=y&aregeographicals=HTTP.To' +
'&peninfo=' + altolat + '|' + altolong + '|128205_To' +
'&width=417&height=260&country=Places&popularity=' +
'&data=%20[' + altolat + '|' + altolong + '|~To~,2]' + '"></iframe>';
}
}
}
}

function moreifok() {
//alert('add row here');
//bthe();
if (cfok) {
//alert(isokformore);
cfok=false;
if (isokformore.trim() != '') {
//alert(5);
document.getElementById('next1').style.display='table-row';
document.getElementById('niframe').style.backgroundColor='yellow';
document.getElementById('niframe').src=document.URL.split('#')[0].split('?')[0] + isokformore;
isokformore=' ';
//alert(55);
}
}
}

function myselit(oso) {
if (oso.value == '1') {
document.getElementById('brg').value='' + eval(eval(180.0 + eval(('' + document.getElementById('brg').value).replace('~0.','.').replace('~',''))) % 360.0);
}
oso.value='2';
}

function dorh() {
//let laSensor = new LinearAccelerationSensor({frequency: 60});

//laSensor.addEventListener('reading', e => {
// console.log("Linear acceleration along the X-axis " + laSensor.x);
// console.log("Linear acceleration along the Y-axis " + laSensor.y);
// console.log("Linear acceleration along the Z-axis " + laSensor.z);
//});
//laSensor.start();

//window.addEventListener('devicemotion', function(event) {
// alert(event.rotationRate.alpha + ' m/s2');
//});

if (1 == 1) {
window.addEventListener("orientationchange", function() {
// Announce the new orientation number
wasangle=eval(180 - eval('' + window.orientation));
var thisso='' + screen.msOrientation || screen.mozOrientation || (screen.orientation || {}).type;
if (('' + thisso) == 'undefined') {
var mql=window.matchMedia("(orientation: portrait)");
// If there are matches, we're in portrait
if (mql.matches) {
thisso="Portrait"; // Portrait orientation
} else {
thisso="Landscape"; // Landscape orientation
}
}

if (thisso != wasthisso) {
wasthisso=thisso;
//alert('ori');
}
}, false);
}

if (window.DeviceOrientationEvent) {
if (1 == 2) { alert(1); }
// Listen for orientation changes ... thanks to https://davidwalsh.name/orientation-change
// Listen for the deviceorientation event and handle the raw data
window.addEventListener('deviceorientation', function(eventData) {
// gamma is the left-to-right tilt in degrees, where right is positive
if (1 == 2) { alert(11); }
if (document.getElementById('ipn')) {
//if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and face north for gyroscope bearing.') == -1) {
if (('' + document.getElementById('ipn').placeholder).indexOf(' and ') == -1) {
document.getElementById('ipn').className='ph';
document.getElementById('ipn').placeholder+='. Append space and portrait face north for gyroscope bearing.';
document.getElementById("myviewport").setAttribute("content", "width=device-width, initial-scale=1.5, minimum-scale=0.1, maximum-scale=8, user-scalable=yes");
setTimeout(asafn, 5000);
}
}
//eventData.absolute=true;

var eventDataalpha = eval(360.0 - eval('' + eventData.alpha)); // lalpha)); //
if (eventData.absolute !== true && +eventData.webkitCompassAccuracy > 0 && +eventData.webkitCompassAccuracy < 50) {
eventDataalpha = eval('' + eventData.webkitCompassHeading || 0);
if (document.getElementById('dntable')) { document.getElementById('dntable').style.display='inline-block'; }
}
if (!datstart) { eventDataalpha-=initial_yaw; }

tiltLeftToRight = eval('' + eventData.gamma);

// beta is the front-to-back tilt in degrees, where front is positive
tiltFrontToBack = eval('' + eventData.beta);

// alpha is the compass direction the device is facing in degrees
lastalpha='' + eventData.alpha; // lalpha; //
dorbrg = eval('' + eventDataalpha); //compassHeading(eval('' + eventDataalpha), tiltFrontToBack, tiltLeftToRight);
if (1 == 2) { alert(dorbrg); }
if (document.URL.indexOf('aleJUNKrt=') != -1) {
alert(dorbrg);
}
if (document.URL.indexOf('upJUNKdate=') != -1 || (fplacen != '' && tplacen == '')) {
if (eventData.absolute || 1 == 1) {
//document.getElementById('brg').value='' + eval(eval(540.0 - eval('' + dorbrg)) % 360.0);
//document.getElementById('brg').value='' + eval(eval(720.0 - eval('' + dorbrg)) % 360.0);
//document.getElementById('brg').value='' + dorbrg;
if (eval(dcnt % 10) == 0) {
document.getElementById('brg').value='' + eval(eval(720.0 + eval('' + dorbrg)) % 360.0);
document.getElementById('brg').style.backgroundColor='yellow';
}
dcnt++;
}
}


if (datstart && (fplacen != '' && tplacen == '')) {
datstart=false;
//initial_yaw=eval(360.0 - eval('' + lalpha)); //eventData.alpha));
//alert('0:' + initial_yaw);
if (!eventData.absolute) {
initial_yaw=eval(360.0 - eval('' + eventData.alpha)); // lalpha)); //
}
//alert('' + initial_yaw);
initial_pitch=Math.round(tiltFrontToBack);
initial_roll=Math.round(tiltLeftToRight);
//alert(initial_yaw + ',' + initial_pitch + ',' + initial_roll);
}

if (document.getElementById('ntable')) {
var ts=450;
if (wasangle != 0) {
ts+=wasangle;
}
try { document.getElementById('ntable').style.webkitTransform = ("rotate(" + eval(ts - Math.round(dorbrg)) + "deg)"); } catch(e10) { }
try { document.getElementById('ntable').style.MozTransform = ("rotate(" + eval(ts - Math.round(dorbrg)) + "deg)"); } catch(e1000) { }
try { document.getElementById('ntable').style.msTransform = ("rotate(" + eval(ts - Math.round(dorbrg)) + "deg)"); } catch(e100) { }
try { document.getElementById('ntable').style.OTransform = ("rotate(" + eval(ts - Math.round(dorbrg)) + "deg)"); } catch(e10000) { }
try { document.getElementById('ntable').style.transform = ("rotate(" + eval(ts - Math.round(dorbrg)) + "deg)"); } catch(e1) { }
}


handleOrientationEvent(tiltFrontToBack, tiltLeftToRight, dorbrg, eventData.absolute);


if ((fplacen != '' && tplacen == '') && document.getElementById('ipn')) {
//if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and face north for gyroscope bearing.') != -1) {
if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and ') != -1) {
document.getElementById('ipn').style.backgroundColor='#f0f0f0';
//document.getElementById('ipn').placeholder=document.getElementById('ipn').placeholder.split('Append space and face north for gyroscope bearing.')[0] + ' Now swivel to direction of interest then tap yellow textbox.';
document.getElementById('ipn').placeholder=document.getElementById('ipn').placeholder.split('Append space and ')[0] + ' Now swivel to direction of interest then tap yellow textbox.';
document.getElementById("myviewport").setAttribute("content", "width=device-width, initial-scale=1.2, minimum-scale=0.1, maximum-scale=8, user-scalable=yes");
//window.scrollBy(0,50); //location.href='#brg';
}
}


}, false);
}
}

var handleOrientationEvent = function(tiltFrontToBack, tiltLeftToRight, dorbrg, absis) {
// do something amazing
if (1 == 2) { alert(dorbrg); }
if (document.URL.indexOf('alJUNKert=') != -1) {
alert(dorbrg);
}
if (document.URL.indexOf('upJUNKdate=') != -1 || (fplacen != '' && tplacen == '')) {
if (absis || 1 == 1) {
//document.getElementById('brg').value='' + eval(eval(540.0 - eval('' + dorbrg)) % 360.0);
//document.getElementById('brg').value='' + eval(eval(720.0 - eval('' + dorbrg)) % 360.0);
//document.getElementById('brg').value='' + dorbrg;
if (eval(dcnt % 10) == 0) {
document.getElementById('brg').value='' + eval(eval(720.0 + eval('' + dorbrg)) % 360.0);
document.getElementById('brg').style.backgroundColor='yellow';
}
dcnt++;
}
}
};

function asafn() {
if (document.getElementById('ipn')) {
//if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and face north for gyroscope bearing.') == -1) {
if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and portrait face north for ') != -1) {
document.getElementById('ipn').placeholder=document.getElementById('ipn').placeholder.split('Append space and ')[0] + 'Append space and portrait face north onto ;elevation(m)?';
setTimeout(asafn, 5000);
} else if (('' + document.getElementById('ipn').placeholder).indexOf('Append space and ') != -1) {
document.getElementById('ipn').placeholder=document.getElementById('ipn').placeholder.split('Append space and ')[0] + 'Append space and portrait face north for horizon bearing.';
setTimeout(asafn, 5000);
}
}
}

function moremaybe() {
var ofplacen=fplacen;
var otplacen=tplacen;
if (xipn != '') {
document.getElementById('ipn').value=xipn;
}
//dorh();
if (document.getElementById('gform')) {
if (document.URL.indexOf('https:') != -1) { document.getElementById('gform').action=document.getElementById('gform').action.replace('http:','https:'); }
}
var latto=location.search.split('latf=')[1] ? decodeURIComponent(location.search.split('latf=')[1].split('&')[0]) : '';
var longto=location.search.split('longf=')[1] ? decodeURIComponent(location.search.split('longf=')[1].split('&')[0]) : '';
var clatto=location.search.split('latt=')[1] ? decodeURIComponent(location.search.split('latt=')[1].split('&')[0]) : '';
var clongto=location.search.split('longt=')[1] ? decodeURIComponent(location.search.split('longt=')[1].split('&')[0]) : '';
var cbrg=location.search.split('brg=')[1] ? decodeURIComponent(location.search.split('brg=')[1].split('&')[0]) : '';
var cdist=location.search.split('dist=')[1] ? decodeURIComponent(location.search.split('dist=')[1].split('&')[0]) : '';
var mysel=location.search.split('mysel=')[1] ? decodeURIComponent(location.search.split('mysel=')[1].split('&')[0]) : '2';
var dosms=location.search.split('sms=')[1] ? decodeURIComponent(location.search.split('sms=')[1].split('&')[0]) : '';

if (fplacen != '') {
document.getElementById('ssf').innerHTML=fplacen;
fplacen='';
}
if (tplacen.trim() != '') {
document.getElementById('sst').innerHTML=tplacen.trim();
if (tplacen.trim() != tplacen) { tplacen=' '; } else { tplacen=''; }
}

if (latto != '' && longto != '') {
nextplease();
top.document.getElementById('goagain').style.display='block';
document.getElementById('latf').value=latto;
document.getElementById('latf').style.backgroundColor="pink";
cwhat[0]=false;
cwhat[1]=false;
if (!decided) {
if (!cwhat[5]) {
cwhat[5]=true;
}
if (!cwhat[4]) {
cwhat[4]=true;
}
decided=true;
}
top.document.getElementById("ltf").value=latto;
document.getElementById('longf').value=longto;
document.getElementById('longf').style.backgroundColor="pink";
cwhat[0]=false;
cwhat[1]=false;
if (!decided) {
if (!cwhat[5]) {
cwhat[5]=true;
}
if (!cwhat[4]) {
cwhat[4]=true;
}
decided=true;
}
top.document.getElementById("lgf").value=longto;
document.getElementById('dtop').style.display='none';
document.getElementById('trhead').style.display='none';
document.getElementById('trfoot').style.display='none';
document.getElementById('myt').border=0;
var recti=parent.document.getElementById('niframe').getBoundingClientRect();
parent.document.getElementById('niframe').height=eval(200 + eval(('' + recti.height).replace('px',''))) + 'px';
if (parent.document.getElementById('niframe') != top.document.getElementById('niframe')) {
var trecti=top.document.getElementById('niframe').getBoundingClientRect();
top.document.getElementById('niframe').height=eval(200 + eval(('' + trecti.height).replace('px',''))) + 'px';
}
setTimeout(checkfill, 500);
parent.document.getElementById("slong").innerHTML=":";
parent.document.getElementById("slong").title="";
parent.document.getElementById("slong").style.textDecoration="none";
//top.document.title+=' started ';
}
if (latto != '' && longto != '' && clatto != '' && clongto != '' && cbrg != '' && cdist != '') {
document.getElementById('gform').action=document.URL.split('?')[0].split('#')[0];
document.getElementById('latf').type='text';
document.getElementById('longf').type='text';
document.getElementById('latt').type='text';
document.getElementById('longt').type='text';
document.getElementById('brg').type='text';
document.getElementById('dist').type='text';
document.getElementById('latf').value=('' + latto).replace('~0.','.').replace('~','');
document.getElementById('longf').value=('' + longto).replace('~0.','.').replace('~','');
document.getElementById('latt').value=('' + clatto).replace('~0.','.').replace('~','');
document.getElementById('longt').value=('' + clongto).replace('~0.','.').replace('~','');

if (('' + mysel) == '1') {
document.getElementById('brg').value='' + eval(eval(180.0 + eval(('' + cbrg).replace('~0.','.').replace('~',''))) % 360.0);
} else {
document.getElementById('brg').value=('' + cbrg).replace('~0.','.').replace('~','');
}
document.getElementById('dist').value=('' + cdist).replace('~0.','.').replace('~','');
document.getElementById('dtop').style.display='block';
document.getElementById('myt').border='10';
document.getElementById('myt').cellspacing='2';
document.getElementById('myt').cellpadding='2';
document.getElementById('trhead').style.display='table-row';
document.getElementById('trfoot').style.display='table-row';
document.getElementById('ifill').style.display='block';
document.getElementById('ifill').type='submit';
//cwhat=[false,false,true,true,true,true];
calcit();
if (document.getElementById('latf').value.indexOf('0.000') != 0) { document.getElementById('latf').focus(); document.getElementById('latf').value+=' '; }
if (document.getElementById('longf').value.indexOf('0.000') != 0) { document.getElementById('longf').focus(); document.getElementById('longf').value+=' '; }
if (document.getElementById('latt').value.indexOf('0.000') != 0) { document.getElementById('latt').focus(); document.getElementById('latt').value+=' '; }
if (document.getElementById('longt').value.indexOf('0.000') != 0) { document.getElementById('longt').focus(); document.getElementById('longt').value+=' '; }
if (document.getElementById('brg').value.indexOf('0.000') != 0) { document.getElementById('brg').focus(); document.getElementById('brg').value+=' '; }
if (document.getElementById('dist').value.indexOf('0.000') != 0) { document.getElementById('dist').focus(); document.getElementById('dist').value+=' '; }
decided=true;
document.getElementById('latf').value=document.getElementById('latf').value.trim();
document.getElementById('longf').value=document.getElementById('longf').value.trim();
document.getElementById('latt').value=document.getElementById('latt').value.trim();
document.getElementById('longt').value=document.getElementById('longt').value.trim();
document.getElementById('brg').value=document.getElementById('brg').value.trim();
document.getElementById('dist').value=document.getElementById('dist').value.trim();
document.getElementById('latf').focus();
cwhat=[true,true,false,false,true,true];
jsokformore=' ';
isokformore=' ';
console.log(cwhat);
faux=true;
mapit(document.getElementById('tdfrom'));
console.log(document.getElementById('afrom').href);
console.log('tdto');
faux=true;
mapit(document.getElementById('tdto'));
console.log(document.getElementById('ato').href);
if (dosms != '') { setTimeout(clicksms, 2000); }
}

if (ofplacen != '' && otplacen.trim() == '') {
fplacen=ofplacen;
tpurl=origtpurl;
mu=mu.replace('[51.5072,','[' + document.getElementById('latf').value + ',');
mu=mu.replace(',-0.1275,',',' + document.getElementById('longf').value + ',');
mu=mu.replace('=LonJunkdon','=' + encodeURIComponent(fplacen)).replace(',~London~]',',~' + encodeURIComponent(fplacen) + '~],[051.5072,-00.1275,~LonDon~]');
tpurl=tpurl.replace("Sydney+NSW,+Australia",encodeURIComponent(fplacen));
viastart=true;
//alert(146);
if (document.URL.indexOf('&brg=0.0000001&') != -1) {
//setTimeout(predfillablemaybe, 2000); //dfillablemaybe(document.getElementById('dist'));
dfillablemaybe(document.getElementById('dist'));
} else {
fillablemaybe(document.getElementById('brg'));
}
//alert(246);
} else if (ofplacen != '' && otplacen.trim() != '') {
mu=mu.replace('[51.5072,','[' + document.getElementById('latf').value + ',');
mu=mu.replace(',-0.1275,',',' + document.getElementById('longf').value + ',');
//mu=mu.replace('=LonJunkdon','=' + encodeURIComponent(fplacen)).replace(',~London~]',',~' + encodeURIComponent(ofplacen) + '~],[051.5072,-00.1275,~LonDon~]');
mu=mu.replace('=LonJunkdon','=' + encodeURIComponent(ofplacen)).replace(',~London~]',',~' + encodeURIComponent(ofplacen) + '~],[051.5072,-00.1275,~LonDon~]');
tpurl=origtpurl;
tpurl=tpurl.replace("Sydney+NSW,+Australia",encodeURIComponent(ofplacen));
mu=mu.replace('[051.5072,','[' + '' + document.getElementById('latt').value + ',');
mu=mu.replace(',-00.1275,',',' + '' + document.getElementById('longt').value + ',');
mu=mu.replace(',~LonDon~]',',~' + encodeURIComponent(otplacen.trim()) + '~]');
mu=mu.replace('=London','=' + encodeURIComponent(ofplacen + ' to ' + otplacen.trim()));
tpurl=tpurl.replace("Brisbane+QLD,+Australia",encodeURIComponent(otplacen.trim()));
if (document.getElementById('posttdmid')) { document.getElementById('posttdmid').style.display='none'; }
document.getElementById('tdmid').colSpan='2';
//alert(5);
tdfoota=' <input ' + trfoota.split('</td>')[0].split('<input ')[0];
trfoota='';
document.getElementById('tdmid').innerHTML='<details id=dftif open><summary id=sftif><a target=_blank title="' + ofplacen + '" style=text-decoration:underline;cursor:pointer; onclick=woit(this); data-href="//en.wikipedia.org/wiki/' + encodeURIComponent(ofplacen) + '">' + ofplacen + '</a> <a target=_blank id=addacc style="display:NONE;text-decoration:underline;cursor:pointer;" title=Accomodation onclick=woit(this); data-href="' + accomurl.replace(/Springwood\,\+New\+South\+Wales/g, encodeURIComponent(ofplacen)) + '">🛌</a> <a target=_blank title="Google Maps Directions" onclick=woit(this); style=text-decoration:underline;cursor:pointer; data-href="' + tpurl.replace('https:','') + '">to</a><a id="addafirst" title="Map of this trip leg" class="adda" onclick="addto(this);" data-from="' + ofplacen + '" data-to="' + otplacen.trim() + '" data-latf=' + document.getElementById('latf').value + ' data-longf=' + document.getElementById('longf').value + ' data-latt=' + document.getElementById('latt').value + ' data-longt=' + document.getElementById('longt').value + ' data-gcd=' + eval(eval('' + great_circle_distance(document.getElementById(eles[0]).value,document.getElementById(eles[1]).value,document.getElementById(eles[4]).value,document.getElementById(eles[5]).value)) / 1000.000) + ' style="display:NONE;cursor:pointer;">⬆<a> <a target=_blank title="' + otplacen.trim() + '" onclick=woit(this); style=text-decoration:underline;cursor:pointer; data-href="//en.wikipedia.org/wiki/' + encodeURIComponent(otplacen.trim()) + '">' + otplacen.trim() + '</a> (' + eval(eval('' + great_circle_distance(document.getElementById(eles[0]).value,document.getElementById(eles[1]).value,document.getElementById(eles[4]).value,document.getElementById(eles[5]).value)) / 1000.000) + ' kilometres)</summary><iframe id=iftif src="' + mu + '" style="width:100%;height:600px;"></iframe></details>';
}
if (document.getElementById('spfr') && fromto == 'to') {
//fromto='';
document.getElementById('spfr').innerHTML='to';
document.getElementById('ipn').focus();
}


if (trfoota != '') {
document.getElementById('trfoot').innerHTML+=trfoota;
}
if (tdfoota != '') {
document.getElementById('tdfoot').innerHTML+=tdfoota;
}

if (xipn != '') {
lkwk(document.getElementById('ipn'));
xipn='';
}
}

function addto(aois) {
var ourmu=origmu;
var ourtpurl=origtpurl;
var origtdm=document.getElementById('tdmid').innerHTML.replace(/\ open/g, ' data-open=');
var ofplacen=aois.getAttribute('data-from');
var otplacen=aois.getAttribute('data-to');
var gcd=aois.getAttribute('data-gcd');
var latf=aois.getAttribute('data-latf');
var longf=aois.getAttribute('data-longf');
var latt=aois.getAttribute('data-latt');
var longt=aois.getAttribute('data-longt');
ourmu=ourmu.replace('[51.5072,','[' + latf + ',');
ourmu=ourmu.replace(',-0.1275,',',' + longf + ',');
ourmu=ourmu.replace('=LonJunkdon','=' + encodeURIComponent(ofplacen)).replace(',~London~]',',~' + encodeURIComponent(ofplacen) + '~],[051.5072,-00.1275,~LonDon~]');
ourtpurl=ourtpurl.replace("Sydney+NSW,+Australia",encodeURIComponent(ofplacen));
ourmu=ourmu.replace('[051.5072,','[' + '' + latt + ',');
ourmu=ourmu.replace(',-00.1275,',',' + '' + longt + ',');
ourmu=ourmu.replace(',~LonDon~]',',~' + encodeURIComponent(otplacen) + '~]');
ourmu=ourmu.replace('=London','=' + encodeURIComponent(ofplacen + ' to ' + otplacen));
ourtpurl=ourtpurl.replace("Brisbane+QLD,+Australia",encodeURIComponent(otplacen));
if (document.getElementById('posttdmid')) { document.getElementById('posttdmid').style.display='none'; }
//alert(55);
document.getElementById('tdmid').colSpan='2';
document.getElementById('tdmid').innerHTML='<details data-id=dftif open><summary data-id=sftif><a target=_blank title="' + ofplacen + '" onclick=woit(this); style=text-decoration:underline;cursor:pointer; data-href="//en.wikipedia.org/wiki/' + encodeURIComponent(ofplacen) + '">' + ofplacen + '</a> <a target=_blank title="Google Maps Directions" onclick=woit(this); style=text-decoration:underline;cursor:pointer; data-href="' + ourtpurl.replace('https:','') + '">to</a> <a target=_blank title="' + otplacen + '" onclick=woit(this); style=text-decoration:underline;cursor:pointer; data-href="//en.wikipedia.org/wiki/' + encodeURIComponent(otplacen) + '">' + otplacen + '</a> (' + gcd + ' kilometres)</summary><iframe data-id=iftif src="' + ourmu + '" style="width:100%;height:600px;"></iframe></details><br>' + origtdm;
}

function clicksms() {
document.getElementById('ssms').click();
}

function filltwo() {
document.getElementById('latf').type='text';
document.getElementById('longf').type='text';
document.getElementById('latt').type='text';
document.getElementById('longt').type='text';
document.getElementById('brg').type='text';
document.getElementById('dist').type='text';
document.getElementById('ifill').type='submit';
}

function checkfill() {
if (!cfok) {
console.log('not cfok');
top.document.getElementById('outofthisworld').value='';
//top.document.title+=' finished ';
} else if (jsokformore == '' && ('' + document.getElementById('latf').value).indexOf('0.000') == -1 && ('' + document.getElementById('longf').value).indexOf('0.000') == -1 && ('' + document.getElementById('latt').value).indexOf('0.000') == -1 && ('' + document.getElementById('longt').value).indexOf('0.000') == -1 && ('' + document.getElementById('brg').value).indexOf('0.000') == -1 && ('' + document.getElementById('dist').value).indexOf('0.000') == -1) {
if (jsokformore == '') { console.log('not cfok two'); top.document.getElementById('outofthisworld').value=''; } else { console.log('huh'); }
//top.document.title+=' finished ';
} else if (top.document.getElementById('outofthisworld').value != '') {
console.log('click ' + top.document.getElementById('outofthisworld').value);
if (lastclick != top.document.getElementById('outofthisworld').value.split('|')[0]) {
lastclick=top.document.getElementById('outofthisworld').value.split('|')[0];
if (!faux) {
if (top.document.getElementById('outofthisworld').value.indexOf('from') != -1) {
document.getElementById('nearestif').src='//www.rjmprogramming.com.au/PHP/tz_places.php?place=&latitude=' + encodeURIComponent(document.getElementById('latf').value) + '&longitude=' + encodeURIComponent(document.getElementById('longf').value); checknp(null); //mapit(document.getElementById('afrom')); //top.document.getElementById('nearestif').src='//www.rjmprogramming.com.au/PHP/tz_places.php?place=&latitude=' + encodeURIComponent(document.getElementById('latf').value) + '&longitude=' + encodeURIComponent(document.getElementById('longf').value);
} else if (top.document.getElementById('outofthisworld').value.indexOf('to') != -1) {
document.getElementById('nearestif').src='//www.rjmprogramming.com.au/PHP/tz_places.php?place=&latitude=' + encodeURIComponent(document.getElementById('latt').value) + '&longitude=' + encodeURIComponent(document.getElementById('longt').value); checknp(null); //mapit(document.getElementById('ato')); //top.document.getElementById('nearestif').src='//www.rjmprogramming.com.au/PHP/tz_places.php?place=&latitude=' + encodeURIComponent(document.getElementById('latt').value) + '&longitude=' + encodeURIComponent(document.getElementById('longt').value);
}
}
document.getElementById(top.document.getElementById('outofthisworld').value.split('|')[0]).click();
}
if (top.document.getElementById('outofthisworld').value.split('|')[0] == 'slong' && ('' + document.getElementById('latf').value).indexOf('0.000') == -1 && ('' + document.getElementById('longf').value).indexOf('0.000') == -1 && ('' + document.getElementById('latt').value).indexOf('0.000') == -1 && ('' + document.getElementById('longt').value).indexOf('0.000') == -1 && ('' + document.getElementById('brg').value).indexOf('0.000') == -1 && ('' + document.getElementById('dist').value).indexOf('0.000') == -1) {
top.document.getElementById('outofthisworld').value='';
//top.document.title+=' finished ';
} else if (top.document.getElementById('outofthisworld').value.indexOf('|') != -1) {
if (top.document.getElementById('outofthisworld').value.split('|')[1] == '') {
if (top.document.getElementById('outofthisworld').value.toLowerCase().indexOf('from') != -1) {
top.document.getElementById('outofthisworld').value+=document.getElementById('latf').value.trim() + ',' + document.getElementById('longf').value.trim();
} else if (top.document.getElementById('outofthisworld').value.toLowerCase().indexOf('to') != -1) {
top.document.getElementById('outofthisworld').value+=document.getElementById('latt').value.trim() + ',' + document.getElementById('longt').value.trim();
}
}
setTimeout(checkfill, 500);
} else {
top.document.getElementById('outofthisworld').value='';
setTimeout(checkfill, 500);
}
} else if (jsokformore == '' && ('' + document.getElementById('latf').value).indexOf('0.000') == -1 && ('' + document.getElementById('longf').value).indexOf('0.000') == -1 && ('' + document.getElementById('latt').value).indexOf('0.000') == -1 && ('' + document.getElementById('longt').value).indexOf('0.000') == -1 && ('' + document.getElementById('brg').value).indexOf('0.000') == -1 && ('' + document.getElementById('dist').value).indexOf('0.000') == -1) {
top.document.getElementById('outofthisworld').value='';
//top.document.title+=' finished ';
} else {
setTimeout(checkfill, 500);
}
}

function toize(defe) {
var suffbits='?latf=' + encodeURIComponent(document.getElementById('latf').value) + '&longf=' + encodeURIComponent(document.getElementById('longf').value) + '&latt=' + encodeURIComponent(document.getElementById('latt').value) + '&longt=' + encodeURIComponent(document.getElementById('longt').value) + '&brg=' + encodeURIComponent(document.getElementById('brg').value) + '&dist=' + encodeURIComponent(document.getElementById('dist').value);
var em='';
if (defe.trim() != '') {
em=defe
} else {
em=prompt('SMS to?', '');
}
if (em == null) { em=''; }
if (em.trim() != '') {
//document.getElementById('from').value=em;
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('asms').href='sms:' + em + '&body=' + dummyencodeURIComponent(encodeURIComponent(document.URL.split('#')[0].split('?')[0] + suffbits)); // + '?gradient=' + encodeURIComponent(encodeURIComponent(document.getElementById('dfix').innerHTML.replace('background: ','').replace('background:','').replace(');',')').replace(';',''))));
} else {
document.getElementById('asms').href='sms:' + em + '&body=' + encodeURIComponent(encodeURIComponent(document.URL.split('#')[0].split('?')[0] + suffbits)); // + '?gradient=' + encodeURIComponent(encodeURIComponent(document.getElementById('dfix').innerHTML.replace('background: ','').replace('background:','').replace(');',')').replace(';',''))));
}
document.getElementById('asms').click();
}
return true;
}

function preemailit(ine) {
if (ine.indexOf('@') != -1) {
emailit(ine);
} else if (ine != '') {
toize(ine);
}
}

function dummyencodeURIComponent(invl) {
return invl;
}

function emailit(defe) {
//document.getElementById('ih').value=document.getElementById('tdlook').innerHTML.replace(/\<br\>/g,String.fromCharCode(10));
var lastfis='youllneverfindthis';
var lasttis='';
var lasteis='youllneverfindthis';
var lastenow='';
var lastsis='youllneverfindthis';
var lastsnow='';
var lasteis2='youllneverfindthis';
var lastenow2='';
var lastsis2='youllneverfindthis';
var lastsnow2='';
var em='';
var suffbits='?latf=' + encodeURIComponent(document.getElementById('latf').value) + '&longf=' + encodeURIComponent(document.getElementById('longf').value) + '&latt=' + encodeURIComponent(document.getElementById('latt').value) + '&longt=' + encodeURIComponent(document.getElementById('longt').value) + '&brg=' + encodeURIComponent(document.getElementById('brg').value) + '&dist=' + encodeURIComponent(document.getElementById('dist').value);
if (defe.indexOf('@') != -1) {
em=defe
} else {
em=prompt('Email to? (all uppercase uses client email else sends an Inline HTML Email Form)', '');
}
if (em == null) { em=''; }
if (em.indexOf('@') != -1) {
//document.getElementById('from').value=em;
if (document.URL.toLowerCase().indexOf('rjmprogramming.com.au') != -1 && em != em.toUpperCase()) {
document.getElementById('asms').href='mailto:' + em.trim() + '?subject=' + encodeURIComponent('Missing Two') + '&body=' + encodeURIComponent(document.URL.split('#')[0].split('?')[0] + suffbits); // + '?missingtwo=' + encodeURIComponent(encodeURIComponent(document.getElementById('dfix').innerHTML.replace('background: ','').replace('background:','').replace(');',')').replace(';',''))));
var xzhr = new XMLHttpRequest();
var xform=new FormData();
xform.append('inline','');
xform.append('to',em.trim());
var flatf=document.getElementById('latf').outerHTML;
var flongf=document.getElementById('longf').outerHTML;
var flatt=document.getElementById('latt').outerHTML;
var flongt=document.getElementById('longt').outerHTML;
var fbrg=document.getElementById('brg').outerHTML;
var fdist=document.getElementById('dist').outerHTML;
var tlatf='<input type=text name=latf id=latf value="' + document.getElementById('latf').value + '"></input>';
var tlongf='<input type=text name=longf id=longf value="' + document.getElementById('longf').value + '"></input>';
var tlatt='<input type=text name=latt id=latt value="' + document.getElementById('latt').value + '"></input>';
var tlongt='<input type=text name=longt id=longt value="' + document.getElementById('longt').value + '"></input>';
var tbrg='<input type=text name=brg id=brg value="' + document.getElementById('brg').value + '"></input>';
var tdist='<input type=text name=dist id=dist value="' + document.getElementById('dist').value + '"></input>';
//if (from.indexOf('@') != -1) { xform.append('cc',from.trim()); }
console.log('tdfrom');
faux=true;
mapit(document.getElementById('tdfrom'));
console.log(document.getElementById('afrom').href);
console.log('tdto');
faux=true;
mapit(document.getElementById('tdto'));
console.log(document.getElementById('ato').href);
if (document.body.innerHTML.indexOf('<tr id="trfoot"') != -1) {
lastfis='<tr id="trfoot"' + document.body.innerHTML.split('<tr id="trfoot"')[1].split('</tr>')[0] + '</tr>';
if (document.getElementById('asms').href.indexOf('sms:') != -1) {
lasteis='<span ';
lastenow='<a target=_blank href="mailto:?subject=' + dummyencodeURIComponent(encodeURIComponent('Missing%20Two')) + '&body=' + dummyencodeURIComponent(encodeURIComponent(document.getElementById('asms').href.split('&body=')[1])) + '" ';
lasteis2='</span>';
lastenow2='</a>';
lastsis='<span ';
lastsnow='<a target=_blank href="' + document.getElementById('asms').href.split('&')[0] + '&body=' + dummyencodeURIComponent(encodeURIComponent(document.getElementById('asms').href.split('&body=')[1])) + '" ';
lastsis2='</span>';
lastsnow2='</a>';
} else if (document.getElementById('asms').href.indexOf('mailto:') != -1) {
lastsis='<span ';
lastsis=document.getElementById('ssms').outerHTML.split('>')[0] + '>';
lastsnow='<a target=_blank href="sms:&body=' + dummyencodeURIComponent(encodeURIComponent(document.getElementById('asms').href.split('&body=')[1])) + '" ';
lastsnow='<input type=submit title=SMS name=sms id=ssms value="';
lastsis2='</span>';
lastsnow2='</a>';
lastsnow2='"></input>';
lasteis='<span ';
lastenow='<a target=_blank href="mailto:' + em.trim() + '?subject=' + dummyencodeURIComponent(encodeURIComponent('Missing%20Two')) + '&body=' + dummyencodeURIComponent(encodeURIComponent(document.getElementById('asms').href.split('&body=')[1])) + '" ';
lasteis2='</span>';
lastenow2='</a>';
}
}
if (em.trim() != em) {
xform.append('subj','Missing Two');
//var cbgtd=document.getElementById('tdlook').getBoundingClientRect();
xform.append('body','<body>' + document.body.innerHTML.replace(/\ id\=\"mysel\"/g, ' name="mysel" id="mysel"').replace(/\ size\=\"3\"/g, ' size="4"').replace(/\ data\-href\=/g, ' target=_blank href=').replace('</form>', '<br><br><input style=background-color:lightgreen; type=submit value=Solve></input></form>').replace('DISPLAY:table-row','DISPLAY:none').replace(lastfis,lasttis).replace(lasteis,lastenow).replace(lasteis2,lastenow2).replace(lastsis,lastsnow).replace(lastsis2,lastsnow2).replace('absolute;','absolute;display:none;').replace(flatf,tlatf).replace(flongf,tlongf).replace(flatt,tlatt).replace(flongt,tlongt).replace(fbrg,tbrg).replace(fdist,tdist) + '</body>');
} else {
xform.append('subj','Missing Two');
xform.append('body','<body>' + document.body.innerHTML.replace(/\ id\=\"mysel\"/g, ' name="mysel" id="mysel"').replace(/\ size\=\"3\"/g, ' size="4"').replace(/\ data\-href\=/g, ' target=_blank href=').replace('</form>', '<br><br><input style=background-color:lightgreen; type=submit value=Solve></input></form>').replace('DISPLAY:table-row','DISPLAY:none').replace(lastfis,lasttis).replace(lasteis,lastenow).replace(lasteis2,lastenow2).replace(lastsis,lastsnow).replace(lastsis2,lastsnow2).replace('absolute;','absolute;display:none;').replace(flatf,tlatf).replace(flongf,tlongf).replace(flatt,tlatt).replace(flongt,tlongt).replace(fbrg,tbrg).replace(fdist,tdist) + '</body>');
}
xzhr.open('post','//www.rjmprogramming.com.au/HTMLCSS/emailhtml.php',true);
xzhr.send(xform);
} else {
document.getElementById('asms').href='mailto:' + em.trim() + '?subject=' + encodeURIComponent('Missing Two') + '&body=' + encodeURIComponent(document.URL.split('#')[0].split('?')[0] + suffbits); // + '?missingtwo=' + encodeURIComponent(encodeURIComponent(document.getElementById('dfix').innerHTML.replace('background: ','').replace('background:','').replace(');',')').replace(';',''))));
document.getElementById('asms').click();
}
}
}

function woit(ina) {
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
window.open(ina.getAttribute('data-href'), '_blank');
} else {
window.open(ina.getAttribute('data-href'), '_blank', 'top=50,left=50,width=900,height=700');
}
}

function askit() {
var ourdist=0.0, ourbrg=0.0;
//alert(gllentry);
if (gllentry.indexOf(',') != -1) {
if ((1 == 2 && gllonesuffix == 'f') || document.getElementById('spfr').innerHTML == 'from') {
tpurl=origtpurl;
document.getElementById('latf').focus();
document.getElementById('latf').value=gllentry.split(',')[0];
//var mu="//www.rjmprogramming.com.au/PHP/Map/map.php?title=London&label=['Lat',&value='Lon','Name']&data=,[51.5072,-0.1275,~London~]";
mu=mu.replace('[51.5072,','[' + gllentry.split(',')[0] + ',');
document.getElementById('longf').focus();
document.getElementById('longf').value=gllentry.split(',')[1];
mu=mu.replace(',-0.1275,',',' + gllentry.split(',')[1] + ',');
document.getElementById('latf').focus();
gllonesuffix = 't';
document.getElementById('spfr').innerHTML=document.getElementById('spfr').innerHTML.replace('from','to<input type=hidden name=fplacen value="' + gllentry.split(',')[2].replace(/\;/g,',') + '"></input>');
fplacen=gllentry.split(',')[2].replace(/\;/g,',');
document.getElementById('ssf').innerHTML=' ' + gllentry.split(',')[2].replace(/\;/g,',');
mu=mu.replace('=LonJunkdon','=' + encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,','))).replace(',~London~]',',~' + encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')) + '~],[051.5072,-00.1275,~LonDon~]');
tpurl=tpurl.replace("Sydney+NSW,+Australia",encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')));
if (document.getElementById('sftif') && document.getElementById('iftif')) {
document.getElementById('iftif').src=document.getElementById('iftif').src.replace('&',encodeURIComponent(' from ' + gllentry.split(',')[2].replace(/\;/g,',')) + '&') + ',[' + gllentry.replace(',' + gllentry.split(',')[1] + ',', ',' + gllentry.split(',')[1] + ',~').replace(/\ /g,'%20') + '~]';
document.getElementById('sftif').innerHTML+=' <a target=_blank title=Accomodation onclick=woit(this); style=text-decoration:underline;cursor:pointer; data-href="' + accomurl.replace(/Springwood\,\+New\+South\+Wales/g, encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')).replace(/\%20/g,'+')) + '">from 🛌</a> <a target=_blank title="' + gllentry.split(',')[2].replace(/\;/g,',') + '" href="//en.wikipedia.org/wiki/' + encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')) + '">' + gllentry.split(',')[2].replace(/\;/g,',') + '</a>';
document.getElementById('brg').value='0.0000000';
document.getElementById('dist').value='0.000';
document.getElementById('brg').style.backgroundColor='white';
document.getElementById('dist').style.backgroundColor='white';
cwhat=[false,false,true,true,false,false];
ourdist=great_circle_distance(document.getElementById(eles[0]).value,document.getElementById(eles[1]).value,document.getElementById(eles[4]).value,document.getElementById(eles[5]).value);
document.getElementById(eles[3]).value='' + ourdist;

//Let ‘R’ be the radius of Earth,
//‘L’ be the longitude,
//‘θ’ be latitude,
//‘β‘ be Bearing.

//Bearing from point A to B, can be calculated as,

//β = atan2(X,Y),

//where, X and Y are two quantities and can be calculated as:

//X = cos θb * sin ∆L

//Y = cos θa * sin θb – sin θa * cos θb * cos ∆L

ourbrg=eval(eval(360.0 + eval(eval(eval(180.0 / Math.PI) * Math.atan2(
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval(eval('' + document.getElementById(eles[5]).value) - eval('' + document.getElementById(eles[1]).value))))),
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value)))) -
eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval(eval('' + document.getElementById(eles[5]).value) - eval('' + document.getElementById(eles[1]).value)))))
)))) % 360.0);

document.getElementById('mysel').value='2';
document.getElementById(eles[2]).value='' + ourbrg;
document.getElementById(eles[2]).style.backgroundColor='lightgreen';
document.getElementById(eles[3]).style.backgroundColor='lightgreen';
}
} else {
var interesting=false, waslatt='', waslongt='', wasfplacen='';
if (gllonesuffix == 'f') {
interesting=true;
waslatt=document.getElementById('latt').value;
waslongt=document.getElementById('longt').value;
if (documentURL == document.URL) {
wasfplacen=location.search.split('tplacen=')[1] ? (' ' + decodeURIComponent(location.search.split('tplacen=')[1].split('&')[0]).replace(/\+/g,' ')) : ''; //document.getElementById('tplacen').value;
} else {
wasfplacen=decodeURIComponent(documentURL.split('tplacen=')[eval(-1 + documentURL.split('tplacen=').length)].split('&')[0]);
}
//alert('interesting');
}
mu=mu.replace('=London','=' + encodeURIComponent(fplacen));
document.getElementById('brg').focus();
document.getElementById('dist').focus();
document.getElementById('latt').focus();
document.getElementById('latt').value=gllentry.split(',')[0];
mu=mu.replace('[051.5072,','[' + gllentry.split(',')[0] + ',');
document.getElementById('longt').focus();
document.getElementById('longt').value=gllentry.split(',')[1];
mu=mu.replace(',-00.1275,',',' + gllentry.split(',')[1] + ',');
document.getElementById('latt').focus();
gllonesuffix = 'f';
if (interesting) {
document.getElementById('spfr').innerHTML=document.getElementById('spfr').innerHTML.replace('to','from<input type=hidden id=tplacen name=tplacen value="' + gllentry.split(',')[2].replace(/\;/g,',') + '"></input>');
} else {
document.getElementById('spfr').innerHTML=document.getElementById('spfr').innerHTML.replace('to','from<input type=hidden id=tplacen name=tplacen value="' + gllentry.split(',')[2].replace(/\;/g,',') + '"></input>');
}
document.getElementById('ifill').value='Map Trip';
document.getElementById('sst').innerHTML=' ' + gllentry.split(',')[2].replace(/\;/g,',');
mu=mu.replace(',~LonDon~]',',~' + encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')) + '~]');
tpurl=tpurl.replace("Brisbane+QLD,+Australia",encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')));
if (document.getElementById('sftif') && document.getElementById('iftif')) {
if (document.getElementById('addafirst')) { document.getElementById('addafirst').style.display='inline-block'; }
if (document.getElementById('addacc')) { document.getElementById('addacc').style.display='inline-block'; }
document.getElementById('iftif').src=document.getElementById('iftif').src.replace('&',encodeURIComponent(' to ' + gllentry.split(',')[2].replace(/\;/g,',')) + '&') + ',[' + gllentry.replace(',' + gllentry.split(',')[1] + ',', ',' + gllentry.split(',')[1] + ',~').replace(/\ /g,'%20') + '~]';
//if (interesting) {
// alert('interesting ... fplacen=' + fplacen);
//}
if (interesting) {
document.getElementById('sftif').innerHTML+=(' from <a target=_blank title="' + wasfplacen + '" href="//en.wikipedia.org/wiki/' + encodeURIComponent(wasfplacen) + '">' + wasfplacen + '</a> ').substring(0,1) + '<a target=_blank title=Accomodation onclick=woit(this); style=text-decoration:underline;cursor:pointer; data-href="' + accomurl.replace(/Springwood\,\+New\+South\+Wales/g, encodeURIComponent(wasfplacen).replace(/\%20/g,'+')) + '">🛌</a>' + '<a target=_blank title="Google Maps Directions" href="' + tpurl.replace('https:','') + '">to</a><a title="Map of this trip leg" class="adda" onclick="addto(this);" data-from="' + (wasfplacen ? wasfplacen : fplacen) + '" data-to="' + gllentry.split(',')[2].replace(/\;/g,',') + '" style="display:inline-block;cursor:pointer;" data-latf=' + (waslatt ? waslatt : document.getElementById('latf').value) + ' data-longf=' + (waslongt ? waslongt : document.getElementById('longf').value) + ' data-latt=' + document.getElementById('latt').value + ' data-longt=' + document.getElementById('longt').value + ' data-gcd=' + eval(eval('' + great_circle_distance((waslatt ? waslatt : document.getElementById(eles[0]).value),(waslongt ? waslongt : document.getElementById(eles[1]).value),document.getElementById(eles[4]).value,document.getElementById(eles[5]).value)) / 1000.000) + '>⬆<a> <a target=_blank title="' + gllentry.split(',')[2].replace(/\;/g,',') + '" href="//en.wikipedia.org/wiki/' + encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')) + '">' + gllentry.split(',')[2].replace(/\;/g,',') + '</a> (' + '<a target=_blank title=Accomodation onclick=woit(this); style=text-decoration:underline;cursor:pointer; data-href="' + accomurl.replace(/Springwood\,\+New\+South\+Wales/g, encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')).replace(/\%20/g,'+')) + '">🛌</a> ' + eval(eval('' + great_circle_distance(document.getElementById(eles[0]).value,document.getElementById(eles[1]).value,document.getElementById(eles[4]).value,document.getElementById(eles[5]).value)) / 1000.000) + ' kilometres)';
//alert('interesting ... fplacen=' + wasfplacen);
} else {
document.getElementById('sftif').innerHTML+=' <a target=_blank title="Google Maps Directions" href="' + tpurl.replace('https:','') + '">to</a><a title="Map of this trip leg" class="adda" onclick="addto(this);" data-from="' + (wasfplacen ? wasfplacen : fplacen) + '" data-to="' + gllentry.split(',')[2].replace(/\;/g,',') + '" style="display:inline-block;cursor:pointer;" data-latf=' + (waslatf ? waslatf : document.getElementById('latf').value) + ' data-longf=' + (waslongf ? waslongf : document.getElementById('longf').value) + ' data-latt=' + document.getElementById('latt').value + ' data-longt=' + document.getElementById('longt').value + ' data-gcd=' + eval(eval('' + great_circle_distance((waslatf ? waslatf : document.getElementById(eles[0]).value),(waslongf ? waslongf : document.getElementById(eles[1]).value),document.getElementById(eles[4]).value,document.getElementById(eles[5]).value)) / 1000.000) + '>⬆<a> <a target=_blank title="' + gllentry.split(',')[2].replace(/\;/g,',') + '" href="//en.wikipedia.org/wiki/' + encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')) + '">' + gllentry.split(',')[2].replace(/\;/g,',') + '</a> (' + '<a target=_blank title=Accomodation onclick=woit(this); style=text-decoration:underline;cursor:pointer; data-href="' + accomurl.replace(/Springwood\,\+New\+South\+Wales/g, encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,',')).replace(/\%20/g,'+')) + '">🛌</a> ' + eval(eval('' + great_circle_distance(document.getElementById(eles[0]).value,document.getElementById(eles[1]).value,document.getElementById(eles[4]).value,document.getElementById(eles[5]).value)) / 1000.000) + ' kilometres)';
}
document.getElementById('brg').style.backgroundColor='white';
document.getElementById('dist').style.backgroundColor='white';
documentURL+='&tplacen=' + encodeURIComponent(gllentry.split(',')[2].replace(/\;/g,','));
cwhat=[false,false,true,true,false,false];
ourdist=great_circle_distance(document.getElementById(eles[0]).value,document.getElementById(eles[1]).value,document.getElementById(eles[4]).value,document.getElementById(eles[5]).value);
document.getElementById(eles[3]).value='' + ourdist;


//Let ‘R’ be the radius of Earth,
//‘L’ be the longitude,
//‘θ’ be latitude,
//‘β‘ be Bearing.

//Bearing from point A to B, can be calculated as,

//β = atan2(X,Y),

//where, X and Y are two quantities and can be calculated as:

//X = cos θb * sin ∆L

//Y = cos θa * sin θb – sin θa * cos θb * cos ∆L

ourbrg=eval(eval(360.0 + eval(eval(eval(180.0 / Math.PI) * Math.atan2(
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval(eval('' + document.getElementById(eles[5]).value) - eval('' + document.getElementById(eles[1]).value))))),
eval(eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value)))) -
eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval(eval('' + document.getElementById(eles[5]).value) - eval('' + document.getElementById(eles[1]).value)))))
)))) % 360.0);

document.getElementById('mysel').value='2';
document.getElementById(eles[2]).value='' + ourbrg;
document.getElementById(eles[2]).style.backgroundColor='lightgreen';
document.getElementById(eles[3]).style.backgroundColor='lightgreen';


if (interesting) {
document.getElementById('spfr').innerHTML='to';
document.getElementById('ipn').focus();
}
}
}
document.getElementById('ipn').placeholder=gllentry.split(',')[2].replace(/\;/g,',');
}
gllentry='';
document.getElementById('placegeo').value='';
}

function lookforg() {
if (document.getElementById('placegeo').value != '') {
gllentry=document.getElementById('placegeo').value + ',' + decodeURIComponent(document.getElementById('ifplacegeo').src.split('?placegeo=')[1]).replace(/\,/g,';');
askit();
} else {
setTimeout(lookforg,1000);
}
}

function checkit(iois) {
if (iois != null) {
if (iois.src.indexOf('?placegeo=') != -1) {
//alert(1);
var aconto = (iois.contentWindow || iois.contentDocument);
//alert(11);
if (aconto != null) {
//alert(111);
if (aconto.document) { aconto = aconto.document; }
//alert(1111);
if (aconto.body != null) {
//alert(2);
document.body.style.cursor='pointer';
if (document.getElementById('placegeo').value != '') {
//alert(3);
gllentry=document.getElementById('placegeo').value + ',' + decodeURIComponent(iois.src.split('?placegeo=')[1]).replace(/\,/g,';');
askit();
} else {
//alert(8);
setTimeout(lookforg,1000);
}
}
}
}
}
}

function lkwk(oiis) {
if (oiis.value.trim() != '') {
if (document.getElementById('tdmid')) {
if (document.getElementById('tdmid').innerHTML.toLowerCase().indexOf('<iframe') != -1) {
if (document.getElementById('spfr')) {
if (document.getElementById('spfr').innerHTML.toLowerCase().indexOf('rom') != -1) {
location.href=document.URL.split('#')[0].split('?')[0] + '?ipn=' + encodeURIComponent(oiis.value);
}
}
}
}
if (oiis.value.trim() != oiis.value) { tplacen=tplacen.trim(); } else { tplacen+=String.fromCharCode(32); }
var ois=oiis.value.trim().split(';');
document.getElementById('ifplacegeo').src=document.getElementById('ifplacegeo').src.split('?')[0].split('#')[0] + '?placegeo=' + encodeURIComponent(ois[0]);
if (eval('' + ois.length) > 1) { elev=eval('' + ois[1]); evel=Math.max(elev, 2.0); }
oiis.value='';
document.body.style.cursor='progress';
}
}

function fillablemaybe(brgo) {
if (('' + brgo.value).replace(/0/g,'').replace('.','') != '') {
//alert('356:' + document.getElementById('dist').value);
if (('' + document.getElementById('dist').value).replace(/0/g,'').replace('.','') == '' || (fplacen != '' && tplacen == '')) {
//alert(456);
if (('' + document.getElementById('latt').value).replace(/0/g,'').replace('.','') == '' || (fplacen != '' && tplacen == '')) {
//alert(556);
if (('' + document.getElementById('longt').value).replace(/0/g,'').replace('.','') == '' || (fplacen != '' && tplacen == '')) {
//alert(656);
if (('' + document.getElementById('ssf').innerHTML) != '') {
//alert(756);
if (!viastart) {
dok=false;
document.getElementById('dist').focus();
if (1 == 1) { // assume 2m elevation ... thanks to https://en.wikipedia.org/wiki/Horizon
document.getElementById('dist').value='' + Math.floor(Math.pow(eval(eval(2.0 * eval('' + elev)) * 6371000.0), 0.5)) + '.000';
} else {
document.getElementById('dist').value='5000.000';
}
elev=2.0;
brgo.focus();
}
if (mu.indexOf('[051.5072,') != -1) {
//alert(856);
if (!viastart) {
document.getElementById('ifill').click();
}
mu=mu.replace('[051.5072,','[' + document.getElementById('latt').value + ',');
mu=mu.replace(',-00.1275,',',' + document.getElementById('longt').value + ',');
mu=mu.replace(',~LonDon~]',',~' + encodeURIComponent(fplacen + ' looking out at bearing ' + brgo.value + ' degrees towards horizon') + '~]');
mu=mu.replace('=London','=' + encodeURIComponent(fplacen + ' looking out at bearing ' + brgo.value + ' degrees towards horizon'));
//alert('956:' + mu);
//document.getElementById('hplacen').innerHTML='<input type=hidden name=fplacen value="' + mu + '"></input>';
//alert(567);
tdfoota=' <input ' + trfoota.split('</td>')[0].split('<input ')[0];
trfoota='';
document.getElementById('tdmid').colSpan='2';
document.getElementById('tdmid').innerHTML='<iframe src="' + mu + '" style="width:100%;height:600px;"></iframe>';
if (viastart) {
fplacen='';
}
}

}
}
}
}
}
}

function predfillablemaybe() {
dfillablemaybe(document.getElementById('dist'));
}

function dfillablemaybe(brgo) {
//alert(45);
if (!dok) { return ''; }
//alert(('' + brgo.value).replace(/0/g,'').replace('.',''));
var i, ourbrg=0.0, ourdist=0.0, j, dvlat='', dvlong='';
if (('' + brgo.value).replace(/0/g,'').replace('.','') != '') {
//alert('356:' + document.getElementById('dist').value);
if (('' + document.getElementById('dist').value).replace(/0/g,'').replace('.','') != '' || (fplacen != '' && tplacen == '')) {
//alert(456);
if (('' + document.getElementById('latt').value).replace(/0/g,'').replace('.','') == '' || (fplacen != '' && tplacen == '')) {
//alert(556);
if (('' + document.getElementById('longt').value).replace(/0/g,'').replace('.','') == '' || (fplacen != '' && tplacen == '')) {
//alert(656);
if (('' + document.getElementById('ssf').innerHTML) != '') {
//alert(756);
if (!viastart) {
//document.getElementById('brg').focus();
document.getElementById('brg').value='0.0000001';
//brgo.focus();
}
if (mu.indexOf('[051.5072,') != -1) {
//alert(856);
if (!viastart) {
//alert(1);
document.getElementById('ifill').click();
//alert(11);
}
mu=mu.replace('[051.5072,','[' + eval('' + document.getElementById('latt').value).toFixed(3) + ',');
mu=mu.replace(',-00.1275,',',' + eval('' + document.getElementById('longt').value).toFixed(3) + ',');
if (('' + brgo.value).indexOf('000.000') != -1) {
//mu=mu.replace(encodeURIComponent('looking out North'), encodeURIComponent(('' + brgo.value).split('000.000')[0] + 'km Ring'));
mu=mu.replace(',~LonDon~]',',~' + encodeURIComponent(fplacen + ' looking North') + '~]');
mu=mu.replace('=London','=' + encodeURIComponent(fplacen + (' ' + brgo.value).split('000.000')[0] + 'km Ring'));
} else {
mu=mu.replace(',~LonDon~]',',~' + encodeURIComponent(fplacen + ' looking North') + '~]');
mu=mu.replace('=London','=' + encodeURIComponent(fplacen + ' looking out North'));
}
//mu=mu.replace(',~LonDon~]',',~' + encodeURIComponent(fplacen + ' looking North') + '~]');
//mu=mu.replace('=London','=' + encodeURIComponent(fplacen + ' looking out North'));
//alert('956:' + mu);
//document.getElementById('hplacen').innerHTML='<input type=hidden name=fplacen value="' + mu + '"></input>';
//document.getElementById('tdmid').innerHTML='<iframe src="' + mu + '" style="width:100%;height:600px;"></iframe>';
if (viastart) {
for (var dbrg=30; dbrg<=330; dbrg+=30) {
//document.getElementById('brg').value='' + dbrg + '.0000000';

if (('' + document.getElementById('mysel').value) == '2') {
ourbrg=eval(eval(540.0 + 180.0 + eval('' + document.getElementById(eles[2]).value)) % 360.0);
} else {
ourbrg=eval('' + document.getElementById(eles[2]).value);
}
ourbrg=eval('' + dbrg);
for (j=eval(3 - eval(('' + document.getElementById('mysel').value))); j>=1; j--) {
ourdist=eval('' + document.getElementById(eles[3]).value);


//Let first point latitude be la1,
///longitude as lo1,
//d be distance,
//R as radius of Earth,
//Ad be the angular distance i.e d/R and
//θ be the bearing,

//Here is the formula to find the second point, when first point, bearing and distance is known:

//latitude of second point = la2 = asin(sin la1 * cos Ad + cos la1 * sin Ad * cos θ), and
//longitude of second point = lo2 = lo1 + atan2(sin θ * sin Ad * cos la1 , cos Ad – sin la1 * sin la2)

dvlat='' +
eval(eval(eval(180.0 / Math.PI) * Math.asin(
Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value)) *
Math.cos(eval(eval('' + ourdist) / 6371000.0)) +
Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value)) *
Math.sin(eval(eval('' + ourdist) / 6371000.0)) *
Math.cos(eval(Math.PI / 180.0) * eval('' + ourbrg)))));

//Let first point latitude be la1,
//longitude as lo1,
//d be distance,
//R as radius of Earth,
//Ad be the angular distance i.e d/R and
//θ be the bearing,
// longitude of second point = lo2 = lo1 + atan2(sin θ * sin Ad * cos la1 , cos Ad – sin la1 * sin la2)

dvlong='' + eval(eval(180.0 / Math.PI) * eval(eval(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[1]).value)) +
Math.atan2(
eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + ourbrg)) *
eval('' + Math.sin(eval(eval('' + ourdist) / 6371000.0)))) *
eval('' + Math.cos(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value)))),
eval(eval('' + Math.cos(eval(eval('' + ourdist) / 6371000.0))) -
eval(eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[0]).value)))) *
eval('' + Math.sin(eval(Math.PI / 180.0) * eval('' + document.getElementById(eles[4]).value)))))));
mu+=',[' + eval('' + dvlat).toFixed(3) + ',' + eval('' + dvlong).toFixed(3) + ',~' + dbrg + '~]';

}

}
//alert(mu);
tdfoota=' <input ' + trfoota.split('</td>')[0].split('<input ')[0];
trfoota='';
document.getElementById('tdmid').colSpan='2';
document.getElementById('tdmid').innerHTML='<iframe src="' + mu + '" style="width:100%;height:600px;"></iframe>';
fplacen='';
}
}

}
}
}
}
}
}

</script>
</head>
<body onload='moremaybe();'>
<button id=ballow style='display:block;background-color:yellow;' onclick='start();'>Allow</button>
<form id=gform method=GET action='//www.rjmprogramming.com.au/HTMLCSS/missing_two.html'><div id=hplacen></div>
<div id=dtop style=display:block;>
<h1 id=myh1 style='display:block;'>Missing Two (<font size=1>optional</font> <span onclick="this.innerHTML=this.innerHTML.replace('to','From').replace('from','to').replace('From','from'); document.getElementById('ipn').focus(); " id=spfr title='Click me to toggle between from and to' style='cursor:pointer;'>from</span> <input title='Optionally semicolon separate an elevation affecting horizon distance used for Place Name/Bearing (where Compass app might show you this elevation value) input scenarios. Note that a Place Name/Distance scenario shows a Locality Distance Ring map. Append space for gyroscope bearing.' onblur='lkwk(this);' style='display:inline-block;width:280px;' placeholder='Place Name' id=ipn value='' type=text></input>) in Table Column <span data-onfocus="document.getElementById('semail').innerHTML='';" data-title='Email to (append a space to just show the table cell with the gradient)?' data-contenteditable=true data-onblur=preemail(this.innerHTML); onclick=emailit(''); id=semail title=Email>📧</span> <span data-onfocus="document.getElementById('semail').innerHTML='';" data-title='SMS to?' data-contenteditable=true data-onblur=preemail(this.innerHTML); onclick=toize(''); id=ssms title=SMS>📟</span><div id=dntable style=display:none;>    <table border=1 id=ntable style="background-color:pink;display:inline-block;font-size:10px;"><tr><td>N</td></tr><tr><td>⬆</td></tr></table>    ⬆</div></h1>
<h3 id=myh3 style='display:block;'>RJM Programming <a style="text-decoration:underline;cursor:pointer;" onclick="location.href=document.URL.split('#')[0].split('?')[0];">-</a> December, 2018</h3>
<h3>Thanks to <a target=_blank title='Thanks' href='//www.igismap.com/formula-to-find-bearing-or-heading-angle-between-two-points-latitude-longitude/'>Formula to Find Bearing angle between 2 points: Latitude Longitude</a></title>
</div>
<table border=10 cellspacing=6 cellpadding=6 style='width:100%;' id=myt>
<tbody id=tdlook>
<tr id=trhead style='display:table-row;'><th style='width:30%;text-align:left;background-color:#f0e0d0;'><a title='Show nearest TimeZone places' id=afrom onclick=mapit(this); style='cursor:pointer;text-decoration:underline;'>From</a> <span id=ssf></span> <div id=dfrom style='display:none;'></div></th><th style='width:30%;text-align:left;background-color:#e0d0f0;'> ... On The Way ...</th><th style='text-align:left;background-color:#d0f0e0;'><a title='Show nearest TimeZone places' id=ato onclick=mapit(this); style='cursor:pointer;text-decoration:underline;'>To</a> <span id=sst></span> <div id=dto style='display:none;'></div></th></tr>
<tr id=trorig style='display:table-row;'><td id='from'>
Latitude (decimal degrees): <input title='' style='width:90px;display:inline-block;' onchange='this.style.backgroundColor="pink";cwhat[0]=false; cwhat[1]=false; if (!decided) { if (!cwhat[5]) { cwhat[5]=true; } if (!cwhat[4]) { cwhat[4]=true; } decided=true; } top.document.getElementById("ltf").value=this.value; ' onblur='this.style.backgroundColor="pink";cwhat[0]=false; cwhat[1]=false; if (!decided) { if (!cwhat[5]) { cwhat[5]=true; } if (!cwhat[4]) { cwhat[4]=true; } decided=true; } top.document.getElementById("ltf").value=this.value; ' id=latf name=latf type=number min=-90.0000000 max=90.0000000 step=0.0000010 value='0.0000000'></input><br>
Longitude (decimal degrees): <input title='' style='width:90pxdisplay:inline-block;;' onchange='this.style.backgroundColor="pink"; cwhat[0]=false; cwhat[1]=false; if (!decided) { if (!cwhat[5]) { cwhat[5]=true; } if (!cwhat[4]) { cwhat[4]=true; } decided=true; } top.document.getElementById("lgf").value=this.value; ' onblur='this.style.backgroundColor="pink"; cwhat[0]=false; cwhat[1]=false; if (!decided) { if (!cwhat[5]) { cwhat[5]=true; } if (!cwhat[4]) { cwhat[4]=true; } decided=true; } top.document.getElementById("lgf").value=this.value; ' id=longf name=longf type=number min=-180.0000000 max=180.0000000 step=0.0000010 value='0.0000000'></input>
</td><td id='ontheway'>
Bearing <select id="mysel" onchange="myselit(this);"><option value='2'>From->To</option><option value='1'>To->From</option></select> (decimal degrees): <input style='width:90px;' onclick="tplacen+=String.fromCharCode(32); if (fplacen.trim().length != 0 && tplacen.trim().length == 0) { this.style.backgroundColor='pink'; cwhat[3]=false; cwhat[2]=false; if (!decided) { decided=true; } fillablemaybe(this); } " onchange='this.style.backgroundColor="pink"; cwhat[3]=false; cwhat[2]=false; if (!decided) { decided=true; } ' onblur='this.style.backgroundColor="pink"; cwhat[3]=false; cwhat[2]=false; if (!decided) { decided=true; } fillablemaybe(this); ' id=brg name=brg type=number min=-360.0000000 max=360.0000000 step=0.0000010 value='0.0000000'></input><br>
Distance (metres):  <input style='width:90px;' onchange='this.style.backgroundColor="pink"; cwhat[3]=false; cwhat[2]=false; if (!decided) { decided=true; } ' onblur='this.style.backgroundColor="pink"; cwhat[3]=false; cwhat[2]=false; if (!decided) { decided=true; } dfillablemaybe(this); ' id=dist name=dist type=number min=0.000 step=0.001 value='0.000'></input>
</td><td id='to'>
Latitude (decimal degrees): <input title='' style='width:90px;' onchange='this.style.backgroundColor="pink"; cwhat[4]=false; cwhat[5]=false; if (!decided) { if (!cwhat[1]) { cwhat[1]=true; } if (!cwhat[0]) { cwhat[0]=true; } decided=true; } top.document.getElementById("ltt").value=this.value; ' onblur='this.style.backgroundColor="pink"; cwhat[4]=false; cwhat[5]=false; if (!decided) { if (!cwhat[1]) { cwhat[1]=true; } if (!cwhat[0]) { cwhat[0]=true; } decided=true; } top.document.getElementById("ltt").value=this.value; ' id=latt name=latt type=number min=-90.0000000 max=90.0000000 step=0.0000010 value='0.0000000'></input><br>
Longitude (decimal degrees)<span onclick='moreifok();' id=slong>:</span> <input title='' style='width:90px;display:inline-block;' onchange='this.style.backgroundColor="pink"; cwhat[5]=false; cwhat[4]=false; if (!decided) { if (!cwhat[1]) { cwhat[1]=true; } if (!cwhat[0]) { cwhat[0]=true; } decided=true; } top.document.getElementById("lgt").value=this.value; ' onblur='this.style.backgroundColor="pink"; cwhat[4]=false; cwhat[5]=false; if (!decided) { if (!cwhat[1]) { cwhat[1]=true; } if (!cwhat[0]) { cwhat[0]=true; } decided=true; } top.document.getElementById("lgt").value=this.value; ' id=longt name=longt type=number min=-180.0000000 max=180.0000000 step=0.0000010 value='0.0000000'></input>
</td></tr>
<tr id=next1 style='display:none;'><td id='nfromonthewayto' colspan=3><iframe style='width:100%;' id=niframe src=''></iframe></td></tr>
<tr id=trgraphics style='display:none;'><td id=tdfrom></td><td id=tdmidh></td><td id=tdto></td></tr>
<tr id="trfoot" style='DISPLAY:table-row;'><td id=tdfoot style='vertical-align:top;'><input id=ifill style='background-color:yellow;font-size:24px;display:block;' onclick="calcit(); filltwo();" type=button value='Fill'></input></td><td id=tdmid style='vertical-align:top;></td><!--td id=posttdmid style='vertical-align:top;><input id=goagain style='display:none;background-color:lightgreen;font-size:24px;' onclick="nextplease(); this.style.display='none';" type=button value='Go Again'></input></td--></tr>
</tbody>
</table>
</form>
<input id=outofthisworld style='position:absolute;top:-200px;left:-200px;' type='text' value=''></input>
<iframe onload='checknp(this);' id=nearestif name=nearestif style=display:none; src=about:none></iframe>
<div id=nearest style=display:none;></div><div id=getmell style=display:none;></div>
<form style='display:none;' target=nearestif action=//www.rjmprogramming.com.au/PHP/tz_places.php method=GET>
Place: <input onblur=" if (this.value.length > 0) { document.getElementById('nearestif').src='//www.rjmprogramming.com.au/PHP/tz_places.php?latitude=&longitude=&place=' + encodeURIComponent(this.value); } " type=text name=place value=></input>
Latitude: <input type=number id=latitude name=latitude value=0.0000 max=90.0000 min=-90.0000 step=0.0001></input>
Longitude: <input type=number id=longitude name=longitude value=0.0000 max=180.0000 min=-180.0000 step=0.0001></input><br>
<input type=submit id=inearest value='Nearest TimeZone Places'></input></form>
<input type=hidden value='' id=ltf></input><input type=hidden value='' id=lgf></input><input type=hidden value='' id=ltt></input><input type=hidden value='' id=lgt></input>
<a target=_top href='sms:' id=asms style=display:none;>SMS</a>
<iframe onload='checkit(this);' style='display:none;' id=ifplacegeo src='../PHP/fgc/index.php'></iframe>
<input type=hidden id=placegeo value=''></input>
</body>
</html>