<?php
// tz_places.php
// RJM Programming
// December, 2016
// Place information regarding nominated TimeZones and Country Codes
// Thanks to ...
// http://php.net/manual/en/datetimezone.getlocation.php
// http://stackoverflow.com/questions/17842003/php-intl-country-code-2-chars-to-country-name

// Use URL like ./tz_places.php?upto= to populate arrays below ...
$nearname=[""];
$nearlatitude=[" "];
$nearlongitude=["  "];

$gmthris=12;
$gmthhris=12;
$gmtminis=0;
$bestemojiclass="";
$thisemojiclass="";
$bestemojicodepoint=128347;
$thisemojicodepoint=128347;

$gmtdatetimeis="";
$onloadbits="";
$fromto="";
$kcnt="";
$bcol=["gray", "yellow", "pink", "lightblue", "lightgreen", "silver", "lightgray", "orange", "olive", "white"];
$mapurl="http://www.rjmprogramming.com.au/PHP/Map/map.php?title=Places&onclick=y&label=['Lat',&value='Lon','Name']&data=,[0.0000,0.0000,~Timbuktu~]";
$iam='1';
if (isset($_POST['iam'])) {
  $iam=$_POST['iam'];
} else if (isset($_GET['iam'])) {
  $iam=$_GET['iam'];
}
$nextis=1 + $iam;
$hprefix="";
$hsuffix="";

$otherform="";

$indt="now";
$udateis = localtimefromtogmt($indt, "Australi" . "a/Perth", "UTC");


if ($iam == "1" && !isset($_POST['iam']) && !isset($_GET['iam'])) {
  $otherform="<br><br><iframe id=nearestif name=nearestif style=display:none; src=about:none></iframe><div id=nearest></div><form target=nearestif action=./tz_places.php method=GET style=background-color:#f0f0f0;>Place: <input onblur=\" if (this.value.length > 0) { document.getElementById('nearestif').src='./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 style=background-color:orange; type=submit id=inearest value='Nearest TimeZone Places'></input></form>";
  $hprefix="<h1>Time<div style=display:inline; id=getmegmt title='" . $gmtdatetimeis . "' class='emoji" . $bestemojiclass . "' onclick=emojistuff(this);>&#" . $bestemojicodepoint . ";</div>Zone Places</h1><h3>RJM Programming - December, 2016</h3><h4>Thanks to <a target=_blank title='http://php.net/manual/en/datetimezone.getlocation.php' href='http://php.net/manual/en/datetimezone.getlocation.php'>http://php.net/manual/en/datetimezone.getlocation.php</a> and <br><a target=_blank title='http://stackoverflow.com/questions/17842003/php-intl-country-code-2-chars-to-country-name' href='http://stackoverflow.com/questions/17842003/php-intl-country-code-2-chars-to-country-name'>http://stackoverflow.com/questions/17842003/php-intl-country-code-2-chars-to-country-name</a> and <br><a target=_blank title=http://php.net/manual/en/function.timezone-identifiers-list.php href=http://php.net/manual/en/function.timezone-identifiers-list.php>http://php.net/manual/en/function.timezone-identifiers-list.php</a> and <br><a target=_blank title=http://www.timezoneconverter.com/ href=http://www.timezoneconverter.com/>http://www.timezoneconverter.com/</a></h4><table border=20><tbody><tr><td>";
  for ($ii=2; $ii<10; $ii++) {
    $hsuffix.="</td><td style=width:600px; id='td" . $ii . "'><a class='round' id='a" . $ii . "' style='background-color:lightgreen;text-decoration:underline;cursor:pointer;' onclick='newiframe(" . $ii . ");'>+" . $ii . "</a>";
  }
  $hsuffix.="</td></tr></tbody></table>";
  $fromto="&nbsp;&nbsp;<select onchange=mapselchange(this); style=display:none;position:absolute;top:40px;left:300px; id=fromto title='From/To functionality'><option value=''>Optionally select a From/To set of interest below ...</option></select>";
  $onloadbits=" setTimeout(checkmailbox,3000); ";
} else if ($iam == "1") {
  $otherform="<br><br><iframe id=nearestif name=nearestif style=display:none; src=about:none></iframe><div id=nearest></div><form target=nearestif action=./tz_places.php method=GET style=background-color:#f0f0f0;>Place: <input onblur=\" if (this.value.length > 0) { document.getElementById('nearestif').src='./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 style=background-color:orange; type=submit id=inearest value='Nearest TimeZone Places'></input></form>";
  $hprefix="<h1>Time<div style=display:inline; id=getmegmt title='" . $gmtdatetimeis . "' class='emoji" . $bestemojiclass . "' onclick=emojistuff(this);>&#" . $bestemojicodepoint . ";</div>Zone Places</h1><h3>RJM Programming - December, 2016</h3><h4>Thanks to <a target=_blank title='http://php.net/manual/en/datetimezone.getlocation.php' href='http://php.net/manual/en/datetimezone.getlocation.php'>http://php.net/manual/en/datetimezone.getlocation.php</a> and <br><a target=_blank title='http://stackoverflow.com/questions/17842003/php-intl-country-code-2-chars-to-country-name' href='http://stackoverflow.com/questions/17842003/php-intl-country-code-2-chars-to-country-name'>http://stackoverflow.com/questions/17842003/php-intl-country-code-2-chars-to-country-name</a> and <br><a target=_blank title=http://php.net/manual/en/function.timezone-identifiers-list.php href=http://php.net/manual/en/function.timezone-identifiers-list.php>http://php.net/manual/en/function.timezone-identifiers-list.php</a> and <br><a target=_blank title=http://www.timezoneconverter.com/ href=http://www.timezoneconverter.com/>http://www.timezoneconverter.com/</a></h4>" . "<table border=20><tbody><tr><td>";
  for ($ii=2; $ii<10; $ii++) {
    $hsuffix.="</td><td style=width:600px; id='td" . $ii . "'><a class='round' id='a" . $ii . "' style='background-color:lightgreen;text-decoration:underline;cursor:pointer;' onclick='newiframe(" . $ii . ");'>+" . $ii . "</a>";
  }
  $hsuffix.="</td></tr></tbody></table>";
  $fromto="&nbsp;&nbsp;<select onchange=mapselchange(this); style=display:none;position:absolute;top:40px;left:300px; id=fromto title='From/To functionality'><option value=''>Optionally select a From/To set of interest below ...</option></select>";
  $onloadbits=" setTimeout(checkmailbox,3000); ";
} else {
  $hprefix=""; //"<table><tbody><tr><td>";
  $hsuffix=""; //"</td><td id='td" . $nextis . "'><a id='a" . $nextis . "' style='text-decoration:underline;cursor:pointer;' onclick='newiframe(" . $nextis . ");'>+" . $nextis . "</a></td></tr></tbody></table>";
}



$iso_country_codes=['AF','Afghanistan',
'AX','Aland Islands',
'AL','Albania',
'DZ','Algeria',
'AS','American Samoa',
'AD','Andorra',
'AO','Angola',
'AI','Anguilla',
'AQ','Antarctica',
'AG','Antigua and Barbuda',
'AR','Argentina',
'AM','Armenia',
'AW','Aruba',
'AU','Australia',
'AT','Austria',
'AZ','Azerbaijan',
'BS','Bahamas the',
'BH','Bahrain',
'BD','Bangladesh',
'BB','Barbados',
'BY','Belarus',
'BE','Belgium',
'BZ','Belize',
'BJ','Benin',
'BM','Bermuda',
'BT','Bhutan',
'BO','Bolivia',
'BA','Bosnia and Herzegovina',
'BW','Botswana',
'BV','Bouvet Island (Bouvetoya)',
'BR','Brazil',
'IO','British Indian Ocean Territory (Chagos Archipelago)',
'VG','British Virgin Islands',
'BN','Brunei Darussalam',
'BG','Bulgaria',
'BF','Burkina Faso',
'BI','Burundi',
'KH','Cambodia',
'CM','Cameroon',
'CA','Canada',
'CV','Cape Verde',
'KY','Cayman Islands',
'CF','Central African Republic',
'TD','Chad',
'CL','Chile',
'CN','China',
'CX','Christmas Island',
'CC','Cocos (Keeling) Islands',
'CO','Colombia',
'KM','Comoros the',
'CD','Congo',
'CG','Congo the',
'CK','Cook Islands',
'CR','Costa Rica',
'CI','Cote d\'Ivoire',
'HR','Croatia',
'CU','Cuba',
'CY','Cyprus',
'CZ','Czech Republic',
'DK','Denmark',
'DJ','Djibouti',
'DM','Dominica',
'DO','Dominican Republic',
'EC','Ecuador',
'EG','Egypt',
'SV','El Salvador',
'GQ','Equatorial Guinea',
'ER','Eritrea',
'EE','Estonia',
'ET','Ethiopia',
'FO','Faroe Islands',
'FK','Falkland Islands (Malvinas)',
'FJ','Fiji the Fiji Islands',
'FI','Finland',
'FR','France, French Republic',
'GF','French Guiana',
'PF','French Polynesia',
'TF','French Southern Territories',
'GA','Gabon',
'GM','Gambia the',
'GE','Georgia',
'DE','Germany',
'GH','Ghana',
'GI','Gibraltar',
'GR','Greece',
'GL','Greenland',
'GD','Grenada',
'GP','Guadeloupe',
'GU','Guam',
'GT','Guatemala',
'GG','Guernsey',
'GN','Guinea',
'GW','Guinea-Bissau',
'GY','Guyana',
'HT','Haiti',
'HM','Heard Island and McDonald Islands',
'VA','Holy See (Vatican City State)',
'HN','Honduras',
'HK','Hong Kong',
'HU','Hungary',
'IS','Iceland',
'IN','India',
'ID','Indonesia',
'IR','Iran',
'IQ','Iraq',
'IE','Ireland',
'IM','Isle of Man',
'IL','Israel',
'IT','Italy',
'JM','Jamaica',
'JP','Japan',
'JE','Jersey',
'JO','Jordan',
'KZ','Kazakhstan',
'KE','Kenya',
'KI','Kiribati',
'KP','Korea',
'KR','Korea',
'KW','Kuwait',
'KG','Kyrgyz Republic',
'LA','Laos',
'LV','Latvia',
'LB','Lebanon',
'LS','Lesotho',
'LR','Liberia',
'LY','Libyan Arab Jamahiriya',
'LI','Liechtenstein',
'LT','Lithuania',
'LU','Luxembourg',
'MO','Macao',
'MK','Macedonia',
'MG','Madagascar',
'MW','Malawi',
'MY','Malaysia',
'MV','Maldives',
'ML','Mali',
'MT','Malta',
'MH','Marshall Islands',
'MQ','Martinique',
'MR','Mauritania',
'MU','Mauritius',
'YT','Mayotte',
'MX','Mexico',
'FM','Micronesia',
'MD','Moldova',
'MC','Monaco',
'MN','Mongolia',
'ME','Montenegro',
'MS','Montserrat',
'MA','Morocco',
'MZ','Mozambique',
'MM','Myanmar',
'NA','Namibia',
'NR','Nauru',
'NP','Nepal',
'AN','Netherlands Antilles',
'NL','Netherlands the',
'NC','New Caledonia',
'NZ','New Zealand',
'NI','Nicaragua',
'NE','Niger',
'NG','Nigeria',
'NU','Niue',
'NF','Norfolk Island',
'MP','Northern Mariana Islands',
'NO','Norway',
'OM','Oman',
'PK','Pakistan',
'PW','Palau',
'PS','Palestinian Territory',
'PA','Panama',
'PG','Papua New Guinea',
'PY','Paraguay',
'PE','Peru',
'PH','Philippines',
'PN','Pitcairn Islands',
'PL','Poland',
'PT','Portugal, Portuguese Republic',
'PR','Puerto Rico',
'QA','Qatar',
'RE','Reunion',
'RO','Romania',
'RU','Russian Federation',
'RW','Rwanda',
'BL','Saint Barthelemy',
'SH','Saint Helena',
'KN','Saint Kitts and Nevis',
'LC','Saint Lucia',
'MF','Saint Martin',
'PM','Saint Pierre and Miquelon',
'VC','Saint Vincent and the Grenadines',
'WS','Samoa',
'SM','San Marino',
'ST','Sao Tome and Principe',
'SA','Saudi Arabia',
'SN','Senegal',
'RS','Serbia',
'SC','Seychelles',
'SL','Sierra Leone',
'SG','Singapore',
'SK','Slovakia (Slovak Republic)',
'SI','Slovenia',
'SB','Solomon Islands',
'SO','Somalia, Somali Republic',
'ZA','South Africa',
'GS','South Georgia and the South Sandwich Islands',
'ES','Spain',
'LK','Sri Lanka',
'SD','Sudan',
'SR','Suriname',
'SJ','Svalbard & Jan Mayen Islands',
'SZ','Swaziland',
'SE','Sweden',
'CH','Switzerland, Swiss Confederation',
'SY','Syrian Arab Republic',
'TW','Taiwan',
'TJ','Tajikistan',
'TZ','Tanzania',
'TH','Thailand',
'TL','Timor-Leste',
'TG','Togo',
'TK','Tokelau',
'TO','Tonga',
'TT','Trinidad and Tobago',
'TN','Tunisia',
'TR','Turkey',
'TM','Turkmenistan',
'TC','Turks and Caicos Islands',
'TV','Tuvalu',
'UG','Uganda',
'UA','Ukraine',
'AE','United Arab Emirates',
'GB','United Kingdom',
'US','United States of America',
'UM','United States Minor Outlying Islands',
'VI','United States Virgin Islands',
'UY','Uruguay, Eastern Republic of',
'UZ','Uzbekistan',
'VU','Vanuatu',
'VE','Venezuela',
'VN','Vietnam',
'WF','Wallis and Futuna',
'EH','Western Sahara',
'YE','Yemen',
'ZM','Zambia',
'ZW','Zimbabwe'];

$sellong='<select id=sellong onchange=document.getElementById("isellong").value=this.value;><option value="">Optionally Select Country of Interest below ...</option>
<option value="AF">Afghanistan</option>
<option value="AX">Aland Islands</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
<option value="AQ">Antarctica</option>
<option value="AG">Antigua and Barbuda</option>
<option value="AR">Argentina</option>
<option value="AM">Armenia</option>
<option value="AW">Aruba</option>
<option value="AU">Australia</option>
<option value="AT">Austria</option>
<option value="AZ">Azerbaijan</option>
<option value="BS">Bahamas the</option>
<option value="BH">Bahrain</option>
<option value="BD">Bangladesh</option>
<option value="BB">Barbados</option>
<option value="BY">Belarus</option>
<option value="BE">Belgium</option>
<option value="BZ">Belize</option>
<option value="BJ">Benin</option>
<option value="BM">Bermuda</option>
<option value="BT">Bhutan</option>
<option value="BO">Bolivia</option>
<option value="BA">Bosnia and Herzegovina</option>
<option value="BW">Botswana</option>
<option value="BV">Bouvet Island (Bouvetoya)</option>
<option value="BR">Brazil</option>
<option value="IO">British Indian Ocean Territory (Chagos Archipelago)</option>
<option value="VG">British Virgin Islands</option>
<option value="BN">Brunei Darussalam</option>
<option value="BG">Bulgaria</option>
<option value="BF">Burkina Faso</option>
<option value="BI">Burundi</option>
<option value="KH">Cambodia</option>
<option value="CM">Cameroon</option>
<option value="CA">Canada</option>
<option value="CV">Cape Verde</option>
<option value="KY">Cayman Islands</option>
<option value="CF">Central African Republic</option>
<option value="TD">Chad</option>
<option value="CL">Chile</option>
<option value="CN">China</option>
<option value="CX">Christmas Island</option>
<option value="CC">Cocos (Keeling) Islands</option>
<option value="CO">Colombia</option>
<option value="KM">Comoros the</option>
<option value="CD">Congo</option>
<option value="CG">Congo the</option>
<option value="CK">Cook Islands</option>
<option value="CR">Costa Rica</option>
<option value="CI">Cote d~Ivoire</option>
<option value="HR">Croatia</option>
<option value="CU">Cuba</option>
<option value="CY">Cyprus</option>
<option value="CZ">Czech Republic</option>
<option value="DK">Denmark</option>
<option value="DJ">Djibouti</option>
<option value="DM">Dominica</option>
<option value="DO">Dominican Republic</option>
<option value="EC">Ecuador</option>
<option value="EG">Egypt</option>
<option value="SV">El Salvador</option>
<option value="GQ">Equatorial Guinea</option>
<option value="ER">Eritrea</option>
<option value="EE">Estonia</option>
<option value="ET">Ethiopia</option>
<option value="FO">Faroe Islands</option>
<option value="FK">Falkland Islands (Malvinas)</option>
<option value="FJ">Fiji the Fiji Islands</option>
<option value="FI">Finland</option>
<option value="FR">France, French Republic</option>
<option value="GF">French Guiana</option>
<option value="PF">French Polynesia</option>
<option value="TF">French Southern Territories</option>
<option value="GA">Gabon</option>
<option value="GM">Gambia the</option>
<option value="GE">Georgia</option>
<option value="DE">Germany</option>
<option value="GH">Ghana</option>
<option value="GI">Gibraltar</option>
<option value="GR">Greece</option>
<option value="GL">Greenland</option>
<option value="GD">Grenada</option>
<option value="GP">Guadeloupe</option>
<option value="GU">Guam</option>
<option value="GT">Guatemala</option>
<option value="GG">Guernsey</option>
<option value="GN">Guinea</option>
<option value="GW">Guinea-Bissau</option>
<option value="GY">Guyana</option>
<option value="HT">Haiti</option>
<option value="HM">Heard Island and McDonald Islands</option>
<option value="VA">Holy See (Vatican City State)</option>
<option value="HN">Honduras</option>
<option value="HK">Hong Kong</option>
<option value="HU">Hungary</option>
<option value="IS">Iceland</option>
<option value="IN">India</option>
<option value="ID">Indonesia</option>
<option value="IR">Iran</option>
<option value="IQ">Iraq</option>
<option value="IE">Ireland</option>
<option value="IM">Isle of Man</option>
<option value="IL">Israel</option>
<option value="IT">Italy</option>
<option value="JM">Jamaica</option>
<option value="JP">Japan</option>
<option value="JE">Jersey</option>
<option value="JO">Jordan</option>
<option value="KZ">Kazakhstan</option>
<option value="KE">Kenya</option>
<option value="KI">Kiribati</option>
<option value="KP">Korea</option>
<option value="KR">Korea</option>
<option value="KW">Kuwait</option>
<option value="KG">Kyrgyz Republic</option>
<option value="LA">Lao</option>
<option value="LV">Latvia</option>
<option value="LB">Lebanon</option>
<option value="LS">Lesotho</option>
<option value="LR">Liberia</option>
<option value="LY">Libyan Arab Jamahiriya</option>
<option value="LI">Liechtenstein</option>
<option value="LT">Lithuania</option>
<option value="LU">Luxembourg</option>
<option value="MO">Macao</option>
<option value="MK">Macedonia</option>
<option value="MG">Madagascar</option>
<option value="MW">Malawi</option>
<option value="MY">Malaysia</option>
<option value="MV">Maldives</option>
<option value="ML">Mali</option>
<option value="MT">Malta</option>
<option value="MH">Marshall Islands</option>
<option value="MQ">Martinique</option>
<option value="MR">Mauritania</option>
<option value="MU">Mauritius</option>
<option value="YT">Mayotte</option>
<option value="MX">Mexico</option>
<option value="FM">Micronesia</option>
<option value="MD">Moldova</option>
<option value="MC">Monaco</option>
<option value="MN">Mongolia</option>
<option value="ME">Montenegro</option>
<option value="MS">Montserrat</option>
<option value="MA">Morocco</option>
<option value="MZ">Mozambique</option>
<option value="MM">Myanmar</option>
<option value="NA">Namibia</option>
<option value="NR">Nauru</option>
<option value="NP">Nepal</option>
<option value="AN">Netherlands Antilles</option>
<option value="NL">Netherlands the</option>
<option value="NC">New Caledonia</option>
<option value="NZ">New Zealand</option>
<option value="NI">Nicaragua</option>
<option value="NE">Niger</option>
<option value="NG">Nigeria</option>
<option value="NU">Niue</option>
<option value="NF">Norfolk Island</option>
<option value="MP">Northern Mariana Islands</option>
<option value="NO">Norway</option>
<option value="OM">Oman</option>
<option value="PK">Pakistan</option>
<option value="PW">Palau</option>
<option value="PS">Palestinian Territory</option>
<option value="PA">Panama</option>
<option value="PG">Papua New Guinea</option>
<option value="PY">Paraguay</option>
<option value="PE">Peru</option>
<option value="PH">Philippines</option>
<option value="PN">Pitcairn Islands</option>
<option value="PL">Poland</option>
<option value="PT">Portugal, Portuguese Republic</option>
<option value="PR">Puerto Rico</option>
<option value="QA">Qatar</option>
<option value="RE">Reunion</option>
<option value="RO">Romania</option>
<option value="RU">Russian Federation</option>
<option value="RW">Rwanda</option>
<option value="BL">Saint Barthelemy</option>
<option value="SH">Saint Helena</option>
<option value="KN">Saint Kitts and Nevis</option>
<option value="LC">Saint Lucia</option>
<option value="MF">Saint Martin</option>
<option value="PM">Saint Pierre and Miquelon</option>
<option value="VC">Saint Vincent and the Grenadines</option>
<option value="WS">Samoa</option>
<option value="SM">San Marino</option>
<option value="ST">Sao Tome and Principe</option>
<option value="SA">Saudi Arabia</option>
<option value="SN">Senegal</option>
<option value="RS">Serbia</option>
<option value="SC">Seychelles</option>
<option value="SL">Sierra Leone</option>
<option value="SG">Singapore</option>
<option value="SK">Slovakia (Slovak Republic)</option>
<option value="SI">Slovenia</option>
<option value="SB">Solomon Islands</option>
<option value="SO">Somalia, Somali Republic</option>
<option value="ZA">South Africa</option>
<option value="GS">South Georgia and the South Sandwich Islands</option>
<option value="ES">Spain</option>
<option value="LK">Sri Lanka</option>
<option value="SD">Sudan</option>
<option value="SR">Suriname</option>
<option value="SJ">Svalbard & Jan Mayen Islands</option>
<option value="SZ">Swaziland</option>
<option value="SE">Sweden</option>
<option value="CH">Switzerland, Swiss Confederation</option>
<option value="SY">Syrian Arab Republic</option>
<option value="TW">Taiwan</option>
<option value="TJ">Tajikistan</option>
<option value="TZ">Tanzania</option>
<option value="TH">Thailand</option>
<option value="TL">Timor-Leste</option>
<option value="TG">Togo</option>
<option value="TK">Tokelau</option>
<option value="TO">Tonga</option>
<option value="TT">Trinidad and Tobago</option>
<option value="TN">Tunisia</option>
<option value="TR">Turkey</option>
<option value="TM">Turkmenistan</option>
<option value="TC">Turks and Caicos Islands</option>
<option value="TV">Tuvalu</option>
<option value="UG">Uganda</option>
<option value="UA">Ukraine</option>
<option value="AE">United Arab Emirates</option>
<option value="GB">United Kingdom</option>
<option value="US">United States of America</option>
<option value="UM">United States Minor Outlying Islands</option>
<option value="VI">United States Virgin Islands</option>
<option value="UY">Uruguay, Eastern Republic of</option>
<option value="UZ">Uzbekistan</option>
<option value="VU">Vanuatu</option>
<option value="VE">Venezuela</option>
<option value="VN">Vietnam</option>
<option value="WF">Wallis and Futuna</option>
<option value="EH">Western Sahara</option>
<option value="YE">Yemen</option>
<option value="ZM">Zambia</option>
<option value="ZW">Zimbabwe</option>
</select> ... <br>or, 2 letter ISO Country Code <input style=width:80px; name=iso onblur=document.getElementById("sellong").value=this.value; id=isellong type=text value=""></input><div style=display:inline; id=disellong class=emoji onclick=emojistuff(this);>&#128249;</div><br>';

function country_code_to_country( $code ){
    $code = strtoupper($code);
    $country = '';
    if( $code == 'AF' ) $country = 'Afghanistan';
    if( $code == 'AX' ) $country = 'Aland Islands';
    if( $code == 'AL' ) $country = 'Albania';
    if( $code == 'DZ' ) $country = 'Algeria';
    if( $code == 'AS' ) $country = 'American Samoa';
    if( $code == 'AD' ) $country = 'Andorra';
    if( $code == 'AO' ) $country = 'Angola';
    if( $code == 'AI' ) $country = 'Anguilla';
    if( $code == 'AQ' ) $country = 'Antarctica';
    if( $code == 'AG' ) $country = 'Antigua and Barbuda';
    if( $code == 'AR' ) $country = 'Argentina';
    if( $code == 'AM' ) $country = 'Armenia';
    if( $code == 'AW' ) $country = 'Aruba';
    if( $code == 'AU' ) $country = 'Australia';
    if( $code == 'AT' ) $country = 'Austria';
    if( $code == 'AZ' ) $country = 'Azerbaijan';
    if( $code == 'BS' ) $country = 'Bahamas the';
    if( $code == 'BH' ) $country = 'Bahrain';
    if( $code == 'BD' ) $country = 'Bangladesh';
    if( $code == 'BB' ) $country = 'Barbados';
    if( $code == 'BY' ) $country = 'Belarus';
    if( $code == 'BE' ) $country = 'Belgium';
    if( $code == 'BZ' ) $country = 'Belize';
    if( $code == 'BJ' ) $country = 'Benin';
    if( $code == 'BM' ) $country = 'Bermuda';
    if( $code == 'BT' ) $country = 'Bhutan';
    if( $code == 'BO' ) $country = 'Bolivia';
    if( $code == 'BA' ) $country = 'Bosnia and Herzegovina';
    if( $code == 'BW' ) $country = 'Botswana';
    if( $code == 'BV' ) $country = 'Bouvet Island (Bouvetoya)';
    if( $code == 'BR' ) $country = 'Brazil';
    if( $code == 'IO' ) $country = 'British Indian Ocean Territory (Chagos Archipelago)';
    if( $code == 'VG' ) $country = 'British Virgin Islands';
    if( $code == 'BN' ) $country = 'Brunei Darussalam';
    if( $code == 'BG' ) $country = 'Bulgaria';
    if( $code == 'BF' ) $country = 'Burkina Faso';
    if( $code == 'BI' ) $country = 'Burundi';
    if( $code == 'KH' ) $country = 'Cambodia';
    if( $code == 'CM' ) $country = 'Cameroon';
    if( $code == 'CA' ) $country = 'Canada';
    if( $code == 'CV' ) $country = 'Cape Verde';
    if( $code == 'KY' ) $country = 'Cayman Islands';
    if( $code == 'CF' ) $country = 'Central African Republic';
    if( $code == 'TD' ) $country = 'Chad';
    if( $code == 'CL' ) $country = 'Chile';
    if( $code == 'CN' ) $country = 'China';
    if( $code == 'CX' ) $country = 'Christmas Island';
    if( $code == 'CC' ) $country = 'Cocos (Keeling) Islands';
    if( $code == 'CO' ) $country = 'Colombia';
    if( $code == 'KM' ) $country = 'Comoros the';
    if( $code == 'CD' ) $country = 'Congo';
    if( $code == 'CG' ) $country = 'Congo the';
    if( $code == 'CK' ) $country = 'Cook Islands';
    if( $code == 'CR' ) $country = 'Costa Rica';
    if( $code == 'CI' ) $country = 'Cote d\'Ivoire';
    if( $code == 'HR' ) $country = 'Croatia';
    if( $code == 'CU' ) $country = 'Cuba';
    if( $code == 'CY' ) $country = 'Cyprus';
    if( $code == 'CZ' ) $country = 'Czech Republic';
    if( $code == 'DK' ) $country = 'Denmark';
    if( $code == 'DJ' ) $country = 'Djibouti';
    if( $code == 'DM' ) $country = 'Dominica';
    if( $code == 'DO' ) $country = 'Dominican Republic';
    if( $code == 'EC' ) $country = 'Ecuador';
    if( $code == 'EG' ) $country = 'Egypt';
    if( $code == 'SV' ) $country = 'El Salvador';
    if( $code == 'GQ' ) $country = 'Equatorial Guinea';
    if( $code == 'ER' ) $country = 'Eritrea';
    if( $code == 'EE' ) $country = 'Estonia';
    if( $code == 'ET' ) $country = 'Ethiopia';
    if( $code == 'FO' ) $country = 'Faroe Islands';
    if( $code == 'FK' ) $country = 'Falkland Islands (Malvinas)';
    if( $code == 'FJ' ) $country = 'Fiji the Fiji Islands';
    if( $code == 'FI' ) $country = 'Finland';
    if( $code == 'FR' ) $country = 'France, French Republic';
    if( $code == 'GF' ) $country = 'French Guiana';
    if( $code == 'PF' ) $country = 'French Polynesia';
    if( $code == 'TF' ) $country = 'French Southern Territories';
    if( $code == 'GA' ) $country = 'Gabon';
    if( $code == 'GM' ) $country = 'Gambia the';
    if( $code == 'GE' ) $country = 'Georgia';
    if( $code == 'DE' ) $country = 'Germany';
    if( $code == 'GH' ) $country = 'Ghana';
    if( $code == 'GI' ) $country = 'Gibraltar';
    if( $code == 'GR' ) $country = 'Greece';
    if( $code == 'GL' ) $country = 'Greenland';
    if( $code == 'GD' ) $country = 'Grenada';
    if( $code == 'GP' ) $country = 'Guadeloupe';
    if( $code == 'GU' ) $country = 'Guam';
    if( $code == 'GT' ) $country = 'Guatemala';
    if( $code == 'GG' ) $country = 'Guernsey';
    if( $code == 'GN' ) $country = 'Guinea';
    if( $code == 'GW' ) $country = 'Guinea-Bissau';
    if( $code == 'GY' ) $country = 'Guyana';
    if( $code == 'HT' ) $country = 'Haiti';
    if( $code == 'HM' ) $country = 'Heard Island and McDonald Islands';
    if( $code == 'VA' ) $country = 'Holy See (Vatican City State)';
    if( $code == 'HN' ) $country = 'Honduras';
    if( $code == 'HK' ) $country = 'Hong Kong';
    if( $code == 'HU' ) $country = 'Hungary';
    if( $code == 'IS' ) $country = 'Iceland';
    if( $code == 'IN' ) $country = 'India';
    if( $code == 'ID' ) $country = 'Indonesia';
    if( $code == 'IR' ) $country = 'Iran';
    if( $code == 'IQ' ) $country = 'Iraq';
    if( $code == 'IE' ) $country = 'Ireland';
    if( $code == 'IM' ) $country = 'Isle of Man';
    if( $code == 'IL' ) $country = 'Israel';
    if( $code == 'IT' ) $country = 'Italy';
    if( $code == 'JM' ) $country = 'Jamaica';
    if( $code == 'JP' ) $country = 'Japan';
    if( $code == 'JE' ) $country = 'Jersey';
    if( $code == 'JO' ) $country = 'Jordan';
    if( $code == 'KZ' ) $country = 'Kazakhstan';
    if( $code == 'KE' ) $country = 'Kenya';
    if( $code == 'KI' ) $country = 'Kiribati';
    if( $code == 'KP' ) $country = 'Korea';
    if( $code == 'KR' ) $country = 'Korea';
    if( $code == 'KW' ) $country = 'Kuwait';
    if( $code == 'KG' ) $country = 'Kyrgyz Republic';
    if( $code == 'LA' ) $country = 'Lao';
    if( $code == 'LV' ) $country = 'Latvia';
    if( $code == 'LB' ) $country = 'Lebanon';
    if( $code == 'LS' ) $country = 'Lesotho';
    if( $code == 'LR' ) $country = 'Liberia';
    if( $code == 'LY' ) $country = 'Libyan Arab Jamahiriya';
    if( $code == 'LI' ) $country = 'Liechtenstein';
    if( $code == 'LT' ) $country = 'Lithuania';
    if( $code == 'LU' ) $country = 'Luxembourg';
    if( $code == 'MO' ) $country = 'Macao';
    if( $code == 'MK' ) $country = 'Macedonia';
    if( $code == 'MG' ) $country = 'Madagascar';
    if( $code == 'MW' ) $country = 'Malawi';
    if( $code == 'MY' ) $country = 'Malaysia';
    if( $code == 'MV' ) $country = 'Maldives';
    if( $code == 'ML' ) $country = 'Mali';
    if( $code == 'MT' ) $country = 'Malta';
    if( $code == 'MH' ) $country = 'Marshall Islands';
    if( $code == 'MQ' ) $country = 'Martinique';
    if( $code == 'MR' ) $country = 'Mauritania';
    if( $code == 'MU' ) $country = 'Mauritius';
    if( $code == 'YT' ) $country = 'Mayotte';
    if( $code == 'MX' ) $country = 'Mexico';
    if( $code == 'FM' ) $country = 'Micronesia';
    if( $code == 'MD' ) $country = 'Moldova';
    if( $code == 'MC' ) $country = 'Monaco';
    if( $code == 'MN' ) $country = 'Mongolia';
    if( $code == 'ME' ) $country = 'Montenegro';
    if( $code == 'MS' ) $country = 'Montserrat';
    if( $code == 'MA' ) $country = 'Morocco';
    if( $code == 'MZ' ) $country = 'Mozambique';
    if( $code == 'MM' ) $country = 'Myanmar';
    if( $code == 'NA' ) $country = 'Namibia';
    if( $code == 'NR' ) $country = 'Nauru';
    if( $code == 'NP' ) $country = 'Nepal';
    if( $code == 'AN' ) $country = 'Netherlands Antilles';
    if( $code == 'NL' ) $country = 'Netherlands the';
    if( $code == 'NC' ) $country = 'New Caledonia';
    if( $code == 'NZ' ) $country = 'New Zealand';
    if( $code == 'NI' ) $country = 'Nicaragua';
    if( $code == 'NE' ) $country = 'Niger';
    if( $code == 'NG' ) $country = 'Nigeria';
    if( $code == 'NU' ) $country = 'Niue';
    if( $code == 'NF' ) $country = 'Norfolk Island';
    if( $code == 'MP' ) $country = 'Northern Mariana Islands';
    if( $code == 'NO' ) $country = 'Norway';
    if( $code == 'OM' ) $country = 'Oman';
    if( $code == 'PK' ) $country = 'Pakistan';
    if( $code == 'PW' ) $country = 'Palau';
    if( $code == 'PS' ) $country = 'Palestinian Territory';
    if( $code == 'PA' ) $country = 'Panama';
    if( $code == 'PG' ) $country = 'Papua New Guinea';
    if( $code == 'PY' ) $country = 'Paraguay';
    if( $code == 'PE' ) $country = 'Peru';
    if( $code == 'PH' ) $country = 'Philippines';
    if( $code == 'PN' ) $country = 'Pitcairn Islands';
    if( $code == 'PL' ) $country = 'Poland';
    if( $code == 'PT' ) $country = 'Portugal, Portuguese Republic';
    if( $code == 'PR' ) $country = 'Puerto Rico';
    if( $code == 'QA' ) $country = 'Qatar';
    if( $code == 'RE' ) $country = 'Reunion';
    if( $code == 'RO' ) $country = 'Romania';
    if( $code == 'RU' ) $country = 'Russian Federation';
    if( $code == 'RW' ) $country = 'Rwanda';
    if( $code == 'BL' ) $country = 'Saint Barthelemy';
    if( $code == 'SH' ) $country = 'Saint Helena';
    if( $code == 'KN' ) $country = 'Saint Kitts and Nevis';
    if( $code == 'LC' ) $country = 'Saint Lucia';
    if( $code == 'MF' ) $country = 'Saint Martin';
    if( $code == 'PM' ) $country = 'Saint Pierre and Miquelon';
    if( $code == 'VC' ) $country = 'Saint Vincent and the Grenadines';
    if( $code == 'WS' ) $country = 'Samoa';
    if( $code == 'SM' ) $country = 'San Marino';
    if( $code == 'ST' ) $country = 'Sao Tome and Principe';
    if( $code == 'SA' ) $country = 'Saudi Arabia';
    if( $code == 'SN' ) $country = 'Senegal';
    if( $code == 'RS' ) $country = 'Serbia';
    if( $code == 'SC' ) $country = 'Seychelles';
    if( $code == 'SL' ) $country = 'Sierra Leone';
    if( $code == 'SG' ) $country = 'Singapore';
    if( $code == 'SK' ) $country = 'Slovakia (Slovak Republic)';
    if( $code == 'SI' ) $country = 'Slovenia';
    if( $code == 'SB' ) $country = 'Solomon Islands';
    if( $code == 'SO' ) $country = 'Somalia, Somali Republic';
    if( $code == 'ZA' ) $country = 'South Africa';
    if( $code == 'GS' ) $country = 'South Georgia and the South Sandwich Islands';
    if( $code == 'ES' ) $country = 'Spain';
    if( $code == 'LK' ) $country = 'Sri Lanka';
    if( $code == 'SD' ) $country = 'Sudan';
    if( $code == 'SR' ) $country = 'Suriname';
    if( $code == 'SJ' ) $country = 'Svalbard & Jan Mayen Islands';
    if( $code == 'SZ' ) $country = 'Swaziland';
    if( $code == 'SE' ) $country = 'Sweden';
    if( $code == 'CH' ) $country = 'Switzerland, Swiss Confederation';
    if( $code == 'SY' ) $country = 'Syrian Arab Republic';
    if( $code == 'TW' ) $country = 'Taiwan';
    if( $code == 'TJ' ) $country = 'Tajikistan';
    if( $code == 'TZ' ) $country = 'Tanzania';
    if( $code == 'TH' ) $country = 'Thailand';
    if( $code == 'TL' ) $country = 'Timor-Leste';
    if( $code == 'TG' ) $country = 'Togo';
    if( $code == 'TK' ) $country = 'Tokelau';
    if( $code == 'TO' ) $country = 'Tonga';
    if( $code == 'TT' ) $country = 'Trinidad and Tobago';
    if( $code == 'TN' ) $country = 'Tunisia';
    if( $code == 'TR' ) $country = 'Turkey';
    if( $code == 'TM' ) $country = 'Turkmenistan';
    if( $code == 'TC' ) $country = 'Turks and Caicos Islands';
    if( $code == 'TV' ) $country = 'Tuvalu';
    if( $code == 'UG' ) $country = 'Uganda';
    if( $code == 'UA' ) $country = 'Ukraine';
    if( $code == 'AE' ) $country = 'United Arab Emirates';
    if( $code == 'GB' ) $country = 'United Kingdom';
    if( $code == 'US' ) $country = 'United States of America';
    if( $code == 'UM' ) $country = 'United States Minor Outlying Islands';
    if( $code == 'VI' ) $country = 'United States Virgin Islands';
    if( $code == 'UY' ) $country = 'Uruguay, Eastern Republic of';
    if( $code == 'UZ' ) $country = 'Uzbekistan';
    if( $code == 'VU' ) $country = 'Vanuatu';
    if( $code == 'VE' ) $country = 'Venezuela';
    if( $code == 'VN' ) $country = 'Vietnam';
    if( $code == 'WF' ) $country = 'Wallis and Futuna';
    if( $code == 'EH' ) $country = 'Western Sahara';
    if( $code == 'YE' ) $country = 'Yemen';
    if( $code == 'ZM' ) $country = 'Zambia';
    if( $code == 'ZW' ) $country = 'Zimbabwe';
    if( $country == '') $country = $code;
    return $country;
} 


function find_nearest() {
  global $nearname, $nearlatitude, $nearlongitude;
  $best1=-1;
  $best2=-1;
  $best3=-1;
  $latlongdistsquared=-1.0;
  $latlongdistsquaredtwo=-1.0;
  $latlongdistsquaredthree=-1.0;
  $gcddistsquared=-1.0;
  $gcddistsquaredtwo=-1.0;
  $gcddistsquaredthree=-1.0;
  if (isset($_GET['latitude']) && isset($_GET['place']) && isset($_GET['longitude'])) {
   if ($_GET['latitude'] == '' && $_GET['longitude'] == '') {
    if (urldecode($_GET['place']) != '') {
      $huh=file_get_contents("https://www.google.com.au/search?q=" . urlencode(urldecode($_GET['place'])) . "+latitude");
      // IigAMAI"><div class="_XWk">33.8688° S, 151.2093° E</div>
      // /www.distancesto.com/coordinates/au/sydney-nsw-latitude-longitude/history/3571.html&amp;sa=U&amp;ved=0ahUKEwjkx_er1P_QAhXJnZQKHRZrD84QFggtMAQ&amp;usg=AFQjCNEcVCnwSmFGVx0FkHV9rFtk1p99Ug"><b>Sydney</b> NSW <b>Latitude</b> and Longitude - Distance Calculator</a></h3><div class="s"><div class="kv" style="margin-bottom:2px"><cite>https://www.distancesto.com/.../au/<b>sydney</b>-nsw-<b>latitude</b>.../3571.html</cite><div class="_nBb"><div style="display:inline" onclick="google.sham(this);" aria-expanded="false" aria-haspopup="true" tabindex="0" data-ved="0ahUKEwjkx_er1P_QAhXJnZQKHRZrD84Q7B0ILjAE"><span class="_O0"></span></div><div style="display:none" class="am-dropdown-menu" role="menu" tabindex="-1"><ul><li class="_Ykb"><a class="_Zkb" href="/url?q=http://webcache.googleusercontent.com/search%3Fq%3Dcache:rfrLxd2wUBEJ:https://www.distancesto.com/coordinates/au/sydney-nsw-latitude-longitude/history/3571.html%252BSydney%2Blatitude%26hl%3Den%26ct%3Dclnk&amp;sa=U&amp;ved=0ahUKEwjkx_er1P_QAhXJnZQKHRZrD84QIAgwMAQ&amp;usg=AFQjCNGD1jX5jtc_7pfR53zdPFMdqAJZHQ">Cached</a></li></ul></div></div></div><span class="st"><b>Sydney</b> NSW <b>Latitude</b> and Longitude. The <b>latitude</b> for <b>Sydney</b> NSW, Australia is: -<br>33.8674869 and the longitude is: 151.20699020000006.</span>
      $hbits=explode(" S, ", $huh);
      if (sizeof($hbits) >= 2) {
       $latsofar=substr(trim(explode(">", $hbits[0])[-1 + sizeof(explode(">", $hbits[0]))]),0,(strlen(trim(explode(">", $hbits[0])[-1 + sizeof(explode(">", $hbits[0]))])) - 1));
       $latsofar=-$latsofar;
       $longsofar=substr(trim(explode(" ", $hbits[1])[0]),0,(strlen(trim(explode(" ", $hbits[1])[0])) - 1));
       if (substr(explode(" ", $hbits[1])[1], 0, 1) == "W") $longsofar=-$longsofar;
       echo "<!doctype html><html><head><scr" . "ipt type='text/javascript'> function lookoutfortop() { if (top.document.getElementById('nearest')) {  top.document.getElementById('latitude').value=\"" . $latsofar . "\";  top.document.getElementById('longitude').value=\"" . $longsofar . "\";  } else { document.body.innerHTML=\"" . $latsofar . "," . $longsofar . "\";   }  } </scr" . "ipt></head><body onload='lookoutfortop();'></body></html>";  
       exit;
      } else {
       $hbits=explode(" N, ", $huh);
       if (sizeof($hbits) >= 2) {
        $latsofar=substr(trim(explode(">", $hbits[0])[-1 + sizeof(explode(">", $hbits[0]))]),0,(strlen(trim(explode(">", $hbits[0])[-1 + sizeof(explode(">", $hbits[0]))])) - 1));
        $longsofar=substr(trim(explode(" ", $hbits[1])[0]),0,(strlen(trim(explode(" ", $hbits[1])[0])) - 1));
        if (substr(explode(" ", $hbits[1])[1], 0, 1) == "W") $longsofar=-$longsofar;
        echo "<!doctype html><html><head><scr" . "ipt type='text/javascript'> function lookoutfortop() { if (top.document.getElementById('nearest')) {  top.document.getElementById('latitude').value=\"" . $latsofar . "\";  top.document.getElementById('longitude').value=\"" . $longsofar . "\";  } else { document.body.innerHTML=\"" . $latsofar . "," . $longsofar . "\";   }  } </scr" . "ipt></head><body onload='lookoutfortop();'></body></html>";  
        exit;
       }
      }
    }
   } else {
    if (sizeof($nearname) > 1) {
      for ($ij=0; $ij<(-1 + sizeof($nearname)); $ij++) {
        if ($latlongdistsquared < 0.0) {
          $latlongdistsquared=($nearlatitude[$ij] - floatval(urldecode($_GET['latitude']))) * ($nearlatitude[$ij] - floatval(urldecode($_GET['latitude']))) + ($nearlongitude[$ij] - floatval(urldecode($_GET['longitude']))) * ($nearlongitude[$ij] - floatval(urldecode($_GET['longitude'])));
          $best1=$ij;
        } else {
          $thisll=($nearlatitude[$ij] - floatval(urldecode($_GET['latitude']))) * ($nearlatitude[$ij] - floatval(urldecode($_GET['latitude']))) + ($nearlongitude[$ij] - floatval(urldecode($_GET['longitude']))) * ($nearlongitude[$ij] - floatval(urldecode($_GET['longitude'])));
          if ($thisll < $latlongdistsquared) {
            if ($best2 < 0) {
              $latlongdistsquaredtwo=$latlongdistsquared;
              $best2=$best1;
              $best1=$ij;
              $latlongdistsquared=$thisll;
            } else {
              $latlongdistsquaredthree=$latlongdistsquaredtwo;
              $latlongdistsquaredtwo=$latlongdistsquared;
              $best3=$best2;
              $best2=$best1;
              $best1=$ij;
              $latlongdistsquared=$thisll;
            } 
          } else if ($thisll < $latlongdistsquaredtwo) {
              $latlongdistsquaredthree=$latlongdistsquaredtwo;
              $best3=$best2;
              $best2=$ij;
              $latlongdistsquaredtwo=$thisll;
          } else if ($thisll < $latlongdistsquaredthree) {
              $best3=$ij;
              $latlongdistsquaredthree=$thisll;
          }
        }
      }
      $coffs=[0,0,0];
      if ($gcddistsquared >= 0.0) {
        $ret="<select id='snearest' style='position:absolute;top:70px;left:350px;' 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></select>";
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best1]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
        $ret=str_replace("</select>", "<option title='Nearest' value='" . $nearname[$best1] . "'>" . $nearname[$best1] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquared / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . "</option></select>");
        if ($gcddistsquaredtwo >= 0.0) $ret=str_replace("</select>", "<option title='Next Nearest' value='" . $nearname[$best2] . "'>" . $nearname[$best2] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquaredtwo / 1000.0 . "km from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
        if ($gcddistsquaredthree >= 0.0) $ret=str_replace("</select>", "<option title='Third Nearest' value='" . $nearname[$best3] . "'>" . $nearname[$best3] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquaredthree / 1000.0 . "km from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
        echo "<!doctype html><html><head><scr" . "ipt type='text/javascript'> function lookoutfortop() { if (top.document.getElementById('nearest')) {  top.document.getElementById('nearest').innerHTML=\"" . $ret . "\"; top.window.scrollTo(0,0);  } else { document.body.innerHTML=\"" . $ret . "\";  }  } </scr" . "ipt></head><body onload='lookoutfortop();'></body></html>";  $ret;
        exit;
      } else if ($latlongdistsquared >= 0.0) {
        //echo $latlongdistsquared . " " . $latlongdistsquaredtwo;
        //exit;
        $ret="<select size=2 id='snearest' style='position:absolute;top:70px;left:350px;' 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></select>";
        $gcddistsquared=great_circle_distance(floatval(urldecode($_GET['latitude'])), floatval(urldecode($_GET['longitude'])), $nearlatitude[$best1], $nearlongitude[$best1]);
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best1]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
        if ($latlongdistsquaredtwo >= 0.0) {
          $ret=str_replace(" size=2 ", " size=3 ", $ret);
          $gcddistsquaredtwo=great_circle_distance(floatval(urldecode($_GET['latitude'])), floatval(urldecode($_GET['longitude'])), $nearlatitude[$best2], $nearlongitude[$best2]);
          if ($latlongdistsquaredthree >= 0.0) {
            $ret=str_replace(" size=3 ", " size=4 ", $ret);
            $gcddistsquaredthree=great_circle_distance(floatval(urldecode($_GET['latitude'])), floatval(urldecode($_GET['longitude'])), $nearlatitude[$best3], $nearlongitude[$best3]);
            if ($gcddistsquared <= $gcddistsquaredtwo && $gcddistsquared <= $gcddistsquaredthree) {
              $ret=str_replace("</select>", "<option title='Nearest' value='" . $nearname[$best1] . "'>" . $nearname[$best1] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquared / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
  
              if ($gcddistsquaredtwo <= $gcddistsquaredthree) {
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best2]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
               $ret=str_replace("</select>", "<option title='Next Nearest' value='" . $nearname[$best2] . "'>" . $nearname[$best2] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquaredtwo / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best3]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
               $ret=str_replace("</select>", "<option title='Third Nearest' value='" . $nearname[$best3] . "'>" . $nearname[$best3] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquaredthree / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
              } else {
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best3]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
               $ret=str_replace("</select>", "<option title='Next Nearest' value='" . $nearname[$best3] . "'>" . $nearname[$best3] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquaredthree / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best2]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
               $ret=str_replace("</select>", "<option title='Third Nearest' value='" . $nearname[$best2] . "'>" . $nearname[$best2] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquaredtwo / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
              }

           } else if ($gcddistsquaredtwo <= $gcddistsquared && $gcddistsquaredtwo <= $gcddistsquaredthree) {
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best2]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
              $ret=str_replace("</select>", "<option title='Nearest' value='" . $nearname[$best2] . "'>" . $nearname[$best2] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquaredtwo / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
 
              if ($gcddistsquared <= $gcddistsquaredthree) {
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best1]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
               $ret=str_replace("</select>", "<option title='Next Nearest' value='" . $nearname[$best1] . "'>" . $nearname[$best1] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquared / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best3]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
               $ret=str_replace("</select>", "<option title='Third Nearest' value='" . $nearname[$best3] . "'>" . $nearname[$best3] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquaredthree / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
              } else {
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best3]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
               $ret=str_replace("</select>", "<option title='Next Nearest' value='" . $nearname[$best3] . "'>" . $nearname[$best3] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquaredthree / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best1]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
               $ret=str_replace("</select>", "<option title='Third Nearest' value='" . $nearname[$best1] . "'>" . $nearname[$best1] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquared / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
              }

 
 
            } else {
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best3]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
              $ret=str_replace("</select>", "<option title='Nearest' value='" . $nearname[$best3] . "'>" . $nearname[$best3] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquaredthree / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
              if ($gcddistsquared <= $gcddistsquaredtwo) {
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best1]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
               $ret=str_replace("</select>", "<option title='Next Nearest' value='" . $nearname[$best1] . "'>" . $nearname[$best1] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquared / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best2]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
               $ret=str_replace("</select>", "<option title='Third Nearest' value='" . $nearname[$best2] . "'>" . $nearname[$best2] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquaredtwo / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
              } else {
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best2]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
               $ret=str_replace("</select>", "<option title='Next Nearest' value='" . $nearname[$best2] . "'>" . $nearname[$best2] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquaredtwo / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best1]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
               $ret=str_replace("</select>", "<option title='Third Nearest' value='" . $nearname[$best1] . "'>" . $nearname[$best1] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquared / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
              }
            }
          } else if ($gcddistsquared <= $gcddistsquaredtwo) {
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best1]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
            $ret=str_replace("</select>", "<option title='Nearest' value='" . $nearname[$best1] . "'>" . $nearname[$best1] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquared / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best2]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
            $ret=str_replace("</select>", "<option title='Next Nearest' value='" . $nearname[$best2] . "'>" . $nearname[$best2] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquaredtwo / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
          } else {
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best2]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
            $ret=str_replace("</select>", "<option title='Nearest' value='" . $nearname[$best2] . "'>" . $nearname[$best2] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquaredtwo / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best1]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
            $ret=str_replace("</select>", "<option title='Next Nearest' value='" . $nearname[$best1] . "'>" . $nearname[$best1] . " in " . country_code_to_country($ctrycode) . " is " . $gcddistsquared / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
          } 
        } else {
        $otz = new DateTimeZone("Europe/London");
        $tz = new DateTimeZone($nearname[$best1]);
        $origin_dt = new DateTime("now", $otz);
        $remote_dt = new DateTime("now", $tz);
        $cloc = $tz->getLocation(); $ctrycode = $cloc['country_code'];  $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
        if ($offset < 0) {
          $coffset=$offset;
        } else {
          $coffset="+" . $offset;
        }
          $ret=str_replace("</select>", "<option title='Nearest' value='" . $nearname[$best1] . "'>" . $nearname[$best1] . " is " . $gcddistsquared / 1000.0 . "km (" . $coffset . ") from " . urldecode($_GET['place']) . " (" . urldecode($_GET['latitude']) . "," . urldecode($_GET['longitude']) .  ")</option></select>", $ret);
        }
        echo "<!doctype html><html><head><scr" . "ipt type='text/javascript'> function lookoutfortop() { if (top.document.getElementById('nearest')) {  top.document.getElementById('nearest').innerHTML=\"" . $ret . "\";  top.window.scrollTo(0,0);  } else { document.body.innerHTML=\"" . $ret . "\";  }  } </scr" . "ipt></head><body onload='lookoutfortop();'></body></html>";  $ret;
        exit;
      }
    }
   }
  }
}  

function great_circle_distance($talis, $gnolis, $latis, $longis) {
  $ourdist=0.0;
  $rgnol=(($gnolis) * pi() / 180.0);
  $rtal=(($talis) * pi() / 180.0);
  $rlong=(($longis) * pi() / 180.0);
  $rlat=(($latis) * pi() / 180.0);


  $deltalong = abs(((($gnolis)-($longis)) * pi() / 180.0));


  $acof = (sin($rtal) * sin($rlat)) + (cos($rtal) * cos($rlat) * cos($deltalong)); // via http://en.wikipedia.org/wiki/Great-circle_distance ... thanks

  $ourdist = (round((acos($acof) * 6371000.0) + 0.00001) * 100) / 100;
  return $ourdist;
}

function localtimefromtogmt($indate, $fromtz, $totz) { // thanks to http://stackoverflow.com/questions/13698779/timezone-with-dst-handling-by-php
  global $bestemojicodepoint, $thisemojicodepoint, $gmtdatetimeis, $gmthhris, $gmthris, $gmtminis, $bestemojiclass, $thisemojiclass;
  $thisemojiclass="";
  if ($indate != "now" && (strpos($indate, "+") !== false || strpos($indate, "-") !== false || strlen($indate) <= 5)) {
  date_default_timezone_set('Australi' . 'a/Perth'); // YOUR timezone, of the server
  $date = new DateTime("now", new DateTimeZone('Australi' . 'a/Perth')); // USER's timezone
  $hoff=intval(str_replace('+','',$indate)) * 60;
  if ($hoff >= 0) {
      $minis=($hoff % 60);
      $hris=(($hoff - $minis) / 60);
      if (($gmtminis + $minis) >= 60) {
      if (((1 + $hris + $gmthhris) % 24) >= 12) {
        $thisemojiclass=" nighttime";
      }
        $hris=($hris % 12) + 1;
        $minis=(($gmtminis + $minis) % 60);
      } else {
      if ((($hris + $gmthhris) % 24) >= 12) {
        $thisemojiclass=" nighttime";
      }
        $minis=($gmtminis + $minis);
      } 
      $hris=($gmthhris + $hris);
      if ($hris > 12) {
        $hris=($hris % 12);
      }
  } else {
      $minis=((0 - $hoff) % 60);
      $hris=(((0 - $hoff) - $minis) / 60);
      if (($gmtminis - $minis) < 0) {
      if (((-1 - $hris + 24 + $gmthhris) % 24) >= 12) {
        $thisemojiclass=" nighttime";
      }
        $hris=($hris % 12) - 1;
        if ($hris == 0) $hris=12;
        $minis=(($gmtminis - $minis) + 60);
      } else {
      if ((($gmthhris - $hris + 24) % 24) >= 12) { 
        $thisemojiclass=" nighttime";
      }
        $minis=($gmtminis - $minis);
      } 
      $hris=($gmthris - $hris);
      if ($hris < 1) $hris=($hris + 12);
  }
  
    if ($minis > 45 && $hris == 12) {
      $thisemojicodepoint=128336;
    } else if ($minis >= 45) {
      $thisemojicodepoint=128336 + $hris;
    } else if ($minis <= 15) {
      $thisemojicodepoint=128335 + $hris;
    } else {
      $thisemojicodepoint=128347 + $hris;
    }
  //echo $thisemojicodepoint;
  //exit;
  } else {
  date_default_timezone_set('Australi' . 'a/Perth'); // YOUR timezone, of the server
  if ($fromtz == 'UTC') {
   $date = new DateTime($indate, new DateTimeZone('UTC')); // USER's timezone
   $date->setTimezone(new DateTimeZone($totz));
  } else {
   //echo $fromtz;
   //exit;
   if ($fromtz == 'Australi' . 'a/Perth') {
   $date = new DateTime($indate);
   } else {
   echo '*' . $fromtz . '*';
   exit;
   $date = new DateTime($indate, new DateTimeZone($fromtz)); // USER's timezone
   }
   $date->setTimezone(new DateTimeZone('UTC'));
   if ($totz != 'UTC') {
     $date = localtimefromtogmt($date, 'UTC', $totz);
   } else {
// 1  o'clock is &#128336;
// 2  o'clock is &#128337;
// 12 o'clock is &#128347;
//  2:30 is &#128349;
// 11:30 is &#128358;
// 12:30 is &#128359;
    $gmtdatetimeis=$date->format('Y-m-d H:i:s') . " GMT at time of first display";
    $hrntis=intval($date->format('H'));
    $gmthhris=$hrntis;
    $bestemojiclass="";
    if ($hrntis >= 12) $bestemojiclass=" nighttime";
    $hris=intval($date->format('h'));
    $minis=intval($date->format('i'));
    $gmthris=$hris;
    $gmtminis=$minis;
    if ($minis > 45 && $hris == 12) {
      $bestemojicodepoint=128336;
    } else if ($minis >= 45) {
      $bestemojicodepoint=128336 + $hris;
    } else if ($minis <= 15) {
      $bestemojicodepoint=128335 + $hris;
    } else {
      $bestemojicodepoint=128347 + $hris;
    }
    //echo $bestemojicodepoint;
   }
  }
  }
  return $date; //->format('Y-m-d H:i:s');
}

function ourtimezonelist($ididea) { // thanks to http://php.net/manual/en/function.timezone-identifiers-list.php
  global $kcnt, $formstuff, $hprefix, $hsuffix, $sellong;
  $tzn="";
  $selstuff="";
  if (isset($_GET['tzname'])) {
    $tzn=urldecode($_GET['tzname']);
    if (strpos($tzn,"/") === false && strpos($tzn,"-") === false && strpos($tzn,"+") === false && $tzn != "") $tzn="+" . trim($tzn);
    //echo $tzn;
    //exit;
  }
  
  if ($ididea == "szt" && $tzn != "") {
  $places="Places";
  if (strpos($hprefix, "<table") !== false) {
  $prefix="<table" . explode("<table",$hprefix)[1] . "<table><tbody><tr><td>";
  //$prefix="<table><tbody><tr><td>";
  } else { 
  $prefix="<table><tbody><tr><td>";
  }
  $hprefix="";
  $suffix="";
  $ourmapstuff="";
  $yourmapstuff="";
  $formstuff="";
  $extrad="";
  $timezone_abbreviations = DateTimeZone::listAbbreviations();
  foreach ($timezone_abbreviations["est"] as $tzo) {
   $okay=false;
   //echo str_replace("+","",urldecode($_GET['tzname'])) . ' ' . ('' . ($tzo['offset'] / 3600)) . '   ' . $tzo['timezone_id'];
   //exit;
   //echo $tzn . ' ' . $tzo['timezone_id'];
   //exit;
   //echo (str_replace("%2B","+",$_GET['tzname']));
   //exit;
  //echo (3600 * str_replace("+","",$_GET['tzname'])) . " " . $tzo['offset'];
  //exit;
   if (strpos($tzo['timezone_id'], $tzn) !== false) {
    $tz = new DateTimeZone($tzo['timezone_id']);
    $okay=true;
    //if (strpos($tzo['timezone_id'], "Auckland") !== false) {
    // echo "A " . $tzn . ' ' . $tzo['timezone_id'];
    // exit;
    //}
   } else if (str_replace("+","",urldecode($_GET['tzname'])) == ('' . ($tzo['offset'] / 3600))) {
    $tz = new DateTimeZone($tzo['timezone_id']);
    $okay=true;
    //if (strpos($tzo['timezone_id'], "Auckland") !== false) {
    // echo "B " . $tzn . ' ' . $tzo['timezone_id'];
    // exit;
    //}
   } //else {
    //if (strpos($tzo['timezone_id'], "Auckland") !== false) {
    // echo "C " . $tzo['offset'] . " " . $tzn . ' ' . $tzo['timezone_id'];
    // exit;
    //}
   //}
   
   if ($okay) {
    $zoneName = $tzo['timezone_id'];
    $loc = $tz->getLocation();
    if ($loc[latitude] != 0 || $loc[longitude] != 0) {
    if ($tzo['offset'] < 0) {
     $coffset=($tzo['offset'] / 3600);
    } else {
     $coffset="+" . ($tzo['offset'] / 3600);
    }
    $zbits=explode("/",$zoneName);
    if ($ourmapstuff == "") {
      $ourmapstuff="</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<iframe style=width:400px;height:400px; id='mapif' name='mapif' src=http://www.rjmprogramming.com.au/PHP/Map/map.php?title=" . urlencode($places) . "&onclick=y&label=[%27Lat%27,&value=%27Lon%27,%27Name%27]&data=,[" . $loc[latitude] . "," . $loc[longitude] . ",~" . $zoneName . "~]></iframe><form target=mapif action=http://www.rjmprogramming.com.au/PHP/Map/map.php method=POST><input type=hidden value=\"" . $places . "\" id=title name=title></input><input type=hidden value=\"['Lat',\" id=label name=label></input><input type=hidden value=\"'Lon','Name']\" id=value name=value></input><input type=hidden value='' id=data name=data></input><input type=hidden value=y id=onclick name=onclick></input><input id=smapif type=submit value=Show style=display:none;></input></form> <scr" . "ipt type='text/javascript'> document.getElementById('smapif').click(); </scr" . "ipt>";
      $yourmapstuff="</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<iframe style=width:400px;height:400px; id='mapif' name='mapif' src=about:blank></iframe>";
      //$formstuff="<form target=\"mapif\" action=\"http://www.rjmprogramming.com.au/PHP/Map/map.php\" method=\"POST\"><input type=\"hidden\" value=\"Places\" name=\"title\"></input><input type=\"hidden\" value=\"[%27Lat%27,\" name=\"label\"></input><input type=\"hidden\" value=\"%27Lon%27,%27Name%27]\" name=\"value\"></input><input type=\"hidden\" value=\"\" name=\"data\"></input><input type=\"hidden\" value=\"y\" name=\"onclick\"></input><input id=\"smapif\" type=\"submit\" value=\"Show\" style=\"display:none;\"></input></form> <scr" . "ipt type='text/javascript'> function doc() { document.getElementById('smapif').click(); } setTimeout(doc, 2000); </scr" . "ipt>";
      $formstuff="<form target=\"mapif\" action=\"http://www.rjmprogramming.com.au/PHP/Map/map.php\" method=\"POST\"><input type=\"hidden\" value=\"" . $places . "\" name=\"title\"></input><input type=\"hidden\" value=\"['Lat',\" name=\"label\"></input><input type=\"hidden\" value=\"'Lon','Name']\" name=\"value\"></input><input type=\"hidden\" value=\"\" name=\"data\"></input><input type=\"hidden\" value=\"y\" name=\"onclick\"></input><input id=\"smapif\" type=\"submit\" value=\"Show\" style=\"display:none;\"></input></form> <scr" . "ipt type='text/javascript'> function doc() { document.getElementById('smapif').click(); } setTimeout(doc, 2000); </scr" . "ipt>";
      $formstuff=str_replace('" name="data"', ',[' . $loc[latitude] . ',' . $loc[longitude] . ',~' . str_replace("_"," ",explode(",",$zbits[-1 + sizeof($zbits)])[0]) . '~]" name="data"', $formstuff);
    } else {
      $ourmapstuff=str_replace("></iframe", ",[" . $loc[latitude] . "," . $loc[longitude] . ",~" . str_replace("_"," ",explode(",",$zbits[-1 + sizeof($zbits)])[0]) . "~]></iframe", $ourmapstuff); 
      $formstuff=str_replace('" name="data"', ',[' . $loc[latitude] . ',' . $loc[longitude] . ',~' . str_replace("_"," ",explode(",",$zbits[-1 + sizeof($zbits)])[0]) . '~]" name="data"', $formstuff);
    }
    
    if (isset($_GET['tzname'])) {
      if (strpos((" " . $zoneName . " = " . $loc['comments'] . " ... " . $coffset), " " . $tzn) !== false || strpos((" " . $zoneName . " = " . $loc['comments'] . " ... " . $coffset), "+" . $tzn) !== false) {
        $prefix.="<b><i>";
        $suffix.="</i></b>";
      }
    } 
    $prepretitlebit="";
    if ($prepretitlebit == "" && isset($_GET['iso'])) {
      $prepretitlebit=$_GET['iso'];
    }
    $zbits=explode("/",$zoneName);
    $extrad="";
    if ($tzo['dst'] === true) {
      $extrad="<div style=display:inline; id=qaof_" . $tzo['offset'] / 3600 . " class=emoji onclick=emojistuff(this);>&#9200;</div>";
    }
    if ($prepretitlebit == "") $prepretitlebit=$loc['country_code'];
    $pretitlebit=explode('"' . $prepretitlebit . '">', $sellong)[1];
    $titlebit=explode("<", $pretitlebit)[0] . "/" . explode(",",$zbits[-1 + sizeof($zbits)])[0] . ',' . $loc[latitude] . ',' . $loc[longitude] . ',' . ($tzo['offset'] / 3600);
    localtimefromtogmt(('' . $tzo['offset'] / 3600),  'Australi' . 'a/Perth', 'UTC');
    if (strpos($titlebit,"Optionally Select Country of Interest below ...") !== false) {
    $selstuff.=$prefix . " <a class=abut target=_blank id=aof_" . explode(",",$zbits[-1 + sizeof($zbits)])[0] . " title='" . $zoneName . ',' . $loc[latitude] . ',' . $loc[longitude] . ',' . $tzo['offset'] / 3600 . "' style=text-decoration:underline;cursor:pointer; onclick='addtolist(this.title); window.open(\"http://www.timezoneconverter.com/cgi-bin/zoneinfo?tz=" . $zoneName . "\",\"_blank\",\"top=100,left=\" + iamleft +  \",width=600,height=900\");'>" . $zoneName . "</a><div style=display:inline; id=daof_" . explode(",",$zbits[-1 + sizeof($zbits)])[0] . " class=emoji onclick=emojistuff(this);>&#128249;</div>" . $extrad . " = " . $loc['comments'] . " ... " . $coffset . "<div style=display:inline; id=oaof_" . str_replace('+','',('' . $coffset)) . " class='emoji" . $thisemojiclass . "'  onclick=emojistuff(this);>" . str_replace("&#;","","&#" . $thisemojicodepoint . ";") . "</div>" . $suffix . "<br>";
    } else {
    $selstuff.=$prefix . " <a class=abut target=_blank id=aof_" . explode(",",$zbits[-1 + sizeof($zbits)])[0] . " title='" . $titlebit . "' style=text-decoration:underline;cursor:pointer; onclick='addtolist(this.title); window.open(\"http://www.timezoneconverter.com/cgi-bin/zoneinfo?tz=" . $zoneName . "\",\"_blank\",\"top=100,left=\" + iamleft +  \",width=600,height=900\");'>" . $zoneName . "</a><div style=display:inline; id=daof_" . explode(",",$zbits[-1 + sizeof($zbits)])[0] . " class=emoji onclick=emojistuff(this);>&#128249;</div>" . $extrad . " = " . $loc['comments'] . " ... " . $coffset . "<div style=display:inline; id=oaof_" . str_replace('+','',('' . $coffset)) . " class='emoji" . $thisemojiclass . "'  onclick=emojistuff(this);>" . str_replace("&#;","","&#" . $thisemojicodepoint . ";") . "</div>" . $suffix . "<br>";
    }
    $prefix="";
    $suffix="";
    }
   }
   
   //if (strpos($tzo['timezone_id'], 'Auckland') !== false) {
   //  echo str_replace("+","",urldecode($_GET['tzname'])) . ' ' . ('' . ($tzo['offset'] / 3600)) . '   ' . $tzo['timezone_id'];
   //  exit;
   //}
  }
  $selstuff.="</td>" . $yourmapstuff . "</tr></tbody></table><br>";
  $ididea="tzs";
  //if (strpos($hprefix, "<table") !== false) {
  //  file_put_contents("x.x", $selstuff);
  //}
  } 
  $selstuff.='<select name=tzname id=s' . "tzs" . $kcnt . ' onchange=changetz(this.value);><option title=' . "''" . ' value=' . "''" . '>Local Time Zone</option><option title= value=0>GMT</option></select>';
  for ($xoff=-24.0; $xoff<=24.0; $xoff+=0.5) {
    $selstuff=str_replace("</select>", "<option title='' value='" . str_replace("+-","-",("+" . (0.0 + $xoff))) . "'>" . str_replace("+-","-",("+" . $xoff . " hours")) . "</option></select>", $selstuff);
  }
  $versus=file_get_contents("tz_places.php");
  $zones = timezone_identifiers_list();
  foreach ($zones as $zone) {
    $origzone=$zone;
    //$ourtz=new DateTimeZone($zone);
    $zzbit=$zone;
    $zone = explode('/', $zone); // 0 => Continent, 1 => City
    // Only use "friendly" continent names
    if ($zone[0] == 'Africa' || $zone[0] == 'America' || $zone[0] == 'Antarctica' || $zone[0] == 'Arctic' || $zone[0] == 'Asia' || $zone[0] == 'Atlantic' || $zone[0] == 'Australia' || $zone[0] == 'Europe' || $zone[0] == 'Indian' || $zone[0] == 'Pacific') {       
        if (isset($zone[1]) != '') {
            if (strpos($versus, '"' . $zzbit . '"') === false && strpos($versus, '"' . '' . '"];') !== false && strpos($versus, '"' . ' ' . '"];') !== false && strpos($versus, '"' . '  ' . '"];') !== false) {
              $ourtz=new DateTimeZone($zzbit);
              $versus=str_replace('"' . '' . '"];', '"' . $zzbit . '","' . '' . '"];', $versus);
              $versus=str_replace('"' . ' ' . '"];', '"' . $ourtz->getLocation()[latitude] . '","' . ' ' . '"];', $versus);
              $versus=str_replace('"' . '  ' . '"];', '"' . $ourtz->getLocation()[longitude] . '","' . '  ' . '"];', $versus);
              @file_put_contents("tz_places.php", $versus);
              echo '<html><body onload=" location.href=' . "'" . "./tz_places.php?upto=" . $zzbit . "'" . '; "></body></html>';
              //header("Location: ./tz_places.php?upto=" . $zzbit);
              exit;
            }
            //$locations[$zone[0]][$zone[0]. '/' . $zone[1]] = str_replace('_', ' ', $zone[1]); // Creates array(DateTimeZone => 'Friendly name')
            //$ourtz=new DateTimeZone(str_replace('_', ' ', $zone[0]. '/' . $zone[1]));
            //$selstuff=str_replace("</select>", "<option title='" . $ourtz->getLocation()[latitude] . "," . $ourtz->getLocation()[longitude] . ",~" . urlencode(str_replace('_', ' ', $zone[1])) . "~' value='" . str_replace('_', ' ', $zone[0]. '/' . $zone[1]) . "'>" . str_replace('_', ' ', $zone[0]. '/' . $zone[1]) . "</option></select>", $selstuff);
            //$selstuff=str_replace("</select>", "<option title='" . $origzone . "' value='" . str_replace('_', ' ', $zone[0]. '/' . $zone[1]) . "'>" . str_replace('_', ' ', $zone[0]. '/' . $zone[1]) . "</option></select>", $selstuff);
            $selstuff=str_replace("</select>", "<option title='" . $origzone . "' value='" . str_replace("/" . $zone[-1 + sizeof($zone)], "", $zzbit) . '/' . explode(",",$zone[-1 + sizeof($zone)])[0] . "'>" . str_replace('_', ' ', str_replace("/" . $zone[-1 + sizeof($zone)], "", $zzbit). '/' . $zone[-1 + sizeof($zone)]) . "</option></select>", $selstuff);
            //$selstuff=str_replace("</select>", "<option value='" . str_replace('_', ' ', $zone[0]. '/' . $zone[1]) . "'>" . str_replace('_', ' ', $zone[0]. '/' . $zone[1]) . "</option></select>", $selstuff);
        }
    }
  }
  
  if (isset($_GET['tzname'])) {
      if (strpos($selstuff, ("'" . urldecode($_GET['tzname']) . "'>")) !== false) {
        $selstuff=str_replace(("'" . urldecode($_GET['tzname']) . "'>"),("'" . urldecode($_GET['tzname']) . "' selected>"),$selstuff);
      }
  }      
  
  return $selstuff;
}

if (isset($_GET['upto'])) {
  ourtimezonelist($ideais);
}

find_nearest();

echo "<!doctype html>
<html>
<head>
<title>TimeZone Places - RJM Programming - December, 2016 ... Thanks to http://php.net/manual/en/datetimezone.getlocation.php and http://stackoverflow.com/questions/17842003/php-intl-country-code-2-chars-to-country-name</title>
<meta charset='UTF-8' />
<link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'>
<style>
td { vertical-align: top; }
.round, #isubmit {  
   /* Safari 3-4, iOS 1-3.2, Android 1.6- */
  -webkit-border-radius: 50%; 

  /* Firefox 1-3.6 */
  -moz-border-radius: 50%; 
  
  /* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, iOS 4, Android 2.1+ */
  border-radius: 50%; 
  padding: 17px 17px 17px 17px;   
  font-family: Tahoma; 
  color: red; 
  font-size: 32px; 
}
select { background-color:#f0f0f0; border: 2px solid lightblue; }
.abut {  background-color:#ffffff; border: 2px solid olive; padding 3px 3px 3px 3px; color: purple; }
.emoji { font-size: 36px; }
.nighttime { background-color: darkgray; }
</style>
<script type='text/javascript'>

 var bestemoji=" . $bestemojicodepoint . "; 
 var iam=" . $iam . "; 
 var iamleft=" . ((600 * ($iam - 1)) + 100) . "; 
 var arrmaplist=[], maplist='', lastmaplist='', mapdelim=';'; 

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 checkmailbox() {
 var urlis='', ih='', jiarr=[], ijarr=[], ijcont='', ijplace='', jicont='', jiplace='';
 //alert(99 + ' ' + maplist);
 if (top.document.getElementById('mapphpmailbox').value != maplist) {
  if (maplist.length > top.document.getElementById('mapphpmailbox').value.length) {
    top.document.getElementById('mapphpmailbox').value=maplist;
  } else {
    maplist=top.document.getElementById('mapphpmailbox').value;
  }
  arrmaplist=maplist.split(mapdelim);
 }
 if (arrmaplist.length > 1) {
 //alert(98);
    if (document.getElementById('fromto') && lastmaplist != maplist) {
 //alert(97);
      lastmaplist=maplist;
      ih=\"<option value=''>Optionally select a From/To set of interest below ...</option>\";
 //alert(ih);
      for (var ij=0; ij<arrmaplist.length; ij++) {
       for (var ji=0; ji<arrmaplist.length; ji++) {
         if (ji != ij && ij < ji) {
           ijarr=arrmaplist[ij].split(',');
           jiarr=arrmaplist[ji].split(',');
           ijplace=ijarr[0].split('/')[eval(-1 + ijarr[0].split('/').length)];  //.replace(/_/g,'%20');
           jiplace=jiarr[0].split('/')[eval(-1 + ijarr[0].split('/').length)];  //.replace(/_/g,'%20');
           ijcont=ijarr[0].replace('/' + ijplace,'');
           jicont=jiarr[0].replace('/' + jiplace,'');
           ijplace=ijplace.replace(/_/g,'%20');
           jiplace=jiplace.replace(/_/g,'%20');
           urlis='https://www.google.com/maps/dir/' + ijplace + '+' + ijcont + '/' + jiplace + '+' + jicont;
           ih+='<option value=\"' + urlis + '\">' + ijplace.replace(/%20/g,' ') + ' to ' + jiplace.replace(/%20/g,' ') + ' ... ' + eval(great_circle_distance(ijarr[1], ijarr[2], jiarr[1], jiarr[2]) / 1000.0) + 'km ... ' + eval(eval(jiarr[3]) - eval(ijarr[3])) + ' hours difference</option>'; 
         }
       }
      }
      document.getElementById('fromto').innerHTML=ih;
      document.getElementById('fromto').style.display='inline';
    }
  
 }
 setTimeout(checkmailbox, 3000);
}

function addtolist(nextarrmember) {
// alert(198);
 if (top.document.getElementById('mapphpmailbox').value.indexOf(nextarrmember) == -1) {
// alert(197);
  if (top.document.getElementById('mapphpmailbox').value != '') {
    top.document.getElementById('mapphpmailbox').value+=mapdelim + nextarrmember;
  } else {
    top.document.getElementById('mapphpmailbox').value=nextarrmember;
  }
  maplist=top.document.getElementById('mapphpmailbox').value;
  arrmaplist=maplist.split(mapdelim);
// alert(maplist);
 }
}

function mapselchange(othis) {
 if (othis.value.length > 0) { 
  window.open(othis.value,'_blank','top=10,left=10,width=1200,height=800');
 }
}

function changetz(intz) { }
function changeiso(intz) { }

function newiframe(wht) {
    document.getElementById('td' + wht).innerHTML='<iframe style=margin-top:-135px;width:600px;height:900px; id=newif' + wht + ' name=newif' + wht + ' src=./tz_places.php?iam=' + wht + '></iframe>';
}

function fixforlocal() {
    var dd=new Date();
    var qw1=eval(eval((eval(dd.toTimeString().replace('-',' ').replace('+',' ').split(' ')[2]) - eval(dd.toTimeString().replace('-',' ').replace('+',' ').split(' ')[2] % 100)) / 100) + eval((0.0 + eval(dd.toTimeString().replace('-',' ').replace('+',' ').split(' ')[2] % 100)) / 60.0));
    if (dd.toTimeString().indexOf('+') != -1) qw1=-qw1;
    var huh='sszt';
    if (document.getElementById('stzs')) huh='stzs';
    if (document.getElementById(huh).innerHTML.indexOf(' value=\"\">') != -1) {
      if (eval(0 - eval(qw1)) >= 0) {
      document.getElementById(huh).innerHTML=document.getElementById('stzs').innerHTML.replace(' value=\"\">Local', ' value=\"+' + eval(0 - eval(qw1)) + '\">Local');
      document.getElementById(huh).value='+' + eval(0 - eval(qw1));
      } else {
      document.getElementById(huh).innerHTML=document.getElementById('stzs').innerHTML.replace(' value=\"\">Local', ' value=\"' + eval(0 - eval(qw1)) + '\">Local');
      document.getElementById(huh).value=eval(0 - eval(qw1));
      }
    } 
    var tds=document.getElementsByTagName('table');
    for (var itds=0; itds<tds.length; itds++) { 
      if (tds[itds].innerHTML.indexOf('<td></td>') != -1) {
        tds[itds].style.display='none';
      } 
    }
}

// 1  o'clock is &#128336;
// 2  o'clock is &#128337;

// 12 o'clock is &#128347;

//  2:30 is &#128349;
// 11:30 is &#128358;
// 12:30 is &#128359;

// http://www.rjmprogramming.com.au/HTMLCSS/daylight_saving_time.html?timezone=0
function emojistuff(ething) {
  var subj='';
  if (ething.innerHTML.length < 10) {
    if (ething.id.indexOf('daof_') == 0) {
      if (top.document.title.indexOf('Time') == 0) {
        top.document.title='Country ' + top.document.title + ' ... Quiz';
      }
      ething.innerHTML='<iframe style=width:700px;height:700px;z-index:5; src=http://www.rjmprogramming.com.au/HTMLCSS/karaoke_youtube_api.htm?emoji=on&nokaraoke=y&youtubeid=' + encodeURIComponent('              ' + ething.id.substring(5).replace('_',' ').replace('_',' ').replace('_',' ').replace('_',' ').replace('_',' ').replace('_',' ').replace('_',' ')) + '></iframe>';
    } else if (ething.id.indexOf('qaof_') == 0) {
      if (top.document.title.indexOf('Time') == 0) {
        top.document.title='Country ' + top.document.title + ' ... Quiz';
      }
      ething.innerHTML='<iframe style=width:700px;height:700px;z-index:5; src=http://www.rjmprogramming.com.au/HTMLCSS/daylight_saving_time.html?timezone=' + ething.id.substring(5) + '></iframe>';
    } else if (ething.id.indexOf('oaof_') == 0) {
      if (top.document.title.indexOf('Time') == 0) {
        top.document.title='Country ' + top.document.title + ' ... Quiz';
      }
      ething.innerHTML='<iframe style=width:700px;height:700px;z-index:5; src=http://www.rjmprogramming.com.au/HTMLCSS/daylight_saving_time.html?timezone=' + ething.id.substring(5) + '></iframe>';
    } else if (ething.id.indexOf('disellong') == 0) {
      if (document.getElementById('isellong').value != '') {
        subj=document.getElementById('sellong').options[document.getElementById('sellong').selectedIndex].text;
      }
      if (subj != '') {
      if (top.document.title.indexOf('Time') == 0) {
        top.document.title='Country ' + top.document.title + ' ... Quiz';
      }
      ething.innerHTML='<iframe style=width:700px;height:700px;z-index:5; src=http://www.rjmprogramming.com.au/HTMLCSS/karaoke_youtube_api.htm?emoji=on&nokaraoke=y&youtubeid=' + encodeURIComponent('              ' + subj.replace('_',' ').replace('_',' ').replace('_',' ').replace('_',' ').replace('_',' ').replace('_',' ').replace('_',' ')) + '></iframe>';
      }
    } else if (ething.id.indexOf('getmegmt') == 0) {
      if (top.document.title.indexOf('Time') == 0) {
        top.document.title='Country ' + top.document.title + ' ... Quiz';
      }
      //ething.innerHTML='<iframe style=width:700px;height:700px;z-index:5; src=http://www.rjmprogramming.com.au/HTMLCSS/daylight_saving_time.html?timezone=0></iframe>';
      ething.innerHTML='<iframe style=width:700px;height:700px;z-index:5; src=http://www.rjmprogramming.com.au/HTMLCSS/analogue_clock.htm?></iframe>';
    }
  }
}

</scr" . "ipt>
</head>
<body style='background-color:" . $bcol[((0 + $iam) % 10)] . ";' onload='" . $onloadbits . " setTimeout(fixforlocal,1000);'>" . $hprefix;
// <body style='background-color:yellow;' onload='setTimeout(fixforlocal,1000);'><h1>TimeZone Places</h1><h3>RJM Programming - December, 2016</h3><h4>Thanks to <a target=_blank title='http://php.net/manual/en/datetimezone.getlocation.php' href='http://php.net/manual/en/datetimezone.getlocation.php'>http://php.net/manual/en/datetimezone.getlocation.php</a> and <br><a target=_blank title='http://stackoverflow.com/questions/17842003/php-intl-country-code-2-chars-to-country-name' href='http://stackoverflow.com/questions/17842003/php-intl-country-code-2-chars-to-country-name'>http://stackoverflow.com/questions/17842003/php-intl-country-code-2-chars-to-country-name</a> and <br><a target=_blank title=http://php.net/manual/en/function.timezone-identifiers-list.php href=http://php.net/manual/en/function.timezone-identifiers-list.php>http://php.net/manual/en/function.timezone-identifiers-list.php</a> and <br><a target=_blank title=http://www.timezoneconverter.com/ href=http://www.timezoneconverter.com/>http://www.timezoneconverter.com/</a></h4>" . $hprefix;


$formstuff="";
if (isset($_GET['iso'])) {
  $places="Places";
  for ($ic=0; $ic<sizeof($iso_country_codes); $ic+=2) {
    if ($iso_country_codes[$ic] == $_GET['iso']) $places=$iso_country_codes[1 + $ic];
  }
  $sellong=str_replace('value="">', 'value="' . $_GET['iso'] . '">',str_replace('"' . $_GET['iso'] . '"', '"' . $_GET['iso'] . '" selected',$sellong));
  $timeZones = DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, $_GET['iso']);
  $prefix="<table><tbody><tr><td>";
  $suffix="";
  $ourmapstuff="";
  $yourmapstuff="";
  $formstuff="";
  $ideais="tzs";
  if ($_GET['iso'] == '' &&  isset($_GET['tzname'])) {
  $ideais="szt";
  } else {
  foreach ( $timeZones as $key => $zoneName ) {
    $otz = new DateTimeZone("Europe/London");
    $tz = new DateTimeZone($zoneName);

    $origin_dt = new DateTime("now", $otz);
    $remote_dt = new DateTime("now", $tz);

    $offset = ($tz->getOffset($remote_dt) - $otz->getOffset($origin_dt)) / 3600;
    if ($offset < 0) {
     $coffset=$offset;
    } else {
     $coffset="+" . $offset;
    }

// <input type=\"hidden\" value=\"Places\" name=\"title\"></input><input type=\"hidden\" value=\"['Lat',\" name=\"label\"></input><input type=\"hidden\" value=\"'Lon','Name']\" name=\"value\"></input>

    $zbits=explode("/",explode(",",$zoneName)[0]);

    $loc = $tz->getLocation();
    if ($ourmapstuff == "") {
      $ourmapstuff="</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<iframe style=width:400px;height:400px; id='mapif' name='mapif' src=http://www.rjmprogramming.com.au/PHP/Map/map.php?title=" . urlencode($places) . "&onclick=y&label=[%27Lat%27,&value=%27Lon%27,%27Name%27]&data=,[" . $loc[latitude] . "," . $loc[longitude] . ",~" . explode(",",$zbits[-1 + sizeof($zbits)])[0] . "~]></iframe><form target=mapif action=http://www.rjmprogramming.com.au/PHP/Map/map.php method=POST><input type=hidden value=\"" . $places . "\" id=title name=title></input><input type=hidden value=\"['Lat',\" id=label name=label></input><input type=hidden value=\"'Lon','Name']\" id=value name=value></input><input type=hidden value='' id=data name=data></input><input type=hidden value=y id=onclick name=onclick></input><input id=smapif type=submit value=Show style=display:none;></input></form> <scr" . "ipt type='text/javascript'> document.getElementById('smapif').click(); </scr" . "ipt>";
      $yourmapstuff="</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<iframe style=width:400px;height:400px; id='mapif' name='mapif' src=about:blank></iframe>";
      //$formstuff="<form target=\"mapif\" action=\"http://www.rjmprogramming.com.au/PHP/Map/map.php\" method=\"POST\"><input type=\"hidden\" value=\"Places\" name=\"title\"></input><input type=\"hidden\" value=\"[%27Lat%27,\" name=\"label\"></input><input type=\"hidden\" value=\"%27Lon%27,%27Name%27]\" name=\"value\"></input><input type=\"hidden\" value=\"\" name=\"data\"></input><input type=\"hidden\" value=\"y\" name=\"onclick\"></input><input id=\"smapif\" type=\"submit\" value=\"Show\" style=\"display:none;\"></input></form> <scr" . "ipt type='text/javascript'> function doc() { document.getElementById('smapif').click(); } setTimeout(doc, 2000); </scr" . "ipt>";
      $formstuff="<form target=\"mapif\" action=\"http://www.rjmprogramming.com.au/PHP/Map/map.php\" method=\"POST\"><input type=\"hidden\" value=\"" . $places . "\" name=\"title\"></input><input type=\"hidden\" value=\"['Lat',\" name=\"label\"></input><input type=\"hidden\" value=\"'Lon','Name']\" name=\"value\"></input><input type=\"hidden\" value=\"\" name=\"data\"></input><input type=\"hidden\" value=\"y\" name=\"onclick\"></input><input id=\"smapif\" type=\"submit\" value=\"Show\" style=\"display:none;\"></input></form> <scr" . "ipt type='text/javascript'> function doc() { document.getElementById('smapif').click(); } setTimeout(doc, 2000); </scr" . "ipt>";
      $formstuff=str_replace('" name="data"', ',[' . $loc[latitude] . ',' . $loc[longitude] . ',~' . str_replace("_"," ",explode(",",$zbits[-1 + sizeof($zbits)])[0]) . '~]" name="data"', $formstuff);
    } else {
      $ourmapstuff=str_replace("></iframe", ",[" . $loc[latitude] . "," . $loc[longitude] . ",~" . str_replace("_"," ",explode(",",$zbits[-1 + sizeof($zbits)])[0]) . "~]></iframe", $ourmapstuff); 
      $formstuff=str_replace('" name="data"', ',[' . $loc[latitude] . ',' . $loc[longitude] . ',~' . str_replace("_"," ",explode(",",$zbits[-1 + sizeof($zbits)])[0]) . '~]" name="data"', $formstuff);
    }
    
    if (isset($_GET['tzname'])) {
      $tzn=urldecode($_GET['tzname']);
      if (strpos($tzn,"/") === false && strpos($tzn,"-") === false && strpos($tzn,"+") === false && $tzn != "") $tzn="+" . trim($tzn);
      if (strpos((" " . $zoneName . " = " . $loc['comments'] . " ... " . $coffset), " " . $tzn) !== false || strpos((" " . $zoneName . " = " . $loc['comments'] . " ... " . $coffset), "+" . $tzn) !== false) {
        $prefix.="<b><i>";
        $suffix.="</i></b>";
      }
    }   

    $prepretitlebit="";
    if ($prepretitlebit == "" && isset($_GET['iso'])) {
      $prepretitlebit=$_GET['iso'];
    }
    if ($prepretitlebit == "") $prepretitlebit=$loc['country_code'];
    $pretitlebit=explode('"' . $prepretitlebit . '" selected>', $sellong)[1];
    $titlebit=explode("<", $pretitlebit)[0] . "/" . explode(",",$zbits[-1 + sizeof($zbits)])[0] . ',' . $loc[latitude] . ',' . $loc[longitude] . ',' . $offset;
    $extrad="";
    if ($tzo['dst'] === true) {
      $extrad="<div style=display:inline; id=qaof_" . $tzo['offset'] / 3600 . " class=emoji onclick=emojistuff(this);>&#9200;</div>";
    }
    localtimefromtogmt($coffset,   'Australi' . 'a/Perth', 'UTC');
    if (strpos($titlebit,"Optionally Select Country of Interest below ...") !== false) {
    print($prefix . " <a class=abut id=aof_" . explode(",",$zbits[-1 + sizeof($zbits)])[0] . " target=_blank title='" . $zoneName . ',' . $loc[latitude] . ',' . $loc[longitude] . ',' . $offset . "' style=text-decoration:underline;cursor:pointer; onclick='addtolist(this.title); window.open(\"http://www.timezoneconverter.com/cgi-bin/zoneinfo?tz=" . $zoneName . "\",\"_blank\",\"top=100,left=\" + iamleft + \",width=600,height=900\");'>" . $zoneName . "</a><div style=display:inline; id=daof_" . explode(",",$zbits[-1 + sizeof($zbits)])[0] . " class=emoji onclick=emojistuff(this);>&#128249;</div> = " . $loc['comments'] . " ... " . $coffset . "<div style=display:inline; id=oaof_" . str_replace('+','',('' . $coffset)) . " class='emoji" . $thisemojiclass . "'  onclick=emojistuff(this);>" . str_replace("&#;","","&#" . $thisemojicodepoint . ";") . "</div>" . $suffix . "<br>");
    } else {
    print($prefix . " <a class=abut id=aof_" . explode(",",$zbits[-1 + sizeof($zbits)])[0] . " target=_blank title='" . $titlebit . "' style=text-decoration:underline;cursor:pointer; onclick='addtolist(this.title); window.open(\"http://www.timezoneconverter.com/cgi-bin/zoneinfo?tz=" . $zoneName . "\",\"_blank\",\"top=100,left=\" + iamleft + \",width=600,height=900\");'>" . $zoneName . "</a><div style=display:inline; id=daof_" . explode(",",$zbits[-1 + sizeof($zbits)])[0] . " class=emoji onclick=emojistuff(this);>&#128249;</div> = " . $loc['comments'] . " ... " . $coffset . "<div style=display:inline; id=oaof_" . str_replace('+','',('' . $coffset)) . " class='emoji" . $thisemojiclass . "'  onclick=emojistuff(this);>" . str_replace("&#;","","&#" . $thisemojicodepoint . ";") . "</div>" . $suffix . "<br>");
    }
    $prefix="";
    $suffix="";
  }
  }
  //$yourmapstuff="";
  print("</td>" . $yourmapstuff . "</tr></tbody></table>");
  //print("</td>" . "</tr></tbody></table>");
}

if ($iam == "1") {
  echo "<input type='hidden' id='mapphpmailbox' value='' type='Where map.php puts and gets information'></input>";
}

echo "<!--br><br-->
<form action=./tz_places.php" . str_replace("~","",str_replace("?~","",("?" . $_SERVER['QUERY_STRING'] . "~"))) . " style=width:100%; method=GET><input id=isubmit type=submit value='Display as Below...' style=background-color:orange;></input>" . $fromto . "<br><br>" . $sellong . ourtimezonelist($ideais) . "
<input type=hidden name=iam id=iam value=" . $iam . "></input></form><br>" . $formstuff . $hsuffix . $otherform . "</body>
</html>
";
?> 
