<?php
// map.php
// RJM Programming
// December, 2016
// Interface to Google Charts Map Chart
require('../php_database.php');


$php_map_db=[""];

function pm_server_remote_addr() {
    $rma = $_SERVER['REMOTE_ADDR'];
    $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
    // you can add different browsers with the same way ..
    if(preg_match('/(chromium)[ \/]([\w.]+)/', $ua))
            $rma = '000000'.$rma;
    elseif(preg_match('/(chrome)[ \/]([\w.]+)/', $ua))
            $rma = '00000'.$rma;
    elseif(preg_match('/(safari)[ \/]([\w.]+)/', $ua))
            $rma = '0000'.$rma;
    elseif(preg_match('/(opera)[ \/]([\w.]+)/', $ua))
            $rma = '000'.$rma;
    elseif(preg_match('/(msie)[ \/]([\w.]+)/', $ua))
            $rma = '00'.$rma;
    elseif(strpos($ua, ' applewebkit') !== false)
            $rma = '0'.$rma;
    elseif(preg_match('/(mozilla)[ \/]([\w.]+)/', $ua)) {
            $rma = '0000000'.$rma;
    }
    return str_replace("/","_",$rma);
}

function nocomm($inwcr) {
    $outwcr=$inwcr;
    $outa=explode("/" . "/ ", $inwcr);
    if (sizeof($outa) > 1) {
      $newa=$outa[0];
      for ($ij=1; $ij<sizeof($outa); $ij++) {
        if (strpos("\n", $outa[$ij]) !== false) {
          $newa.=str_replace((explode("\n", $outa[$ij])[0] . "\n"), "\n", $outa[$ij]); 
        } else {
          $newa.=str_replace((explode(".", $outa[$ij])[0] . "."), "", $outa[$ij]); 
        }
      }
      $outwcr=$newa;
    }
    if (substr((trim($outwcr) . " "),0,1) != ',') {
    //echo "1: " . str_replace('+',' ',str_replace('};','',str_replace('"', "'", str_replace("\n", " ", ("," . $outwcr)))));
    return str_replace('+',' ',str_replace('};','',str_replace('"', "'", str_replace("\n", " ", ("," . $outwcr)))));
    } else {
    //echo "2: " . str_replace('+',' ',str_replace('};','',str_replace('"', "'", str_replace("\n", " ", $outwcr))));
    return str_replace('+',' ',str_replace('};','',str_replace('"', "'", str_replace("\n", " ", $outwcr))));
    }
}

  $promptsuffix="";
  $optsfound="";
  $options_suffix="";
  $map_style_tailored="";
  $myfnameis="val";
  $dbval="";
  $dbval = include_get_params(dirname(__FILE__) . '/../php_database.php?' . $myfnameis . '=');  
  
  if ($dbval != "") {
   for ($idbv=0; $idbv<sizeof($php_map_db); $idbv++) {
     if (strpos(('~' . $php_map_db[$idbv]), ('~' . pm_server_remote_addr() . '`')) !== false) {
       $optsfound=(pm_server_remote_addr() . '`');
       $options_suffix=(explode((pm_server_remote_addr() . '`'), $php_map_db[$idbv])[1]);
       $optsfound=(pm_server_remote_addr() . '`') . $options_suffix;
       $options_suffix=urldecode($options_suffix);
     }
   }
   if (isset($_POST['custom_map'])) {
      $c_m=nocomm(urldecode($_POST['custom_map']));
      $herestr=file_get_contents(dirname(__FILE__) . "/map.php");
      if ($optsfound != "") {
      file_put_contents(dirname(__FILE__) . "/map.php", str_replace($optsfound, (pm_server_remote_addr() . '`' . urlencode($c_m)), $herestr));
      $options_suffix=$c_m;
      } else {
      $phpdb=explode('[' . '"' . '"' . '', $herestr)[0];
      $phprest=str_replace(($phpdb . '[' . '"' . '"' . ''), '', $herestr);
      file_put_contents(dirname(__FILE__) . "/map.php", ($phpdb . '[' . '"' . '"' . '') . ',"' . (pm_server_remote_addr() . '`' . urlencode($c_m)) . '"' . $phprest);
      $options_suffix=$c_m;
      }
   } else if (isset($_GET['custom_map'])) {
      $c_m=nocomm(urldecode($_GET['custom_map']));
      $herestr=file_get_contents(dirname(__FILE__) . "/map.php");
      if ($optsfound != "") {
      file_put_contents(dirname(__FILE__) . "/map.php", str_replace($optsfound, (pm_server_remote_addr() . '`' . urlencode($c_m)), $herestr));
      $options_suffix=$c_m;
      } else {
      $phpdb=explode('[' . '"' . '"' . '', $herestr)[0];
      $phprest=str_replace(($phpdb . '[' . '"' . '"' . ''), '', $herestr);
      file_put_contents(dirname(__FILE__) . "/map.php", ($phpdb . '[' . '"' . '"' . '') . ',"' . (pm_server_remote_addr() . '`' . urlencode($c_m)) . '"' . $phprest);
      $options_suffix=$c_m;
      }
   }
   if ($options_suffix == "") {
     $promptsuffix="  You have none so far, but you can read Styling Maps section of https://developers.google.com/chart/interactive/docs/gallery/map about ... ,maps: { ... prefixed ... ]}} ... suffixed ... entry you can tailor your maps with here. ";
   } else {
     $promptsuffix="  You have one defined already, but you can read Styling Maps section of https://developers.google.com/chart/interactive/docs/gallery/map about ... ,maps: { ... prefixed ... ]}} ... suffixed ... entry you can tailor your maps with here. ";
   }
  } else if (isset($_POST['custom_map'])) {
      $options_suffix=nocomm(urldecode($_POST['custom_map']));
  } else if (isset($_GET['custom_map'])) {
      $options_suffix=nocomm(urldecode($_GET['custom_map']));
  }

// Use URL like ./tz_places.php?upto= to populate arrays below ...
$nearname=["Africa/Abidjan","Africa/Accra","Africa/Addis_Ababa","Africa/Algiers","Africa/Asmara","Africa/Bamako","Africa/Bangui","Africa/Banjul","Africa/Bissau","Africa/Blantyre","Africa/Brazzaville","Africa/Bujumbura","Africa/Cairo","Africa/Casablanca","Africa/Ceuta","Africa/Conakry","Africa/Dakar","Africa/Dar_es_Salaam","Africa/Djibouti","Africa/Douala","Africa/El_Aaiun","Africa/Freetown","Africa/Gaborone","Africa/Harare","Africa/Johannesburg","Africa/Juba","Africa/Kampala","Africa/Khartoum","Africa/Kigali","Africa/Kinshasa","Africa/Lagos","Africa/Libreville","Africa/Lome","Africa/Luanda","Africa/Lubumbashi","Africa/Lusaka","Africa/Malabo","Africa/Maputo","Africa/Maseru","Africa/Mbabane","Africa/Mogadishu","Africa/Monrovia","Africa/Nairobi","Africa/Ndjamena","Africa/Niamey","Africa/Nouakchott","Africa/Ouagadougou","Africa/Porto-Novo","Africa/Sao_Tome","Africa/Tripoli","Africa/Tunis","Africa/Windhoek","America/Adak","America/Anchorage","America/Anguilla","America/Antigua","America/Araguaina","America/Argentina/Buenos_Aires","America/Argentina/Catamarca","America/Argentina/Cordoba","America/Argentina/Jujuy","America/Argentina/La_Rioja","America/Argentina/Mendoza","America/Argentina/Rio_Gallegos","America/Argentina/Salta","America/Argentina/San_Juan","America/Argentina/San_Luis","America/Argentina/Tucuman","America/Argentina/Ushuaia","America/Aruba","America/Asuncion","America/Atikokan","America/Bahia","America/Bahia_Banderas","America/Barbados","America/Belem","America/Belize","America/Blanc-Sablon","America/Boa_Vista","America/Bogota","America/Boise","America/Cambridge_Bay","America/Campo_Grande","America/Cancun","America/Caracas","America/Cayenne","America/Cayman","America/Chicago","America/Chihuahua","America/Costa_Rica","America/Creston","America/Cuiaba","America/Curacao","America/Danmarkshavn","America/Dawson","America/Dawson_Creek","America/Denver","America/Detroit","America/Dominica","America/Edmonton","America/Eirunepe","America/El_Salvador","America/Fortaleza","America/Glace_Bay","America/Godthab","America/Goose_Bay","America/Grand_Turk","America/Grenada","America/Guadeloupe","America/Guatemala","America/Guayaquil","America/Guyana","America/Halifax","America/Havana","America/Hermosillo","America/Indiana/Indianapolis","America/Indiana/Knox","America/Indiana/Marengo","America/Indiana/Petersburg","America/Indiana/Tell_City","America/Indiana/Vevay","America/Indiana/Vincennes","America/Indiana/Winamac","America/Inuvik","America/Iqaluit","America/Jamaica","America/Juneau","America/Kentucky/Louisville","America/Kentucky/Monticello","America/Kralendijk","America/La_Paz","America/Lima","America/Los_Angeles","America/Lower_Princes","America/Maceio","America/Managua","America/Manaus","America/Marigot","America/Martinique","America/Matamoros","America/Mazatlan","America/Menominee","America/Merida","America/Metlakatla","America/Mexico_City","America/Miquelon","America/Moncton","America/Monterrey","America/Montevideo","America/Montreal","America/Montserrat","America/Nassau","America/New_York","America/Nipigon","America/Nome","America/Noronha","America/North_Dakota/Beulah","America/North_Dakota/Center","America/North_Dakota/New_Salem","America/Ojinaga","America/Panama","America/Pangnirtung","America/Paramaribo","America/Phoenix","America/Port-au-Prince","America/Port_of_Spain","America/Porto_Velho","America/Puerto_Rico","America/Rainy_River","America/Rankin_Inlet","America/Recife","America/Regina","America/Resolute","America/Rio_Branco","America/Santa_Isabel","America/Santarem","America/Santiago","America/Santo_Domingo","America/Sao_Paulo","America/Scoresbysund","America/Shiprock","America/Sitka","America/St_Barthelemy","America/St_Johns","America/St_Kitts","America/St_Lucia","America/St_Thomas","America/St_Vincent","America/Swift_Current","America/Tegucigalpa","America/Thule","America/Thunder_Bay","America/Tijuana","America/Toronto","America/Tortola","America/Vancouver","America/Whitehorse","America/Winnipeg","America/Yakutat","America/Yellowknife","Antarctica/Casey","Antarctica/Davis","Antarctica/DumontDUrville","Antarctica/Macquarie","Antarctica/Mawson","Antarctica/McMurdo","Antarctica/Palmer","Antarctica/Rothera","Antarctica/South_Pole","Antarctica/Syowa","Antarctica/Vostok","Arctic/Longyearbyen","Asia/Aden","Asia/Almaty","Asia/Amman","Asia/Anadyr","Asia/Aqtau","Asia/Aqtobe","Asia/Ashgabat","Asia/Baghdad","Asia/Bahrain","Asia/Baku","Asia/Bangkok","Asia/Beirut","Asia/Bishkek","Asia/Brunei","Asia/Choibalsan","Asia/Chongqing","Asia/Colombo","Asia/Damascus","Asia/Dhaka","Asia/Dili","Asia/Dubai","Asia/Dushanbe","Asia/Gaza","Asia/Harbin","Asia/Hebron","Asia/Ho_Chi_Minh","Asia/Hong_Kong","Asia/Hovd","Asia/Irkutsk","Asia/Jakarta","Asia/Jayapura","Asia/Jerusalem","Asia/Kabul","Asia/Kamchatka","Asia/Karachi","Asia/Kashgar","Asia/Kathmandu","Asia/Kolkata","Asia/Krasnoyarsk","Asia/Kuala_Lumpur","Asia/Kuching","Asia/Kuwait","Asia/Macau","Asia/Magadan","Asia/Makassar","Asia/Manila","Asia/Muscat","Asia/Nicosia","Asia/Novokuznetsk","Asia/Novosibirsk","Asia/Omsk","Asia/Oral","Asia/Phnom_Penh","Asia/Pontianak","Asia/Pyongyang","Asia/Qatar","Asia/Qyzylorda","Asia/Rangoon","Asia/Riyadh","Asia/Sakhalin","Asia/Samarkand","Asia/Seoul","Asia/Shanghai","Asia/Singapore","Asia/Taipei","Asia/Tashkent","Asia/Tbilisi","Asia/Tehran","Asia/Thimphu","Asia/Tokyo","Asia/Ulaanbaatar","Asia/Urumqi","Asia/Vientiane","Asia/Vladivostok","Asia/Yakutsk","Asia/Yekaterinburg","Asia/Yerevan","Atlantic/Azores","Atlantic/Bermuda","Atlantic/Canary","Atlantic/Cape_Verde","Atlantic/Faroe","Atlantic/Madeira","Atlantic/Reykjavik","Atlantic/South_Georgia","Atlantic/St_Helena","Atlantic/Stanley","Australia/Adelaide","Australia/Brisbane","Australia/Broken_Hill","Australia/Currie","Australia/Darwin","Australia/Eucla","Australia/Hobart","Australia/Lindeman","Australia/Lord_Howe","Australia/Melbourne","Australia/Sydney","Europe/Amsterdam","Europe/Andorra","Europe/Athens","Europe/Belgrade","Europe/Berlin","Europe/Bratislava","Europe/Brussels","Europe/Bucharest","Europe/Budapest","Europe/Chisinau","Europe/Copenhagen","Europe/Dublin","Europe/Gibraltar","Europe/Guernsey","Europe/Helsinki","Europe/Isle_of_Man","Europe/Istanbul","Europe/Jersey","Europe/Kaliningrad","Europe/Kiev","Europe/Lisbon","Europe/Ljubljana","Europe/Luxembourg","Europe/Madrid","Europe/Malta","Europe/Mariehamn","Europe/Minsk","Europe/Monaco","Europe/Moscow","Europe/Oslo","Europe/Paris","Europe/Podgorica","Europe/Prague","Europe/Riga","Europe/Rome","Europe/Samara","Europe/San_Marino","Europe/Sarajevo","Europe/Simferopol","Europe/Skopje","Europe/Sofia","Europe/Stockholm","Europe/Tallinn","Europe/Tirane","Europe/Uzhgorod","Europe/Vaduz","Europe/Vatican","Europe/Vienna","Europe/Vilnius","Europe/Volgograd","Europe/Warsaw","Europe/Zagreb","Europe/Zaporozhye","Europe/Zurich","Indian/Antananarivo","Indian/Chagos","Indian/Christmas","Indian/Cocos","Indian/Comoro","Indian/Kerguelen","Indian/Mahe","Indian/Maldives","Indian/Mauritius","Indian/Mayotte","Indian/Reunion","Pacific/Apia","Pacific/Auckland","Pacific/Chatham","Pacific/Chuuk","Pacific/Easter","Pacific/Efate","Pacific/Enderbury","Pacific/Fakaofo","Pacific/Fiji","Pacific/Funafuti","Pacific/Galapagos","Pacific/Gambier","Pacific/Guadalcanal","Pacific/Guam","Pacific/Honolulu","Pacific/Johnston","Pacific/Kiritimati","Pacific/Kosrae","Pacific/Kwajalein","Pacific/Majuro","Pacific/Marquesas","Pacific/Midway","Pacific/Nauru","Pacific/Niue","Pacific/Norfolk","Pacific/Noumea","Pacific/Pago_Pago","Pacific/Palau","Pacific/Pitcairn","Pacific/Pohnpei","Pacific/Port_Moresby","Pacific/Rarotonga","Pacific/Saipan","Pacific/Tahiti","Pacific/Tarawa","Pacific/Tongatapu","Pacific/Wake","Pacific/Wallis","Australia/Perth","Antarctica/Troll","Asia/Chita","Asia/Khandyga","Asia/Srednekolymsk","Asia/Ust-Nera","Europe/Busingen","Pacific/Bougainville",""];
$nearlatitude=["5.31666","5.55","9.03333","36.78333","15.33333","12.65","4.36666","13.46666","11.85","-15.78334","-4.26667","-3.38334","30.05","33.65","35.88333","9.51666","14.66666","-6.8","11.6","4.05","27.15","8.5","-24.65001","-17.83334","-26.25","4.85","0.31666","15.6","-1.95","-4.3","6.45","0.38333","6.13333","-8.8","-11.66667","-15.41667","3.75","-25.96667","-29.46667","-26.3","2.06666","6.3","-1.28334","12.11666","13.51666","18.1","12.36666","6.48333","0.33333","32.9","36.8","-22.56667","51.88","61.21805","18.2","17.05","-7.2","-34.6","-28.46667","-31.4","-24.18334","-29.43334","-32.88334","-51.63334","-24.78334","-31.53334","-33.31667","-26.81667","-54.8","12.5","-25.26667","48.75861","-12.98334","20.8","13.1","-1.45","17.5","51.41666","2.81666","4.6","43.61361","69.11388","-20.45","21.08333","10.5","4.93333","19.3","41.85","28.63333","9.93333","49.1","-15.58334","12.18333","76.76666","64.06666","59.76666","39.73916","42.33138","15.3","53.55","-6.66667","13.7","-3.71667","46.19999","64.18333","53.33333","21.46666","12.05","16.23333","14.63333","-2.16667","6.8","44.65","23.13333","29.06666","39.76833","41.29583","38.37555","38.49194","37.95305","38.74777","38.67722","41.05138","68.34972","63.73333","18","58.30194","38.25416","36.82972","12.15083","-16.5","-12.05","34.05222","18.05138","-9.66667","12.15","-3.13334","18.06666","14.6","25.83333","23.21666","45.10777","20.96666","55.12694","19.4","47.05","46.1","25.66666","-34.88334","45.51666","16.71666","25.08333","40.71416","49.01666","64.50111","-3.85","47.26416","47.11638","46.845","29.56666","8.96666","66.13333","5.83333","33.44833","18.53333","10.65","-8.76667","18.46833","48.71666","62.81666","-8.05","50.4","74.69555","-9.96667","30.3","-2.43334","-33.45","18.46666","-23.53334","70.48333","36.78555","57.17638","17.88333","47.56666","17.3","14.01666","18.35","13.15","50.28333","14.1","76.56666","48.38333","32.53333","43.65","18.45","49.26666","60.71666","49.88333","59.54694","62.44999","-66.28334","-68.58334","-66.66667","-54.5","-67.6","-77.83334","-64.8","-67.56667","-90","-69.00612","-78.40001","78","12.75","43.25","31.95","64.75","44.51666","50.28333","37.95","33.35","26.38333","40.38333","13.75","33.88333","42.9","4.93333","48.06666","29.56666","6.93333","33.5","23.71666","-8.55","25.3","38.58333","31.5","45.75","31.53333","10.75","22.28333","48.01666","52.26666","-6.16667","-2.53334","31.76666","34.51666","53.01666","24.86666","39.48333","27.71666","22.53333","56.01666","3.16666","1.55","29.33333","22.23333","59.56666","-5.11667","14.58333","23.6","35.16666","53.75","55.03333","55","51.21666","11.55","-0.03334","39.01666","25.28333","44.8","16.78333","24.63333","46.96666","39.66666","37.55","31.23333","1.28333","25.05","41.33333","41.71666","35.66666","27.46666","35.65444","47.91666","43.8","17.96666","43.16666","62","56.85","40.18333","37.73333","32.28333","28.1","14.91666","62.01666","32.63333","64.15","-54.26667","-15.91667","-51.70001","-34.91667","-27.46667","-31.95","-39.93334","-12.46667","-31.71667","-42.88334","-20.26667","-31.55","-37.81667","-33.86667","52.36666","42.5","37.96666","44.83333","52.5","48.15","50.83333","44.43333","47.5","47","55.66666","53.33333","36.13333","49.44999","60.16666","54.15","41.01666","49.19999","54.71666","50.43333","38.71666","46.05","49.6","40.4","35.9","60.1","53.9","43.69999","55.75","59.91666","48.86666","42.43333","50.08333","56.94999","41.9","53.19999","43.91666","43.86666","44.94999","41.98333","42.68333","59.33333","59.41666","41.33333","48.61666","47.15","41.90222","48.21666","54.68333","48.73333","52.25","45.8","47.83333","47.38333","-18.91667","-7.33334","-10.41667","-12.16667","-11.68334","-49.35278","-4.66667","4.16666","-20.16667","-12.78334","-20.86667","-13.83334","-36.86667","-43.95","7.41666","-27.15","-17.66667","-3.13334","-9.36667","-18.13334","-8.51667","-0.9","-23.13334","-9.53334","13.46666","21.30694","16.75","1.86666","5.31666","9.08333","7.15","-9","28.21666","-0.51667","-19.01667","-29.05","-22.26667","-14.26667","7.33333","-25.06667","6.96666","-9.5","-21.23334","15.2","-17.53334","1.41666","-21.16667","19.28333","-13.3","-31.95","-72.01139","52.05","62.65638","67.46666","64.56027","47.69999","-6.21667"," "];
$nearlongitude=["-4.03334","-0.21667","38.7","3.05","38.88333","-8","18.58333","-16.65","-15.58334","35","15.28333","29.36666","31.25","-7.58334","-5.31667","-13.71667","-17.43334","39.28333","43.15","9.7","-13.2","-13.25","25.91666","31.05","28","31.6","32.41666","32.53333","30.06666","15.3","3.4","9.45","1.21666","13.23333","27.46666","28.28333","8.78333","32.58333","27.5","31.1","45.36666","-10.78334","36.81666","15.05","2.11666","-15.95","-1.51667","2.61666","6.73333","13.18333","10.18333","17.1","-176.65806","-149.90028","-63.06667","-61.8","-48.2","-58.45","-65.78334","-64.18334","-65.3","-66.85","-68.81667","-69.21667","-65.41667","-68.51667","-66.35","-65.21667","-68.3","-69.96667","-57.66667","-91.62167","-38.51667","-105.25","-59.61667","-48.48334","-88.2","-57.11667","-60.66667","-74.08334","-116.2025","-105.05278","-54.61667","-86.76667","-66.93334","-52.33334","-81.38334","-87.65","-106.08334","-84.08334","-116.51667","-56.08334","-69","-18.66667","-139.41667","-120.23334","-104.98417","-83.04584","-61.4","-113.46667","-69.86667","-89.2","-38.5","-59.95","-51.73334","-60.41667","-71.13334","-61.75","-61.53334","-90.51667","-79.83334","-58.16667","-63.6","-82.36667","-110.96667","-86.15806","-86.625","-86.34473","-87.27862","-86.76139","-85.06723","-87.52862","-86.60306","-133.71667","-68.46667","-76.8","-134.41973","-85.75945","-84.84917","-68.27667","-68.15","-77.05","-118.24278","-63.04723","-35.71667","-86.28334","-60.01667","-63.08334","-61.08334","-97.5","-106.41667","-87.61417","-89.61667","-131.57639","-99.15001","-56.33334","-64.78334","-100.31667","-56.18334","-73.56667","-62.21667","-77.35","-74.00639","-88.26667","-165.40639","-32.41667","-101.77778","-101.29917","-101.41084","-104.41667","-79.53334","-65.73334","-55.16667","-112.07334","-72.33334","-61.51667","-63.9","-66.10612","-94.56667","-92.08306","-34.9","-104.65001","-94.82917","-67.8","-114.86667","-54.86667","-70.66667","-69.9","-46.61667","-21.96667","-108.68639","-135.30195","-62.85","-52.71667","-62.71667","-61","-64.93334","-61.23334","-107.83334","-87.21667","-68.78334","-89.25","-117.01667","-79.38334","-64.61667","-123.11667","-135.05001","-97.15001","-139.72723","-114.35","110.51666","77.96666","140.01666","158.95","62.88333","166.6","-64.1","-68.13334","0","39.59","106.89999","16","45.2","76.95","35.93333","177.48333","50.26666","57.16666","58.38333","44.41666","50.58333","49.85","100.51666","35.5","74.6","114.91666","114.5","106.58333","79.85","36.3","90.41666","125.58333","55.3","68.8","34.46666","126.68333","35.095","106.66666","114.14999","91.64999","104.33333","106.8","140.7","35.23333","69.2","158.65","67.05","75.98333","85.31666","88.36666","92.83333","101.7","110.33333","47.98333","113.58333","150.8","119.39999","121","58.58333","33.36666","87.11666","82.91666","73.4","51.35","104.91666","109.33333","125.75","51.53333","65.46666","96.16666","46.71666","142.7","66.8","126.96666","121.46666","103.85","121.5","69.3","44.81666","51.43333","89.64999","139.74472","106.88333","87.58333","102.6","131.93333","129.66666","60.6","44.5","-25.66667","-64.76667","-15.4","-23.51667","-6.76667","-16.9","-21.85","-36.53334","-5.7","-57.85","138.58333","153.03333","141.45","143.86666","130.83333","128.86666","147.31666","149","159.08333","144.96666","151.21666","4.9","1.51666","23.71666","20.5","13.36666","17.11666","4.33333","26.1","19.08333","28.83333","12.58333","-6.25","-5.35","-2.53334","24.96666","-4.46667","28.96666","-2.11667","20.5","30.51666","-9.13334","14.51666","6.15","-3.68334","14.51666","19.95","27.56666","7.38333","37.58333","10.75","2.33333","19.26666","14.43333","24.1","12.48333","50.15","12.46666","18.41666","34.1","21.43333","23.31666","18.05","24.75","19.83333","22.3","9.51666","12.45305","16.33333","25.31666","44.41666","21","15.96666","35.16666","8.53333","47.51666","72.41666","105.71666","96.91666","43.26666","70.2175","55.46666","73.5","57.5","45.23333","55.46666","-171.73334","174.76666","-176.55001","151.78333","-109.43334","168.41666","-171.08334","-171.23334","178.41666","179.21666","-89.6","-134.95","160.2","144.75","-157.85834","-169.51667","-157.33334","162.98333","167.33333","171.2","-139.5","-177.36667","166.91666","-169.91667","167.96666","166.45","-170.7","134.48333","-130.08334","158.21666","147.16666","-159.76667","145.75","-149.56667","173","-175.16667","166.61666","-176.16667","115.85","2.535","113.46666","135.55388","153.71666","143.22666","8.68333","155.56666","  "];
$nearoffset=array();
$neartnow=array();
$seltz="";
$wparts=[];

$seltz="<select onchange='tzsuffix=calcofftimenow(this,String.fromCharCode(32));' style='display:none' id='seltz'><option value=''>Please select a Time Zone place ...</option></select>";
if (1 == 1) {
for ($ik=0; $ik<((sizeof($nearname) * 1) / 1 - 2); $ik++) {
  if (substr($nearlatitude[$ik],0,1) != " ") {
    $origin_dtz = new DateTimeZone("Europe/London");  // Thanks to //php.net/manual/en/function.timezone-offset-get.php
    $remote_dtz = new DateTimeZone($nearname[$ik]);
    $origin_dt = new DateTime("now", $origin_dtz);
    $remote_dt = new DateTime("now", $remote_dtz);
    if (1 == 1) {   // better idea is ...
    $bnow = new DateTime(null, $remote_dtz);
    $offset = $bnow->getOffset() / 3600.0;
    } else {
    $offset = ($remote_dtz->getOffset($remote_dt) - $origin_dtz->getOffset($origin_dt)) / 3600.0;  
    }
    array_push($nearoffset, $offset);  
    array_push($neartnow, $remote_dt->format('Y/m/d/H:i'));  
    $aseltz=explode("/",$nearname[$ik]);
    //array_push($neartnow, $remote_dt->format('H:i'));  
    //$aseltz=explode("/",$nearname[$ik]);
    $seltz=str_replace("</select>", "<option value='" . str_replace("_"," ",$aseltz[-1 + sizeof($aseltz)]) . "' title='|" . str_replace("+-","-",("+" . $offset)) . "|" . $remote_dt->format('Y/m/d/H:i') . ";" . $nearlatitude[$ik] . "," . $nearlongitude[$ik] . "'>" . $nearname[$ik] . "</option>"  . "</select>",$seltz);
  }
}
}


  if (file_exists("csv.php")) {
    include "csv.php";
  } else if (file_exists("../csv.php")) { 
    include "../csv.php";
  }
  function retval($inv) {
    if (strpos($inv, "E-") !== false) return "0";
    return $inv;
  }

  function dlltf($gettzname, $getgmtoff, $getrightnow, $dllmode, $dllbitsmode, $tzais, $lastpar) {
      global $dllt, $dlltbits, $nearname, $nearoffset, $neartnow, $dllw, $dllwbits;
      $getweather=$lastpar;
      if ($dllmode >= 0 && $dllbitsmode >= 0) {
       $dllarr=explode("|", $dllt);
       $dllbitsarr=explode("|", $dlltbits);
       if (sizeof($dllarr) > $dllmode && sizeof($dllbitsarr) > $dllbitsmode) {
        return $dllarr[$dllmode] . "|" . $dllbitsarr[$dllbitsmode];
       } else if (sizeof($dllarr) > $dllmode) {
        return $dllarr[$dllarr] . "|";
       } else if (sizeof($dllbitsarr) > $dllbitsmode) {
        return "|" . $dllbitsarr[$dllbitsarr];
       } else {
        return "|";
       }
      } else if ($dllmode >= 0) {
       $dllarr=explode("|", $dllt);
       if (sizeof($dllarr) > $dllmode) {
        return $dllarr[$dllmode];
       } else {
        return "";
       }
      } else if ($dllbitsmode >= 0) {
       $dllbitsarr=explode("|", $dlltbits);
       if (sizeof($dllbitsarr) > $dllbitsmode) {
        return $dllbitsarr[$dllbitsmode];
       } else {
        return "";
       }
      } else {
       //echo "\n1: ... " . $zdllarr[0] . " ... " . $zdllarr[1] . " ... " . $zdllarr[2] . " ... " . $zdllarr[3] . " ... " . " getgmtoff,gettzname,getrightnow=" . $getgmtoff . ' ... ' . $gettzname . ' ... ' . $getrightnow;
       if (str_replace("?","",$getgmtoff) == "") {
         if (array_search($gettzname, $nearname) !== false) {
           $getgmtoff=$nearoffset[array_search($gettzname, $nearname)];
           if (str_replace("?","",$getrightnow) == "") {
            $getrightnow=$neartnow[array_search($gettzname, $nearname)];
           }
         }
       } 
       if (str_replace("?","",$getrightnow) == "") {
         if (array_search($gettzname, $nearname) !== false) {
           $getrightnow=$neartnow[array_search($gettzname, $nearname)];
         }
       } 
       //echo "\n2: getgmtoff,gettzname,getrightnow=" . $getgmtoff . ' ... ' . $gettzname . ' ... ' . $getrightnow;
       if ($getgmtoff != "" && $gettzname != "") {
        $arrdll=explode("|", $dllt);
        if ($dllt != "") $dllt.="|";
        if ($dlltbits != "") {
          $dlltbits.=" else if (ir == " . $tzais . ") { ";
        } else {
          $dlltbits=" if (ir == " . $tzais . ") { ";
        }
        if ($getrightnow != "") {
         $huhw=explode("http", $getrightnow);
         if (sizeof($huhw) > 1) {
           $getnonw=$huhw[0];
           if ($getweather == "") $getweather=str_replace($getnonw . "http", "http", $getrightnow);
           $getrightnow=$getnonw;
         }
         if (strpos($gettzname,"/") === false && strpos($getgmtoff, ":") !== false) {
           $spareg=$gettzname;
           $gettzname=$getrightnow;
           $getrightnow=$getgmtoff;
           $getgmtoff=$spareg;
         }
         $dlltm="TimeZone " . $gettzname . " (GMT " . str_replace("+-","-",("+" . $getgmtoff)) . ") (where it is " . $getrightnow . ") Information=T";
         $dllt.=$dlltm; //"TimeZone " . $gettzname . " (GMT " . str_replace("+-","-",("+" . $getgmtoff)) . ") (where it is " . $getrightnow . ") Information=T";
        } else {
         $dlltm="TimeZone " . $gettzname . " (GMT " . str_replace("+-","-",("+" . $getgmtoff)) . ") Information=T";
         $dllt.=$dlltm; //"TimeZone " . $gettzname . " (GMT " . str_replace("+-","-",("+" . $getgmtoff)) . ") Information=T";
        }
        $dlltbitsm="window.open('HTTP://timezoneconverter.com/cgi-bin/zoneinfo?tz=" . urldecode($gettzname) . "','_blank');";
        $dlltbits.=$dlltbitsm; //"window.open('HTTP://timezoneconverter.com/cgi-bin/zoneinfo?tz=" . urldecode($gettzname) . "','_blank');";
        echo "\n" . ' if (' . $tzais . ' >= 0) {  while (tzarr.length < ' . $tzais . ') { tzbrr.push(""); tzbrrbits.push(""); tzarr.push(""); tzarrbits.push("");  }  } ' . "\n" . ' tzarr.push("' . $dlltm . '"); ' . "\n";
        echo "\n" . ' tzarrbits.push("' . $dlltbitsm . '"); ' . "\n";

        if (strpos($dllwbits, "'',") !== false) $dllwbits="";

        if ($dllw != "") {
         $dllw.="|";
        } 

        if ($getweather != "") {
         $dllw.="Weather=W";
         $zdlltbitsm="window.open('" . $getweather . "','_blank');";
        if ($dllwbits != "") {
          $dllwbits.=" else if (ir == " . $tzais . ") { ";
        } else {
          $dllwbits=" if (ir == " . $tzais . ") { ";
        }
        $dllwbits.=$zdlltbitsm;
         echo "\n" . ' tzbrrbits.push("' . $zdlltbitsm . '"); tzbrr.push("Weather=W");  ' . "\n";
        } else {
          echo "\n" . ' tzbrrbits.push(""); tzbrr.push(""); ' . "\n";
        }

        $dlltbits.=" } ";
        if (strpos($dllwbits, "if (ir") !== false) $dllwbits.="   } ";
      // }
      } else {
       $arrdll=explode("|", $dllt);
       $dllt.="|";
       if ($dlltbits != "") {
          $dlltbits.=" else if (ir == " . $tzais . ") { ir=ir; } ";
       } else {
          $dlltbits=" if (ir == " . $tzais . ") { ir=ir } ";
       }
      }
      }
      return "";
  }

  function whereinwparts($wpa, $sf) {
   global $wparts;
   $rq=-1;
   for ($irq=0; $irq<sizeof($wpa); $irq++) {
     if (strpos($wpa[$irq], $sf) !== false) {
       $wparts[$irq]="";
       return $irq;
     }
   }
   return $rq;
  }

  function tzlook($inwithtz) {  // am expecting PlaceName|TimeZoneName|GMTOffset|TimeRightNow from inside data 
   global $dllt, $dlltbits, $wparts, $dllw, $dllwbits;
   if (strpos($inwithtz, "]") === false) {
      $inwithtz=urldecode($inwithtz);
   }
   $outwithouttz=$inwithtz;
   $wparts=explode("]", $inwithtz);
   if (strpos($inwithtz, "|") !== false) {
     if ($dllt == "") {
       $withinbar=explode("|", $inwithtz);

           $gweather="";
           for ($iiz=0; $iiz<sizeof($withinbar); $iiz++) {
             if (strpos($withinbar[$iiz], "http") !== false && $gweather == "") {
           $zhuhw=explode("http", (";" . $withinbar[$iiz]));
           $zgetnonw=$zhuhw[0];
           $gweather=str_replace($zgetnonw . "http", "http", (";" . $withinbar[$iiz]));
           $inwithtz=str_replace($gweather,"",$inwithtz);
           $withinbar=explode("|", $inwithtz);
           //echo "\ngetweather=" . $getweather;
             }
           }

       $outwithouttz=$withinbar[0];
       if (strpos($inwithtz, "|" . "+") === false && strpos($inwithtz, "|" . " ") === false && strpos($inwithtz, "|" . "?") === false && strpos($inwithtz, "|" . "-") === false && strpos($inwithtz, "|" . "0") === false) {
       for ($iwb=1; $iwb<sizeof($withinbar); $iwb+=1) {
         if (strpos($withinbar[$iwb + 0], "~") !== false) {
          $withoutbar=explode("~", $withinbar[$iwb + 0]);
          $outwithouttz.=str_replace($withoutbar[0],"",$withinbar[$iwb + 0]);
          dlltf($withoutbar[0], "?", "?", -1, -1, whereinwparts($wparts, $withoutbar[0]), $gweather);
         } else if (strpos($withinbar[$iwb + 0], '"') !== false) {
          $withoutbar=explode('"', $withinbar[$iwb + 0]);
          $outwithouttz.=str_replace($withoutbar[0],"",$withinbar[$iwb + 0]);
          dlltf($withoutbar[0], "?", "?", -1, -1, whereinwparts($wparts, $withoutbar[0]), $gweather);
         } else if (strpos($withinbar[$iwb + 0], "'") !== false) {
          $withoutbar=explode("'", $withinbar[$iwb + 0]);
          $outwithouttz.=str_replace($withoutbar[0],"",$withinbar[$iwb + 0]);
          dlltf($withoutbar[0], "?", "?", -1, -1, whereinwparts($wparts, $withoutbar[0]), $gweather);
         } else {
          $outwithouttz.="";
         }
       }
       } else { 
       for ($iwb=1; $iwb<sizeof($withinbar); $iwb+=3) {
         if (strpos($withinbar[$iwb + 2], "~") !== false) {
          $withoutbar=explode("~", $withinbar[$iwb + 2]);
          $outwithouttz.=str_replace($withoutbar[0],"",$withinbar[$iwb + 2]);
          dlltf($withinbar[$iwb], $withinbar[$iwb + 1], $withoutbar[0], -1, -1, whereinwparts($wparts, $withinbar[$iwb]), $gweather);
         } else if (strpos($withinbar[$iwb + 2], '"') !== false) {
          $withoutbar=explode('"', $withinbar[$iwb + 2]);
          $outwithouttz.=str_replace($withoutbar[0],"",$withinbar[$iwb + 2]);
          dlltf($withinbar[$iwb], $withinbar[$iwb + 1], $withoutbar[0], -1, -1, whereinwparts($wparts, $withinbar[$iwb]), $gweather);
         } else if (strpos($withinbar[$iwb + 2], "'") !== false) {
          $withoutbar=explode("'", $withinbar[$iwb + 2]);
          $outwithouttz.=str_replace($withoutbar[0],"",$withinbar[$iwb + 2]);
          dlltf($withinbar[$iwb], $withinbar[$iwb + 1], $withoutbar[0], -1, -1, whereinwparts($wparts, $withinbar[$iwb]), $gweather);
         } else {
          $outwithouttz.="";
         }
       }
       }
     }
   }
   return $outwithouttz;
  }

?>
<html>
  <head> 
    <title>Map - RJM Programming - //www.rjmprogramming.com.au (Copyright &copy; 2013 rjmprogramming.com.au all rights reserved.)</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">

   var dllw='', dllt='', dllwbits='', dlltbits='', dllc='Draw Link Lines=D', lastel=null, ifoeo='', x=-1, y=-1, prevx=-1, prevy=-1, posx=-1, posy=-1, elemLeft=0, elemTop=0, ir=-1, ic=-1, talkingpoint='', lcnt=0, lasttrip='', thisplace='', lastplace='';   

   var tzarr=[], tzarrbits=[], tzbrr=[], tzbrrbits=[], tzsuffix='', tzoffs=[], tztns=[];

   var datalineprefix='', datalineprefix2='';

<?php echo "\n var topdocumentURL='" . $_SERVER['HTTP_REFERER'] . "'; \n"; ?>

function jnocomm(inwcr) {
    outwcr=inwcr;
    outa=inwcr.split("/" + "/ ");
    if (outa.length > 1) {
      newa=outa[0];
      for (ij=1; ij<outa.length; ij++) {
        if (outa[ij].indexOf(String.fromCharCode(10)) != -1) {
          newa+=outa[ij].replace(outa[ij].split(String.fromCharCode(10))[0] +  String.fromCharCode(10), String.fromCharCode(10)); 
        } else {
          newa+=outa[ij].replace(outa[ij].split(".")[0] + ".", ""); 
        }
      }
      outwcr=newa;
    }
    while (outwcr.indexOf(String.fromCharCode(10)) != -1) {
      outwcr=outwcr.replace(String.fromCharCode(10), " ");
    }
    while (outwcr.indexOf('"') != -1) {
      outwcr=outwcr.replace('"', "'");
    }
    while (outwcr.indexOf('+') != -1) {
      outwcr=outwcr.replace('+', ' ');
    }
    if ((outwcr.trim() + " ").substring(0,1) != ',') {
    return ("," + outwcr).replace('};','');
    } else {
    return outwcr.replace('};','');
    }
}


function calcofftimenow(osels,sugg) {
  var rva="";
  if (sugg == '') {
    osels.value='';
  } else if (sugg.replace(' ','') != '') {
    if (osels.innerHTML.indexOf('="' + sugg.split('|')[0] + '"') != -1) {
     osels.value=sugg.split('|')[0];
    } else {
     osels.value='';
    }
  } 
  if (osels.value != "") {
    var lalo=osels.options[osels.selectedIndex].title;
    var asugg=sugg.split('|');
    if (asugg.length < 3) {
     if (lalo.indexOf(';') != -1) {
      rva="|" + osels.options[osels.selectedIndex].text + lalo; 
     } else {
      rva="|" + osels.options[osels.selectedIndex].text + "|+0|00:00;" + lalo; 
     }
    }
  }
  tzsuffix=rva;
  return rva;
}

  function ourprompt(ourp1, ourp2) {
      var ourp1lines=ourp1.split(String.fromCharCode(10));
      if (ourp1lines.length > 10) {
         if (navigator.userAgent.match(/Android/i)) { 
           while (ourp1.indexOf(String.fromCharCode(10)) != -1) {
             ourp1=ourp1.replace(String.fromCharCode(10), '  ');
           }
           ourp1=ourp1.replace('Is there something you want to try with ','Options for ');
           ourp1=ourp1.replace('Comma Separated Values Spreadsheet Export','CSV Export');
           ourp1=ourp1.replace('Email with or without Talking Point','Email');
           ourp1=ourp1.replace('else leave as blank or as is or choose Cancel to leave the status quo.','else ...');
           ourp1=ourp1.replace('Moon Angle at Noon','Moon Angle');
           ourp1=ourp1.replace('(where it is ','(');
         } 
      } 
      return prompt(ourp1, ourp2); 
  }

function giveandtake(dpr) {
   if (dpr.indexOf('|') != -1 && dpr.indexOf(';') != -1) {
      if (datalineprefix2 != '') {
      datalineprefix2+=dpr.split(';')[0];
      } else {
      datalineprefix+=dpr.split(';')[0];
      }
      return dpr.split(';')[1];
   }
   return dpr;
}

function ourencodeURIComponent(insis) {
  var outsis=encodeURIComponent(insis), ebits;
  var kbits=insis.split('&');
  var jbits=insis.split('=');
  var altsis='';
  if (eval(kbits.length) > 1 && eval(jbits.length) > 1 && eval(kbits.length) == eval(jbits.length) && eval(jbits[0].length) > eval(kbits[0].length)) {
    altsis=encodeURIComponent(kbits[0]);
    for (var iu=1; iu<eval(jbits.length); iu++) {
        ebits=kbits[iu].split('=');
        altsis+='&' + ebits[0] + '='; // &title=
        altsis+=encodeURIComponent(ebits[1]);  // hello
    }
  }
  if (altsis != '') return altsis;
  return outsis;
}

function maybeir(indl, inir) {
  if (tzarr.length > inir) {
    if (tzarr[inir] != "") {
     return tzarr[inir] + String.fromCharCode(10);
    } else {
     return "";
    }
  } else if (tzarr.length <= inir && dllt != "") {
    return "";
  }
  return indl;
}

function maybeirw(indl, inir) {
  if (tzbrr.length > inir) {
    if (tzbrr[inir] != "") {
     return tzbrr[inir] + String.fromCharCode(10);
    } else {
     return "";
    }
  } else if (tzbrr.length <= inir && dllw != "") {
    return "";
  }
  return indl;
}

function handleStart(evt) {
  evt.preventDefault();
  more(lastel, 1);
}

function draw_a_line() {
  lcnt++;
  //document.getElementById('xydiv').innerHTML+='<svg height="' + Math.abs(y - prevy) + '" width="' + Math.abs(x - prevx) + '" title="' + lasttrip + '" id="sl' + lcnt + '"  style="position:absolute;z-index:8;margin-top:0px;margin-left:0px;" xmlns="//www.w3.org/2000/svg"><line title="' + lasttrip + '" id="l' + lcnt + '" onclick="more(this);" style="stroke:red;stroke-width:4;" x1="' + prevx + '" y1="' + prevy + '" x2="' + x + '" y2="' + y + '" /></svg>';
  //document.getElementById('xydiv').innerHTML+='<svg id="sl' + lcnt + '"  style="position:absolute;z-index:8;margin-top:0px;margin-left:0px;top:' + prevy + 'px;" xmlns="//www.w3.org/2000/svg"><g><title>' + lasttrip + '</title><line id="l' + lcnt + '" onmouseover="more(this,0);" onclick="more(this,1);" style="stroke:red;stroke-width:4;" x1="' + prevx + '" y1="' + 0 + '" x2="' + x + '" y2="' + eval(y - prevy) + '" /></g></svg>';
  document.getElementById('xydiv').innerHTML='<svg id="sl' + lcnt + '"  style="position:absolute;z-index:8;margin-top:0px;margin-left:0px;top:' + prevy + 'px;" xmlns="//www.w3.org/2000/svg"><g><title>' + distmore(lasttrip) + '</title><line id="l' + lcnt + '" onmouseover="more(this,0);" onclick="more(this,1);" style="stroke:red;stroke-width:4;" x1="' + prevx + '" y1="' + 0 + '" x2="' + x + '" y2="' + eval(y - prevy) + '" /></g></svg>';
  lastel=document.getElementById(document.getElementById('l' + lcnt));
  if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { 
    lastel.addEventListener("touchstart", handleStart, false);  // idea via https://developer.mozilla.org/en-US/docs/Web/API/Touch_events
  }
  more(lastel, 0);
}

<?php  
      $opa='';     
      $dllc='Draw Link Lines=D';
      $dllw='';
      $dllt='';
      $dllwbits='';
      $dlltbits='';
      $wlok=true;
        if (isset($_GET['rightnow'])) {
          if (strpos($_GET['rightnow'], "http") !== false) $wlok=false;
        } else if (isset($_POST['rightnow'])) {
          if (strpos($_POST['rightnow'], "http") !== false) $wlok=false;
        }
      if (isset($_GET['wlink']) && $wlok) $dllw="Weather=W";
      if (isset($_POST['wlink']) && $wlok) $dllw="Weather=W";
      if (isset($_GET['gmtoff']) && isset($_GET['tzname'])) {
        if (isset($_GET['rightnow'])) {
         $dllt="TimeZone " . urldecode($_GET['tzname']) . " (GMT " . str_replace("+-","-",("+" . $_GET['gmtoff'])) . ") (where it is " . urldecode($_GET['rightnow']) . ") Information=T";
        } else {
         $dllt="TimeZone " . urldecode($_GET['tzname']) . " (GMT " . str_replace("+-","-",("+" . $_GET['gmtoff'])) . ") Information=T";
        }
        $dlltbits="window.open('HTTP://timezoneconverter.com/cgi-bin/zoneinfo?tz=" . urldecode($_GET['tzname']) . "','_blank');";
      }
      if (isset($_POST['gmtoff']) && isset($_POST['tzname'])) {
        if (isset($_POST['rightnow'])) {
         $dllt="TimeZone " . urldecode($_POST['tzname']) . " (GMT " . str_replace("+-","-",("+" . $_POST['gmtoff'])) . ") (where it is " . urldecode($_POST['rightnow']) . ") Information=T";
        } else {
         $dllt="TimeZone " . urldecode($_POST['tzname']) . " (GMT " . str_replace("+-","-",("+" . $_POST['gmtoff'])) . ") Information=T";
        }
        $dlltbits="window.open('HTTP://timezoneconverter.com/cgi-bin/zoneinfo?tz=" . urldecode($_POST['tzname']) . "','_blank');";
      }
      if (isset($_GET['wlink']) && $wlok) $dllwbits="window.open('" . urldecode($_GET['wlink']) . "','_blank');";
      if (isset($_POST['wlink']) && $wlok) $dllwbits="window.open('" . urldecode($_POST['wlink']) . "','_blank');";
      $GETtp="";
      if (isset($_GET['tp'])) $GETtp = urldecode($_GET['tp']);
      if (isset($_POST['tp'])) $GETtp = urldecode($_POST['tp']);
      if ($GETtp != "") echo "\n talkingpoint=String.fromCharCode(10) + String.fromCharCode(10) + " . '"' . str_replace("`", '" + String.fromCharCode(10) + "', str_replace("\n", '" + String.fromCharCode(10) + "', $GETtp)) . '"' . " + String.fromCharCode(10) + String.fromCharCode(10); \n";

      $GETr = "";
      $GETc = "";
      if (isset($_GET['r'])) $GETr = urldecode($_GET['r']);
      if (isset($_POST['r'])) $GETr = urldecode($_POST['r']);
      if (isset($_GET['c'])) $GETc = urldecode($_GET['c']);
      if (isset($_POST['c'])) $GETc = urldecode($_POST['c']);
      if ($GETr != "") echo "\n ir=eval('" . $GETr . "'); \n";
      if ($GETc != "") echo "\n ic=eval('" . $GETc . "'); \n";

      $GETx = "";
      $GETy = "";
      if (isset($_GET['x'])) $GETx = urldecode($_GET['x']);
      if (isset($_POST['x'])) $GETx = urldecode($_POST['x']);
      if (isset($_GET['y'])) $GETy = urldecode($_GET['y']);
      if (isset($_POST['y'])) $GETy = urldecode($_POST['y']);
      if ($GETx != "" && $GETy != "") {
        echo "\n x=eval('" . $GETx . "'); \n";
        echo "\n y=eval('" . $GETy . "'); \n";
      }

      $GETtitle = "Places";
      $GETlabel = "['Lat',";
      $GETvalue = "'Lon', 'Name']";
      $GETdata = ",[37.4232, -122.0853, 'Work'],[37.4289, -122.1697, 'University'],[37.6153, -122.3900, 'Airport'],[37.4422, -122.1731, 'Shopping']";
            
      if (isset($_GET['value'])) {
       $GETtitle = $_GET['title'];
       $GETlabel = str_replace("\\","",$_GET['label']);
       $GETvalue = str_replace("\\","",$_GET['value']);
       $GETdata = tzlook($_GET['data']);
      } else if (isset($_POST['value'])) {
       $GETtitle = urldecode($_POST['title']);
       $GETlabel = str_replace("\\","",urldecode($_POST['label']));
       $GETvalue = str_replace("\\","",urldecode($_POST['value']));
       $GETdata = tzlook(urldecode($_POST['data']));
      }
      
      
      $hdgs = split(",", $GETvalue);
      $GETval = "";
      if (isset($hdgs[0])) $GETval = "'" . str_replace("'", "", $hdgs[0]) . "'";
      if (isset($hdgs[1])) $GETval .= ",'" . str_replace("'", "", $hdgs[1]) . "'";
      if (isset($hdgs[2])) $GETval .= ",'" . str_replace("'", "", $hdgs[2]) . "'";
      if (isset($hdgs[3])) $GETval .= ",'" . str_replace("'", "", $hdgs[3]) . "'";
      
      $ifoeo="";
      
      echo "var data, chart, pardata = (location.search.split('data=')[1] ? location.search.split('data=')[1].split('&')[0] : ''), paramdata=decodeURIComponent(pardata);\n";
      echo "var xparamdata=\"" . str_replace('"',"'",$GETdata) . "\";\n";
      $GETonclick = "";
      if (isset($_GET['onclick'])) $GETonclick = urldecode($_GET['onclick']) + " ";
      if (isset($_POST['onclick'])) $GETonclick = urldecode($_POST['onclick']) + " ";
      $GETlines = "";
      $GETlinescall = "";
      if (isset($_GET['lines'])) $GETlines = "\n if (eval(prevx) >= 0 && eval(prevy) >= 0 && eval(x) >= 0 && eval(y) >= 0) { setTimeout(draw_a_line,500); } \n";
      if (isset($_POST['lines'])) $GETlines =  "\n if (eval(prevx) >= 0 && eval(prevy) >= 0 && eval(x) >= 0 && eval(y) >= 0) { setTimeout(draw_a_line,500); } \n";
      if ($GETlines != "") $GETlinescall = "\n postcollectclick(olat + '~' + olong + '~' + oplace); \n";
      if ($GETlines != "") $dllc='Link Lines Pen Up=D';
      if ($GETlines != "") $opa='opacity:0.8;';
      echo "\n dllc='" . $dllc . "'; \n";
      if ($dllw != "") echo "\n dllw='" . $dllw . "' + String.fromCharCode(10) + String.fromCharCode(10); \n tzbrr.push(dllw); \n";
      if ($dllwbits != "") echo "\n dllwbits=\"" . str_replace('"',"'",$dllwbits) . "\" + String.fromCharCode(10) + String.fromCharCode(10); \n tzbrrbits.push(dllwbits); \n";
      if ($dllt != "") echo "\n dllt='" . $dllt . "' + String.fromCharCode(10) + String.fromCharCode(10); \n tzarr.push(dllt); \n";
      if ($dlltbits != "") echo "\n dlltbits=\"" . str_replace('"',"'",$dlltbits) . "\" + String.fromCharCode(10) + String.fromCharCode(10); \n tzarrbits.push(dlltbits); \n";
      echo " var selonclick='" . $GETonclick . str_replace("\n","",$GETlines) . "';\n";
      echo " google.load('visualization', '1', {packages:['map']}); " . "\n";
      echo ' google.setOnLoadCallback(drawChart); ' . "\n";
      echo ' function drawChart() { ' . "\n";
 if ((isset($_GET['value']) || isset($_POST['value'])) && (isset($_GET['tooltip']) || isset($_POST['tooltip']) || strpos($GETdata, "'") !== false || strpos($GETdata, '"') !== false)) {
  echo "     data = new google.visualization.DataTable(); /" . "/" . $GETlabel . $GETvalue . " \n";
  echo "   data.addColumn('number', '" . str_replace("'","",str_replace(",","",str_replace("['","",$GETlabel))) . "');  \n";
  //echo "   data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}});  \n";
  echo "   data.addColumn('number', " . str_replace(",", "); data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}}); data.addColumn('string', ", str_replace("]","",$GETvalue)) . ");  \n";
  echo " data.addRows([ \n";
      echo str_replace("''" . "''", "''", str_replace("~", "'", substr($GETdata,1)));
  echo "   ]); \n";
 } else {
      echo ' data = google.visualization.arrayToDataTable([ ' . "\n";
      echo " " . $GETlabel . $GETvalue . " \n";
      echo str_replace("''" . "''", "''", str_replace("~", "'", $GETdata));
      echo "        ]);\n";
 }
      
      //echo "        var options = { \n";
      //if (isset($hdgs[3])) {
      //echo "        title: '" . $GETtitle . "', \n";
      //echo "        hAxis: {title: '" . $hdgs[0] . "'}," . " \n";
      //echo "        vAxis: {title: '" . $hdgs[1] . "'}," . " \n";
      //echo "        Map: {textStyle: {fontSize: 11}} \n";
      //} else {
      //echo "        colorAxis: {colors: ['yellow', 'red']} \n";
      //}
      //echo "       }; \n";

      
      if ($GETlines != "" && (!isset($_GET['onclick']) && !isset($_POST['onclick']))) $ifoeo=" if (1 == 2) ";
      
      echo "\n ifoeo='" . $ifoeo . "'; \n";


      echo " chart = new google.visualization.Map(document.getElementById('chart_div')); \n";
      //echo " chart.draw(data, {showTip: true, focusTarget: 'category', tooltip: {isHtml: true}}); \n } \n";
      //echo " chart.draw(data, {focusTarget: 'category',  tooltip: {isHtml: true}, showTip: true}); \n } \n";
      //echo " chart.draw(data, {focusTarget: 'category',  tooltip.isHtml: true, showTip: true}); \n } \n";
      //echo " chart.draw(data, { tooltip: {isHtml: true}, showTip: true }); \n } \n";
      $GEToptions = "";
      if (isset($_GET['options'])) $GEToptions = urldecode($_GET['options']);
      if (isset($_POST['options'])) $GEToptions = urldecode($_POST['options']);
  if (isset($_POST['custom_map'])) {
      $options_suffix=nocomm(urldecode($_POST['custom_map']));
  } else if (isset($_GET['custom_map'])) {
      $options_suffix=nocomm(urldecode($_GET['custom_map']));
  }
  
  
  
  
  echo " if (top.document.URL.indexOf('rjmprogramming.com.au/HTMLCSS/other_side_of_the_world.htm') != -1) {  chart.draw(data, { useMapTypeControl:true, tooltip: {isHtml: true}" . $GEToptions . $options_suffix . ", showTip: true,  icons: { default: { normal: 'https://icons.iconarchive.com/icons/icons-land/vista-map-markers/48/Map-Marker-Ball-Azure-icon.png', selected: 'https://icons.iconarchive.com/icons/icons-land/vista-map-markers/48/Map-Marker-Ball-Right-Azure-icon.png' } }   ,maps: { styledMap: { name: 'Styled Map', styles: [ {featureType: 'poi.attraction', stylers: [{color: '#fce8b2'}] }, {featureType: 'road.highway', stylers: [{hue: '#0277bd'}, {saturation: -50}] }, {featureType: 'road.highway', elementType: 'labels.icon', stylers: [{hue: '#000'}, {saturation: 100}, {lightness: 50}] }, {featureType: 'landscape', stylers: [{hue: '#259b24'}, {saturation: 10}, {lightness: -22}] } ]}} });  } else { chart.draw(data, { useMapTypeControl:true, tooltip: {isHtml: true}" . $GEToptions . $options_suffix . ", showTip: true  }); } \n"; // } \n";
  $cssis="";
      if ($GETr != "" && $GETc == "") $cssis=" if (1 == 2) { chart.setSelection([{'row': " . $GETr . "}]); } setTimeout(selectHandler,4100); \n";
      if ($GETr == "" && $GETc != "") $cssis=" if (1 == 2) { chart.setSelection([{'column': " . $GETc . "}]); }  setTimeout(selectHandler,4100); \n";
      if ($GETr != "" && $GETc != "") $cssis=" if (1 == 2) { chart.setSelection([{'row': " . $GETr . ", 'column': " . $GETc . "}]); }  setTimeout(selectHandler,4100); \n";

echo "
 if (selonclick != '') { " . $cssis . "
  google.visualization.events.addListener(chart, 'select', selectHandler);
 }
}

function getirplace(idea) {
  var qpbirs=paramdata.split('[');
  if (paramdata == '') qpbirs=xparamdata.split('[');
  var xqpbirs;
  if (eval(1 + ir) >= qpbirs.length) {
    //alert(paramdata);
    return idea;
  }
  if (qpbirs[eval(1 + ir)].indexOf('~') != -1) {
    xqpbirs=qpbirs[eval(1 + ir)].split('~');
    return xqpbirs[1];
  }
  return qpbirs[eval(1 + ir)].split(',')[2];
}

function getirlat(idea) {
  var qpbirs=paramdata.split('[');
  if (paramdata == '') qpbirs=xparamdata.split('[');
  if (eval(1 + ir) >= qpbirs.length) {
    //alert(paramdata);
    return idea;
  }
  return qpbirs[eval(1 + ir)].split(',')[0];
}

function getirlong(idea) {
  var qpbirs=paramdata.split('[');
  if (paramdata == '') qpbirs=xparamdata.split('[');
  if (eval(1 + ir) >= qpbirs.length) {
    //alert(paramdata);
    return idea;
  }
  return qpbirs[eval(1 + ir)].split(',')[1];
}

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 //en.wikipedia.org/wiki/Great-circle_distance ... thanks
  ourdist = eval(Math.round((Math.acos(acof) * 6371000.0) + 0.00001) * 100) / 100;
  return ourdist;
}

function distmore(tofrominfo1) {
    var twoplaces=tofrominfo1.split('_');
    if (twoplaces.length > 1 && tofrominfo1.indexOf(' km)') == -1) {
     for (var ipl=1; ipl<twoplaces.length; ipl++) {
       qbitsare=twoplaces[eval(-1 + ipl)].split('~');
       qlatfrom=eval(qbitsare[0]);
       qlongfrom=eval(qbitsare[1]);
       qplacefrom=twoplaces[eval(-1 + ipl)].replace(qlatfrom + '~' + qlongfrom + '~','').replace(/~/g, ' ');
       qbitsare=twoplaces[ipl].split('~');
       qlatto=eval(qbitsare[0]);
       qlongto=eval(qbitsare[1]);
       qplaceto=twoplaces[ipl].replace(qlatto + '~' + qlongto + '~','').replace(/~/g, ' ');
       var dis=Math.floor(eval(eval(0.001 * great_circle_distance(qlatfrom,qlongfrom,qlatto,qlongto)) + 0.5));
       return tofrominfo1 + ' (' + dis + ' km)';
     }
    }
    return tofrominfo1;
}

function more(svgo,dmode) {
  var qlatfrom=0, qlongfrom=0, qplacefrom='', qlatto=0, qlongto=0, qplaceto='', qbitsare, dih='', dihs, ds;
  if (svgo) {
  dihs=document.body.innerHTML.split('<svg id=' + String.fromCharCode(34) + 's' + svgo.id + '' + String.fromCharCode(34) + '');
  if (dihs.length > 1) {
  dih=dihs[1];
  } else if (document.getElementById('s' + svgo.id)) {
  dih=document.getElementById('s' + svgo.id).innerHTML;
  } 
  var tofrominfo=dih.replace('</title>','<title>').split('<title>');
  if (tofrominfo.length > 1) {
    var twoplaces=tofrominfo[1].split('_');
    if (twoplaces.length > 1) {
     for (var ipl=1; ipl<twoplaces.length; ipl++) {
       qbitsare=twoplaces[eval(-1 + ipl)].split('~');
       qlatfrom=eval(qbitsare[0]);
       qlongfrom=eval(qbitsare[1]);
       qplacefrom=twoplaces[eval(-1 + ipl)].replace(qlatfrom + '~' + qlongfrom + '~','').replace(/~/g, ' ');
       qbitsare=twoplaces[ipl].split('~');
       qlatto=eval(qbitsare[0]);
       qlongto=eval(qbitsare[1]);
       qplaceto=twoplaces[ipl].replace(qlatto + '~' + qlongto + '~','').replace(/~/g, ' ');
       if (qplaceto.indexOf(' km)') != -1 && qplaceto.indexOf(' (') != -1) {
         ds=qplaceto.split(' (');
         qplaceto=ds[0];
       }
       if (Math.floor(eval(eval(0.001 * great_circle_distance(qlatfrom,qlongfrom,qlatto,qlongto)) + 0.5)) > 0) {
       if (dmode == 0) {
        document.title=Math.floor(eval(eval(0.001 * great_circle_distance(qlatfrom,qlongfrom,qlatto,qlongto)) + 0.5)) + ' kilometres separate ' + qplacefrom + ' (' + qlatfrom + ',' + qlongfrom + ') from ' + qplaceto + ' (' + qlatto + ',' + qlongto + ') as the crow flies.';
        document.getElementById('dh1').innerHTML='<font size=1>' + 'As the crow flies it is ' + Math.floor(eval(eval(0.001 * great_circle_distance(qlatfrom,qlongfrom,qlatto,qlongto)) + 0.5)) + ' kilometres from ' + qplacefrom + ' (' + qlatfrom + ',' + qlongfrom + ') to ' + qplaceto + ' (' + qlatto + ',' + qlongto + ').' + '</font>';
       } else {
        alert('As the crow flies it is ' + Math.floor(eval(eval(0.001 * great_circle_distance(qlatfrom,qlongfrom,qlatto,qlongto)) + 0.5)) + ' kilometres from ' + qplacefrom + ' (' + qlatfrom + ',' + qlongfrom + ') to ' + qplaceto + ' (' + qlatto + ',' + qlongto + ').');
       }
       }
     }
    }
  }
  }
}

function collectclick(event) {
       if (event.clientX || event.clientY) {
       posx = event.clientX - elemLeft;
       posy = event.clientY - elemTop;
       } else {
       posx = event.pageX - elemLeft;
       posy = event.pageY - elemTop;
       }
}

function postcollectclick(aplace) {
       if (eval(x) >= 0 && eval(y) >= 0) {
       if (  eval((eval(posx) - eval(x)) * (eval(posx) - eval(x)) +  (eval(posy) - eval(y)) * (eval(posy) - eval(y)) ) > 5) {
        lastplace=thisplace;
        prevx=x;
        prevy=y;
       } else {
        prevx=-1;
        prevy=-1;
       }
       }
       x = posx;
       y = posy;
       thisplace=aplace.replace(' ','~').replace(' ','~').replace(' ','~').replace(' ','~').replace(' ','~').replace(' ','~').replace(' ','~').replace(' ','~').replace(' ','~');
       if (lastplace != '') lasttrip=lastplace + '_' + thisplace;
       " . $GETlines . "       
}

function selectHandler() {
  var relist=['remail',''],ire,andthen='', str, oplace='', numthing='4', ansbits,avblurb=talkingpoint,ans='',mc,mctwo;
  var selection = chart.getSelection();
  var jj=eval(selection.length);
  if (jj == 0 && (eval(ir) >= 0 || eval(ic) >= 0)) jj=1;
  var clong, message = '', olat='-190.0', olong='-190.0', latlongs, delim='',ij;
  var documentheadinnerHTML=document.head.innerHTML;
  mc=documentheadinnerHTML.split('data.a' + 'ddRows([');
  if (mc.length == 2) {
    documentheadinnerHTML=mc[1].replace('[',',[');
  } 
  for (var i = 0; i < jj; i++) {
    var item = selection[i];
    if ((eval(ir) >= 0 && eval(ic) < 0)) {
      str = data.getFormattedValue(ir, 0);
      latlongs=documentheadinnerHTML.replace(/, \[/g,',[').split(',['); // + str + ',');
      olat=eval(str);
      if (1 == 1) {
        oplace='';
        mc=latlongs[eval(1 + ir)].split('>');
        if (mc.length > 1) {
          mctwo=mc[1].split('<');
          oplace=mctwo[0];
        }
        clong=latlongs[eval(1 + ir)].replace(str + ',', '').replace(']',',').split(',');
        olong=eval(clong[0]);
        if (oplace == '') oplace=clong[1].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'');
      } else if (eval(eval(latlongs.length) - eval(ir)) == 2) {
        clong=latlongs[eval(1 + ir)].replace(']',',').split(',');
        olong=eval(clong[0]);
        oplace=clong[1].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'');
      } else if (eval(eval(latlongs.length) - eval(ir)) > 2) {
        olong='';
        oplace='()';
        for (ij=1; ij<latlongs.length; ij++) {
         clong=latlongs[ij].replace(']',',').split(',');
         olong+=(delim + eval(clong[0]));
         oplace=oplace.replace(')',(delim + (clong[1].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'')) + ')'));
         if (delim == '' && selonclick.length > 0 && eval(olong) >= -180.0 && eval(olong) <= 180.0 && eval(olat) >= -90.0 && eval(olat) <= 90.0) {
          andthen=' ';
         } else if (delim == '') {
          oplace='';
         }
         delim=',';
        }
        if (andthen == ' ') {
         andthen='';
         clong=olong.split(',');
         if (ifoeo == '') {
           
           var tprop='';
           if (topdocumentURL.indexOf('rjmprogramming.com.au') != -1) {
           if (top.document.getElementById('mapphpmailbox')) {
             if (parent.document.getElementById('aof_' + oplace.replace('(','([').replace(',','],').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_'))) {
              tprop=parent.document.getElementById('aof_' + oplace.replace('(','([').replace(',','],').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_')).title;
              if (top.document.getElementById('mapphpmailbox').value.indexOf(tprop) == -1) {
                if (top.document.getElementById('mapphpmailbox').value == '') {
                  top.document.getElementById('mapphpmailbox').value=tprop;
                } else {
                  top.document.getElementById('mapphpmailbox').value+=';' + tprop;
                }
                tprop=String.fromCharCode(10) + 'As you click multiple places see TimeZone Places supervisor dropdown options' + String.fromCharCode(10);
              }
             }
           }
           }
           
           andthen=ourprompt('Is there something you want to try with Latitude ' + olat + ' and one of Longitudes ' + ('(' + olong + ')').replace('(','([').replace(',','],') + '' + oplace.replace('(','([').replace(',','],').split('|')[0] + ' ? ' + String.fromCharCode(10) + '' + String.fromCharCode(10) + avblurb + '' + 'Google Map=G (optional, plus zoom factor[10])' + String.fromCharCode(10) + '' + 'Sun Angle at Noon=S' + String.fromCharCode(10) + 'Moon Angle at Noon=M' + String.fromCharCode(10) + 'Coriolis Force=C' + String.fromCharCode(10) + '' + 'Nearest Airports=A (optional, plus number of nearest airports[4])' + String.fromCharCode(10) + '' + dllc + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Comma Separated Values Spreadsheet Export=filename.csv' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Email with or without Talking Point=fillin.email@address This is when the improvement started.  Robert' + String.fromCharCode(10) + tprop + String.fromCharCode(10) + maybeirw(dllw,ir) + maybeir(dllt,ir) + '' + '... and please suffix answer by comma and preferred Longitude to use, else leave as blank or as is or choose Cancel to leave the status quo.', paramdata);
         }
         if (andthen == null) andthen='';
         if (andthen.indexOf(',') == -1 && andthen != '') {
           olong=eval(clong[0]);
         } else if (andthen != '') {
           clong=andthen.split(',');
           olong=eval(clong[1]);
           andthen=clong[0];
         }
        }
      }
         " . $GETlinescall . "       
    } else if ((item.row != null && item.column != null) || (eval(ir) >= 0 && eval(ic) >= 0)) {
      if (eval(ir) >= 0 && eval(ic) >= 0) {
  //alert(999);
        item.row=ir;
        item.column=ic;
  //alert(9999);
        ir=-1;
        ic=-1;
      } else {
        ir=item.row;
        ic=item.column;
        //document.title=ir + ',' + ic;
      }
      str = data.getFormattedValue(item.row, item.column);
      clong = str.replace('[','').replace(']','').replace('{','').replace('}','').split(',');
      olat=eval(clong[0]);
      olong=eval(clong[1]);
         " . $GETlinescall . "       
    } else if ((item.row != null) || (eval(ir) >= 0 && eval(ic) < 0)) {
      if (eval(ir) >= 0 && eval(ic) < 0) {
  //alert(999);
        item.row=ir;
        //item.column=ic;
  //alert(9999);
        ir=-1;
        //ic=-1;
      } else {
        ir=item.row;
        //ic=item.column;
        //document.title=ir + ',' + ic;
      }
      str = data.getFormattedValue(item.row, 0);
      latlongs=documentheadinnerHTML.replace(/, \[/g,',[').split(',['); // + str + ',');
      olat=eval(str);
      if (1 == 1) {
        oplace='';
        mc=latlongs[eval(1 + item.row)].split('>');
        if (mc.length > 1) {
          mctwo=mc[1].split('<');
          oplace=mctwo[0];
        }
        clong=latlongs[eval(1 + item.row)].replace(str + ',', '').replace(']',',').split(',');
        olong=eval(clong[0]);
        if (oplace == '') oplace=clong[1].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'');
      } else if (eval(eval(latlongs.length) - eval(item.row)) == 2) {
        clong=latlongs[eval(1 + item.row)].replace(']',',').split(',');
        olong=eval(clong[0]);
        oplace=clong[1].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'');
      } else if (eval(eval(latlongs.length) - eval(item.row)) > 2) {
        olong='';
        oplace='()';
        for (ij=1; ij<latlongs.length; ij++) {
         clong=latlongs[ij].replace(']',',').split(',');
         olong+=(delim + eval(clong[0]));
         oplace=oplace.replace(')',(delim + (clong[1].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'')) + ')'));
         if (delim == '' && selonclick.length > 0 && eval(olong) >= -180.0 && eval(olong) <= 180.0 && eval(olat) >= -90.0 && eval(olat) <= 90.0) {
          andthen=' ';
         } else if (delim == '') {
          oplace='';
         }
         delim=',';
        }
        if (andthen == ' ') {
         andthen='';
         clong=olong.split(',');
         if (ifoeo == '') {
         
           var tptrop='';
           if (topdocumentURL.indexOf('rjmprogramming.com.au') != -1) {
           if (top.document.getElementById('mapphpmailbox')) {
             if (parent.document.getElementById('aof_' + oplace.replace('(','([').replace(',','],').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_'))) {
              tptrop=parent.document.getElementById('aof_' + oplace.replace('(','([').replace(',','],').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_')).title;
              if (top.document.getElementById('mapphpmailbox').value.indexOf(tprop) == -1) {
                if (top.document.getElementById('mapphpmailbox').value == '') {
                  top.document.getElementById('mapphpmailbox').value=tptrop;
                } else {
                  top.document.getElementById('mapphpmailbox').value+=';' + tptrop;
                }
                tptrop=String.fromCharCode(10) + 'As you click multiple places see TimeZone Places supervisor dropdown options' + String.fromCharCode(10);
              }
             }
           }
           }

           andthen=ourprompt('Is there something you want to try with Latitude ' + olat + ' and one of Longitudes ' + ('(' + olong + ')').replace('(','([').replace(',','],') + '' + oplace.replace('(','([').replace(',','],').split('|')[0] + ' ? ' + String.fromCharCode(10) + '' + String.fromCharCode(10) + avblurb + '' + 'Google Map=G (optional, plus zoom factor[10])' + String.fromCharCode(10) + '' + 'Sun Angle at Noon=S' + String.fromCharCode(10) + 'Moon Angle at Noon=M' + String.fromCharCode(10) + 'Coriolis Force=C' + String.fromCharCode(10) + '' + 'Nearest Airports=A (optional, plus number of nearest airports[4])' + String.fromCharCode(10) + '' + maybeirw(dllw,ir) + maybeir(dllt,ir) + dllc + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Comma Separated Values Spreadsheet Export=filename.csv' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Email with or without Talking Point=fillin.email@address This is when the improvement started.  Robert' + String.fromCharCode(10) + tptrop + String.fromCharCode(10) + '' + '... and please suffix answer by comma and preferred Longitude to use, else leave as blank or as is or choose Cancel to leave the status quo.', paramdata);
         }
         if (andthen == null) andthen='';
         if (andthen.indexOf(',') == -1 && andthen != '') {
           olong=eval(clong[0]);
         } else if (andthen != '') {
           clong=andthen.split(',');
           olong=eval(clong[1]);
           andthen=clong[0];
         }
        }
      }
         " . $GETlinescall . "       
    } else if ((item.column != null) || (eval(ir) < 0 && eval(ic) >= 0)) {
      if (eval(ir) >= 0 && eval(ic) < 0) {
  //alert(999);
        //item.row=ir;
        item.column=ic;
  //alert(9999);
        //ir=-1;
        ic=-1;
      } else {
        //ir=item.row;
        ic=item.column;
        //document.title=ir + ',' + ic;
      }
      str = data.getFormattedValue(0, item.column);
      latlongs=documentheadinnerHTML.split(',' + str + ',');
      olong=eval(str);
      if (eval(latlongs.length) == 2) {
        clong=latlongs[0].split('[');
        olat=eval(clong[eval(-1 + clong.length)]);
        clong=latlongs[1].split(']');
        oplace=clong[0].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'');
      } else if (eval(latlongs.length) > 2) {
        olat='';
        oplace='()';
        for (ij=1; ij<latlongs.length; ij++) {
         clong=latlongs[ij].replace(']',',').split(',');
         oplace=oplace.replace(')',(delim + (clong[0].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'')) + ')'));
         clong=latlongs[eval(-1 + ij)].replace(']',',').split('[');
         olat+=(delim + eval(clong[eval(-1 + clong.length)]));
         if (delim == '' && selonclick.length > 0 && eval(olong) >= -180.0 && eval(olong) <= 180.0 && eval(olat) >= -90.0 && eval(olat) <= 90.0) {
          andthen=' ';
         } else if (delim == '') {
          oplace='';
         }
         delim=',';
        }
        if (andthen == ' ') {
         andthen='';
         clong=olat.split(',');
         if (ifoeo == '') {
         
           var xtprop='';
           if (topdocumentURL.indexOf('rjmprogramming.com.au') != -1) {
           if (top.document.getElementById('mapphpmailbox')) {
             if (parent.document.getElementById('aof_' + oplace.replace('(','([').replace(',','],').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_'))) {
              xtprop=parent.document.getElementById('aof_' + oplace.replace('(','([').replace(',','],').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_')).title;
              if (top.document.getElementById('mapphpmailbox').value.indexOf(tprop) == -1) {
                if (top.document.getElementById('mapphpmailbox').value == '') {
                  top.document.getElementById('mapphpmailbox').value=xtprop;
                } else {
                  top.document.getElementById('mapphpmailbox').value+=';' + xtprop;
                }
                xtprop=String.fromCharCode(10) + 'As you click multiple places see TimeZone Places supervisor dropdown options' + String.fromCharCode(10);
              }
             }
           }
           }
           
           andthen=ourprompt('Is there something you want to try with one of Latitudes ' + ('(' + olat + ')').replace('(','([').replace(',','],') + ' and Longitude ' + olong + ' ' + oplace.replace('(','([').replace(',','],').split('|')[0] + ' ? ' + String.fromCharCode(10) + '' + String.fromCharCode(10) + avblurb + '' + 'Google Map=G (optional, plus zoom factor[10])' + String.fromCharCode(10) + '' + 'Sun Angle at Noon=S' + String.fromCharCode(10) + 'Moon Angle at Noon=M' + String.fromCharCode(10) + 'Coriolis Force=C' + String.fromCharCode(10) + '' + 'Nearest Airports=A (optional, plus number of nearest airports[4])' + String.fromCharCode(10) + '' + maybeirw(dllw,ir) + maybeir(dllt,ir) + dllc + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Comma Separated Values Spreadsheet Export=filename.csv' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Email with or without Talking Point=fillin.email@address This is when the improvement started.  Robert' + String.fromCharCode(10) + xtprop + String.fromCharCode(10) + '' + '... and please suffix answer by comma and preferred Latitude to use, else leave as blank or as is or choose Cancel to leave the status quo.', paramdata);
         }
         if (andthen == null) andthen='';
         if (andthen.indexOf(',') == -1 && andthen != '') {
           olat=eval(clong[0]);
         } else if (andthen != '') {
           clong=andthen.split(',');
           olat=eval(clong[1]);
           andthen=clong[0];
         }
        }
      }
         " . $GETlinescall . "       
    }
  }
  if (selonclick.length > 0 && eval(olong) >= -180.0 && eval(olong) <= 180.0 && eval(olat) >= -90.0 && eval(olat) <= 90.0) {
    if (andthen == '' && ifoeo == '') {
      olat=getirlat(olat);  // new idea as of September, 2016
      olong=getirlong(olong);
      oplace=getirplace(oplace);

           var ytprop='';
           if (topdocumentURL.indexOf('rjmprogramming.com.au') != -1) {
           if (top.document.getElementById('mapphpmailbox')) {
             if (parent.document.getElementById('aof_' + oplace.replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_'))) {
              ytprop=parent.document.getElementById('aof_' + oplace.replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_').replace(' ','_')).title;
              if (top.document.getElementById('mapphpmailbox').value.indexOf(tprop) == -1) {
                if (top.document.getElementById('mapphpmailbox').value == '') {
                  top.document.getElementById('mapphpmailbox').value=ytprop;
                } else {
                  top.document.getElementById('mapphpmailbox').value+=';' + ytprop;
                }
                ytprop=String.fromCharCode(10) + 'As you click multiple places see TimeZone Places supervisor dropdown options' + String.fromCharCode(10);
              }
             }
           }
           }

      andthen=ourprompt('Is there something you want to try with Latitude ' + olat + ' and Longitude ' + olong + ' ' + oplace.split('|')[0] + ' ? ' + String.fromCharCode(10) + '' + String.fromCharCode(10) + avblurb + '' + 'Google Map=G (optional, plus zoom factor[10])' + String.fromCharCode(10) + '' + 'Sun Angle at Noon=S' + String.fromCharCode(10) + 'Moon Angle at Noon=M' + String.fromCharCode(10) + 'Coriolis Force=C' + String.fromCharCode(10) + '' + 'Nearest Airports=A (optional, plus number of nearest airports[4])' + String.fromCharCode(10) + '' + maybeirw(dllw,ir) + maybeir(dllt,ir) + dllc + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Comma Separated Values Spreadsheet Export=filename.csv' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Email with or without Talking Point=fillin.email@address This is when the improvement started.  Robert' + String.fromCharCode(10) + ytprop + String.fromCharCode(10) + '' + '...  else leave as blank or as is or choose Cancel to leave the status quo.', paramdata);
    }
    if (andthen == null) andthen='';
  }
  
  if (andthen.length > 0) {
    if (andthen.toLowerCase().substring(0,1) == 'd')  {
     if (dllc != 'Draw Link Lines=D') {
      x=-1; 
      y=-1; 
      prevx=-1; 
      prevy=-1; 
      andthen='';
     } else {
      andthen=paramdata + '&lines=y';
     }
    }
    if ((andthen.toLowerCase() + '~').indexOf('.csv~') != -1 && andthen.toLowerCase().indexOf('&') == -1) andthen=paramdata + '&csv=' + andthen;
    ans=andthen;
    ansbits=ans.split(' ');
    
                  if (document.getElementById('altemail')) {
              document.getElementById('altemail').value=ansbits[0];
              document.getElementById('remail').href=document.getElementById('remail').href.replace('mt=','mt=' + ansbits[0] + '&junk=youshallneverfindthis').replace('get=','mt=' + ansbits[0] + '&junk=youshallneverfindthis');
              }
              if (document.getElementById('email')) relist[1]='email';

    
             if (ansbits[0].indexOf('@') != -1) {
               for (ire=0; ire<2; ire++) {
              if (trim(relist[ire]) != '') {
             document.getElementById(relist[ire]).href=document.getElementById(relist[ire]).href.replace('fillin.email@address', ansbits[0]);
              if (item.row != null && document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('&r=') + item.row) == -1) document.getElementById(relist[ire]).href+=encodeURIComponent('&r=') + item.row;
              if (item.column != null && document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('&c=') + item.column) == -1) document.getElementById(relist[ire]).href+=encodeURIComponent('&c=') + item.column;
              if (ansbits.length > 1) {
                ans=ans.replace(ansbits[0] + ' ','');
                while (ans.indexOf(' ') != -1) {
                  ans=ans.replace(' ','%20');
                }
                while (ans.indexOf('?') != -1) {
                  ans=ans.replace('?','%3f');
                }
                while (ans.indexOf('&') != -1) {
                  ans=ans.replace('&','%26');
                }
                if (document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('&tp=')) == -1 && document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('?tp=')) == -1) {
                  document.getElementById(relist[ire]).href+=encodeURIComponent('&tp=') + encodeURIComponent(ans);
                } else if (document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('&tp=')) != -1) {
                  document.getElementById(relist[ire]).href=document.getElementById(relist[ire]).href.replace(encodeURIComponent('&tp='), encodeURIComponent('&tp=') + encodeURIComponent(ans) + String.fromCharCode(96));
				} else if (document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('?tp=')) != -1) {
                  document.getElementById(relist[ire]).href=document.getElementById(relist[ire]).href.replace(encodeURIComponent('?tp='), encodeURIComponent('?tp=') + encodeURIComponent(ans) + String.fromCharCode(96));
                }
                while (document.getElementById(relist[ire]).href.indexOf(' ') != -1) {
                  document.getElementById(relist[ire]).href=document.getElementById(relist[ire]).href.replace(' ','%20');
                }
                //alert(document.getElementById(relist[ire]).href);
              }
              document.getElementById(relist[ire]).click();
              }
              }
             } else if (andthen.toLowerCase().substring(0,1) == 'w') {
      " . $dllwbits . "
             } else if (andthen.toLowerCase().substring(0,1) == 't') {
      " . $dlltbits . "
             } else if (andthen.toLowerCase().substring(0,1) == 'a') {
      andthen=andthen.replace('a','').replace('A','');
      numthing='4';
      if ((andthen + ' ').substring(0,1) >= '1' && (andthen + ' ').substring(0,1) <= '9') {
       numthing=andthen;
      }
      //andthen=document.getElementById('chart_div').innerHTML;
      //alert('airports');
      document.getElementById('cdiv').innerHTML='<a id=mya href=#></a><iframe id=myiframe src=' + String.fromCharCode(34) + '//www.rjmprogramming.com.au/PHP/Map/map.php?title=Your%20Place%20and%20Airports&label=[%27Lat%27,&value=%27Lon%27,%27Name%27]&data=,[' + olat + ',' + olong + ',~' + encodeURIComponent(oplace) + '~]' + String.fromCharCode(34) + ' width=450 height=450></iframe><iframe id=mypiframe src=' + String.fromCharCode(34) + '//www.rjmprogramming.com.au/HTMLCSS/intair.php?num=' + numthing + String.fromCharCode(38) + 'lat=' + olat + String.fromCharCode(38) + 'long=' + olong + String.fromCharCode(34) + ' style=display:none></iframe>';
      //window.open('//www.rjmprogramming.com.au/HTMLCSS/intair.php?num=' + numthing + '&lat=' + olat + '&long=' + olong, '_blank');
    } else if (andthen.toLowerCase().substring(0,1) == 'g') {
      andthen=andthen.replace('g','').replace('G','');
      numthing='10';
      if ((andthen + ' ').substring(0,1) >= '1' && (andthen + ' ').substring(0,1) <= '9') {
       numthing=andthen;
      }
      //alert('google map');
      if (('' + olat).indexOf('.') == -1) olat='' + olat + '.0';
      if (eval(olong) >= 0.0) olong='+' + olong;
      window.open('//maps.google.com/maps?z=' + numthing + '&t=m&q=loc:' + olat + olong.replace('-',',-'), '_blank','top=50,left=450,width=600,height=600');
    } else if (andthen.toLowerCase().substring(0,1) == 's') {
      var latss=('' + olat).split('.'), latd,latm=0,lats=0;
      if (latss.length == 1) {
        latd=eval(latss[0]);
      } else {
        latd=eval(latss[0]);
        latm=Math.floor(60.0 * eval('0.' + latss[1]));
        lats=Math.floor(eval(3600.0 * (Math.abs(eval(olat)) -  (Math.abs(eval(latd)) + eval(latm / 60.0)) )));
      }
      var longss=('' + olong).split('.'), longd,longm=0,longs=0;
      if (longss.length == 1) {
        longd=eval(longss[0]);
      } else {
        longd=eval(longss[0]);
        longm=Math.floor(60.0 * eval('0.' + longss[1]));
        longs=Math.floor(eval(3600.0 * (Math.abs(eval(olong)) -  (Math.abs(eval(longd)) + eval(longm / 60.0)) )));
      }
      window.open('//www.rjmprogramming.com.au/PHP/SunAngle/sun_angle_now_at.php?latd=' + latd + '&latm=' + latm + '&lats=' + lats + '&longd=' + longd + '&longm=' + longm + '&longs=' + longs + '&from=from&done=y', '_blank','top=80,left=480,width=600,height=600');
    } else if (andthen.toLowerCase().substring(0,1) == 'm') {
      var latss=('' + olat).split('.'), latd,latm=0,lats=0;
      if (latss.length == 1) {
        latd=eval(latss[0]);
      } else {
        latd=eval(latss[0]);
        latm=Math.floor(60.0 * eval('0.' + latss[1]));
        lats=Math.floor(eval(3600.0 * (Math.abs(eval(olat)) -  (Math.abs(eval(latd)) + eval(latm / 60.0)) )));
      }
      var longss=('' + olong).split('.'), longd,longm=0,longs=0;
      if (longss.length == 1) {
        longd=eval(longss[0]);
      } else {
        longd=eval(longss[0]);
        longm=Math.floor(60.0 * eval('0.' + longss[1]));
        longs=Math.floor(eval(3600.0 * (Math.abs(eval(olong)) -  (Math.abs(eval(longd)) + eval(longm / 60.0)) )));
      }
      window.open('//www.rjmprogramming.com.au/PHP/MoonAngle/moon_angle_now_at.php?latd=' + latd + '&latm=' + latm + '&lats=' + lats + '&longd=' + longd + '&longm=' + longm + '&longs=' + longs + '&from=from&done=y', '_blank','top=100,left=500,width=600,height=600');
    } else if (andthen.toLowerCase().substring(0,1) == 'c') {
      var latss=('' + olat).split('.'), latd,latm=0,lats=0;
      if (latss.length == 1) {
        latd=eval(latss[0]);
      } else {
        latd=eval(latss[0]);
        latm=Math.floor(60.0 * eval('0.' + latss[1]));
        lats=Math.floor(eval(3600.0 * (Math.abs(eval(olat)) -  (Math.abs(eval(latd)) + eval(latm / 60.0)) )));
      }
      var longss=('' + olong).split('.'), longd,longm=0,longs=0;
      if (longss.length == 1) {
        longd=eval(longss[0]);
      } else {
        longd=eval(longss[0]);
        longm=Math.floor(60.0 * eval('0.' + longss[1]));
        longs=Math.floor(eval(3600.0 * (Math.abs(eval(olong)) -  (Math.abs(eval(longd)) + eval(longm / 60.0)) )));
      }
      window.open('//www.rjmprogramming.com.au/PHP/Coriolis/coriolis_force_at.php?latd=' + latd + '&latm=' + latm + '&lats=' + lats + '&longd=' + longd + '&longm=' + longm + '&longs=' + longs + '&from=from&done=y', '_blank','top=120,left=520,width=600,height=600');
    } else if (andthen != paramdata && andthen != '') {
      location.href=document.URL.replace(pardata, ourencodeURIComponent(andthen));
    }
  }
  ir=-1;
  ic=-1; 
}
";
      
      echo " </script> \n";
      echo " </head> \n";
      
      
      if (!isset($_GET['value']) && !isset($_POST['value'])) {
      echo " <body ontouchstart=' collectclick(event); ' onmousedown=' collectclick(event); ' onload=\" document.getElementById('myoptform').action=document.URL.split('#')[0];  if (later) { setTimeout(later, 2 * 1000); } \" style='background-color: silver;'> \n";
      } else {
      echo " <body ontouchstart=' collectclick(event); ' onmousedown=' collectclick(event); ' style='background-color: silver;' onload=\" document.getElementById('myoptform').action=document.URL.split('#')[0]; \"> \n";
      }
      echo " <h1 id='myh1'>" . $GETtitle . " Map <div id='dh1'></div></h1> \n";

      echo '<div id="chart_div" style="width: 400px; height: 300px;' . $opa . '" ontouchstart=" collectclick(event); " onmousedown=" collectclick(event); "></div>' . " \n";
      echo '<a title="Another Map" href="./map.php">Another Map?</a>' . '&nbsp;&nbsp;<a href="MAILTO:fillin.email@address?subject=Google%20Chart%20Snapshot&body=' . urlencode("//" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI']) . '" style="display:inline;" title="To email a snapshot of this Google Chart click me." id="remail">Email snapshot of Google Chart ...</a>' . " \n";
      echo '<' . 'script' . ' type="text/javascript">' . "\n " . " function later() { \n"; 
      if (!isset($_GET['value']) && !isset($_POST['value'])) {
      
        echo ' datalineprefix = " "; ' . "\n";
        echo ' datalinesuffix = ""; ' . "\n";
        echo ' var prethisline = "", extra = ""; ' . "\n";
        echo ' var thisline = 1; ' . "\n";
        echo ' var ii = 0; ' . "\n";
        if ($dbval == "") { // && $options_suffix != "") {
        echo ' var c_m = " ", thisdef = "0"; ' . "\n";
        } else {
        echo ' var c_m = "", thisdef = "0"; ' . "\n";
        }
        echo ' var totalleft = 100.0; ' . "\n";

        echo ' var title = ourprompt("Enter Map Title (suffix by &lines=y for overlay clickable link lines and/or suffix by &onclick=y for all types of onclick functionality). ' . $promptsuffix . '", "' . $GETtitle . '"); ' . "\n";
        echo ' if (title != null) { ' . "\n";
        echo ' if (title.indexOf(",") == 0) { if (title.indexOf("]}}") != -1) {  document.getElementById("custom_map").value=title.replace("};","").split("]}}")[0] + "]}} "; title=title.replace("};","").split("]}}")[1];  } else if (title.indexOf("}") != -1) {    document.getElementById("custom_map").value=(title + "            ").replace("};","").replace("}" + (title + "            ").replace("};","").split("}")[eval(-1 + (title + "            ").replace("};","").split("}").length)],"}"); title=title.replace("};","").replace(document.getElementById("custom_map").value,"");   } else {  document.getElementById("custom_map").value=title; }  if (c_m.length == 0) { document.getElementById("myoptsbutton").click(); } c_m=document.getElementById("custom_map").value;  }  ' . "\n";
        echo ' if (title.indexOf("&onclick=") != -1) { prethisline=" (note, here, suffix of |TimeZoneName|GMTOffset|TimeNow is recognized in the onclick select event prompt window later ... for example Sydney|Australia/Sydney|+11|12:32 uses this functionality) "; } ' . "\n";
        echo ' var label = "' . $GETlabel . '"; ' . "\n";
        echo ' if (label == null) label = ""; ' . "\n";
        echo ' var xlabel = "' . "'" . '" + label.replace("' . "'" . '","") + "' . "'" . '"; ' . "\n";
        //echo ' var value = ourprompt("Enter Map " + xlabel + " Criteria (separated by ,) ...  decimal latitude and longitude ", "' . $GETvalue . '"); ' . "\n";
        echo ' var value = "' . $GETvalue . '"; ' . "\n";


        echo ' if (value.indexOf(",") != (0 - 1)) { ' . "\n";
        echo '  for (ii=0; ii < value.length; ii++) { if (value.substring(ii,(ii+1)) == ",") { if (value.substring((ii+1),(ii+2)) == "' . "'" . '") {  thisdef = thisdef + ",' . "'0'" . '"; } else { thisdef = thisdef + ",0"; } } } ' . "\n";
        echo ' } ' . "\n";


        echo ' var dlsa, dlp2="", datac = ""; ' . "\n";
        echo ' dataprefix2 = ""; ' . "\n";
        echo ' var sq = "' . "'" . '"; ' . "\n";
        echo ' datalineprefix = "' . "''" . '";' . "\n";
        echo ' if (label.length != 0) { datalineprefix2 = ourprompt("Enter ' . " " . $GETtitle . ' Name' . " " . ' " + prethisline + thisline, ""); if (datalineprefix2 != null) {  calcofftimenow(document.getElementById("seltz"),datalineprefix2); dlp2=datalineprefix2; } } ' . "\n";


        echo ' while (datalineprefix.length != 0 && (value.indexOf("ercent") == (0 - 1) || value.indexOf("  ercent ") != (0 - 1) || (value.indexOf("ercent") != (0 - 1) && totalleft > 0))) { ' . "\n";
        echo ' datalineprefix = "' . "''" . '";' . "\n";
        echo ' if (datalinesuffix.length != 0 && label.length != 0) { datalineprefix = ourprompt("Enter ' . " " . $GETtitle . ' Name' . " " . ' " + prethisline + thisline + " (for no more hit Cancel button)", ""); if (datalineprefix != null) {  calcofftimenow(document.getElementById("seltz"),datalineprefix);  datalineprefix2=""; dlp2=datalineprefix; } } ' . "\n";
        echo ' if (datalineprefix == null) { ' . "\n";
        echo '     datalineprefix = ""; ' . "\n";
        echo '     totalleft = 0; ' . "\n";
        echo ' } else if (datalineprefix.length != 0) { ' . "\n";
        echo '     extra = "";  ' . "\n";
        echo '     if (value.indexOf("ercent") != (0 - 1) && value.indexOf("  ercent ") == (0 - 1)) extra = " (for " + totalleft + " enter nothing or hit Cancel button)";  ' . "\n";
        echo "  if (tzsuffix == '') {   datalinesuffix = ourprompt('Enter decimal Latitude,Longitude ' + thisline + extra +  ' (for no more hit Cancel button and append with ' + '\\n\\n' + ',\"A tooltip and clicking link for Google Map of <a target=_blank href=' + \"'\" + 'https://www.google.com.au/maps/place/' + encodeURIComponent(dlp2) + \"'\" + '>' + dlp2 + '</a>\" ' + '\\n\\n' + ' or maybe perhaps ' + '\\n\\n' + ',\"A tooltip and clicking link for Google Map based on latitude and longitude of <a target=_blank href=' + \"'\" + 'https://maps.google.com.au/maps?' + encodeURIComponent('z=15&t=m&q=loc:') + '{latitude}{longitude}' + \"'\" + '>' + dlp2 + '</a>\"' + '\\n\\n' + ' optionally (as (just) two examples of what is possible with HTML included (activates with onclick bit not onmouseover))', thisdef); " . "\n";
        echo "  } else if (tzsuffix != '') {   datalinesuffix = ourprompt('Just click OK to accept the ' + tzsuffix.split('|')[1] + ' Time Zone place geographicals we found, else enter decimal Latitude,Longitude ' + thisline + extra +  ' (for no more hit Cancel button and append with ' + '\\n\\n' + ',\"A tooltip and clicking link for Google Map of <a target=_blank href=' + \"'\" + 'https://www.google.com.au/maps/place/' + encodeURIComponent(dlp2) + \"'\" + '>' + dlp2 + '</a>\" ' + '\\n\\n' + ' or maybe perhaps ' + '\\n\\n' + ',\"A tooltip and clicking link for Google Map based on latitude and longitude of <a target=_blank href=' + \"'\" + 'https://maps.google.com.au/maps?' + encodeURIComponent('z=15&t=m&q=loc:') + '{latitude}{longitude}' + \"'\" + '>' + dlp2 + '</a>\"' + '\\n\\n' + ' optionally (as (just) two examples of what is possible with HTML included (activates with onclick bit not onmouseover))', tzsuffix); tzsuffix=''; } " . "\n";
        echo '     if (datalinesuffix != null) { datalinesuffix=giveandtake(datalinesuffix).replace(/#/g, "%23");  if (datalinesuffix.indexOf("{latitude}") != -1) { dlsa=datalinesuffix.split(","); if (dlsa[0].indexOf(".") == -1) { dlsa[0]=dlsa[0]+".0";  } if (dlsa[0].indexOf("-") == -1) { datalinesuffix=datalinesuffix.replace("{latitude}",encodeURIComponent("" + dlsa[0]));  } else { datalinesuffix=datalinesuffix.replace("{latitude}",encodeURIComponent(dlsa[0]));  }  } if (datalinesuffix.indexOf("{longitude}") != -1) { dlsa=datalinesuffix.split(","); if (dlsa.length > 1) {  if (dlsa[0].indexOf(".") == -1) { dlsa[0]=dlsa[0]+".0";  }  if (dlsa[1].indexOf(".") == -1) { dlsa[1]=dlsa[1]+".0";  } if (dlsa[1].indexOf("-") == -1) { datalinesuffix=datalinesuffix.replace("{longitude}",encodeURIComponent("+" + dlsa[1]));  } else { datalinesuffix=datalinesuffix.replace("{longitude}","+" + encodeURIComponent(dlsa[1])); }  }  }  datalinesuffix=("@!@" + datalinesuffix).replace(/loc:+/g, "loc:").replace(/,0,/g, ",0.00000001,").replace(/@!@0,/g, "0.00000001,").replace(/@!@/g, "");    } ' . "\n";
        echo '     if (datalinesuffix == null && value.indexOf("ercent") != (0 - 1) && value.indexOf("  ercent ") == (0 - 1)) datalinesuffix = totalleft; ' . "\n";
        echo '     if (datalinesuffix == null) break; ' . "\n";
        echo '     if (datalinesuffix == null) datalinesuffix = "0,0"; ' . "\n";
        echo '     if (datalinesuffix.length == 0) { ' . "\n";
        echo '       datalinesuffix = eval(totalleft); ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(totalleft) == eval(datalinesuffix) && value.indexOf("ercent") != (0 - 1) && value.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(datalinesuffix) > eval(totalleft) && value.indexOf("ercent") != (0 - 1) && value.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       datalinesuffix = eval(totalleft); ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(datalinesuffix) > eval(totalleft) && value.indexOf("ercent") == (0 - 1) && value.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       value = value + "  ercent "; ' . "\n";
        echo '     } else { ' . "\n";
        echo '       totalleft = eval(totalleft) - eval(datalinesuffix); ' . "\n";
        echo '     } ' . "\n";
        echo '     if (datalineprefix2 != "") datalineprefix = datalineprefix2;  ' . "\n";
        echo '     if (datalinesuffix.indexOf("' . "'" . '") == -1) datac = datac + ", [" + datalinesuffix + ",~" + datalineprefix + "~] "; ' . "\n";
        echo '     if (datalinesuffix.indexOf("' . "'" . '") != -1) datac = datac + ", [" + datalinesuffix + ",' . "'" . '" + datalineprefix + "~] "; ' . "\n";
        echo '     dataprefix2 = ""; ' . "\n";
        echo '     thisline++; ' . "\n";
        echo '   } ' . "\n";
        echo ' } ' . "\n";
        if ($dbval == "" && $options_suffix != "") {
        echo " document.getElementById('custom_map').value=\"" . $options_suffix . "\";  " . "\n";
        echo " document.getElementById('myoptform').innerHTML+='<input name=title type=hidden value=\"' + title.split('&')[0] + '\"></input>';  " . "\n";

        echo " if (title.indexOf('&onclick=') != -1) { document.getElementById('myoptform').innerHTML+='<input name=onclick type=hidden value=\"' + (title + '&').split('&onclick=')[1].split('&')[0] + '\"></input>' };  " . "\n";
        echo " if (title.indexOf('&lines=') != -1) { document.getElementById('myoptform').innerHTML+='<input name=lines type=hidden value=\"' + (title + '&').split('&lines=')[1].split('&')[0] + '\"></input>' };  " . "\n";
        echo " if (title.indexOf('&options=') != -1) { document.getElementById('myoptform').innerHTML+='<input name=options type=hidden value=\"' + (title + '&').split('&options=')[1].split('&')[0] + '\"></input>' };  " . "\n";

        echo " document.getElementById('myoptform').innerHTML+='<input name=label type=hidden value=\"' + label + '\"></input>';  " . "\n";
        echo " document.getElementById('myoptform').innerHTML+='<input name=value type=hidden value=\"' + value.replace(\"  ercent \", \"\") + '\"></input>';  " . "\n";
        echo " document.getElementById('myoptform').innerHTML+='<input name=data type=hidden value=\"' + datac + '\"></input>';  " . "\n";
        echo " document.getElementById('myoptsbutton').click(); " . "\n";
        } else {
        echo ' if (("./map.php?title=" + title + "&custom_map=" + encodeURIComponent(jnocomm(c_m)) + "&label=" + label + "&value=" + value.replace("  ercent ", "") + "&data=" + datac).length > 900 || c_m.trim() != "") { ' . "\n";
        echo " document.getElementById('custom_map').value=jnocomm(c_m);  " . "\n";

        echo " if (title.indexOf('&onclick=') != -1) { document.getElementById('myoptform').innerHTML+='<input name=onclick type=hidden value=\"' + (title + '&').split('&onclick=')[1].split('&')[0] + '\"></input>' };  " . "\n";
        echo " if (title.indexOf('&lines=') != -1) { document.getElementById('myoptform').innerHTML+='<input name=lines type=hidden value=\"' + (title + '&').split('&lines=')[1].split('&')[0] + '\"></input>' };  " . "\n";
        echo " if (title.indexOf('&options=') != -1) { document.getElementById('myoptform').innerHTML+='<input name=options type=hidden value=\"' + (title + '&').split('&options=')[1].split('&')[0] + '\"></input>' };  " . "\n";

        echo " document.getElementById('myoptform').innerHTML+='<input name=title type=hidden value=\"' + title.split('&')[0] + '\"></input>';  " . "\n";
        echo " document.getElementById('myoptform').innerHTML+='<input name=label type=hidden value=\"' + label + '\"></input>';  " . "\n";
        echo " document.getElementById('myoptform').innerHTML+='<input name=value type=hidden value=\"' + value.replace(\"  ercent \", \"\") + '\"></input>';  " . "\n";
        echo " document.getElementById('myoptform').innerHTML+='<input name=data type=hidden value=\"' + datac + '\"></input>';     " . "\n";
        echo " document.getElementById('myoptsbutton').click(); " . "\n";
        echo ' } else if (c_m.trim() != "") { ' . "\n";
        echo ' window.location = "./map.php?title=" + title + "&label=" + label + "&value=" + value.replace("  ercent ", "") + "&custom_map=" + encodeURIComponent(jnocomm(c_m)) + "&data=" + datac; ' . "\n";
        echo ' } else { ' . "\n";
        echo ' window.location = "./map.php?title=" + title + "&label=" + label + "&value=" + value.replace("  ercent ", "") + "&data=" + datac; ' . "\n";
        echo ' } ' . "\n";
        }
        echo "} \n"; 
      } 
      echo "} \n" . '</' . 'script' . '>' . "\n";
    ?>
  <form style='display:none;' id='myoptform' method='POST' target='_self' action='map.php'><input id='custom_map' name='custom_map' type='hidden' value=''></input><input type='submit' id='myoptsbutton' value='Show This Way'></input></form>
  <a title='menu' href='//www.rjmprogramming.com.au/PHP/butsel.php?justmenu=justmenu'>Menu</a>
  <div id='cdiv'></div><div id='xydiv'></div>
<?php echo $seltz; ?>
</body>
</html>
