<?php
  // geo_chart.php
  // Google Geo Chart supervisor
  // RJM Programming
  // November, 2015
  // 
  if (file_exists("csv.php")) {
    include "csv.php";
  } else if (file_exists("../csv.php")) { 
    include "../csv.php";
  }
  if (file_exists("bigemail.php")) {
    include "bigemail.php";
  } else if (file_exists("../bigemail.php")) { 
    include "../bigemail.php";
  }


if (isset($_GET['llplace']) && isset($_GET['lldefvnum'])) {
    if (trim(urldecode($_GET['llplace'])) != "") {
        $wurl="http://en.wikipedia.org/wiki/" . urldecode($_GET['llplace']);
        $wcontll=@file_get_contents($wurl);
        if (strpos($wcontll, '{"lat":') !== false && strpos($wcontll, ',"lon":') !== false) {
        echo "<!doctype html><html><body onload=\"  if (1 == 7 && parent.document) {   if (parent.document.getElementById('defv" . urldecode($_GET['lldefvnum']) . "')) {   if (parent.document.getElementById('defv" . urldecode($_GET['lldefvnum']) . "').value.indexOf('0|0|') == 0) {    parent.document.getElementById('defv" . urldecode($_GET['lldefvnum']) . "').value=parent.document.getElementById('defv" . urldecode($_GET['lldefvnum']) . "').value.replace('0|0|','" . explode(',',explode('{"lat":',$wcontll)[1])[0] . '|' . explode('}',explode(',"lon":',$wcontll)[1])[0] . '|' . "');  }   } } \">document.getElementById('defv" . urldecode($_GET['lldefvnum']) . "').value=\"" . explode(',',explode('{"lat":',$wcontll)[1])[0] . '|' . explode('}',explode(',"lon":',$wcontll)[1])[0] . '|' . urldecode($_GET['llplace']) . "\";</body></html>";
        } else if (strpos($wcontll, '>' . str_replace('_',' ',urldecode($_GET['llplace'])) . ',') !== false) {
        $wurl.=',' . str_replace(' ','_',explode('</a>', explode('>' . str_replace('_',' ',urldecode($_GET['llplace'])) . ',', $wcontll)[1])[0]);
        if (strpos($wurl, "<") === false) {
          $wcontll=@file_get_contents($wurl);
        }
        if (strpos($wcontll, '{"lat":') !== false && strpos($wcontll, ',"lon":') !== false) {
        echo "<!doctype html><html><body onload=\"  if (1 == 7 && parent.document) {   if (parent.document.getElementById('defv" . urldecode($_GET['lldefvnum']) . "')) {   if (parent.document.getElementById('defv" . urldecode($_GET['lldefvnum']) . "').value.indexOf('0|0|') == 0) {    parent.document.getElementById('defv" . urldecode($_GET['lldefvnum']) . "').value=parent.document.getElementById('defv" . urldecode($_GET['lldefvnum']) . "').value.replace('0|0|','" . explode(',',explode('{"lat":',$wcontll)[1])[0] . '|' . explode('}',explode(',"lon":',$wcontll)[1])[0] . '|' . "');  }   } } \">document.getElementById('defv" . urldecode($_GET['lldefvnum']) . "').value=\"" . explode(',',explode('{"lat":',$wcontll)[1])[0] . '|' . explode('}',explode(',"lon":',$wcontll)[1])[0] . '|' . urldecode($_GET['llplace']) . "\";</body></html>";
        } else {
        echo "<!doctype html><html><body>document.getElementById('defv" . urldecode($_GET['lldefvnum']) . "').value=\"\";</body></html>";
        }
        } else {
        echo "<!doctype html><html><body>document.getElementById('defv" . urldecode($_GET['lldefvnum']) . "').value=\"\";</body></html>";
        }
    }
    exit;
}


$burl="";
$bdivstart="";
$bdivend="";
$cdivc="background-color: yellow;";
      $nondefs=" ";

$guess="";
$guessquestion="";
if (isset($_POST['guess'])) {
 $nondefs="legend: 'none',";
 $guess=urldecode($_POST['guess']);
if (isset($_POST['question'])) {
 $guessquestion=urldecode($_POST['question']);
} else if (isset($_GET['question'])) {
 $guessquestion=urldecode($_GET['question']);
}
} else if (isset($_GET['guess'])) {
 $nondefs="legend: 'none',";
 $guess=urldecode($_GET['guess']);
if (isset($_POST['question'])) {
 $guessquestion=urldecode($_POST['question']);
} else if (isset($_GET['question'])) {
 $guessquestion=urldecode($_GET['question']);
}
} else {
 $nondefs="";
}

$top="";
if (isset($_POST['area']) || isset($_GET['area'])) $top=" ";
$ntop="1";
$roff="0";
$mtop="1";
$newextras="";
$lastgo = "";
$GETimage = "<img src='geo_chart.jpg'></img>";
$myextras = " + ' or maybe perhaps ' + '\\n\\n' + ',\"A tooltip (regarding {popularity}) of some sort like <a target=_blank href=' + \"'\" + 'https://en.wikipedia.org/wiki/{country}' + \"'\" + '>{country}</a>\"' + '\\n\\n'";


$inplace="";
$iso_country_codes=['AF','Afghanistan',
'AX','Aland Islands',
'AL','Albania',
'DZ','Algeria',
'AS','American Samoa',
'AD','Andorra',
'AO','Angola',
'AI','Anguilla',
'AQ','Antarctica',
'AG','Antigua and Barbuda',
'AR','Argentina',
'AM','Armenia',
'AW','Aruba',
'AU','Australia',
'AT','Austria',
'AZ','Azerbaijan',
'BS','Bahamas the',
'BH','Bahrain',
'BD','Bangladesh',
'BB','Barbados',
'BY','Belarus',
'BE','Belgium',
'BZ','Belize',
'BJ','Benin',
'BM','Bermuda',
'BT','Bhutan',
'BO','Bolivia',
'BA','Bosnia and Herzegovina',
'BW','Botswana',
'BV','Bouvet Island (Bouvetoya)',
'BR','Brazil',
'IO','British Indian Ocean Territory (Chagos Archipelago)',
'VG','British Virgin Islands',
'BN','Brunei Darussalam',
'BG','Bulgaria',
'BF','Burkina Faso',
'BI','Burundi',
'KH','Cambodia',
'CM','Cameroon',
'CA','Canada',
'CV','Cape Verde',
'KY','Cayman Islands',
'CF','Central African Republic',
'TD','Chad',
'CL','Chile',
'CN','China',
'CX','Christmas Island',
'CC','Cocos (Keeling) Islands',
'CO','Colombia',
'KM','Comoros the',
'CD','Congo',
'CG','Congo the',
'CK','Cook Islands',
'CR','Costa Rica',
'CI','Cote d\'Ivoire',
'HR','Croatia',
'CU','Cuba',
'CY','Cyprus',
'CZ','Czech Republic',
'DK','Denmark',
'DJ','Djibouti',
'DM','Dominica',
'DO','Dominican Republic',
'EC','Ecuador',
'EG','Egypt',
'SV','El Salvador',
'GQ','Equatorial Guinea',
'ER','Eritrea',
'EE','Estonia',
'ET','Ethiopia',
'FO','Faroe Islands',
'FK','Falkland Islands (Malvinas)',
'FJ','Fiji the Fiji Islands',
'FI','Finland',
'FR','France, French Republic',
'GF','French Guiana',
'PF','French Polynesia',
'TF','French Southern Territories',
'GA','Gabon',
'GM','Gambia the',
'GE','Georgia',
'DE','Germany',
'GH','Ghana',
'GI','Gibraltar',
'GR','Greece',
'GL','Greenland',
'GD','Grenada',
'GP','Guadeloupe',
'GU','Guam',
'GT','Guatemala',
'GG','Guernsey',
'GN','Guinea',
'GW','Guinea-Bissau',
'GY','Guyana',
'HT','Haiti',
'HM','Heard Island and McDonald Islands',
'VA','Holy See (Vatican City State)',
'HN','Honduras',
'HK','Hong Kong',
'HU','Hungary',
'IS','Iceland',
'IN','India',
'ID','Indonesia',
'IR','Iran',
'IQ','Iraq',
'IE','Ireland',
'IM','Isle of Man',
'IL','Israel',
'IT','Italy',
'JM','Jamaica',
'JP','Japan',
'JE','Jersey',
'JO','Jordan',
'KZ','Kazakhstan',
'KE','Kenya',
'KI','Kiribati',
'KP','Korea',
'KR','Korea',
'KW','Kuwait',
'KG','Kyrgyz Republic',
'LA','Laos',
'LV','Latvia',
'LB','Lebanon',
'LS','Lesotho',
'LR','Liberia',
'LY','Libyan Arab Jamahiriya',
'LI','Liechtenstein',
'LT','Lithuania',
'LU','Luxembourg',
'MO','Macao',
'MK','Macedonia',
'MG','Madagascar',
'MW','Malawi',
'MY','Malaysia',
'MV','Maldives',
'ML','Mali',
'MT','Malta',
'MH','Marshall Islands',
'MQ','Martinique',
'MR','Mauritania',
'MU','Mauritius',
'YT','Mayotte',
'MX','Mexico',
'FM','Micronesia',
'MD','Moldova',
'MC','Monaco',
'MN','Mongolia',
'ME','Montenegro',
'MS','Montserrat',
'MA','Morocco',
'MZ','Mozambique',
'MM','Myanmar',
'NA','Namibia',
'NR','Nauru',
'NP','Nepal',
'AN','Netherlands Antilles',
'NL','Netherlands the',
'NC','New Caledonia',
'NZ','New Zealand',
'NI','Nicaragua',
'NE','Niger',
'NG','Nigeria',
'NU','Niue',
'NF','Norfolk Island',
'MP','Northern Mariana Islands',
'NO','Norway',
'OM','Oman',
'PK','Pakistan',
'PW','Palau',
'PS','Palestinian Territory',
'PA','Panama',
'PG','Papua New Guinea',
'PY','Paraguay',
'PE','Peru',
'PH','Philippines',
'PN','Pitcairn Islands',
'PL','Poland',
'PT','Portugal, Portuguese Republic',
'PR','Puerto Rico',
'QA','Qatar',
'RE','Reunion',
'RO','Romania',
'RU','Russian Federation',
'RW','Rwanda',
'BL','Saint Barthelemy',
'SH','Saint Helena',
'KN','Saint Kitts and Nevis',
'LC','Saint Lucia',
'MF','Saint Martin',
'PM','Saint Pierre and Miquelon',
'VC','Saint Vincent and the Grenadines',
'WS','Samoa',
'SM','San Marino',
'ST','Sao Tome and Principe',
'SA','Saudi Arabia',
'SN','Senegal',
'RS','Serbia',
'SC','Seychelles',
'SL','Sierra Leone',
'SG','Singapore',
'SK','Slovakia (Slovak Republic)',
'SI','Slovenia',
'SB','Solomon Islands',
'SO','Somalia, Somali Republic',
'ZA','South Africa',
'GS','South Georgia and the South Sandwich Islands',
'ES','Spain',
'LK','Sri Lanka',
'SD','Sudan',
'SR','Suriname',
'SJ','Svalbard & Jan Mayen Islands',
'SZ','Swaziland',
'SE','Sweden',
'CH','Switzerland, Swiss Confederation',
'SY','Syrian Arab Republic',
'TW','Taiwan',
'TJ','Tajikistan',
'TZ','Tanzania',
'TH','Thailand',
'TL','Timor-Leste',
'TG','Togo',
'TK','Tokelau',
'TO','Tonga',
'TT','Trinidad and Tobago',
'TN','Tunisia',
'TR','Turkey',
'TM','Turkmenistan',
'TC','Turks and Caicos Islands',
'TV','Tuvalu',
'UG','Uganda',
'UA','Ukraine',
'AE','United Arab Emirates',
'GB','United Kingdom',
'US','United States of America',
'UM','United States Minor Outlying Islands',
'VI','United States Virgin Islands',
'UY','Uruguay, Eastern Republic of',
'UZ','Uzbekistan',
'VU','Vanuatu',
'VE','Venezuela',
'VN','Vietnam',
'WF','Wallis and Futuna',
'EH','Western Sahara',
'YE','Yemen',
'ZM','Zambia',
'ZW','Zimbabwe'];

// https://www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=My%20World%20Survey&arexplaces=y&aregeographicals=http.128249_Sydney%2Chttp.128249_Brisbane&peninfo=128249%20Sydney,128249%20Brisbane&width=556&height=347&country=Places&popularity=Popularity&data=%20[-33.865|151.20944444444|~Sydney~,2]%20,%20[-27.466666666667|153.03333333333|~Brisbane~,2]

function noemoji($inentity) {
  $allnum=true;
  if ($inentity != '' && explode(' ',str_replace("_"," ",$inentity))[0] != str_replace("_"," ",$inentity)) {
   if (substr(str_replace("_"," ",$inentity),0,1) != ' ') {
    for ($iu=0; $iu<strlen(explode(' ',str_replace("_"," ",$inentity))[0]); $iu++) {
      if (substr(explode(' ',str_replace("_"," ",$inentity))[0],$iu,1) != '.' && (substr(explode(' ',str_replace("_"," ",$inentity))[0],$iu,1) < '0' || substr(explode(' ',str_replace("_"," ",$inentity))[0],$iu,1) > '9')) $allnum=false;
    }
    if ($allnum && strpos($inentity,"_") !== false) {
      return str_replace(" ","_",substr($inentity, (strlen(explode(' ',str_replace("_"," ",$inentity))[0]) + 1)));
    }
    if ($allnum) {
      return substr($inentity, (strlen(explode(' ',$inentity)[0]) + 1));
    }
   }
  }
  return $inentity;
}

// https://www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?title=My%20World%20Survey&arexplaces=y&aregeographicals=http.128249_Sydney%2Chttp.128249_Brisbane&peninfo=128249%20Sydney,128249%20Brisbane&width=556&height=347&country=Places&popularity=Popularity&data=%20[-33.865|151.20944444444|~Sydney~,2]%20,%20[-27.466666666667|153.03333333333|~Brisbane~,2]

function wlook($fupa) {
        global $GETdata; // = "['Germany',200],['United States',300],['Brazil',400],['Canada',500],['France',600],['RU',700] ";      
        if (strpos(strtolower(str_replace("https.","http.",$fupa)), "http.") === false) return $fupa;
        $fgsis=explode(",",str_replace("https.","http.",str_replace("HTTPS.","http.",$fupa)));
        $ofupa=$fgsis[0];
        $fdel=",";
        $wurll="";
        for ($jfgsis=0; $jfgsis<sizeof($fgsis); $jfgsis++) {
         $wurll="";
         if (strpos(strtolower($fgsis[$jfgsis]), "http") !== false) {
            if (strpos(strtolower($fgsis[$jfgsis]), "http.") !== false) {
             $fgsis[$jfgsis]="http." . noemoji(substr($fgsis[$jfgsis],5));
             if (strpos(strtolower($fgsis[$jfgsis] . "*"), "http.*") !== false) {
               $wplacex=str_replace("+","_", str_replace("%20","_", urlencode(  explode("|",  explode("~", explode("]", urldecode($GETdata))[$jfgsis]  )[1])[-1 + sizeof(explode("|",explode("~",explode("]", urldecode($GETdata))[$jfgsis])[1]))]  )));
               $wplace=str_replace("+","_", str_replace("%20","_", urlencode(  explode("|",  explode("~",explode("]", urldecode($GETdata))[$jfgsis])[1])[-1 + sizeof(explode("|",explode("~",explode("]", urldecode($GETdata))[$jfgsis])[1]))]  )));
             } else {
               $wplacex=str_replace("+","_", str_replace("%20","_", urlencode( explode("|", substr($fgsis[$jfgsis],5) )[-1 + sizeof(explode("|", substr($fgsis[$jfgsis],5) ))]  )));
               $wplace=str_replace("+","_", str_replace("%20","_", urlencode(noemoji(  explode("|", substr($fgsis[$jfgsis],5) )[-1 + sizeof(explode("|", substr($fgsis[$jfgsis],5) ))]  ))));
               //if ($wplacex != $wplace) file_put_contents('broome.txt', $fupa . "\n" . substr($fgsis[$jfgsis],5) . "\n" . noemoji(substr($fgsis[$jfgsis],5))); 
             }
             $wurll="http://en.wikipedia.org/wiki/" . $wplace;
             $wcont=@file_get_contents("http://en.wikipedia.org/wiki/" . $wplace);
             $butthen="";
             if (strpos($wcont, '>' . str_replace("_"," ",$wplace) . ',') !== false && sizeof(explode("<img ", $wcont)) < 6) {
               $wasw=$wurll;
               $newwurll="http://en.wikipedia.org/wiki/" . $wplace . "," . str_replace(" ","_",explode('</a>',explode('>' . str_replace("_"," ",$wplace) . ',', $wcont)[1])[0]);
               if (strpos($newwurll, "<") === false) {
                $wcont=@file_get_contents($newwurll);
               } else {
                $wurll=$wasw;
               }
             }
             if (strpos($wcont, ' id="content"') !== false) {
               $isc=sizeof(explode("<img ", $wcont));
               $wconts=explode(' id="content"', $wcont);
               $wcont=$wconts[1];
               if (strpos($wcont, '<table ') !== false) {
                $wconts=explode('<table ', $wcont);
                $wcont=str_replace($wconts[0],"",$wcont);
               } else if ($isc >= 8) {
                if (strpos($wcont, ' id="firstHeading"') !== false) {
                $wconts=explode(' id="firstHeading"', $wcont);
                $wcont=str_replace($wconts[0],"",$wcont);
                } else {
                $wcont=$wcont;
                }
               } else {
                $wcont="";
               }
             } else {
               $wcont="";
             }
             if (strpos($wcont, "<img ") !== false) {
               $wcs=explode("<img ", $wcont);
               if (strpos(explode(' src="', $wcs[1])[0], '-logo') !== false) {
                 if ($jfgsis > 0) {
                   $ofupa.=$fdel . " "; //$gfsis[$jfgsis];
                 } else {
                   $ofupa=" ";
                 }
               } else if (strpos($wcs[1], ' src="http') !== false) {
                 if ($jfgsis > 0) {
                   $ofupa.=$fdel . str_replace("ht" . "tp:","", str_replace("ht" . "tps:","", explode('"', explode(' src="', $wcs[1])[1])[0])) . "#" . $wurll;
                 } else {
                   $ofupa=explode('"', explode(' src="', $wcs[1])[1])[0] . "#" . $wurll;
                 }
               } else if (strpos($wcs[1], ' src="//') !== false) {
                 if ($jfgsis > 0) {
                   $ofupa.=$fdel . explode('"', explode(' src="', $wcs[1])[1])[0] . "#" . $wurll;
                 } else {
                   $ofupa=explode('"', explode(' src="', $wcs[1])[1])[0] . "#" . $wurll;
                 }
               } else if (strpos($wcs[1], ' src="') !== false) {
                 if ($jfgsis > 0) {
                   $ofupa.=$fdel . "//en.wikipedia.org/wiki/" . explode('"', explode(' src="', $wcs[1])[1])[0] . "#" . $wurll;
                 } else {
                   $ofupa="//en.wikipedia.org/wiki/" . explode('"', explode(' src="', $wcs[1])[1])[0] . "#" . $wurll;
                 }
               } else if ($jfgsis > 0) {
                 $ofupa.=$fdel . " "; //$gfsis[$jfgsis];
               }
             } else if ($jfgsis > 0) {
               $ofupa.=$fdel . ""; //$gfsis[$jfgsis];
             } else {
               $ofupa="";
             }
            } else if ($jfgsis > 0) {
             $ofupa.=$fdel . $gfsis[$jfgsis] . "#" . $wurll;
            }
         } else if ($jfgsis > 0) {
            $ofupa.=$fdel . $gfsis[$jfgsis] . "#" . $wurll;
         }
        }
        return $ofupa;
}

function tzl($inwith, $dc) {
   if (!$dc) $inwithtz=($inwith);
   if ($dc) $inwithtz=urldecode($inwith);
   if (strpos($inwithtz, "~http;") !== false) { // co-ordinates via net
     $inwithtz=str_replace("`","",str_replace("`,","",'`' . read_and_array("http;" . explode("~",explode("~http;", $inwithtz)[1])[0], str_replace('geo_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])))));
   } else if (strpos($inwithtz, "~Http;") !== false) { // co-ordinates via net
     $inwithtz=str_replace("`","",str_replace("`,","",'`' . read_and_array("http;" . explode("~",explode("~Http;", $inwithtz)[1])[0], str_replace('geo_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])))));
   } else if (strpos($inwithtz, "~HTTP;") !== false) { // co-ordinates via net
     $inwithtz=str_replace("`","",str_replace("`,","",'`' . read_and_array("http;" . explode("~",explode("~HTTP;", $inwithtz)[1])[0], str_replace('geo_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])))));
   } else if (strpos($inwithtz, "~https;") !== false) { // co-ordinates via net
     $inwithtz=str_replace("`","",str_replace("`,","",'`' . read_and_array("http;" . explode("~",explode("~https;", $inwithtz)[1])[0], str_replace('geo_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])))));
   } else if (strpos($inwithtz, "~Https;") !== false) { // co-ordinates via net
     $inwithtz=str_replace("`","",str_replace("`,","",'`' . read_and_array("http;" . explode("~",explode("~Https;", $inwithtz)[1])[0], str_replace('geo_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])))));
   } else if (strpos($inwithtz, "~HTTPS;") !== false) { // co-ordinates via net
     $inwithtz=str_replace("`","",str_replace("`,","",'`' . read_and_array("http;" . explode("~",explode("~HTTPS;", $inwithtz)[1])[0], str_replace('geo_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])))));
   } else if (strpos($inwithtz, "~http") !== false) { // co-ordinates via net
     $inwithtz=str_replace("`","",str_replace("`,","",'`' . read_and_array("http" . explode("~",explode("~http", $inwithtz)[1])[0], str_replace('geo_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])))));
   } else if (strpos($inwithtz, "~Http") !== false) { // co-ordinates via net
     $inwithtz=str_replace("`","",str_replace("`,","",'`' . read_and_array("http" . explode("~",explode("~Http", $inwithtz)[1])[0], str_replace('geo_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])))));
   } else if (strpos($inwithtz, "~HTTP") !== false) { // co-ordinates via net
     $inwithtz=str_replace("`","",str_replace("`,","",'`' . read_and_array("HTTP" . explode("~",explode("~HTTP", $inwithtz)[1])[0], str_replace('geo_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])))));
   } else if (strpos(str_replace("https;","http;",substr(strtolower($inwithtz . "      "),0,6)), "http;") !== false) { // co-ordinates longhand via prompt
     $inwithtz=str_replace("`","",str_replace("`,","",'`' . read_and_array($inwithtz, str_replace('geo_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])))));
   } else if (strpos(str_replace("https:","http:",substr(strtolower($inwithtz . "      "),0,6)), "http:") !== false) { // co-ordinates via URL via net
     $inwithtz=str_replace("`","",str_replace("`,","",'`' . read_and_array($inwithtz, str_replace('geo_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])))));
   } else {
     return $inwith;
   }
   echo "\n pardata=\"" . urlencode("," . $inwithtz) . "\"; paramdata=decodeURIComponent(pardata);  \n  xcom=paramdata.replace(/, 66]/g,'').replace(/,66]/g,'').replace(/\\[/g,'').replace(/~/g,'').replace(/'/g,''); \n var xxpardata=\"" . ("," . $inwithtz) . "\"; \n";
   return $inwithtz;
}

function recode($iniso) {
  global $iso_country_codes, $inplace;
  $outiso=$iniso . $inplace;
  for ($ic=0; $ic<sizeof($iso_country_codes); $ic+=2) {
    if ($iso_country_codes[$ic] == $iniso) return $iniso . " (" . $iso_country_codes[1 + $ic] . ")";
  }
  return $outiso;
}

function server_remote_addr($inst) {
    global $lastgo;
    $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(preg_match('/(mozilla)[ \/]([\w.]+)/', $ua))
            $rma = '0'.$rma;
    if (isset($_GET['popularity'])) {
      $file_handle = fopen("TestGeoChart_" . $rma . ".html", "w");
      fwrite($file_handle, $_SERVER['REQUEST_URI']);
      fclose($file_handle);
      $timesuff = date("Y-m-d-H-i-s");
      while (file_exists("GeoChart_" . $rma . "_" . $timesuff . ".html")) {
       $timesuff = date("Y-m-d-H-i-s");
      }
      $file_handle = fopen("GeoChart_" . $timesuff . ".html", "w");
      fwrite($file_handle, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="//www.w3.org/1999/xhtml"><head>  <script type="text/javascript" src="//www.rjmprogramming.com.au/gchartgen.js?c=h"></script> <script type="text/javascript" src="//www.rjmprogramming.com.au/gchartgen.js?d=f"></script><meta http-equiv="Refresh" content="5;url=' . $_SERVER['REQUEST_URI'] . '"><meta name="viewport" content="width=device-width, initial-scale=0.75"> <link rel="stylesheet" href="//code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /><script src="//code.jquery.com/jquery-1.8.2.min.js"></script><script src="//code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script><style> .ochart_div { min-width:800px; -webkit-overflow-scrolling:touch;overflow:scroll; } </style></head><body> <div data-role="page"></div><!-- /page --></body></html>');
      fclose($file_handle);
      $lastgo = "&nbsp;&nbsp;&nbsp;<a target=_blank title='Last Geo Map' href='" . $_SERVER['REQUEST_URI'] . "'>Last</a>" . "&nbsp;&nbsp;<a href='mailto:rmetcalfe15@gmail.com?subject=Email Last Geo Map link to " . $GETtitle . " //www.rjmprogramming.com.au/PHP/GeoChart/GeoChart_" . $timesuff . ".html" . "&body=Change Email Address then Email Last Geo Map link to " . $GETtitle . " //www.rjmprogramming.com.au/PHP/GeoChart/GeoChart_" . $timesuff . ".html&cc=&bcc='>Email</a>&nbsp;&nbsp;<a onclick='var qqq=document.getElementById(" . '"' . "ourw" . '"' . "); qqq.style.display=" . '"' . "block" . '";' . "' title='Width?' href='#'>W?</a>&nbsp;&nbsp;<a onclick='var qqq=document.getElementById(" . '"' . "ourh" . '"' . "); qqq.style.display=" . '"' . "block" . '";' . "' title='Height?' href='#'>H?</a>&nbsp;&nbsp;<a title='Intensity Map?' href='../IntensityChart/intensity_chart.php?isMobile=y'>+</a>";
      if (isset($_GET['isMobile']) || isset($_POST['isMobile'])) {
  if (strpos($_SERVER['QUERY_STRING'], "justmenu") === false && strpos($_SERVER['HTTP_REFERER'], "justmenu") === false) {
      $lastgo .= '&nbsp;&nbsp;<a title="Another Geo Map" href="./geo_chart.php?isMobile=y">Another?</a>' . $lastgo . "\n";
  } else {
      $lastgo .= '&nbsp;&nbsp;<a title="Another Geo Map" href="./geo_chart.php?isMobile=yjustmenu">Another?</a>' . $lastgo . "\n";
  }
      } else {
  if (strpos($_SERVER['QUERY_STRING'], "justmenu") === false && strpos($_SERVER['HTTP_REFERER'], "justmenu") === false) {
      $lastgo .= '&nbsp;&nbsp;<a title="Another Geo Map" href="./geo_chart.php">Another?</a>';
  } else {
      $lastgo .= '&nbsp;&nbsp;<a title="Another Geo Map" href="./geo_chart.php?justmenu=justmenu">Another?</a>';
  }
      }
    } else if (strlen($inst) > 0 && file_exists("TestGeoChart_" . $rma . ".url")) {
      $file_handle = fopen("TestGeoChart_" . $rma . ".url", "r");
      $rma=fgets($file_handle);
      fclose($file_handle);
      $timesuff = date("Y-m-d-H-i-s");
      while (file_exists("GeoChart_" . $rma . "_" . $timesuff . ".html")) {
       $timesuff = date("Y-m-d-H-i-s");
      }
      $file_handle = fopen("GeoChart_" . $timesuff . ".html", "w");
      fwrite($file_handle, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="//www.w3.org/1999/xhtml"><head>  <script type="text/javascript" src="//www.rjmprogramming.com.au/gchartgen.js?w=g"></script><meta http-equiv="Refresh" content="5;url=' . $rma . '"><meta name="viewport" content="width=device-width, initial-scale=0.75"> <link rel="stylesheet" href="//code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /><script src="//code.jquery.com/jquery-1.8.2.min.js"></script><script src="//code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script><style> .ochart_div { min-width:800px; -webkit-overflow-scrolling:touch;overflow:scroll; } </style></head><body> <div data-role="page"></div><!-- /page --></body></html>');
      fclose($file_handle);
      $rma = "&nbsp;&nbsp;&nbsp;<a target=_blank title='Last Geo Map' href='" . $rma . "'>Last</a>" . "&nbsp;&nbsp;<a href='mailto:rmetcalfe15@gmail.com?subject=Email Last Geo Map link to //www.rjmprogramming.com.au/PHP/GeoChart/GeoChart_" . $timesuff . ".html" . "&body=Change Email Address then Email Last Geo Map link to //www.rjmprogramming.com.au/PHP/GeoChart/GeoChart_" . $timesuff . ".html&cc=&bcc='>Email</a>&nbsp;&nbsp;<a onclick='var qqq=document.getElementById(" . '"' . "ourw" . '"' . "); qqq.style.display=" . '"' . "block" . '";' . "' title='Width?' href='#'>W?</a>&nbsp;&nbsp;<a onclick='var qqq=document.getElementById(" . '"' . "ourh" . '"' . "); qqq.style.display=" . '"' . "block" . '";' . "' title='Height?' href='#'>H?</a>&nbsp;&nbsp;<a title='Intensity Map?' href='../IntensityChart/intensity_chart.php?isMobile=y'>+</a>";
      if (isset($_GET['isMobile']) || isset($_POST['isMobile'])) {
  if (strpos($_SERVER['QUERY_STRING'], "justmenu") === false && strpos($_SERVER['HTTP_REFERER'], "justmenu") === false) {
      $rma .= '&nbsp;&nbsp;<a title="Another Geo Map" href="./geo_chart.php?isMobile=y">Another?</a>' . $lastgo . "\n";
  } else {
      $rma .= '&nbsp;&nbsp;<a title="Another Geo Map" href="./geo_chart.php?isMobile=yjustmenu">Another?</a>' . $lastgo . "\n";
  }
      } else {
  if (strpos($_SERVER['QUERY_STRING'], "justmenu") === false && strpos($_SERVER['HTTP_REFERER'], "justmenu") === false) {
      $rma .= '&nbsp;&nbsp;<a title="Another Geo Map" href="./geo_chart.php">Another?</a>';
  } else {
      $rma .= '&nbsp;&nbsp;<a title="Another Geo Map" href="./geo_chart.php?justmenu=justmenu">Another?</a>';
  }
      }
      $lastgo = $rma;
    }
    return $rma;
}

  function retval($inv) {
    if (strpos($inv, "E-") !== false) return "0";
    return $inv;
  }



    echo '<html>' . "\n";
    echo '<head> <script type="text/javascript" src="//www.rjmprogramming.com.au/gchartgen.js?c=f"></script> ' . "\n";
    echo '<title>Geo Map - RJM Programming - //www.rjmprogramming.com.au (Copyright &copy; 2013 rjmprogramming.com.au all rights reserved.)</title>' . "\n";
    echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . "\n";
    echo '<meta name="viewport" content="width=device-width, initial-scale=0.75">' . "\n";
    echo '<script type="text/javascript" src="https://www.google.com/jsapi"></script>' . "\n";
    echo '<script type="text/javascript">' . "\n var exra=''; \n var comma=''; \n";

    echo "var lastgmd='',fti=false,ready=false, x=-1, y=-1, elemLeft=0, elemTop=0, ir=-1, ic=-1, talkingpoint=''; "  . "\n"; 
    echo "var xpnum=1; /" . "/ done here at supervisor "  . "\n"; 
    echo "var allowed=true; /" . "/ done here at supervisor "  . "\n"; 
    echo "var nojwinextra=''; /" . "/ done here at supervisor "  . "\n"; 
  if (!isset($_POST['data'])) {
  echo "
   if (document.URL.indexOf('nojwin') == -1 && navigator.userAgent.match(/iPhone|iPad/i)) {
     if (document.URL.indexOf('?') == -1) {
       location.href=document.URL.split('#')[0] + '?nojwin=Q';
     } else {
       location.href=document.URL.split('#')[0] + '&nojwin=Q';
     }
   }
   ";
  }

    echo "  if (document.URL.indexOf('nojwin') != -1 || navigator.userAgent.match(/iPhone|iPad/i)) {
     nojwinextra='&nojwinyes=Y';
     }  
     ";
     
 echo "
 
 function dlp(thisris) {
      if (thisris != null) {
        var commacount=thisris.toLowerCase().replace(/\\<\\/td\\>/g,'  ,  ').indexOf(',');
        if (thisris.toLowerCase().replace('https:','http:').indexOf('http:') == 0) {
             fti=true;
             allowed=true;
             datac=thisris;
        } else if (commacount >= 0) {   
             var thatris=thisris.replace(/\\ \\" . '"' . "/g,String.fromCharCode(10) + '" . '"' . "').replace(/\\<tr\\>/g,'').replace(/\\<\\/td\\>\\<td\\>/g,',').replace(/\\<\\/tr\\>/g,String.fromCharCode(10)).replace(/\\<\\/td\\>/g,',').replace(/\\,\\,/g,',').replace(/\\,\\,/g,',').replace(',' + String.fromCharCode(10),String.fromCharCode(10));
             var zisok=true, fldq=thatris.split(',');
             var pielines=thatris.split(String.fromCharCode(10));
             if ((fldq[0].replace('" . '"' . "','').trim() + ' ').substring(0,1) < '0' || (fldq[0].replace('" . '"' . "','').trim() + ' ').substring(0,1) > '9') {
              if ((fldq[eval(-1 + fldq.length)].replace('" . '"' . "','').trim() + ' ').substring(0,1) < '0' || (fldq[eval(-1 + fldq.length)].replace('" . '"' . "','').trim() + ' ').substring(0,1) > '9') {
               zisok=false;
              }
             }
             if (!zisok && pielines.length > 1) {
             fldq=pielines[1].split(',');
             zisok=true;
             if ((fldq[0].replace('" . '"' . "','').trim() + ' ').substring(0,1) < '0' || (fldq[0].replace('" . '"' . "','').trim() + ' ').substring(0,1) > '9') {
              if ((fldq[eval(-1 + fldq.length)].replace('" . '"' . "','').trim() + ' ').substring(0,1) < '0' || (fldq[eval(-1 + fldq.length)].replace('" . '"' . "','').trim() + ' ').substring(0,1) > '9') {
               zisok=false;
              }
             }
             }
             if (zisok) {
             while (thatris.indexOf(String.fromCharCode(10)) != -1) {
              var inpies, pied='';
              thatris='';
              var sthatris='';
              for (var ipie=0; ipie<pielines.length; ipie++) {
               inpies=pielines[ipie].split(',');
               if (inpies.length > 1) {
                if ((inpies[0].trim() + ' ').substring(0,1) == '" . '"' . "' && (inpies[1].trim() + ' ').substring(0,1) == '" . '"' . "') {
                sthatris=pied + inpies[0].trim().substring(1).split('" . '"' . "')[0].trim().replace('%','').replace(',','').replace(',','') + ',' + inpies[1].trim().substring(1).split('" . '"' . "')[0].trim().replace('%','').replace(',','').replace(',','');
                } else if ((inpies[0].trim() + ' ').substring(0,1) == '" . '"' . "') {
                sthatris=pied + inpies[0].trim().substring(1).split('" . '"' . "')[0].trim().replace('%','').replace(',','').replace(',','') + ',' + inpies[1].trim().replace('%','').replace('" . '"' . "','');
                } else if ((inpies[1].trim() + ' ').substring(0,1) == '" . '"' . "') {
                sthatris=pied + inpies[0].trim().replace('%','') + ',' + inpies[1].trim().substring(1).split('" . '"' . "')[0].trim().replace('%','').replace(',','').replace(',','');
                } else {
                sthatris=pied + inpies[0].trim().replace('%','') + ',' + inpies[1].trim().replace('%','').replace('" . '"' . "','');
                }
                inpies=sthatris.replace(pied,'').split(',');
                //alert(sthatris + ' ' + inpies[0] + ' ' + inpies[1]);
                if (((inpies[0].trim() + ' ').substring(0,1) >= '0' && (inpies[0].trim() + ' ').substring(0,1) <= '9') || ((inpies[1].trim() + ' ').substring(0,1) >= '0' && (inpies[1].trim() + ' ').substring(0,1) <= '9')) {
                thatris+=sthatris;
                //alert(thatris);
                pied=',';
                }
               }
              }
             }
             thatris=thatris.replace(/\\,\\,/g,',');
             fti=true;
             allowed=true;
             datac='http;' + thatris;
             thisris='http;' + thatris;   
             }
        }
      }
      
      return thisris;
      
 }
";    
     

 echo "
 
     function selectevent(ans) {
            var relist;
            if (ans != '' && ans != paramdata) {
             if ((ans.toLowerCase() + '~').indexOf('.csv~') != -1 && ans.toLowerCase().indexOf('&') == -1) ans=paramdata + '&csv=' + ans;
             var ansbits=ans.split(' ');
             if (ansbits[0].indexOf('@') != -1) {
              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';
              for (var ire=0; ire<2; ire++) {
              if (relist[ire] != '') {
              document.getElementById(relist[ire]).href=document.getElementById(relist[ire]).href.replace('fillin.email@address', ansbits[0]);
              if (document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('&r=') + item.row) == -1) document.getElementById(relist[ire]).href+=encodeURIComponent('&r=') + item.row;
              //if (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 (ans.substring(0,1).toLowerCase() == 'p') {
              location.href=document.URL.replace('/GeoChart', '/PieChart').replace('geo_chart.php', 'pie_chart.php');
             } else if (document.URL.indexOf(pardata) != -1) {
              location.href=document.URL.replace(pardata, ourencodeURIComponent(ans));
             } else if (document.URL.indexOf('data=') != -1) {
              location.href=document.URL.replace(document.URL.split('data=')[1].split('&')[0], ourencodeURIComponent(('`' + ans).replace('`,','').replace('`','')));
             }
            }     
     }

     function selecteventtwo(ans) {
            var relist;
            if (ans != '' && ans != paramdata) {
             if ((ans.toLowerCase() + '~').indexOf('.csv~') != -1 && ans.toLowerCase().indexOf('&') == -1) ans=paramdata + '&csv=' + ans;
             var ansbits=ans.split(' ');
             if (ansbits[0].indexOf('@') != -1) {
              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';
              for (var ire=0; ire<2; ire++) {
              if (relist[ire] != '') {
              document.getElementById(relist[ire]).href=document.getElementById(relist[ire]).href.replace('fillin.email@address', ansbits[0]);
              if (document.getElementById(relist[ire]).href.indexOf(encodeURIComponent('&r=') + item.row) == -1) document.getElementById(relist[ire]).href+=encodeURIComponent('&r=') + item.row;
              //if (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 (ans.substring(0,1).toLowerCase() == 'p') {
              location.href=document.URL.replace('/GeoChart', '/PieChart').replace('geo_chart.php', 'pie_chart.php');
             } else if (document.URL.indexOf(pardata) != -1) {
              location.href=document.URL.replace(pardata, ourencodeURIComponent(ans));
             } else if (document.URL.indexOf('data=') != -1) {
              location.href=document.URL.replace(document.URL.split('data=')[1].split('&')[0], ourencodeURIComponent(('`' + ans).replace('`,','').replace('`','')));
             }
            }     
     
     }

    ";




    echo "var data, chart, pardata = (location.search.split('data=')[1] ? location.search.split('data=')[1].split('&')[0] : ''), paramdata=decodeURIComponent(pardata) , xcom=paramdata.replace(/, 66]/g,'').replace(/,66]/g,'').replace(/\[/g,'').replace(/~/g,'').replace(/'/g,''); \n";
 
      $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 != "") {
       if (substr($GETr,0,1) == "0" && strlen($GETr) > 1) {
        $top="top.";
        $ntop="2";
        $mtop="1";
        $roff="1";
       }
       echo "\n ir=eval('" . $GETr . "'); \n";
      }
      if ($GETc != "") {
       if (substr($GETc,0,1) == "0" && strlen($GETc) > 1) {
        $top="top.";
        $ntop="2";
        $mtop="1";
        $roff="1";
       }
       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";
      }

      

      $xgd = ""; 
      $gd = ""; 
      $ntt=false;
      $GETarea="";
      if (isset($_GET['area'])) {
         if ($top == "") $top=" ";
         $GETarea = str_replace("~","",str_replace(",~~", "", ",~" . $_GET['area'] . "~"));
      }
      if (isset($_GET['popularity']) || isset($_POST['popularity'])) server_remote_addr("");
      $GETtitle = "My World Survey";
      $GETcountry = "Country";
      $GETpopularity = "Popularity";
      $GETdata = "['Germany',200],['United States',300],['Brazil',400],['Canada',500],['France',600],['RU',700] ";      
      if (isset($_GET['isMobile']) || isset($_POST['isMobile']) || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'mobile') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'android')) {
      $GETwidth = "305";
      $GETheight = "190";
      $myextras = "";
      } else {
      $GETwidth = "556";
      $GETheight = "347";
      }
      if (isset($_GET['isMobile']) || isset($_POST['isMobile'])) $GETimage="";
      if (isset($_GET['popularity'])) {
       if ($GETimage == "" && strpos($_GET['data'], "%2C") === false) {
       $GETtitle = $_GET['title'];
       titlebits($burl, $GETtitle, $cdivc, $bdivstart, $bdivend, $nondefs);
       $GETcountry = $_GET['country'];
       $GETpopularity = $_GET['popularity'];
       $GETdata = tzl($_GET['data'],true);
       $GETwidth = $_GET['width'];
       $GETheight = $_GET['height'];
       if (isset($_GET['area'])) {
         if ($top == "") $top=" ";
         $GETarea = str_replace("~","",str_replace(",~~", "", ",~" . $_GET['area'] . "~"));
       }
       } else {
       $GETtitle = urldecode($_GET['title']);
       titlebits($burl, $GETtitle, $cdivc, $bdivstart, $bdivend, $nondefs);
       $GETcountry = urldecode($_GET['country']);
       $GETpopularity = urldecode($_GET['popularity']);
       $GETdata = tzl(urldecode($_GET['data']),false);
       $GETwidth = urldecode($_GET['width']);
       $GETheight = urldecode($_GET['height']);
       if (isset($_POST['area'])) {
         if ($top == "") $top=" ";
         $GETarea = str_replace("~","",str_replace(",~~", "", ",~" . urldecode($_POST['area']) . "~"));
       }
       }
       $ourtitles=explode(";", $GETtitle);
       if (sizeof($ourtitles) > 1) {
        $newextras="region: '" . $ourtitles[0] . "', displayMode: 'markers', colorAxis: {colors: ['green', 'blue']}, ";
       }
       $GETtitle = $ourtitles[sizeof($ourtitles) - 1];
       $GETimage="";
      } else if (isset($_POST['popularity']) && (isset($_POST['isMobile']) || isset($_POST['wouldlikeyoutoseekpermission']))) {
       $GETimage="";
       $GETtitle = urldecode($_POST['title']);
       titlebits($burl, $GETtitle, $cdivc, $bdivstart, $bdivend, $nondefs);
       $ourtitles=explode(";", $GETtitle);
       if (sizeof($ourtitles) > 1) {
        $newextras="region: '" . $ourtitles[0] . "', displayMode: 'markers', colorAxis: {colors: ['green', 'blue']}, ";
       }
       $GETtitle = $ourtitles[sizeof($ourtitles) - 1];
       $GETcountry = urldecode($_POST['country']);
       $GETpopularity = urldecode($_POST['popularity']);
       $GETdata = tzl(urldecode($_POST['data']),false);
       $GETwidth = urldecode($_POST['width']);
       $GETheight = urldecode($_POST['height']);
       if (isset($_POST['area'])) {
         if ($top == "") $top=" ";
         $GETarea = str_replace("~","",str_replace(",~~", "", ",~" . urldecode($_POST['area']) . "~"));
       }
      }

      echo " var colnames= '" . $GETcountry . "," . str_replace("'", "", $GETpopularity) . $GETarea . "'; \n";

      $nondefs.="width: " . $GETwidth . ", height: " . $GETheight;
      $newextras.=$nondefs;
      
      echo "   var sliceid = 0; /" . "/ thanks to https://gist.github.com/alexrainman/bb8d49357250df0859c0  \n";
      echo "   var refresh=0; prerefresh=0;   \n";
      echo ' google.load("visualization", "1", {packages:["geochart"]}); ' . "\n";
      echo ' google.setOnLoadCallback(drawChart); ' . "\n";
      
      if ($GETarea == '') {
       echo "\nfunction unzero(cin) { return cin; } \n";
      } else {
       echo "\nfunction unzero(cin) { return cin.replace('.0000000000', ' and " . str_replace(","," ",$GETarea) . " of '); } \n";
      }
      
      
      echo ' function drawChart() { ' . "\n";
 if ((isset($_GET['data']) || isset($_POST['data'])) && (isset($_GET['tooltip']) || isset($_POST['tooltip']) || strpos($GETdata, "'") !== false || strpos($GETdata, '"') !== false)) {
      $ntt=true;
  //$newextras=$nondefs . ", focusTarget: 'category', tooltip: {isHtml: true} ";
  $newextras=$nondefs . ", tooltip: {isHtml: true}, showTip: true"; //, selectionMode: 'multiple', tooltip: {trigger: 'selection'}, aggregationTarget: 'none' ";
  echo "       var tooltip = [ \n";
  $bits=explode("~,", substr($GETdata,1));
  $delts="";
  for ($iy=1; $iy<sizeof($bits); $iy++) {
   $postbits=explode(",", $bits[$iy]);
   $xgd.=str_replace("%3C", "<", str_replace("%3E", ">", $postbits[0]));
   echo $delts . str_replace("%3C", "<", str_replace("%3E", ">", $postbits[0]));
   $delts=",";
  }
  echo "]; \n";
  $gd=$GETdata;
  for ($iy=1; $iy<sizeof($bits); $iy++) {
   $postbits=explode(",", $bits[$iy]);
   $gd=str_replace("," . $postbits[0] . "", "", $gd);
  }
  $GETdata=$gd;
  echo "     data = new google.visualization.DataTable();  \n";
  if (isset($_GET['aregeographicals']) || isset($_POST['aregeographicals'])) {
  echo "   data.addColumn('number', 'Lat'); \n";
  echo "   data.addColumn('number', 'Lon'); \n";
  }
  echo "   data.addColumn('string', '" . $GETcountry . "');  \n";
  //echo "   data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}});  \n";
  $things=explode(",",$GETpopularity);
  for ($it=0; $it<sizeof($things); $it++) { 
    echo "   data.addColumn('number', '" . $things[$it] . "');  \n";
  }
  echo " data.addRows([ \n";
  //echo str_replace("~,", "',", str_replace("[~", "['", str_replace(",]", ",0]", str_replace(",]", ",0]", str_replace(",]", ",0]", substr($GETdata,1))))));
  echo str_replace("|", ",", str_replace("~", "'", substr($GETdata,1)));
  echo "   ]); \n";
 } else {
      echo ' data = google.visualization.arrayToDataTable([ ' . "\n";
  if (isset($_GET['aregeographicals']) || isset($_POST['aregeographicals'])) {
      echo " ['Lat','Long','" . $GETcountry . "','" . str_replace(",", "','", $GETpopularity) . "'], \n";
  } else {
      echo " ['" . $GETcountry . "','" . str_replace(",", "','", $GETpopularity) . "'], \n";
  }
      echo str_replace("|", ",", str_replace("~", "'", str_replace("~,", "',", str_replace("[~", "['", str_replace(",]", ",0]", str_replace(",]", ",0]", str_replace(",]", ",0]", $GETdata))))) ));
      echo "        ]);\n";
 }
      echo " chart = new google.visualization.GeoChart(document.getElementById('chart_div')); \n";

 if ($ntt) {
   
      //echo "   var selection; \n";

      echo "   function checkhere() { prerefresh++; if (prerefresh == 20) { if (refresh == 0) { refresh=1; document.getElementById('ihide').value=1;  } } \n";
      echo "   refresh=document.getElementById('ihide').value; if (refresh != 0) { prerefresh=0; refresh++; document.getElementById('ihide').value=refresh; if (refresh == 10) { var huhss=document.URL.split('&xx='); if (huhss.length == 1) {  top.location.href=document.URL + '&xx=1'; } else { var two=eval(huhss[1]); two++; top.location.href=huhss[0] + '&xx=' + two;  }  }    } setTimeout(checkhere,1000); \n } \n";

      echo "   checkhere(); \n";
  
      echo "   function eventHandler(e){ \n";
      //echo "     chart.setSelection([e]); \n";
      echo "     try { \n";
      echo "       selection = chart.getSelection(); \n";
      echo "       sliceid = selection[0].row; \n";
      echo '    $(".google-visualization-tooltip-item-list li:eq(0)").css("font-weight", "bold"); ' . "\n";
      echo '    $(".google-visualization-tooltip-item-list li:eq(1)").html(tooltip[sliceid]).css("font-family", "Arial");  ' . "\n";
      echo "     } \n";
      echo "     catch(err) { \n";
      echo "       ; \n";
      echo "     } \n";
      echo "   } \n";
  
      echo "   function ceventHandler(e){   \n";
      //echo "   google.visualization.events.addListener(chart, 'select', eventHandler); \n";
      //echo "     chart.setSelection([e]); \n";
      echo "     try { \n";
      echo "       selection = chart.getSelection(); \n";
      echo "       sliceid = selection[0].row; \n if (1 == 2) { alert(tooltip[sliceid]); } document.getElementById('chart_div').innerHTML+=' '; \n document.getElementById('ihide').value='1'; \n";
      echo '    $(".google-visualization-tooltip-item-list li:eq(0)").css("font-weight", "bold"); ' . "\n";
      echo '    $(".google-visualization-tooltip-item-list li:eq(1)").html(tooltip[sliceid]).css("font-family", "Verdana");  ' . "\n";
      echo "     } \n";
      echo "     catch(err) {   \n";
      echo "       ; \n";
      echo "     } \n";
      echo "   } \n";
  
  
      if (strpos($xgd, "<") !== false) {
        echo "   google.visualization.events.addListener(chart, 'select', ceventHandler); \n";
        echo "   google.visualization.events.addListener(chart, 'onmouseover', eventHandler);  \n";
      } else {
        echo "   google.visualization.events.addListener(chart, 'onmouseover', eventHandler); \n";
      }
}
      $GETonclick = "";
      if (isset($_GET['onclick'])) $GETonclick = urldecode($_GET['onclick']);
      if (isset($_POST['onclick'])) $GETonclick = urldecode($_POST['onclick']);
      if ($GETonclick != "") {
      echo "google.visualization.events.addListener(chart, 'ready', function() { ready=true; }); \n";
      echo "google.visualization.events.addListener(chart, 'select', myselectfunction); \n function myselectfunction() {
 if (ready) {
  var relist=['remail',''],ire,ansbits,avblurb=talkingpoint,ioffset=0,ans=null,doit=true,kl,lk, thisnum, num=0,message = '', dparts, colparts=colnames.split(','), colav=new Array(), predparts, postdparts, diffcolnames=colnames,diffvalues, str;
  selection = chart.getSelection();
  sliceid = selection[0].row;

  for (var i = 0; i < selection.length; i++) {
    var item = selection[i];
    if ((eval(ir) >= 0 && eval(ic) < 0)) {
      if (eval(ir) >= 0 && eval(ic) < 0) {
  //alert(999);
        item.row=eval(ir + " . $roff . ");
        //item.column=ic;
  //alert(9999);
        ir=-1;
        ic=-1;
      } else {
        ir=item.row;
        //ic=item.column;
        //document.title=ir + ',' + ic;
        if ('" . $top . "' == ' ') {
         top.document.location=top.document.URL.replace('&r=','&xr=').replace('?','?r=' + ir + '&');
         return;
        }
      }
      //document.title=str;
      message=" . $top . "document.head.innerHTML.replace(/, \[/g,',' + '[').replace('[' + String.fromCharCode(39),'[ ' + String.fromCharCode(39)).replace('[' + String.fromCharCode(39),', [' + String.fromCharCode(39)).substring(ioffset);
      while (message.indexOf(',' + ' [') != -1) {
       message=message.replace(',' + ' [',',' + '[');
      }
      //alert(message);
      dparts=message.split(',[');
        //document.title='';
        colav.push(0.0);
      for (kl=" . $ntop . "; kl<colparts.length; kl++) {
        //alert('dp[1]=' + dparts[1]);
        //document.title=1;
        colav.push(0.0);
        doit=true;
        num=1;
        for (lk=" . $mtop . "; lk<dparts.length; lk++) {
         if (doit) {
        //document.title=3;
        //alert('dparts[' + lk + ']=' + dparts[lk].replace(']',','));
         thisnum=dparts[lk].replace(']);',',').replace(']',',').split(',');
         //if (kl == 1) document.title+=4 + ' .. '  + eval(thisnum[kl]) + ' ... ' + lk + ' ... ' + colav[kl] + ' ... ' + thisnum.length + ' ... ' + dparts[lk];
         //alert(dparts[lk].replace(']',',') + ' 77 ' + thisnum.length + ' vs ' + kl);
        colav[kl] = eval(eval(colav[kl] * eval(-1 + num)) + eval(thisnum[kl])) / eval(0.0 + num);
        //alert(777);
        //document.title=5;
         if (dparts[lk].indexOf(';') != -1) doit=false;
         if (doit) num++;
         }
        }
        //alert(7);
        //document.title=7;
        if (avblurb == '') avblurb+=String.fromCharCode(10) + String.fromCharCode(10);
        //document.title=8;
        //avblurb+='Average ' + colparts[kl] + ' over ' + num + ' ' + colparts[0] + ' values is ' + colav[kl] + String.fromCharCode(10);
        //document.title=7;
      }
      if (avblurb != '') avblurb+=String.fromCharCode(10) + String.fromCharCode(10);
        //alert(dparts.length + ' bigger than ' + eval(1 + item.row));
      if (eval(dparts.length) >= eval(1 + item.row)) {
      //alert(97);
        postdparts=dparts[eval(1 + item.row)].replace(']',',').split(',');
       //alert(977);
       if (eval(postdparts.length) >= eval(1 + item.column)) {
      //alert(197);
         if (eval(colparts.length) >= 2) { 
      //alert(397);
          if (1 == 1) {
          avblurb+=String.fromCharCode(10) + String.fromCharCode(10) + 'Show this as Pie Chart=P' + String.fromCharCode(10) + String.fromCharCode(10);
          avblurb+='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) + '' + String.fromCharCode(10);
          avblurb+='Change data as required below (keeping it the same or being blank or choosing Cancel leaves the status quo)';
          ans=null; \n";

  if ($guess != "") {
          echo "\n var agoes=[0,0]; pscore='';\n if (parent.document.getElementById('score')) {\n pscore=parent.document.getElementById('score').innerHTML;\n agoes=pscore.replace('Score:','').split('/');\n }\n if (eval(('' + postdparts[0].replace(']','')).indexOf('" . $guess . "') / 2) >= 0) {\n if (pscore == '') {\n alert('Correct.'); }\n else if (agoes.length == 2) {\n parent.document.getElementById('score').innerHTML='Score: ' + eval(1 + eval(agoes[0])) + '/' + eval(1 + eval(agoes[1].split(' ')[0]));\n    } else if (agoes.length == 1) { parent.document.getElementById('score').innerHTML='' + eval(1 + eval(agoes[0]));   } } else { var huhhuh='Your guess of ' + postdparts[0].replace(']','') + ' is not correct.  The correct answer is ' + '" . $guess . ".';  if (agoes.length == 2) {\n parent.document.getElementById('score').innerHTML='Score: ' + eval(0 + eval(agoes[0])) + '/' + eval(1 + eval(agoes[1].split(' ')[0]));\n    } else if (agoes.length == 1) { parent.document.getElementById('score').innerHTML=' ' + eval(0 + eval(agoes[0]));   }  alert(huhhuh);  } \n"; 
  } else {
          echo "\n ans=prompt(unzero('For ' + colparts[0] + ' ' + postdparts[0].replace(']','') + ' you clicked ' + colparts[1] + ' of ' + postdparts[1].replace(']','')) + avblurb, paramdata); \n";
  }

      echo "
          if (ans != null) {
			selectevent(ans);
          }
          } else {
          alert('In ' + colparts[0] + ' ' + postdparts[0].replace(']','') + ' you clicked ' + colparts[item.column] + ' of ' + str + ' while ' + colparts[eval(3 - item.column)] + ' were ' + postdparts[eval(3 - item.column)].replace(']','') + ' the difference being ' + eval(eval(postdparts[1].replace(']','')) - eval(postdparts[2].replace(']',''))) + avblurb);
          }
         }
        }
      }
    } 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=eval(ir + " . $roff . ");
        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);
      message += '{row:' + item.row + ',column:' + item.column + '} = ' + str;
    } 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;
        if ('" . $top . "' == ' ') {
         top.document.location=top.document.URL.replace('&r=','&xr=').replace('?','?r=' + ir + '&');
         return;
        }
      }
      str = data.getFormattedValue(item.row, 0);
      //document.title=str;
      //document.title=str;
      message=" . $top . "document.head.innerHTML.replace(/, \[/g,',' + '[').replace('[' + String.fromCharCode(39),'[ ' + String.fromCharCode(39)).replace('[' + String.fromCharCode(39),', [' + String.fromCharCode(39)).substring(ioffset);
      while (message.indexOf(',' + ' [') != -1) {
       message=message.replace(',' + ' [',',' + '[');
      }
      dparts=message.split(',[');
        //document.title='';
        colav.push(0.0);
      for (kl=" . $ntop . "; kl<colparts.length; kl++) {
        //document.title=1;
        colav.push(0.0);
        doit=true;
        num=1;
        for (lk=" . $mtop . "; lk<dparts.length; lk++) {
         if (doit) {
        //document.title=3;
         //alert(dparts[lk].replace(']',','));
         thisnum=dparts[lk].replace(']',',').split(',');
         //if (kl == 1) document.title+=4 + ' .. '  + eval(thisnum[kl]) + ' ... ' + lk + ' ... ' + colav[kl] + ' ... ' + thisnum.length + ' ... ' + dparts[lk];
         colav[kl] = eval(eval(colav[kl] * eval(-1 + num)) + eval(thisnum[kl])) / eval(0.0 + num);
        //document.title=5;
         if (dparts[lk].indexOf(';') != -1) doit=false;
         if (doit) num++;
         }
        }
        //alert('07');
        //document.title=7;
        if (avblurb == '') avblurb+=String.fromCharCode(10) + String.fromCharCode(10);
        //document.title=8;
        //avblurb+='Average ' + colparts[kl] + ' over ' + num + ' ' + colparts[0] + ' values is ' + colav[kl] + String.fromCharCode(10);
        //document.title=7;
      }
      if (avblurb != '') avblurb+=String.fromCharCode(10) + String.fromCharCode(10);
      if (eval(dparts.length) >= eval(1 + item.row)) {
        postdparts=dparts[eval(1 + item.row)].replace(']',',').split(',');
        if (eval(postdparts.length) >= eval(1 + item.column)) {
         if (eval(colparts.length) >= 2) { 
          if (1 == 1) {
          avblurb+=String.fromCharCode(10) + String.fromCharCode(10) + 'Show this as Pie Chart=P' + String.fromCharCode(10) + String.fromCharCode(10);
          avblurb+='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) + '' + String.fromCharCode(10);
          avblurb+='Change data as required below (keeping it the same or being blank or choosing Cancel leaves the status quo)';
          ans=null; \n";

  if ($guess != "") {
          echo "\n var agoes=[0,0]; pscore='';\n if (parent.document.getElementById('score')) {\n pscore=parent.document.getElementById('score').innerHTML;\n agoes=pscore.replace('Score:','').split('/');\n }\n if (eval(('' + postdparts[0].replace(']','')).indexOf('" . $guess . "') / 2) >= 0) {\n if (pscore == '') {\n alert('Correct.'); }\n else if (agoes.length == 2) {\n parent.document.getElementById('score').innerHTML='Score: ' + eval(1 + eval(agoes[0])) + '/' + eval(1 + eval(agoes[1].split(' ')[0]));\n    } else if (agoes.length == 1) { parent.document.getElementById('score').innerHTML='' + eval(1 + eval(agoes[0]));   } } else { var huhhuh='Your guess of ' + postdparts[0].replace(']','') + ' is not correct.  The correct answer is ' + '" . $guess . ".';  if (agoes.length == 2) {\n parent.document.getElementById('score').innerHTML='Score: ' + eval(0 + eval(agoes[0])) + '/' + eval(1 + eval(agoes[1].split(' ')[0]));\n    } else if (agoes.length == 1) { parent.document.getElementById('score').innerHTML=' ' + eval(0 + eval(agoes[0]));   } alert(huhhuh);  } \n"; 
 } else {
          echo "\n ans=prompt(unzero(' For ' + colparts[0] + ' ' + postdparts[0].replace(']','') + ' you clicked ' + colparts[1] + ' of ' + postdparts[1].replace(']','')) + avblurb, paramdata); \n";
  }
      echo "
          if (ans != null) {
			selecteventtwo(ans);
          }
          } else {
          alert('In ' + colparts[0] + ' ' + postdparts[0].replace(']','') + ' you clicked ' + colparts[item.column] + ' of ' + str + ' while ' + colparts[eval(3 - item.column)] + ' were ' + postdparts[eval(3 - item.column)].replace(']','') + ' the difference being ' + eval(eval(postdparts[1].replace(']','')) - eval(postdparts[2].replace(']',''))) + avblurb);
          }
         }
        }
      }

    } 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);
      message += '{row:none, column:' + item.column + '}; value (row 0) = ' + str;
    }
  }
  if (message == '') {
    message = 'nothing';
  }
  if (1 == 2) console.log('You selected ' + message);
 }
 ir=-1;
 ic=-1;    
 } 
      //);  
      ";
      }      

      $optstuff=str_replace("'none' width","'none',width",str_replace("{,","{","{" . $newextras)) . "}";
      if (strpos($optstuff, "markers") === false && (isset($_GET['areplaces']) || isset($_POST['areplaces']) || isset($_GET['aregeographicals']) || isset($_POST['aregeographicals']))) $optstuff=str_replace("}",", displayMode: 'markers'}",$optstuff);      
      echo " chart.draw(data," . $optstuff . "); \n";
      if ($GETr != "" && $GETc == "") echo " chart.setSelection([{'row': " . $GETr . ", 'column': null}]); setTimeout(myselectfunction,4100); \n";
      if ($GETr == "" && $GETc != "") echo " chart.setSelection([{'row': null, 'column': " . $GETc . "}]);  setTimeout(myselectfunction,4100); \n";
      if ($GETr != "" && $GETc != "") echo " chart.setSelection([{'row': " . $GETr . ", 'column': " . $GETc . "}]);  setTimeout(myselectfunction,4100); \n";
      echo " } \n";
      
      if ($guess != "") {
       if ($guessquestion != "") {
        echo "\n function guesswork() { ouralert('" . $guessquestion . "  Click country answer below." . "'); } \n";
       } else {
        echo "\n function guesswork() { ouralert('Click country answer below." . "'); } \n";
       }
       echo "\n\n setTimeout(guesswork,2300); \n\n";
      }      


 echo "   function ouralert(ourpis) {
   var postdparts0='';
   var phuh=" . sizeof($ourtitles) . "; 
if (phuh == 2 || navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) || ('" . $guess . "' != '' && '" . $guess . "'.replace('Andorra','').replace('Monaco','').replace('Vatican City','').replace('Monaco','').replace('Liechtenstein','').replace('Luxembourg','').replace('San Marino','').replace('Nauru','').replace('Maldives','').replace('Grenada','').replace('Malta','').replace('Saint Kitts and Nevis','') == '')) {
if (xcom.length < 300) {
if (phuh == 2) {
postdparts0=prompt(ourpis.replace('Click ','We think that clicks below may not work so you could type country code " . recode($ourtitles[0]) . " city name from ' + xcom + ' or you can try click '),'');
} else {
postdparts0=prompt(ourpis.replace('Click ','We think that clicks below may not work so you could type country from ' + xcom + ' or you can try click '),'');
}
if (postdparts0 == null) postdparts0='';
} else {
if (phuh == 2) {
postdparts0=prompt(ourpis.replace('Click ','We think that clicks below may not work so you could type country code " . recode($ourtitles[0]) . " city name below or you can try click '),'');
} else {
postdparts0=prompt(ourpis.replace('Click ','We think that clicks below may not work so you could type country below or you can try click '),'');
}
if (postdparts0 == null) postdparts0='';
}
  var agoes=[0,0]; pscore='';
  if (parent.document.getElementById('score')) {           pscore=parent.document.getElementById('score').innerHTML;  agoes=pscore.replace('Score:','').split('/');
 }
 if (eval(('' + postdparts0.toLowerCase().replace(']','')).indexOf('" . $guess . "'.toLowerCase()) / 2) >= 0) {
 if (pscore == '') {
alert('Correct.'); 
} else if (agoes.length == 2) {
parent.document.getElementById('score').innerHTML='Score: ' + eval(1 + eval(agoes[0])) + '/' + eval(1 + eval(agoes[1].split(' ')[0])); 
} else if (agoes.length == 1) { 
parent.document.getElementById('score').innerHTML='' + eval(1 + eval(agoes[0])); 
 }
} else if (postdparts0 != '') {
if (agoes.length == 2) {
parent.document.getElementById('score').innerHTML='Score: ' + eval(0 + eval(agoes[0])) + '/' + eval(1 + eval(agoes[1].split(' ')[0])) + ' The correct answer is " . $guess . "'; 
} else if (agoes.length == 1) { 
parent.document.getElementById('score').innerHTML=' ' + eval(0 + eval(agoes[0])); 
 }
}
 } else {
  alert(ourpis);
 }
} \n\n  "; 

 echo "\n function lkin(lfx) {
       return noemoji(lfx.split('|')[eval(-1 + lfx.split('|').length)]);
    }
    function placelook(tis) {
        var xcz;
        var outtis=tis;
        var lookin='';
     if (tis.indexOf('&aregeographicals=') != -1) {
       lookin+=lkin(tis.split('&aregeographicals=')[1].split('&')[0].replace(/\ /g,'_').replace(/\+/g,''));
       if (lookin.length <= 1) lookin='';
     }
     if (tis.indexOf('&areplaces=') != -1) {
         if (lookin != '' && lkin(tis.split('&areplaces=')[1].split('&')[0]).length > 1) {
          lookin+=',' + lkin(tis.split('&areplaces=')[1].split('&')[0].replace(/\ /g,'_').replace(/\+/g,''));
         } else if (lkin(tis.split('&areplaces=')[1].split('&')[0]).length > 1) {
          lookin+=lkin(tis.split('&areplaces=')[1].split('&')[0].replace(/\ /g,'_').replace(/\+/g,''));
         }
         if (lookin.length <= 1) lookin='';
     }
   if (lookin.toLowerCase().replace(/https\./g,'http.').indexOf('http.') == -1 && lookin.indexOf(',') > 0) {
     lookin='http.' + (lookin + '`').replace(/\,/g,',http.').replace('http.`','').replace('`','').replace(/http\.\,/g,',').replace(/\+/g,'');
            if (outtis.indexOf('&aregeographicals=') == -1) {
              outtis=outtis.replace('&areplaces=', '&arexplaces=y&aregeographicals=' + encodeURIComponent(lookin).replace(/\%20/g,'_') + '&peninfo=');
            } else {
              outtis=outtis.replace('&aregeographicals=', '&aregexographicals=y&aregeographicals=' + encodeURIComponent(lookin).replace(/\%20/g,'_') + '&peninfo=');
            }
   } else if (lookin.toLowerCase().replace(/https\./g,'http.').indexOf('http.') == -1 && lookin.indexOf(',') == 0) {
     lookin=(lookin + '`').replace(/\,/g,',http.').replace('http.`','').replace('`','').replace(/http\.\,/g,',').replace(/\+/g,'');
            if (outtis.indexOf('&aregeographicals=') == -1) {
              outtis=outtis.replace('&areplaces=', '&arexplaces=y&aregeographicals=' + encodeURIComponent(lookin).replace(/\%20/g,'_') + '&peninfo=');
            } else {
              outtis=outtis.replace('&aregeographicals=', '&aregexographicals=y&aregeographicals=' + encodeURIComponent(lookin).replace(/\%20/g,'_') + '&peninfo=');
            }
   } else {
     lookin='';
   }
   if (tis.toLowerCase().replace(/https\./g,'http.').indexOf('http.') != -1 || lookin != '') {
     if (lookin == '') {
     if (tis.indexOf('&aregeographicals=') != -1) {
       lookin+=lkin(tis.split('&aregeographicals=')[1].split('&')[0].replace(/\ /g,'_').replace(/\+/g,''));
       if (lookin.toLowerCase().replace(/https\./g,'http.').indexOf('http.') == -1) lookin='';
     }
     if (tis.indexOf('&areplaces=') != -1) {
       if (lkin(tis.split('&areplaces=')[1].split('&')[0]).toLowerCase().replace(/https\./g,'http.').indexOf('http.') != -1) {
         if (lookin != '') {
          lookin+=',' + lkin(tis.split('&areplaces=')[1].split('&')[0].replace(/\ /g,'_').replace(/\+/g,''));
         } else {
          lookin+=lkin(tis.split('&areplaces=')[1].split('&')[0].replace(/\ /g,'_').replace(/\+/g,''));
         }
       } 
       if (lookin.toLowerCase().replace(/https\./g,'http.').indexOf('http.') == -1) lookin='';
     }
     }
     if (lookin.toLowerCase().replace(/https\./g,'http.').indexOf('http.') != -1) {
 var nearnames='\"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\",\"Europe/London\",\"\"';
 var 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\",\"51.5074\",\" \"];
 var 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\",\"-0.1278\",\"  \"];
        var lofis=lookin.replace(/https\./g,'http.').replace(/HTTPS\./g,'http.').replace(/Https\./g,'http.').split('http.');
        var jlofis=lookin.replace(/https\./g,'http.').replace(/HTTPS\./g,'http.').replace(/Https\./g,'http.') + ','; 
        var thispl='';
        var ilofpos=-1;
        var jlofpos=-1;
        var preflof='';
        var ilofis=1;
        for (ilofis=1; ilofis<lofis.length; ilofis++) {
          thispl=lofis[ilofis].split(',')[0].replace(/\ /g,'_');
          if (nearnames.toLowerCase().indexOf('/' + noemoji(thispl.toLowerCase()) + '\"') != -1) {
            ilofpos=eval(-1 + nearnames.toLowerCase().split('/' + noemoji(thispl.toLowerCase()) + '\"')[0].split(',').length);
            jlofpos=eval(-1 + jlofis.toLowerCase().split('http.' + thispl.toLowerCase() + ',')[0].split(',').length);
            document.getElementById('placelookup').innerHTML+='<input type=hidden id=defv' + jlofpos + ' value=\"' + nearlatitude[ilofpos] + '|' + nearlongitude[ilofpos] + '|' +  noemoji(lofis[ilofis].split(',')[0]) + '\"></input> ';
            if (outtis.indexOf('&aregeographicals=') == -1) {
              outtis=outtis.replace('&areplaces=', '&areplaces=y&aregeographicals=');
            }
          } else if (thispl.trim() != '') {
            jlofpos=eval(-1 + jlofis.toLowerCase().split('http.' + thispl.toLowerCase() + ',')[0].split(',').length);
            if (outtis.indexOf('&aregeographicals=') != -1) {
            document.getElementById('placelookup').innerHTML+='<input type=hidden id=defv' + jlofpos + ' value=\"0|0|' + noemoji(lofis[ilofis].split(',')[0]).replace(/\ /g,'_') + '\"></input> ';
            //xcz=new XMLHttpRequest();
            //xcz.open(\"GET\", \"//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?lldefvnum=\" + jlofpos + '&llplace=' + encodeURIComponent( noemoji(lofis[ilofis].split(',')[0])).replace(/\%20/g,'_'), false);
            //xcz.send();
            } else {
            document.getElementById('placelookup').innerHTML+='<input type=hidden id=defv' + jlofpos + ' value=\"' +  noemoji(lofis[ilofis].split(',')[0]).replace(/\ /g,'_') + '\"></input> ';
            }
          }
        }
        //alert(document.getElementById('placelookup').innerHTML);
        for (ilofis=1; ilofis<lofis.length; ilofis++) {
          thispl=lofis[ilofis].split(',')[0].replace(/\ /g,'_');
          if (nearnames.toLowerCase().indexOf('/' + thispl.toLowerCase() + '\"') != -1) {
            ilofpos=eval(-1 + nearnames.toLowerCase().split('/' + thispl.toLowerCase() + '\"')[0].split(',').length);
            jlofpos=eval(-1 + jlofis.toLowerCase().split('http.' + thispl.toLowerCase() + ',')[0].split(',').length);
            //document.getElementById('placelookup').innerHTML+='<input type=hidden id=defv' + jlofpos + ' value=\"' + nearlatitude[ilofpos] + '|' + nearlongitude[ilofpos] + '|' + lofis[ilofis].split(',')[0].replace(/\ /g,'_') + '\"></input> ';
            //if (outtis.indexOf('&aregeographicals=') == -1) {
            //  outtis=outtis.replace('&areplaces=', '&areplaces=y&aregeographicals=');
            //}
          } else if (thispl.trim() != '') {
            jlofpos=eval(-1 + jlofis.toLowerCase().split('http.' + thispl.toLowerCase() + ',')[0].split(',').length);
            if (outtis.indexOf('&aregeographicals=') != -1) {
            //document.getElementById('placelookup').innerHTML+='<input type=hidden id=defv' + jlofpos + ' value=\"0|0|' + noemoji(lofis[ilofis].split(',')[0]).replace(/\ /g,'_') + '\"></input> ';
            xcz=new XMLHttpRequest();
            xcz.open(\"GET\", \"//www.rjmprogramming.com.au/PHP/GeoChart/geo_chart.php?lldefvnum=\" + jlofpos + '&llplace=' + encodeURIComponent(noemoji(lofis[ilofis].split(',')[0])).replace(/\%20/g,'_'), false);
            xcz.send();
            } else if (1 == 5) {
            document.getElementById('placelookup').innerHTML+='<input type=hidden id=defv' + jlofpos + ' value=\"' + noemoji(lofis[ilofis].split(',')[0]).replace(/\ /g,'_') + '\"></input> ';
            }
          }
        }
        return outtis;
     }
   }
   return outtis;
 } 
 
 
 function icheck(iois) {
    var presw=iois; //top.document.getElementById('ipostings');
    if (presw != null) {
      var aconto = (presw.contentWindow || presw.contentDocument);
      if (aconto != null) {
        if (aconto.document) { aconto = aconto.document; }
        if (aconto.body != null) {
          if (aconto.body.innerHTML.indexOf('document') == 0) {
            eval(aconto.body.innerHTML);
          }
        }
      }
    }
}

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

function tripd(ilineo,x1is,y1is,x2is,y2is,isc) {
  var fromto=ilineo.getAttribute('title');
  //var x1is=eval(ilineo.getAttribute('x1'));
  //var y1is=eval(ilineo.getAttribute('y1'));
  //var x2is=eval(ilineo.getAttribute('x2'));
  //var y2is=eval(ilineo.getAttribute('y2'));
  if (document.getElementById('myh').innerHTML.indexOf(' ... ') != -1) {
   document.getElementById('myh').innerHTML=document.getElementById('myh').innerHTML.split(' ... ')[0] + ' ... <br>' + eval(great_circle_distance(x1is,y1is,x2is,y2is) / 1000.0) + ' kilometres ' + fromto;
  } else {
   document.getElementById('myh').innerHTML+=' ... <br>' + eval(great_circle_distance(x1is,y1is,x2is,y2is) / 1000.0) + ' kilometres ' + fromto;
  }
  if (isc) {
   if (lastgmd != 'https://www.google.com.au/maps/dir/' + encodeURIComponent(fromto.split(' to ')[0]) + '/' + encodeURIComponent(fromto.split(' to ')[1])) {
    lastgmd='https://www.google.com.au/maps/dir/' + encodeURIComponent(fromto.split(' to ')[0]) + '/' + encodeURIComponent(fromto.split(' to ')[1]);
    window.open(lastgmd,'_blank', 'top=50,left=50,width=500,height=500');
   }
  }
}

function gck(igck) {
  if (document.getElementById('attachedImage' + ('' + igck).replace('-1',''))) {
    var xxx=document.getElementById('attachedImage' + ('' + igck).replace('-1','')).getAttribute('title');
    if (xxx.indexOf('#') != -1) {
    window.open(xxx.split('#')[1],'_blank', 'top=50,left=50,width=500,height=500');
    } else if (xxx == '') {
    window.open(document.getElementById('attachedImage' + ('' + igck).replace('-1','')).title,'_blank', 'top=50,left=50,width=500,height=500');
    } else {
    window.open(xxx,'_blank', 'top=50,left=50,width=500,height=500');
    }
  }
}

function noemoji(inentity) {
  var allnum=true;
  if (inentity != '' && inentity.replace(/\_/g,' ').split(' ')[0] != inentity.replace(/\_/g,' ')) {
   if (inentity.replace(/\_/g,' ').substring(0,1) != ' ') {
    for (var iu=0; iu<inentity.replace(/\_/g,' ').split(' ')[0].length; iu++) {
      if (inentity.replace(/\_/g,' ').split(' ')[0].substring(iu,eval(1 + iu)) != '.' && (inentity.replace(/\_/g,' ').split(' ')[0].substring(iu,eval(1 + iu)) < '0' || inentity.replace(/\_/g,' ').split(' ')[0].substring(iu,eval(1 + iu)) > '9')) allnum=false
    }
    if (allnum && inentity.indexOf('_') != -1) return inentity.replace(/\_/g,' ').replace(inentity.replace(/\_/g,' ').split(' ')[0] + ' ','').replace(/\ /g,'_');
    if (allnum) return inentity.replace(/\_/g,' ').replace(inentity.replace(/\_/g,' ').split(' ')[0] + ' ','');
   }
  }
  return inentity;
}

function emojimaybe(inentity, inentwo, endtag) {
  var allnum=true, iu;
  if (inentwo != '') {
   if (inentwo.replace(/\_/g,' ').substring(0,1) != ' ') {
    for (iu=0; iu<inentwo.replace(/\_/g,' ').split(' ')[0].length; iu++) {
      if (inentwo.replace(/\_/g,' ').split(' ')[0].substring(iu,eval(1 + iu)) != '.' && (inentwo.replace(/\_/g,' ').split(' ')[0].substring(iu,eval(1 + iu)) < '0' || inentwo.replace(/\_/g,' ').split(' ')[0].substring(iu,eval(1 + iu)) > '9')) allnum=false
    }
    if (allnum && inentwo.indexOf('_') != -1) return '>&#' + inentwo.replace(/\_/g,' ').split(' ')[0].replace(/\./g,';&#') + ';</text>'; 
    if (allnum) return '>&#' + inentwo.replace(/\_/g,' ').split(' ')[0].replace(/\./g,';&#') + ';</text>';
   }
  }
  allnum=true;
  if (inentity != '') {
   if (inentity.replace(/\_/g,' ').substring(0,1) != ' ') {
    for (iu=0; iu<inentity.replace(/\_/g,' ').split(' ')[0].length; iu++) {
      if (inentity.replace(/\_/g,' ').split(' ')[0].substring(iu,eval(1 + iu)) != '.' && (inentity.replace(/\_/g,' ').split(' ')[0].substring(iu,eval(1 + iu)) < '0' || inentity.replace(/\_/g,' ').split(' ')[0].substring(iu,eval(1 + iu)) > '9')) allnum=false
    }
    if (allnum && inentity.indexOf('_') != -1) return '>&#' + inentity.replace(/\_/g,' ').split(' ')[0].replace(/\./g,';&#') + ';</text>'; 
    if (allnum) return '>&#' + inentity.replace(/\_/g,' ').split(' ')[0].replace(/\./g,';&#') + ';</text>';
   }
  }
  return endtag;
}

// Thanks to https://stackoverflow.com/questions/133310/how-can-i-get-jquery-to-perform-a-synchronous-rather-than-asynchronous-ajax-re
/* wrap XMLHttpRequest for synchronous operation */
var XHRQueue = [];
var _XMLHttpRequest = XMLHttpRequest;
XMLHttpRequest = function() {
//alert(1);
  var xhr   = new _XMLHttpRequest();
  var _send = xhr.send;
//alert(11);

  xhr.send = function() {
//alert(111);
    /* queue the request, and if it's the first, process it */
    XHRQueue.push([this, arguments]);
    if (XHRQueue.length == 1)
      this.processQueue();
  };

  xhr.processQueue = function() {
//alert(1111);
    var call = XHRQueue[0];
    var xhr  = call[0];
    var args = call[1];

    /* you could also set a CSRF token header here */

    /* send the request */
    _send.apply(xhr, args);
  };


  xhr.addEventListener('load', function(e) {
//alert(21111);
    /* you could also retrieve a CSRF token header here */
    //alert(e.responseText);
    if (xhr.status < 400) {
      if (xhr.responseText.indexOf('</body></html>') != -1) {
        //alert(xhr.responseText.split('</body></html>')[0].split('>')[eval(-1 + xhr.responseText.split('</body></html>')[0].split('>').length)]);
        //alert(xhr.responseText.split(\"lementById('\")[1].split(\"'\")[0]);
        //alert('*' + xhr.responseText.split('\"')[-2 + xhr.responseText.split('\"').length] + '*');
        if (xhr.responseText.split('\"')[-2 + xhr.responseText.split('\"').length] != \"\") {
        document.getElementById(xhr.responseText.split(\"lementById('\")[1].split(\"'\")[0]).value=xhr.responseText.split('\"')[-2 + xhr.responseText.split('\"').length];
        } //else {
        //alert('!' + xhr.responseText);
        //}
      }
      //alert(xhr.responseText);
    }
    /* remove the completed request and if there is more, trigger the next */
    XHRQueue.shift();
    if (XHRQueue.length)
      this.processQueue();
  });

  return xhr;
};
 \n";

 echo "\n function twosecs() { \n";
        echo "\n if (document.getElementById('od1')) { document.getElementById('od1').style.width='' + eval(window.getComputedStyle(document.body, null).getPropertyValue('width').replace('px','')) + 'px'; } \n";
        echo "\n if (document.getElementById('od2')) { document.getElementById('od2').style.width='' + eval(window.getComputedStyle(document.body, null).getPropertyValue('width').replace('px','')) + 'px'; } \n";

  if (isset($_GET['aregeographicals'])) {
    if (strpos(strtolower(urldecode($_GET['aregeographicals'])), "http") !== false) {
        $upa=wlook(urldecode($_GET['aregeographicals']));
        //echo ' alert("' . $upa . '"); ';
        //exit;
        $gsis=explode(",",$upa);
        $igsis=0;
        if (strpos(strtolower($gsis[0]), "http") === false) {
          for ($jgsis=1; $jgsis<sizeof($gsis); $jgsis++) {
            if ($igsis == 0 && strpos(strtolower($gsis[$jgsis]), "http") !== false) {
              $igsis=$jgsis;
            }
          }
        }
        echo "\n var froma=['<circle ','></circle>',' cx=',' cy=',' r=',' fill=',' stroke=',' stroke-width=',' opacity='], toa=['<circle ','></circle>',' cx=',' cy=',' r=',' fill=',' stroke=',' stroke-width=',' opacity='], igsis=0, gdis=(\"" . $GETdata . "\").split(']'), gsis=(\"" . $upa . "\").split(','), peninfo=(\"" . $upa . "\").split(',');    \n";
        if (isset($_GET['peninfo'])) {
          echo "\n peninfo=(\"" . $_GET['peninfo'] . "\").replace(/\,\ /g,',+').split(','); for (var pjgs=0; pjgs<peninfo.length; pjgs++) { if ((peninfo[pjgs] + ' ').substring(0,1) == '+') { peninfo[pjgs]='+' + peninfo[pjgs].split('|')[eval(-1 + peninfo[pjgs].split('|').length)].replace('+',''); } else { peninfo[pjgs]=peninfo[pjgs].split('|')[eval(-1 + peninfo[pjgs].split('|').length)]; } if (peninfo[pjgs] != '' && gsis.length > pjgs) { if (gsis[pjgs] == '') { gsis[pjgs]='//www.wikipedia.org'; }  }  } \n";
        }
        echo "\n if (document.getElementById('defs')) {  document.getElementById('defs').innerHTML+='<pattern id = \"attachedImage\" height = \"100%\" width = \"100%\" patternContentUnits = \"objectBoundingBox\" title=\"" . noemoji($gsis[$igsis]) . "\"><image xlink:href = \"" . noemoji($gsis[$igsis]) . "\" preserveAspectRatio = \"none\" width = \"1\" height = \"1\"/></pattern>';   \n";
        echo "\n if (document.getElementById('defs') && gsis.length >= 1) { for (var jgs=0; jgs<gsis.length; jgs++) { if (gsis[jgs] != '') {    document.getElementById('defs').innerHTML+='<pattern id = \"attachedImage' + jgs + '\" height = \"100%\" width = \"100%\" patternContentUnits = \"objectBoundingBox\" title=\"' + noemoji(gsis[jgs]) + '\"><image xlink:href = \"' + noemoji(gsis[jgs]) + '\" preserveAspectRatio = \"none\" width = \"1\" height = \"1\"/></pattern>'; } } }   \n";
        echo "\n var lastpl='', lastcx=-1, lastcy=-1, lastlx=-1, lastly=-1, gsuff='', linew='', postgs=[], gs=document.getElementsByTagName('g'), iigs=0, malt=''; for (var igs=0; igs<gs.length; igs++) {  if (peninfo.length > iigs) { malt=peninfo[iigs].replace('+','').trim(); } else { malt=''; } if (gsis.length > iigs) { if (gsis[iigs] != '') { if (gsis[iigs].trim() == '') { gsuff='x'; } else { toa[1]=emojimaybe(gsis[iigs],malt,'></circle>'); if (toa[1] == '></circle>') {  toa[0]='<circle '; toa[2]=' cx='; toa[3]=' cy='; toa[4]=' r='; toa[5]=' fill='; toa[6]=' stroke='; toa[7]=' stroke-width='; toa[8]=' opacity='; } else {   toa[1]=toa[1].replace('>',' onclick=gck(' + ('~' + iigs + '~').replace('~~','-1').replace('~','').replace('~','') + '); title=\"' + gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + '\">'); toa[0]='<text '; toa[2]=' x='; toa[3]=' y=';  toa[4]=' data-r='; toa[5]=' data-fill='; toa[6]=' data-stroke='; toa[7]=' data-stroke-width='; toa[8]=' data-opacity='; if (gsis[iigs].indexOf(' ') != -1) { gsis[iigs]=gsis[iigs].replace(gsis[iigs].split(' ')[0] + ' ',''); } }  gsuff='' + iigs; }  } else { gsuff='';  } } else  {  gsuff='';  }  if (gsuff != 'x' && gs[igs].innerHTML.indexOf('fill=') != -1 && gs[igs].innerHTML.replace('<text ','<circle ').indexOf('<circle') != -1 && (gs[igs].innerHTML + '*').replace('</text>*','</circle>*').indexOf('</circle>*') != -1 && gs[igs].innerHTML.indexOf('fill=') != -1 && gs[igs].innerHTML.indexOf('font-family=') == -1) {   if (peninfo.length > iigs) { if (peninfo[iigs].indexOf('+') != -1) { linew='<line title=\"' + gdis[eval(-1 + iigs)].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + ' to ' + gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + '\" onmouseover=\"tripd(this,' + lastlx + ',' + lastly + ',' + gdis[iigs].split('[')[1].split('|')[0] + ',' + gdis[iigs].split('[')[1].split('|')[1] + ',true);\" onclick=\"tripd(this,' + lastlx + ',' + lastly + ',' + gdis[iigs].split('[')[1].split('|')[0] + ',' + gdis[iigs].split('[')[1].split('|')[1] + ',true);\" x1=\"' + lastcx + '\" y1=\"' + lastcy + '\" x2=\"' + eval(gs[igs].innerHTML.split('x=\"')[1].split('\"')[0]) + '\" y2=\"' + eval(gs[igs].innerHTML.split('y=\"')[1].split('\"')[0]) + '\" style=\"stroke:rgb(255,0,0);stroke-width:2\" />';   }  } postgs=gs[igs].innerHTML.split(' fill=');  gs[igs].innerHTML=gs[igs].innerHTML.replace(' fill=' + postgs[1].substring(0,1) + postgs[1].substring(1).split(postgs[1].substring(0,1))[0], ' onclick=gck(' + ('~' + gsuff + '~').replace('~~','-1').replace('~','').replace('~','') + '); title=\"' + gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + '\" fill=' + postgs[1].substring(0,1) + 'url(#attachedImage' + gsuff + ')').replace(froma[0],toa[0]).replace(froma[1],toa[1]).replace(froma[2],toa[2]).replace(froma[3],toa[3]).replace(froma[4],toa[4]).replace(froma[5],toa[5]).replace(froma[6],toa[6]).replace(froma[7],toa[7]).replace(froma[8],toa[8]) + linew;  } linew='';  if ((gs[igs].innerHTML.replace('<line ','*<line ') + '*').replace('</text>','</circle>').replace('-stroke','</circle>*').indexOf('</circle>*') != -1 && gs[igs].innerHTML.indexOf('font-family=') == -1 && gs[igs].innerHTML.indexOf(' onclick=') != -1 && gs[igs].innerHTML.replace('<text x=','<text fill= ').indexOf('fill=') != -1) { lastcx=eval(gs[igs].innerHTML.split('x=\"')[1].split('\"')[0]); lastcy=eval(gs[igs].innerHTML.split('y=\"')[1].split('\"')[0]); lastlx=gdis[iigs].split('[')[1].split('|')[0];  lastly=gdis[iigs].split('[')[1].split('|')[1];  lastpl=gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' '); iigs++; }  } } \n";
    }
  } else if (isset($_POST['aregeographicals'])) {
    if (strpos(strtolower(urldecode($_POST['aregeographicals'])), "http") !== false) {
        $upa=wlook(urldecode($_POST['aregeographicals']));
        $gsis=explode(",",$upa);
        $igsis=0;
        if (strpos(strtolower($gsis[0]), "http") === false) {
          for ($jgsis=1; $jgsis<sizeof($gsis); $jgsis++) {
            if ($igsis == 0 && strpos(strtolower($gsis[$jgsis]), "http") !== false) {
              $igsis=$jgsis;
            }
          }
        }
        echo "\n var froma=['<circle ','></circle>',' cx=',' cy=',' r=',' fill=',' stroke=',' stroke-width=',' opacity='], toa=['<circle ','></circle>',' cx=',' cy=',' r=',' fill=',' stroke=',' stroke-width=',' opacity='], igsis=0, gdis=(\"" . $GETdata . "\").split(']'), gsis=(\"" . $upa . "\").split(','), peninfo=(\"" . $upa . "\").split(',');    \n";
        if (isset($_POST['peninfo'])) {
          echo "\n peninfo=(\"" . $_POST['peninfo'] . "\").replace(/\,\ /g,',+').split(',');  for (var pjgs=0; pjgs<peninfo.length; pjgs++) {  if ((peninfo[pjgs] + ' ').substring(0,1) == '+') { peninfo[pjgs]='+' + peninfo[pjgs].split('|')[eval(-1 + peninfo[pjgs].split('|').length)].replace('+',''); } else { peninfo[pjgs]=peninfo[pjgs].split('|')[eval(-1 + peninfo[pjgs].split('|').length)]; } if (peninfo[pjgs] != '' && gsis.length > pjgs) { if (gsis[pjgs] == '') { gsis[pjgs]='//www.wikipedia.org'; }  }   }   \n";
        }
        echo "\n if (document.getElementById('defs')) {  document.getElementById('defs').innerHTML+='<pattern id = \"attachedImage\" height = \"100%\" width = \"100%\" patternContentUnits = \"objectBoundingBox\" title=\"" . noemoji($gsis[$igsis]) . "\"><image xlink:href = \"" . noemoji($gsis[$igsis]) . "\" preserveAspectRatio = \"none\" width = \"1\" height = \"1\"/></pattern>';   \n";
        echo "\n if (document.getElementById('defs') && gsis.length >= 1) { for (var jgs=0; jgs<gsis.length; jgs++) { if (gsis[jgs] != '') {    document.getElementById('defs').innerHTML+='<pattern id = \"attachedImage' + jgs + '\" height = \"100%\" width = \"100%\" patternContentUnits = \"objectBoundingBox\" title=\"' + noemoji(gsis[jgs]) + '\"><image xlink:href = \"' + noemoji(gsis[jgs]) + '\" preserveAspectRatio = \"none\" width = \"1\" height = \"1\"/></pattern>'; } } }  \n";
        echo "\n var lastpl='', lastcx=-1, lastcy=-1, lastlx=-1, lastly=-1, gsuff='', linew='', postgs=[], gs=document.getElementsByTagName('g'), iigs=0, malt=''; for (var igs=0; igs<gs.length; igs++) {  if (peninfo.length > iigs) { malt=peninfo[iigs].replace('+','').trim(); } else { malt=''; } if (gsis.length > iigs) { if (gsis[iigs] != '') { if (gsis[iigs].trim() == '') { gsuff='x'; } else { toa[1]=emojimaybe(gsis[iigs],malt,'></circle>'); if (toa[1] == '></circle>') {  toa[0]='<circle '; toa[2]=' cx='; toa[3]=' cy='; toa[4]=' r='; toa[5]=' fill='; toa[6]=' stroke='; toa[7]=' stroke-width='; toa[8]=' opacity='; } else {   toa[1]=toa[1].replace('>',' onclick=gck(' + ('~' + iigs + '~').replace('~~','-1').replace('~','').replace('~','') + '); title=\"' + gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + '\">'); toa[0]='<text '; toa[2]=' x='; toa[3]=' y=';  toa[4]=' data-r='; toa[5]=' data-fill='; toa[6]=' data-stroke='; toa[7]=' data-stroke-width='; toa[8]=' data-opacity='; if (gsis[iigs].indexOf(' ') != -1) { gsis[iigs]=gsis[iigs].replace(gsis[iigs].split(' ')[0] + ' ',''); } }  gsuff='' + iigs; }  } else { gsuff=''; } } else  {  gsuff=''; }  if (gsuff != 'x' && gs[igs].innerHTML.indexOf('fill=') != -1 && gs[igs].innerHTML.replace('<text ','<circle ').indexOf('<circle') != -1 && (gs[igs].innerHTML + '*').replace('</text>*','</circle>*').indexOf('</circle>*') != -1 && gs[igs].innerHTML.indexOf('fill=') != -1 && gs[igs].innerHTML.indexOf('font-family=') == -1) {   if (peninfo.length > iigs) { if (peninfo[iigs].indexOf('+') != -1) { linew='<line title=\"' + gdis[eval(-1 + iigs)].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + ' to ' + gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + '\" onmouseover=\"tripd(this,' + lastlx + ',' + lastly + ',' + gdis[iigs].split('[')[1].split('|')[0] + ',' + gdis[iigs].split('[')[1].split('|')[1] + ',true);\" onclick=\"tripd(this,' + lastlx + ',' + lastly + ',' + gdis[iigs].split('[')[1].split('|')[0] + ',' + gdis[iigs].split('[')[1].split('|')[1] + ',true);\" x1=\"' + lastcx + '\" y1=\"' + lastcy + '\" x2=\"' + eval(gs[igs].innerHTML.split('x=\"')[1].split('\"')[0]) + '\" y2=\"' + eval(gs[igs].innerHTML.split('y=\"')[1].split('\"')[0]) + '\" style=\"stroke:rgb(255,0,0);stroke-width:2\" />';   }  } postgs=gs[igs].innerHTML.split(' fill=');  gs[igs].innerHTML=gs[igs].innerHTML.replace(' fill=' + postgs[1].substring(0,1) + postgs[1].substring(1).split(postgs[1].substring(0,1))[0], ' onclick=gck(' + ('~' + gsuff + '~').replace('~~','-1').replace('~','').replace('~','') + '); title=\"' + gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + '\" fill=' + postgs[1].substring(0,1) + 'url(#attachedImage' + gsuff + ')').replace(froma[0],toa[0]).replace(froma[1],toa[1]).replace(froma[2],toa[2]).replace(froma[3],toa[3]).replace(froma[4],toa[4]).replace(froma[5],toa[5]).replace(froma[6],toa[6]).replace(froma[7],toa[7]).replace(froma[8],toa[8]) + linew;  } linew='';  if ((gs[igs].innerHTML.replace('<line ','*<line ') + '*').replace('</text>','</circle>').replace('-stroke','</circle>*').indexOf('</circle>*') != -1 && gs[igs].innerHTML.indexOf('font-family=') == -1 && gs[igs].innerHTML.indexOf(' onclick=') != -1 && gs[igs].innerHTML.replace('<text x=','<text fill= ').indexOf('fill=') != -1) { lastcx=eval(gs[igs].innerHTML.split('x=\"')[1].split('\"')[0]); lastcy=eval(gs[igs].innerHTML.split('y=\"')[1].split('\"')[0]); lastlx=gdis[iigs].split('[')[1].split('|')[0];  lastly=gdis[iigs].split('[')[1].split('|')[1];  lastpl=gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' '); iigs++; }  } } \n";
    }
  } else if (isset($_GET['areplaces'])) {
    if (strpos(strtolower(urldecode($_GET['areplaces'])), "http") !== false) {
        $upa=wlook(urldecode($_GET['areplaces']));
        $gsis=explode(",",$upa);
        $igsis=0;
        if (strpos(strtolower($gsis[0]), "http") === false) {
          for ($jgsis=1; $jgsis<sizeof($gsis); $jgsis++) {
            if ($igsis == 0 && strpos(strtolower($gsis[$jgsis]), "http") !== false) {
              $igsis=$jgsis;
            }
          }
        }
        echo "\n var froma=['<circle ','></circle>',' cx=',' cy=',' r=',' fill=',' stroke=',' stroke-width=',' opacity='], toa=['<circle ','></circle>',' cx=',' cy=',' r=',' fill=',' stroke=',' stroke-width=',' opacity='],  igsis=0, gdis=(\"" . $GETdata . "\").split(']'), gsis=(\"" . $upa . "\").split(','), peninfo=(\"" . $upa . "\").split(',');    \n";
        if (isset($_GET['peninfo'])) {
          echo "\n peninfo=(\"" . $_GET['peninfo'] . "\").replace(/\,\ /g,',+').split(',');   for (var pjgs=0; pjgs<peninfo.length; pjgs++) {  if ((peninfo[pjgs] + ' ').substring(0,1) == '+') { peninfo[pjgs]='+' + peninfo[pjgs].split('|')[eval(-1 + peninfo[pjgs].split('|').length)].replace('+',''); } else { peninfo[pjgs]=peninfo[pjgs].split('|')[eval(-1 + peninfo[pjgs].split('|').length)]; }   if (peninfo[pjgs] != '' && gsis.length > pjgs) { if (gsis[pjgs] == '') { gsis[pjgs]='//www.wikipedia.org'; }  }   }  \n";
        }
        echo "\n if (document.getElementById('defs')) {  document.getElementById('defs').innerHTML+='<pattern id = \"attachedImage\" height = \"100%\" width = \"100%\" patternContentUnits = \"objectBoundingBox\" title=\"" . noemoji($gsis[$igsis]) . "\"><image xlink:href = \"" . noemoji($gsis[$igsis]) . "\" preserveAspectRatio = \"none\" width = \"1\" height = \"1\"/></pattern>';   \n";
        echo "\n if (document.getElementById('defs') && gsis.length >= 1) { for (var jgs=0; jgs<gsis.length; jgs++) { if (gsis[jgs] != '') {    document.getElementById('defs').innerHTML+='<pattern id = \"attachedImage' + jgs + '\" height = \"100%\" width = \"100%\" patternContentUnits = \"objectBoundingBox\" title=\"' + noemoji(gsis[jgs]) + '\"><image xlink:href = \"' + noemoji(gsis[jgs]) + '\" preserveAspectRatio = \"none\" width = \"1\" height = \"1\"/></pattern>'; } } }  \n";
        echo "\n var lastpl='', lastcx=-1, lastcy=-1, lastlx=-1, lastly=-1, gsuff='', linew='', postgs=[], gs=document.getElementsByTagName('g'), iigs=0, malt=''; for (var igs=0; igs<gs.length; igs++) {  if (peninfo.length > iigs) { malt=peninfo[iigs].replace('+','').trim(); } else { malt=''; } if (gsis.length > iigs) { if (gsis[iigs] != '') { if (gsis[iigs].trim() == '') { gsuff='x'; } else { toa[1]=emojimaybe(gsis[iigs],malt,'></circle>'); if (toa[1] == '></circle>') {  toa[0]='<circle '; toa[2]=' cx='; toa[3]=' cy='; toa[4]=' r='; toa[5]=' fill='; toa[6]=' stroke='; toa[7]=' stroke-width='; toa[8]=' opacity='; } else {   toa[1]=toa[1].replace('>',' onclick=gck(' + ('~' + iigs + '~').replace('~~','-1').replace('~','').replace('~','') + '); title=\"' + gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + '\">'); toa[0]='<text '; toa[2]=' x='; toa[3]=' y=';  toa[4]=' data-r='; toa[5]=' data-fill='; toa[6]=' data-stroke='; toa[7]=' data-stroke-width='; toa[8]=' data-opacity='; if (gsis[iigs].indexOf(' ') != -1) { gsis[iigs]=gsis[iigs].replace(gsis[iigs].split(' ')[0] + ' ',''); } }  gsuff='' + iigs; }  } else { gsuff=''; } } else  {  gsuff=''; }  if (gsuff != 'x' && gs[igs].innerHTML.indexOf('fill=') != -1 && gs[igs].innerHTML.replace('<text ','<circle ').indexOf('<circle') != -1 && (gs[igs].innerHTML + '*').replace('</text>*','</circle>*').indexOf('</circle>*') != -1 && gs[igs].innerHTML.indexOf('fill=') != -1 && gs[igs].innerHTML.indexOf('font-family=') == -1) {   if (peninfo.length > iigs) { if (peninfo[iigs].indexOf('+') != -1) { linew='<line title=\"' + gdis[eval(-1 + iigs)].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + ' to ' + gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + '\" onmouseover=\"tripd(this,' + lastlx + ',' + lastly + ',' + gdis[iigs].split('[')[1].split('|')[0] + ',' + gdis[iigs].split('[')[1].split('|')[1] + ',true);\" onclick=\"tripd(this,' + lastlx + ',' + lastly + ',' + gdis[iigs].split('[')[1].split('|')[0] + ',' + gdis[iigs].split('[')[1].split('|')[1] + ',true);\" x1=\"' + lastcx + '\" y1=\"' + lastcy + '\" x2=\"' + eval(gs[igs].innerHTML.split('x=\"')[1].split('\"')[0]) + '\" y2=\"' + eval(gs[igs].innerHTML.split('y=\"')[1].split('\"')[0]) + '\" style=\"stroke:rgb(255,0,0);stroke-width:2\" />';   }  } postgs=gs[igs].innerHTML.split(' fill=');  gs[igs].innerHTML=gs[igs].innerHTML.replace(' fill=' + postgs[1].substring(0,1) + postgs[1].substring(1).split(postgs[1].substring(0,1))[0], ' onclick=gck(' + ('~' + gsuff + '~').replace('~~','-1').replace('~','').replace('~','') + '); title=\"' + gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + '\" fill=' + postgs[1].substring(0,1) + 'url(#attachedImage' + gsuff + ')').replace(froma[0],toa[0]).replace(froma[1],toa[1]).replace(froma[2],toa[2]).replace(froma[3],toa[3]).replace(froma[4],toa[4]).replace(froma[5],toa[5]).replace(froma[6],toa[6]).replace(froma[7],toa[7]).replace(froma[8],toa[8]) + linew;  } linew='';  if ((gs[igs].innerHTML.replace('<line ','*<line ') + '*').replace('</text>','</circle>').replace('-stroke','</circle>*').indexOf('</circle>*') != -1 && gs[igs].innerHTML.indexOf('font-family=') == -1 && gs[igs].innerHTML.indexOf(' onclick=') != -1 && gs[igs].innerHTML.replace('<text x=','<text fill= ').indexOf('fill=') != -1) { lastcx=eval(gs[igs].innerHTML.split('x=\"')[1].split('\"')[0]); lastcy=eval(gs[igs].innerHTML.split('y=\"')[1].split('\"')[0]); lastlx=gdis[iigs].split('[')[1].split('|')[0];  lastly=gdis[iigs].split('[')[1].split('|')[1];  lastpl=gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' '); iigs++; }  } } \n";
    }
  } else if (isset($_POST['areplaces'])) {
    if (strpos(strtolower(urldecode($_POST['areplaces'])), "http") !== false) {
        $upa=wlook(urldecode($_POST['areplaces']));
        $gsis=explode(",",$upa);
        $igsis=0;
        if (strpos(strtolower($gsis[0]), "http") === false) {
          for ($jgsis=1; $jgsis<sizeof($gsis); $jgsis++) {
            if ($igsis == 0 && strpos(strtolower($gsis[$jgsis]), "http") !== false) {
              $igsis=$jgsis;
            }
          }
        }
        echo "\n var froma=['<circle ','></circle>',' cx=',' cy=',' r=',' fill=',' stroke=',' stroke-width=',' opacity='], toa=['<circle ','></circle>',' cx=',' cy=',' r=',' fill=',' stroke=',' stroke-width=',' opacity='],  igsis=0, gdis=(\"" . $GETdata . "\").split(']'), gsis=(\"" . $upa . "\").split(','), peninfo=(\"" . $upa . "\").split(',');    \n";
        if (isset($_POST['peninfo'])) {
          echo "\n peninfo=(\"" . $_POST['peninfo'] . "\").replace(/\,\ /g,',+').split(',');   for (var pjgs=0; pjgs<peninfo.length; pjgs++) {  if ((peninfo[pjgs] + ' ').substring(0,1) == '+') { peninfo[pjgs]='+' + peninfo[pjgs].split('|')[eval(-1 + peninfo[pjgs].split('|').length)].replace('+',''); } else { peninfo[pjgs]=peninfo[pjgs].split('|')[eval(-1 + peninfo[pjgs].split('|').length)]; }   if (peninfo[pjgs] != '' && gsis.length > pjgs) { if (gsis[pjgs] == '') { gsis[pjgs]='//www.wikipedia.org'; }  }    }  \n";
        }
        echo "\n if (document.getElementById('defs')) {  document.getElementById('defs').innerHTML+='<pattern id = \"attachedImage\" height = \"100%\" width = \"100%\" patternContentUnits = \"objectBoundingBox\" title=\"" . noemoji($gsis[$igsis]) . "\"><image xlink:href = \"" . noemoji($gsis[$igsis]) . "\" preserveAspectRatio = \"none\" width = \"1\" height = \"1\"/></pattern>';   \n";
        echo "\n if (document.getElementById('defs') && gsis.length >= 1) { for (var jgs=0; jgs<gsis.length; jgs++) { if (gsis[jgs] != '') {    document.getElementById('defs').innerHTML+='<pattern id = \"attachedImage' + jgs + '\" height = \"100%\" width = \"100%\" patternContentUnits = \"objectBoundingBox\" title=\"' + noemoji(gsis[jgs]) + '\"><image xlink:href = \"' + noemoji(gsis[jgs]) + '\" preserveAspectRatio = \"none\" width = \"1\" height = \"1\"/></pattern>'; } } }  \n";
        echo "\n var lastpl='', lastcx=-1, lastcy=-1, lastlx=-1, lastly=-1, gsuff='', linew='', postgs=[], gs=document.getElementsByTagName('g'), iigs=0, malt=''; for (var igs=0; igs<gs.length; igs++) {  if (peninfo.length > iigs) { malt=peninfo[iigs].replace('+','').trim(); } else { malt=''; } if (gsis.length > iigs) { if (gsis[iigs] != '') { if (gsis[iigs].trim() == '') { gsuff='x'; } else { toa[1]=emojimaybe(gsis[iigs],malt,'></circle>'); if (toa[1] == '></circle>') {  toa[0]='<circle '; toa[2]=' cx='; toa[3]=' cy='; toa[4]=' r='; toa[5]=' fill='; toa[6]=' stroke='; toa[7]=' stroke-width='; toa[8]=' opacity='; } else {   toa[1]=toa[1].replace('>',' onclick=gck(' + ('~' + iigs + '~').replace('~~','-1').replace('~','').replace('~','') + '); title=\"' + gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + '\">'); toa[0]='<text '; toa[2]=' x='; toa[3]=' y=';  toa[4]=' data-r='; toa[5]=' data-fill='; toa[6]=' data-stroke='; toa[7]=' data-stroke-width='; toa[8]=' data-opacity='; if (gsis[iigs].indexOf(' ') != -1) { gsis[iigs]=gsis[iigs].replace(gsis[iigs].split(' ')[0] + ' ',''); } }  gsuff='' + iigs; }  } else { gsuff=''; } } else  {  gsuff=''; }  if (gsuff != 'x' && gs[igs].innerHTML.indexOf('fill=') != -1 && gs[igs].innerHTML.replace('<text ','<circle ').indexOf('<circle') != -1 && (gs[igs].innerHTML + '*').replace('</text>*','</circle>*').indexOf('</circle>*') != -1 && gs[igs].innerHTML.indexOf('fill=') != -1 && gs[igs].innerHTML.indexOf('font-family=') == -1) {   if (peninfo.length > iigs) { if (peninfo[iigs].indexOf('+') != -1) { linew='<line title=\"' + gdis[eval(-1 + iigs)].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + ' to ' + gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + '\" onmouseover=\"tripd(this,' + lastlx + ',' + lastly + ',' + gdis[iigs].split('[')[1].split('|')[0] + ',' + gdis[iigs].split('[')[1].split('|')[1] + ',true);\" onclick=\"tripd(this,' + lastlx + ',' + lastly + ',' + gdis[iigs].split('[')[1].split('|')[0] + ',' + gdis[iigs].split('[')[1].split('|')[1] + ',true);\" x1=\"' + lastcx + '\" y1=\"' + lastcy + '\" x2=\"' + eval(gs[igs].innerHTML.split('x=\"')[1].split('\"')[0]) + '\" y2=\"' + eval(gs[igs].innerHTML.split('y=\"')[1].split('\"')[0]) + '\" style=\"stroke:rgb(255,0,0);stroke-width:2\" />';   }  } postgs=gs[igs].innerHTML.split(' fill=');  gs[igs].innerHTML=gs[igs].innerHTML.replace(' fill=' + postgs[1].substring(0,1) + postgs[1].substring(1).split(postgs[1].substring(0,1))[0], ' onclick=gck(' + ('~' + gsuff + '~').replace('~~','-1').replace('~','').replace('~','') + '); title=\"' + gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' ') + '\" fill=' + postgs[1].substring(0,1) + 'url(#attachedImage' + gsuff + ')').replace(froma[0],toa[0]).replace(froma[1],toa[1]).replace(froma[2],toa[2]).replace(froma[3],toa[3]).replace(froma[4],toa[4]).replace(froma[5],toa[5]).replace(froma[6],toa[6]).replace(froma[7],toa[7]).replace(froma[8],toa[8]) + linew;  } linew='';  if ((gs[igs].innerHTML.replace('<line ','*<line ') + '*').replace('</text>','</circle>').replace('-stroke','</circle>*').indexOf('</circle>*') != -1 && gs[igs].innerHTML.indexOf('font-family=') == -1 && gs[igs].innerHTML.indexOf(' onclick=') != -1 && gs[igs].innerHTML.replace('<text x=','<text fill= ').indexOf('fill=') != -1) { lastcx=eval(gs[igs].innerHTML.split('x=\"')[1].split('\"')[0]); lastcy=eval(gs[igs].innerHTML.split('y=\"')[1].split('\"')[0]); lastlx=gdis[iigs].split('[')[1].split('|')[0];  lastly=gdis[iigs].split('[')[1].split('|')[1];  lastpl=gdis[iigs].split('~')[1].replace(/\%20/g,' ').replace(/\_/g,' '); iigs++; }  } } \n";
    }
  }

  
 echo "\n } \n setTimeout(twosecs,2000); \n";

      echo " </script> \n";
      if ((!isset($_GET['onclick']) && !isset($_POST['onclick'])) && (isset($_GET['data']) || isset($_POST['data']))) echo ' <!--meta name="viewport" content="width=device-width, initial-scale=0.75"--> <link rel="stylesheet" href="//code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /><script src="//code.jquery.com/jquery-1.8.2.min.js"></script><script src="//code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js">';
      echo '</script><style> .ochart_div { min-width:800px; -webkit-overflow-scrolling:touch;overflow:scroll; } </style></head>' . " \n";
      //echo " <body onload='setTimeout(prelater, 2 * 1000);'> \n";
      echo " <body style='background-color:lightgray;width:100%;'><div id=od1 style='display:inline-block;width:800px;overflow:scroll;-webkit-overflow-scrolling:touch;' data-role='page'><div id=od2 style='display:inline-block;width:800px;overflow:scroll;-webkit-overflow-scrolling:touch;' data-role='header'> \n";
      if (isset($_GET['isMobile']) || isset($_POST['isMobile'])) {
      echo " <h2 id=myh>" . $GETtitle . " Geo Map</h2></div><!-- /header --><div style='display:inline-block;overflow:scroll;-webkit-overflow-scrolling:touch;' data-role='content'>" . $GETimage . " \n";
      } else {
      echo " <h1 id=myh>" . $GETtitle . " Geo Map</h1></div><!-- /header --><div style='display:inline-block;overflow:scroll;-webkit-overflow-scrolling:touch;' data-role='content'>" . $GETimage . " \n";
      }
      if ((!isset($_GET['isMobile']) && !isset($_POST['isMobile'])) || isset($_GET['popularity'])) {
      echo $bdivstart . '<div id="chart_div" style="' . $cdivc . '"></div>' . $bdivend . "\n";
      if (isset($_GET['isMobile']) || isset($_POST['isMobile'])) {
  if (strpos($_SERVER['QUERY_STRING'], "justmenu") === false && strpos($_SERVER['HTTP_REFERER'], "justmenu") === false) {
       echo '<a id=another title="Another Geo Map" href="./geo_chart.php?isMobile=y">Another geo map?</a>' . $lastgo . "\n";
  } else {
       echo '<a id=another title="Another Geo Map" href="./geo_chart.php?isMobile=yjustmenu">Another geo map?</a>' . $lastgo . "\n";
  }
      } else {
  if (strpos($_SERVER['QUERY_STRING'], "justmenu") === false && strpos($_SERVER['HTTP_REFERER'], "justmenu") === false) {
       echo '<a id=another title="Another Geo Map" href="./geo_chart.php">Another geo map?</a>' . $lastgo . "\n";
  } else {
       echo '<a id=another title="Another Geo Map" href="./geo_chart.php?justmenu=justmenu">Another geo map?</a>' . $lastgo . "\n";
  }
      }
      }
      if (!isset($_GET['popularity']) && !isset($_POST['popularity']) && strpos($_SERVER['QUERY_STRING'], "x=x") === false) {
      
        if ((isset($_GET['isMobile']) || isset($_POST['isMobile'])) && strpos($_SERVER['QUERY_STRING'], "x=x") === false) {
      echo '<div id="chart_div"></div>' . "\n";
         echo '<form target="_top" style="margin-top:-10px;" action="./geo_chart.php" method="GET">' . "\n";
         echo '<input name="isMobile" type="hidden" value="y"></input><input name="x" type="hidden" value="x"></input><br>' . "\n";
         echo '<table cellpadding=0 style="background-color:pink;"><tr><td>Title</td><td><input onclick=' . "'" . 'this.style.backgroundColor = "white"; ' . "'" . ' style="background-color:yellow;" id="title" name="title" type="text" value="' . $GETtitle . '"></input></td></tr>' . "\n";
         echo '<tr id="ourw" style="display:none;"><td>Width</td><td><input onclick=' . "'" . 'this.style.backgroundColor = "white"; ' . "'" . ' style="background-color:white;" id="width" name="width" type="text" value="' . $GETwidth . '"></input></td></tr>' . "\n";
         echo '<tr id="ourh" style="display:none;"><td>Height</td><td><input style="background-color:white;" id="height" name="height" type="text" value="' . $GETheight . '"></input></td></tr>' . "\n";
         echo '<tr><td>Via</td><td><input onclick=' . "'" . 'this.style.backgroundColor = "white"; ' . "'" . '  style="background-color:yellow;" id="country" name="country" type="text" value="' . $GETcountry . '"></input></td></tr>' . "\n";
         echo '<tr><td>Basis</td><td><input onclick=' . "'" . 'this.style.backgroundColor = "white"; ' . "'" . '  style="background-color:yellow;" id="popularity" name="popularity" type="text" value="' . $GETpopularity . '"></input></td></tr>' . "\n";
         echo '<tr><td><input style="background-color:yellow;" type="button" onclick=' . "'" . 'later(document.getElementById("title").value,document.getElementById("width").value,document.getElementById("height").value,document.getElementById("country").value,document.getElementById("popularity").value,"&amp;isMobile=y");' . "'" . ' value="Data"></input></td><td><input onclick=' . "'" . 'this.style.backgroundColor = "white"; ' . "'" . ' style="width:240px;font-size:6px;background-color:yellow;" id="data" name="data" type="text" value="' . $GETdata . '"></input></td></tr>' . "\n";     
         //echo '<tr><td><input style="background-color:green;" id="submit" type="submit" value="Show"></input></td><td><input style="background-color:yellow;" id="prompt" type="button" value="Prompt Me" onclick="location.href=' . "'" . './geo_chart.php' . "'" . ';"></input><input style="background-color:yellow;" id="clear" type="button" value="Clear" onclick="clearit();"></input>' . server_remote_addr('1') . '</td></tr></table>' . "\n";
         echo '<tr><td><input style="background-color:green;" id="submit" type="submit" value="Show"></input></td><td><input style="background-color:yellow;" id="prompt" type="button" value="Prompt Me" onclick="top.location.href=' . "'" . './geo_chart.php' . "'" . ';"></input><input style="background-color:yellow;" id="clear" type="button" value="Clear" onclick="clearit();"></input></td></tr></table>' . "\n";
         echo '</form></div><!-- /content -->' . "\n";
      //echo '<div id="chart_div"></div>' . "\n";
      if (strpos($lastgo, "Another") === false) {
      if (isset($_GET['isMobile']) || isset($_POST['isMobile'])) {
  if (strpos($_SERVER['QUERY_STRING'], "justmenu") === false && strpos($_SERVER['HTTP_REFERER'], "justmenu") === false) {
       echo '<a d=another title="Another Geo Map" href="./geo_chart.php?isMobile=y">Another geo map?</a>' . $lastgo . "\n";
  } else {
       echo '<a id=another title="Another Geo Map" href="./geo_chart.php?isMobile=yjustmenu">Another geo map?</a>' . $lastgo . "\n";
  }
      } else {
  if (strpos($_SERVER['QUERY_STRING'], "justmenu") === false && strpos($_SERVER['HTTP_REFERER'], "justmenu") === false) {
       echo '<a id=another title="Another Geo Map" href="./geo_chart.php">Another geo map?</a>' . $lastgo . "\n";
  } else {
       echo '<a id=another title="Another Geo Map" href="./geo_chart.php?justmenu=justmenu">Another geo map?</a>' . $lastgo . "\n";
  }
      }
      }
        }
      
        echo '<' . 'script' . ' type="text/javascript">' . "\n ";
          if (!isset($_GET['isMobile']) && !isset($_POST['isMobile'])) {
   //echo '<' . 'script type="text/javascript">' . "\n";
   echo ' setTimeout(prelater, 2 * 1000);' . "\n";
   //echo '<' . '/' . 'script>' . "\n";
  }

        echo ' function clearit() {  ' . "\n" . ' if (document.getElementById("data").style.backgroundColor.indexOf("yellow") != (0 - 1)) document.getElementById("data").value=""; ' . "\n";
        echo ' if (document.getElementById("title").style.backgroundColor.indexOf("yellow") != (0 - 1)) document.getElementById("title").value=""; ' . "\n";
        echo ' if (document.getElementById("width").style.backgroundColor.indexOf("yellow") != (0 - 1)) document.getElementById("width").value=""; ' . "\n";
        echo ' if (document.getElementById("height").style.backgroundColor.indexOf("yellow") != (0 - 1)) document.getElementById("height").value=""; ' . "\n";
        echo ' if (document.getElementById("country").style.backgroundColor.indexOf("yellow") != (0 - 1)) document.getElementById("country").value=""; ' . "\n";
        echo ' if (document.getElementById("popularity").style.backgroundColor.indexOf("yellow") != (0 - 1)) document.getElementById("popularity").value=""; ' . "\n" . ' }  ' . "\n";


   if (1 == 7) {
        echo ' var datalineprefix = " "; ' . "\n";
        echo ' var acnt = -1; ' . "\n";
        echo ' var defv = ""; ' . "\n";
        echo ' var dlpll = ""; ' . "\n";
        echo ' var datalinesuffix = ""; ' . "\n";
        echo ' var extra = "", four; ' . "\n";
        echo ' var thisline = 1; ' . "\n";
        echo ' var totalleft = 100.0; ' . "\n";
        echo ' var title = ""; ' . "\n";
        echo ' var alttitle = ""; ' . "\n";
        echo ' var width = ""; ' . "\n";
        echo ' var height = ""; ' . "\n";
        echo ' var country = ""; ' . "\n";
        echo ' var popularity = ""; ' . "\n";

        echo ' function whileinnards() {  if (datalinesuffix.length != 0) { ' . "\n";
        echo "    if (fti) {  datalineprefix = ''; dlpll = '';  } else { dlpll=''; if (alttitle.indexOf('&aregeographicals=') != -1) {  datalineprefix = prompt(\"Enter Latitude|Longitude|\" + country + \" Name (can enter URL whose contents contains country,numerical sets or your own list entered here comma separated) \" + thisline +  ' (for no more please hit Cancel button and optionally append with ' + '\\n\\n' + ',\"A tooltip (regarding {popularity}) of some sort like <a target=_blank href=' + \"'\" + 'https://www.google.com/#q={country}' + \"'\" + '>{country}</a>\" ' + '\\n\\n'" . $myextras . " + ' as an example of what is possible with HTML included)', ('`' + defv).replace('`0|0|','').replace('`','')); if (datalineprefix == null) { datalineprefix='';   } dlpll=datalineprefix.split('|')[0]; if (dlpll != '') { dlpll+='|' + datalineprefix.split('|')[1] + '|'; datalineprefix=datalineprefix.replace(dlpll,''); } } else { dlpll = '';  datalineprefix = prompt(\"Enter \" + country + \" Name (can enter URL whose contents contains country,numerical sets or your own list entered here comma separated) \" + thisline +  ' (for no more please hit Cancel button and optionally append with ' + '\\n\\n' + ',\"A tooltip (regarding {popularity}) of some sort like <a target=_blank href=' + \"'\" + 'https://www.google.com/#q={country}' + \"'\" + '>{country}</a>\" ' + '\\n\\n'" . $myextras . " + ' as an example of what is possible with HTML included)', ('`' + defv).replace('`0|0|','').replace('`','')); } } " . "\n";
        echo '    if (datalineprefix != null) {  datalineprefix=dlp(datalineprefix); iof=0; dlsa=datalineprefix.split(","); if (dlsa.length > 1 && (eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(39))) > eval(datalineprefix.indexOf(",")) && eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(34))) > eval(datalineprefix.indexOf(",")))) { while (eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(39))) > eval(datalineprefix.indexOf(",")) && eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(34))) > eval(datalineprefix.indexOf(","))) { datalineprefix=datalineprefix.replace(",", "%2C"); iof+=0;   }  }   datalineprefix=datalineprefix.replace(/#/g, "%23"); if (datalineprefix.indexOf("{country}") != -1 && datalineprefix.indexOf(",") != -1) { dlsa=datalineprefix.split(","); if (dlsa.length > 1) {  datalineprefix=datalineprefix.replace("{country}",encodeURIComponent(dlsa[0])).replace("{country}",encodeURIComponent(dlsa[0]));   } }   } ' . "\n";
        echo ' } ' . "\n";
        //echo ' } ' . "\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 (popularity.indexOf("ercent") != (0 - 1) && popularity.indexOf("  ercent ") == (0 - 1)) extra = " (for " + totalleft + " enter nothing or hit Cancel button)";  ' . "\n";
        echo '     if (fti) { datalinesuffix = "";  } else {  datalinesuffix = prompt("Enter " + popularity.replace("  ercent ", "") + " " + thisline + extra, "0"); }  ' . "\n";
        echo '     if (datalinesuffix == null && popularity.indexOf("ercent") != (0 - 1) && popularity.indexOf("  ercent ") == (0 - 1)) datalinesuffix = totalleft; ' . "\n";
        echo '     if (datalinesuffix == null) datalinesuffix = "0"; ' . "\n";
        echo '     if (datalinesuffix != null) datalineprefix = datalineprefix.replace("{popularity}", datalinesuffix); ' . "\n";
        echo '     if (datalinesuffix.length == 0) { ' . "\n";
        echo '       datalinesuffix = eval(totalleft); ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(totalleft) == eval(datalinesuffix) && popularity.indexOf("ercent") != (0 - 1) && popularity.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(datalinesuffix) > eval(totalleft) && popularity.indexOf("ercent") != (0 - 1) && popularity.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       datalinesuffix = eval(totalleft); ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(datalinesuffix) > eval(totalleft) && popularity.indexOf("ercent") == (0 - 1) && popularity.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       popularity = popularity + "  ercent "; ' . "\n";
        echo '     } else { ' . "\n";
        echo '       totalleft = eval(totalleft) - eval(datalinesuffix); ' . "\n";
        echo '     } ' . "\n";
        //echo '     datac = datac + ",[~" + datalineprefix + "~," + datalinesuffix + "]"; ' . "\n";
        echo '     if (datalineprefix.indexOf("' . "'" . '") == -1) {  four=("" + datalinesuffix).split(","); if (exra != "") { exra=String.fromCharCode(39) + "Regarding " + popularity + four[0] + String.fromCharCode(39) + ","; }  datac = datac + comma + " [" + dlpll + "~" + datalineprefix + "~," + exra + datalinesuffix + "] "; } ' . "\n";
        echo '     if (datalineprefix.indexOf("' . "'" . '") != -1) {  four=("" + datalinesuffix).split(","); exra=String.fromCharCode(39) + "Regarding " + popularity + four[0] + String.fromCharCode(39) + ","; datac = datac + comma + " [" + dlpll + "~" + datalineprefix.replace(",", "~,") +  "," + datalinesuffix + "] "; } ' . "\n"; 
        echo '     thisline++;   defv=""; acnt=eval(-1 + thisline); if (document.getElementById("defv" + acnt)) { defv=document.getElementById("defv" + acnt).value;   }   ' . "\n comma=','; \n";
        echo '   }    ' . "\n";
        echo ' if (datalineprefix.length != 0 && (popularity.indexOf("ercent") == (0 - 1) || popularity.indexOf("  ercent ") != (0 - 1) || (popularity.indexOf("ercent") != (0 - 1) && totalleft > 0))) { ' . "\n";

        echo ' alert(1); } else { alert(2); ' . "\n";
        echo ' } ' . "\n";
        
        echo ' } ' . "\n";
   }


        echo "function prelater() { \n later('','','','','',''); \n } \n function later(t,w,h,c,p,m) { \n";

        echo "\n if (document.getElementById('od1')) { document.getElementById('od1').style.width='' + eval(window.getComputedStyle(document.body, null).getPropertyValue('width').replace('px','')) + 'px'; } \n";
        echo "\n if (document.getElementById('od2')) { document.getElementById('od2').style.width='' + eval(window.getComputedStyle(document.body, null).getPropertyValue('width').replace('px','')) + 'px'; } \n";

   if (1 == 1) {
        echo ' var datalineprefix = " "; ' . "\n";
        echo ' var acnt = -1; ' . "\n";
        echo ' var defv = ""; ' . "\n";
        echo ' var dlpll = ""; ' . "\n";
        echo ' var datalinesuffix = ""; ' . "\n";
        echo ' var extra = "", four; ' . "\n";
        echo ' var thisline = 1; ' . "\n";
        echo ' var totalleft = 100.0; ' . "\n";
        echo ' var title = ""; ' . "\n";
        echo ' var alttitle = ""; ' . "\n";
        echo ' var width = ""; ' . "\n";
        echo ' var height = ""; ' . "\n";
        echo ' var country = ""; ' . "\n";
        echo ' var popularity = ""; ' . "\n";
   }
        echo ' if ((t.length + w.length + h.length + c.length + p.length) == 0) { ' . "\n";
        echo '   title = prompt("Enter Geo Map Title (background image URL or background image data URI ; separated (followed by ;) before title are available options, and you can prefix by a Region Code (eg. IT) (followed by ;) before title as an available options, and you can suffix by &onclick=y for added onclick functionality and/or &aregeographicals=y (or instead of y put an http marker image URL like http://www.rjmprogramming.com.au/PHP/GeoChart/mapc64b.png) for you prefixing Labels by lat|long| values and/or &areplaces=y (or instead of y put a comma separated http marker image URL or placename list (with ,+ usage indicating to plot a line)) for places (prefixable by the number part of an emoji HTML Entity (decimal)	eg. 128249 is video camera) rather than countries, Email Attachment Title suffixes are &emailto=[emailTo] &emailsubject=[EmailSubject] (and to make a quiz question for someone after all your entries also append (things like) &guess=Brazil&question=Which country had Tijuana brass?))", "' . $GETtitle . '");   if (title != null) { alttitle=title;   if (title.indexOf("&are") != -1) {  alttitle=placelook(title);  title=alttitle;  }   } else {  alttitle=""; } ' . "\n";
        echo '   defv=""; acnt++; if (document.getElementById("defv" + acnt)) { defv=document.getElementById("defv" + acnt).value;  } ' . "\n";
        echo ' }  ' . "\n";
        echo ' if ((t.length + w.length + h.length + c.length + p.length) != 0) { ' . "\n";
        echo ' title = t; ' . "\n";
        echo ' width = w; ' . "\n";
        echo ' height = h; ' . "\n";
        echo ' country = c; ' . "\n";
        echo ' popularity = p; ' . "\n";
        echo ' } else if (title != null) { ' . "\n";
        echo ' width = prompt("Enter Geo Map Width", "' . $GETwidth . '"); ' . "\n";
        echo ' height = prompt("Enter Geo Map Height", "' . $GETheight . '"); ' . "\n";
        echo ' if (title.indexOf("&are") != -1) { country = prompt("Enter Places Label", "Places");  } else { country = prompt("Enter Country Label", "' . $GETcountry . '"); } ' . "\n";
        echo ' popularity = prompt("Enter " + country + " Numerical Measure(s) (ie. can be comma separated)", "' . $GETpopularity . '"); ' . "\n";
        echo ' }  ' . "\n";
        echo ' var datac = ""; ' . "\n";
        echo ' var sq = "' . "'" . '"; ' . "\n";
        //echo ' datalineprefix = prompt("Enter " + country + " Name " + thisline, ""); ' . "\n";
        echo "    if (fti) {   datalineprefix = ''; dlpll = '';  } else { dlpll=''; if (alttitle.indexOf('&aregeographicals=') != -1) {  datalineprefix = prompt(\"Enter Latitude|Longitude|\" + country + \" Name (can enter URL whose contents contains country,numerical sets or your own list entered here comma separated) \" + thisline +  ' (optionally append with ' + '\\n\\n' + ',\"A tooltip (regarding {popularity}) of some sort like <a target=_blank href=' + \"'\" + 'https://www.google.com/#q={country}' + \"'\" + '>{country}</a>\" ' + '\\n\\n'" . $myextras . " + ' as an example of what is possible with HTML included)', ('`' + defv).replace('`0|0|','').replace('`','')); if (datalineprefix == null) { datalineprefix='';   } dlpll=datalineprefix.split('|')[0]; if (dlpll != '') { dlpll+='|' + datalineprefix.split('|')[1] + '|'; datalineprefix=datalineprefix.replace(dlpll,''); } } else { dlpll = '';   datalineprefix = prompt(\"Enter \" + country + \" Name (can enter URL whose contents contains country,numerical sets or your own list entered here comma separated) \" + thisline +  ' (optionally append with ' + '\\n\\n' + ',\"A tooltip (regarding {popularity}) of some sort like <a target=_blank href=' + \"'\" + 'https://www.google.com/#q={country}' + \"'\" + '>{country}</a>\" ' + '\\n\\n'" . $myextras . " + ' as an example of what is possible with HTML included)', ('`' + defv).replace('`0|0|','').replace('`',''));  } } " . "\n";
        echo ' if (datalineprefix == null) { datalineprefix="";   } ' . "\n" . ' if (datalineprefix != null) { datalineprefix=dlp(datalineprefix); iof=0; dlsa=datalineprefix.split(","); if (dlsa.length > 1 && (eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(39))) > eval(datalineprefix.indexOf(",")) && eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(34))) > eval(datalineprefix.indexOf(",")))) { while (eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(39))) > eval(datalineprefix.indexOf(",")) && eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(34))) > eval(datalineprefix.indexOf(","))) { datalineprefix=datalineprefix.replace(",", "%2C"); iof+=0;   }  }    datalineprefix=datalineprefix.replace(/#/g, "%23"); if (datalineprefix.indexOf("{country}") != -1 && datalineprefix.indexOf(",") != -1) { dlsa=datalineprefix.split(","); if (dlsa.length > 1) {  datalineprefix=datalineprefix.replace("{country}",encodeURIComponent(dlsa[0])).replace("{country}",encodeURIComponent(dlsa[0]));   } }   } ' . "\n";
        echo ' while (datalineprefix.length != 0 && (popularity.indexOf("ercent") == (0 - 1) || popularity.indexOf("  ercent ") != (0 - 1) || (popularity.indexOf("ercent") != (0 - 1) && totalleft > 0))) { ' . "\n";
   if (1 == 1) {
        echo ' if (datalinesuffix.length != 0) { ' . "\n";
        echo "    if (fti) {  datalineprefix = ''; dlpll = '';  } else { dlpll=''; if (alttitle.indexOf('&aregeographicals=') != -1) {  datalineprefix = prompt(\"Enter Latitude|Longitude|\" + country + \" Name (can enter URL whose contents contains country,numerical sets or your own list entered here comma separated) \" + thisline +  ' (for no more please hit Cancel button and optionally append with ' + '\\n\\n' + ',\"A tooltip (regarding {popularity}) of some sort like <a target=_blank href=' + \"'\" + 'https://www.google.com/#q={country}' + \"'\" + '>{country}</a>\" ' + '\\n\\n'" . $myextras . " + ' as an example of what is possible with HTML included)', ('`' + defv).replace('`0|0|','').replace('`','')); if (datalineprefix == null) { datalineprefix='';   } dlpll=datalineprefix.split('|')[0]; if (dlpll != '') { dlpll+='|' + datalineprefix.split('|')[1] + '|'; datalineprefix=datalineprefix.replace(dlpll,''); } } else { dlpll = '';  datalineprefix = prompt(\"Enter \" + country + \" Name (can enter URL whose contents contains country,numerical sets or your own list entered here comma separated) \" + thisline +  ' (for no more please hit Cancel button and optionally append with ' + '\\n\\n' + ',\"A tooltip (regarding {popularity}) of some sort like <a target=_blank href=' + \"'\" + 'https://www.google.com/#q={country}' + \"'\" + '>{country}</a>\" ' + '\\n\\n'" . $myextras . " + ' as an example of what is possible with HTML included)', ('`' + defv).replace('`0|0|','').replace('`','')); } } " . "\n";
        echo '    if (datalineprefix != null) {  datalineprefix=dlp(datalineprefix); iof=0; dlsa=datalineprefix.split(","); if (dlsa.length > 1 && (eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(39))) > eval(datalineprefix.indexOf(",")) && eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(34))) > eval(datalineprefix.indexOf(",")))) { while (eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(39))) > eval(datalineprefix.indexOf(",")) && eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(34))) > eval(datalineprefix.indexOf(","))) { datalineprefix=datalineprefix.replace(",", "%2C"); iof+=0;   }  }   datalineprefix=datalineprefix.replace(/#/g, "%23"); if (datalineprefix.indexOf("{country}") != -1 && datalineprefix.indexOf(",") != -1) { dlsa=datalineprefix.split(","); if (dlsa.length > 1) {  datalineprefix=datalineprefix.replace("{country}",encodeURIComponent(dlsa[0])).replace("{country}",encodeURIComponent(dlsa[0]));   } }   } ' . "\n";
        echo ' } ' . "\n";
        //echo ' } ' . "\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 (popularity.indexOf("ercent") != (0 - 1) && popularity.indexOf("  ercent ") == (0 - 1)) extra = " (for " + totalleft + " enter nothing or hit Cancel button)";  ' . "\n";
        echo '     if (fti) { datalinesuffix = "";  } else {  datalinesuffix = prompt("Enter " + popularity.replace("  ercent ", "") + " " + thisline + extra, "0"); }  ' . "\n";
        echo '     if (datalinesuffix == null && popularity.indexOf("ercent") != (0 - 1) && popularity.indexOf("  ercent ") == (0 - 1)) datalinesuffix = totalleft; ' . "\n";
        echo '     if (datalinesuffix == null) datalinesuffix = "0"; ' . "\n";
        echo '     if (datalinesuffix != null) datalineprefix = datalineprefix.replace("{popularity}", datalinesuffix); ' . "\n";
        echo '     if (datalinesuffix.length == 0) { ' . "\n";
        echo '       datalinesuffix = eval(totalleft); ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(totalleft) == eval(datalinesuffix) && popularity.indexOf("ercent") != (0 - 1) && popularity.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(datalinesuffix) > eval(totalleft) && popularity.indexOf("ercent") != (0 - 1) && popularity.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       datalinesuffix = eval(totalleft); ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(datalinesuffix) > eval(totalleft) && popularity.indexOf("ercent") == (0 - 1) && popularity.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       popularity = popularity + "  ercent "; ' . "\n";
        echo '     } else { ' . "\n";
        echo '       totalleft = eval(totalleft) - eval(datalinesuffix); ' . "\n";
        echo '     } ' . "\n";
        //echo '     datac = datac + ",[~" + datalineprefix + "~," + datalinesuffix + "]"; ' . "\n";
        echo '     if (datalineprefix.indexOf("' . "'" . '") == -1) {  four=("" + datalinesuffix).split(","); if (exra != "") { exra=String.fromCharCode(39) + "Regarding " + popularity + four[0] + String.fromCharCode(39) + ","; }  datac = datac + comma + " [" + dlpll + "~" + datalineprefix.replace(/\%5f/g,"%20").replace(/\_/g,"%20") + "~," + exra + datalinesuffix + "] "; } ' . "\n";
        echo '     if (datalineprefix.indexOf("' . "'" . '") != -1) {  four=("" + datalinesuffix).split(","); exra=String.fromCharCode(39) + "Regarding " + popularity + four[0] + String.fromCharCode(39) + ","; datac = datac + comma + " [" + dlpll + "~" + datalineprefix.replace(",", "~,").replace(/\%5f/g,"%20").replace(/\_/g,"%20") +  "," + datalinesuffix + "] "; } ' . "\n"; 
        echo '     thisline++;   defv=""; acnt=eval(-1 + thisline); if (document.getElementById("defv" + acnt)) { defv=document.getElementById("defv" + acnt).value;   }   ' . "\n comma=','; \n";
        echo '   } ' . "\n";
    } else {
        echo "\n whileinnards(); \n";
    }
        echo ' } ' . "\n";
          if (!isset($_GET['isMobile']) && !isset($_POST['isMobile'])) {
        echo ' if (allowed) window.location = "./geo_chart.php?title=" + title + m + "&width=" + width + "&height=" + height + "&country=" + country + nojwinextra + "&popularity=" + popularity.replace("  ercent ", "") + "&data=" + datac; ' . "\n";
		  } else {
        echo ' if (allowed) window.location = "./geo_chart.php?isMobile=y&title=" + title + m + "&width=" + width + "&height=" + height + "&country=" + country + nojwinextra + "&popularity=" + popularity.replace("  ercent ", "") + "&data=" + datac; ' . "\n";
          }
        echo "} \n"; // . "} \n";
        echo '</' . 'script' . '>' . "\n";
      } 
      
    echo "\n" . '<input type="hidden" id="ihide" value="0"></input>' . "\n";

   

  if (strpos($_SERVER['QUERY_STRING'], "justmenu") === false && strpos($_SERVER['HTTP_REFERER'], "justmenu") === false) {
  echo '</div><!-- /page -->' . "\n";
  } else {   
  echo '</div><!-- /page -->&nbsp;&nbsp;&nbsp;<a target="top" title="menu" href="//www.rjmprogramming.com.au/PHP/butsel.php?justmenu=justmenu">Menu</a>' . "\n";
  }
    ?>
<script type='text/javascript'>
if (document.URL.indexOf('nojwin') != -1 || navigator.userAgent.match(/iPhone|iPad/i)) {
  //document.getElementById('pch1').innerHTML+='.';
  var xansis='x', hiddenbits='';
  xpnum=1;
  if (document.URL.indexOf('?') != -1) {
    var pairing, argsare=document.URL.split('#')[0].split('?')[1].split('&');
    for (var iargsare=0; iargsare<argsare.length; iargsare++) {
      pairing=argsare[iargsare].split('=');
      if (('*' + pairing[0]).indexOf('*val') == -1 && ('*' + pairing[0]).indexOf('*prompt') == -1 && ('*' + pairing[0]).indexOf('*OK') == -1 && ('*' + pairing[0]).indexOf('*Cancel') == -1) {
       hiddenbits+="<input type=hidden name=" + pairing[0] + " value='" + pairing[1].split(decodeURIComponent('#'))[0].split('#')[0] + "'></input>";
      }
    }
  }
  while (xansis != '') {
   xansis=location.search.split('val' + xpnum + '=')[1] ? decodeURIComponent(decodeURIComponent(location.search.split('val' + xpnum + '=')[1].split('&')[0]).replace(/\+/g,' ')) : '';
   if (document.URL.indexOf('val' + xpnum + '=') != -1) {
     hiddenbits+="<input type=hidden name=val" + xpnum + " value='" + encodeURIComponent(xansis.split(decodeURIComponent('#'))[0].split('#')[0]) + "'></input>";
     xpnum++;
     xansis='x';
   } else {
     xansis='';
   }
  }
  if (document.URL.indexOf('nojwinyes=') != -1) { 
  document.write("<form onsubmit=\" if (document.getElementById('val" + xpnum + "').value.replace('null','') != '') { if (decodeURIComponent(document.getElementById('prompt').value).indexOf(' For ') == 0) {  selecteventtwo(document.getElementById('val" + xpnum + "').value);  } else { selectevent(document.getElementById('val" + xpnum + "').value); } } else if (document.URL.indexOf('&data=') != -1) { location.href=document.URL; } else { this.style.display='none'; } xpnum++; return false; \" enctype='text/plain' style='opacity:0.9;display:none;position:absolute;top:70;left:2%;z-index:56;width:48%;background-color:rgba(255,165,0,0.8);border:2px solid red;' id=safariform method=GET action=" + document.URL.split('#')[0].split('?')[0] + " readonly>" + hiddenbits + "<textarea style='width:96%;background-color:#eeeeee;' rows=5 id='prompt' readonly='readonly'></textarea><br><input type=hidden value='' name=val" + xpnum + " id=hval" + xpnum + "></input><input onkeypress=\"checkEnter(event);\" onblur=\" document.getElementById('h' + this.id).value=encodeURIComponent(this.value); \" style='width:50%;background-color:yellow;' type=text value='' id=val" + xpnum + "></input>&nbsp;&nbsp;<input style='float:right;width:25%;' type=submit value=OK name=OK id=OK></input>&nbsp;<input style='display:none;' type=submit value=Cancel name=Cancel id=Cancel></input>&nbsp;<input type=button value=Cancel id=bCancel onclick=\" document.getElementById('val" + xpnum + "').value='null'; document.getElementById('hval" + xpnum + "').value=encodeURIComponent('null'); this.style.display='none';  document.getElementById('Cancel').style.display='block'; document.getElementById('Cancel').click(); \"></input>&nbsp;</input></form>"); 
  //document.getElementById('pch1').innerHTML+='....';
  } else {
  document.write("<form enctype='text/plain' style='opacity:0.9;display:none;position:absolute;top:70;left:2%;z-index:56;width:48%;background-color:rgba(255,165,0,0.8);border:2px solid red;' id=safariform method=GET action=" + document.URL.split('#')[0].split('?')[0] + " readonly>" + hiddenbits + "<textarea style='width:96%;background-color:#eeeeee;' rows=2 id='prompt' readonly='readonly'></textarea><br><input type=hidden value='' name=val" + xpnum + " id=hval" + xpnum + "></input><input onkeypress=\"checkEnter(event);\" onblur=\" document.getElementById('h' + this.id).value=encodeURIComponent(this.value); \" style='width:50%;background-color:yellow;' type=text value='' id=val" + xpnum + "></input>&nbsp;&nbsp;<input style='float:right;width:25%;' type=submit value=OK name=OK id=OK></input>&nbsp;<input style='display:none;' type=submit value=Cancel name=Cancel id=Cancel></input>&nbsp;<input type=button value=Cancel id=bCancel onclick=\" document.getElementById('val" + xpnum + "').value='null'; document.getElementById('hval" + xpnum + "').value=encodeURIComponent('null'); this.style.display='none';  document.getElementById('Cancel').style.display='block'; document.getElementById('Cancel').click(); \"></input>&nbsp;</input></form>"); 
  //document.getElementById('pch1').innerHTML+='..';
  }
  if (document.getElementById('another')) {
    if (document.getElementById('another').href.indexOf('nojwin') == -1 && document.getElementById('another').href.indexOf('?') == -1) {
     document.getElementById('another').href+='?nojwin=Y';
    } else if (document.getElementById('another').href.indexOf('nojwin') == -1) {
     document.getElementById('another').href+='&nojwin=Y';
    }
  }
}

function preclickforemail() {
<?php 
 if (isset($_POST['emailto'])) {
   if (strpos(urldecode($_POST['emailto']), '@') !== false) {
      if (isset($_POST['emailto'])) echo "\n if (document.getElementById('theto') && yesgo) { document.getElementById('theto').value='" . urldecode($_POST['emailto']) . "'; } \n";
      if (isset($_POST['emailsubject'])) echo "\n if (document.getElementById('thesubject') && yesgo) { document.getElementById('thesubject').innerHTML=\"" . urldecode($_POST['emailsubject']) . "\"; } \n";
      if (isset($_POST['emailcc'])) echo "\n if (document.getElementById('thecc') && yesgo) { document.getElementById('thecc').value='" . urldecode($_POST['emailcc']) . "'; } \n";
      if (isset($_POST['emailbcc'])) echo "\n if (document.getElementById('thebcc') && yesgo) { document.getElementById('thebcc').value='" . urldecode($_POST['emailbcc']) . "'; } \n";
    echo "\n 
    if (yesgo) {
    yesgo3='MAILTO:" . urldecode($_POST['emailto']) . "';
    nogo3='MAILTO:fillin.email@address';
    yesgo2='\"' + document.URL.split('#')[0].split('?')[0].substring(0,10) + document.URL.split('#')[0].split('?')[0].substring(10).split('/')[0] + '/PHP/butsel.php';
    nogo2='\"//www.rjmprogramming.com.au/PHP/butsel.php';
    if (document.getElementById('another')) {
    yesgo=document.getElementById('another').href=document.URL.split('#')[0].split('?')[0];
    nogo='./' + document.URL.split('#')[0].split('?')[0].split('/')[eval(-1 + document.URL.split('#')[0].split('?')[0].split('/').length)];
    }
    }
     \n ";
      echo "\n if (clickforemail) { clickforemail(); } else if (document.getElementById('thesemail')) { document.getElementById('thesemail').click(); } \n";
   }
 }
?>
}

<?php 
 if (isset($_POST['emailto'])) {
   if (strpos(urldecode($_POST['emailto']), '@') !== false) {
     echo "\n setTimeout(preclickforemail,4000); \n";
   }
 }
?>


</script>
<div id="thedivemail"></div>
<div id="placelookup"></div>
</body>
</html>
