<?php
// australian_ports.php
// RJM Programming
// September, 2017
// Thanks to Wikipedia at https://en.wikipedia.org/wiki/List_of_reservoirs_and_ports_in_Australia

 function selcreate($def) {
   $ret=$def;
   $selstr='<select onchange=" window.location=this.value; "><option value="' . str_replace(" ", "_", strtolower($def)) . '_ports.php">' . $def . '</option>';
   $cnt=0;
   foreach (glob("*_ports.php") as $filename) {
    if (strpos(($filename . "*"), (str_replace(" ", "_", strtolower($def)) . '_ports.php*')) === false) {
     $cnt++;
     $newidea=str_replace("_", " ", str_replace("_ports.php", "", strtolower($filename)));
     $newideas=explode(" ", $newidea);
     $ideas=strtoupper(substr($newideas[0],0,1)) . strtolower(substr($newideas[0],1));
     for ($ii=1; $ii<sizeof($newideas); $ii++) {
       $ideas.=(" " . strtoupper(substr($newideas[$ii],0,1)) . strtolower(substr($newideas[$ii],1)));
     }
     $selstr.='<option value="' . $filename . '">' . $ideas . '</option>';
    }
   } 
   if ($cnt > 0) return $selstr . "</select>";  
   return $ret;
 }
 
 if (isset($_GET['notyet'])) {
 echo '<html><head><title>Australian Ports - RJM Programming - September, 2017</title></head><body><input style="font-size:32px;background-color:yellow;" type=button value="Show Australian Ports now ..." onclick=location.href="./australian_ports.php";></input></body></html>';
 } else { 
 if (!file_exists(dirname(__FILE__) . "/australian_ports.txt")) {
  file_put_contents(dirname(__FILE__) . "/australian_ports.txt", file_get_contents("https://en.wikipedia.org/wiki/List_of_ports_in_Australia"));
  //$lhcont=str_replace("</table>", "<table", file_get_contents("https://en.wikipedia.org/wiki/List_of_ports_in_Australia"));
 }
 $lhcont=str_replace("</table>", "<table", file_get_contents(dirname(__FILE__) . "/australian_ports.txt"));
 $url="//www.rjmprogramming.com.au/PHP/Map/map.php";
 $method="POST";
 $iname="my_iframe";
 $ourtitle=urlencode("Australian Ports");
 $ourlabel="[%27Lat%27,";
 $ourvalue="%27Lon%27,%20%27Name%27]";
 $ourdata="";
 $prefix=$url . "?title=" . $ourtitle . "&onclick=y&lines=y&label=" . $ourlabel . "&value=" . $ourvalue . "&data=";
 $isok=true;
 $titleis="";
 $altis="";
 $imgbit="";
 $simgbit="";
 $seimgbit="";
 $listsofar=";";
 $tdzdone=0;
 $tdzd=false;
 // Prepare HTML form and iframe for later ...
 $ourform="<" . "form target='" . $iname . "' method='" . $method . "' action='" . $url . "'><input name='title' type='hidden' id='title' value='" . $ourtitle . "'></input><input name='onclick' value='y' type='hidden'></input><input name='lines' value='y' type='hidden'></input><input name='label' type='hidden' id='label' value='" . $ourlabel . "'></input><input type='hidden' name='wouldlikeyoutoseekpermission' id='wouldlikeyoutoseekpermission' value='y'></input><input name='value' type='hidden' id='value' value='" . $ourvalue . "'></input><textarea style='display:none;' rows=40 cols=80 name='data' id='data' value=''></textarea><input style='display:none;' type='submit' id='submit'></input></form>\n";


 if (isset($_GET['emailto'])) $ourform=str_replace("</form>","<input type=hidden name=emailto value='" . urldecode($_GET['emailto']) . "'></input></form>", $ourform); 
 if (isset($_GET['emailsubject'])) $ourform=str_replace("</form>","<input type=hidden name=emailsubject value='" . urldecode($_GET['emailsubject']) . "'></input></form>", $ourform); 
 if (isset($_GET['emailcc'])) $ourform=str_replace("</form>","<input type=hidden name=emailcc value='" . urldecode($_GET['emailcc']) . "'></input></form>", $ourform); 
 if (isset($_GET['emailbcc'])) $ourform=str_replace("</form>","<input type=hidden name=emailbcc value='" . urldecode($_GET['emailbcc']) . "'></input></form>", $ourform); 

 $ourscript="<" . "script type='text/javascript'>\nfunction populate() {   var vemailto=(location.search.split('emailto=')[1] ? decodeURIComponent(location.search.split('emailto=')[1].split('&')[0]) : ''); if (vemailto.indexOf('@') != -1) { document.getElementById('emailopt').innerHTML=document.getElementById('emailopt').innerHTML.replace('Email to ','Email to ' + vemailto + ' '); }  document.getElementById('title').value=decodeURIComponent('" . $ourtitle . "'); document.getElementById('label').value=decodeURIComponent('" . $ourlabel . "'); document.getElementById('value').value=decodeURIComponent('" . $ourvalue . "'); document.getElementById('data').value=''; \n";
 // Write out start of HTML ready for the one table row that will be created ...
 $tbits=explode('<tr', $lhcont);
 echo '<html><head><script type="text/javascript" src="australian_lighthouses.js" async="async"></script><link href="//www.rjmprogramming.com.au/PHP/emboss_h1.css" rel="stylesheet" type="text/css"><style> body {  background-color: pink;  } td { border: 2px solid blue; padding-left:10px; padding-right: 10px; background-color: magenta; } </style><title>Australian Ports - RJM Programming - September, 2017</title><' . 'script type="text/javascript"> var fsize=' . (-1 + sizeof($tbits)) . ', anim=false, eightthousand=8000, curanim=1;   function startit() { if (anim) { location.href="#td" + curanim; curanim++; if (curanim > fsize || !document.getElementById("td" + curanim)) { curanim=1; }  setTimeout(startit,eightthousand);  }  }  function startorstop() { if (!anim) { anim=true; setTimeout(startit,eightthousand);  } else { anim=false; location.href="#td0"; if (eightthousand > 2999) {  eightthousand-=1000; }   }   }  function after() { document.getElementById("submit").click(); document.getElementById("' .$iname . '").style.display="inline"; } </' . 'script></head><body onload="populate(); document.getElementById(' . "'" . 'emailopt' . "'" . ').value=document.URL.split(String.fromCharCode(35))[0].split(String.fromCharCode(63))[0];"><div align="center"><h1>' . selcreate("Australian") . ' Ports <select onchange="  var smore=' . "''" . ';   if (this.value == document.URL.split(String.fromCharCode(35))[0].split(String.fromCharCode(63))[0]) {    var presmore=prompt(' . "'" . 'Email To?  Cann add &emailsubject=[EmailSubject] &emailcc=[EmailCC] &emailbcc=[EmailBCC]' . "'" . ',' . "''" . ');    if (presmore == null) { presmore=' . "''" . '; }    if (presmore.indexOf(' . "'" . '@' . "'" . ') != -1) {    smore=' . "'" . '?emailto=' . "'" . ' + presmore;     }   }  location.href=this.value + smore;"><option value=#>...</option><option id=emailopt value="">Share via Email to ...</option><option value=./australian_lighthouses.php>Australian Lighthouses</option><option value=./australian_waterfalls.php>Australian Waterfalls</option><option value=./australian_dams.php>Australian Dams</option><option value=./australian_ports.php>Australian Ports</option><option value=./australian_parks.php>Australian National Parks</option></select> Thanks to <a target=_blank title="Australian Ports information from Wikipedia ... thanks" href="https://en.wikipedia.org/wiki/List_of_ports_in_Australia">Wikipedia</a></h1></div><table cellspacing=5 style="margin-top:-16px;"><tr>';
 // For each table ...
 //$tbits=explode('<table', $lhcont);
 for ($i=1; $i<sizeof($tbits); $i++) {
  // For each relevant table cell ...
  $bits=explode('<td><a href="/', $tbits[$i]);
    $altis="";
    $titleis="";
  for ($ii=1; $ii<sizeof($bits); $ii++) {
   $preabits=explode('</td>', $bits[$ii]);
   for ($iij=0; $iij<sizeof($preabits); $iij++) {
    $postabits=explode(">", str_replace("</a>", "", $preabits[$iij]));  
    for ($iijj=1; $iijj<sizeof($postabits); $iijj++) {
     //if (strpos($postabits[$iijj], ' src="') !== false || strpos($postabits[$iijj], '<') === false || (strpos($postabits[$iijj], ".") !== false && (strpos($postabits[$iijj], "°S") !== false || strpos($postabits[$iijj], "°N") !== false || strpos($postabits[$iijj], "°E") !== false || strpos($postabits[$iijj], "°W") !== false))) {
      //if ($isok) {
       if (strpos($postabits[$iijj], "°") !== false && 1 == 1) {
       } else if (strpos($postabits[$iijj], "<img ") !== false) {
       } else {
        if ($titleis == "") {
          $titleis=str_replace(">", "&gt;", str_replace("<", "&lt;", str_replace("</span", "", $postabits[$iijj])));
          $altis=$titleis;
          $altis=str_replace("'", "`", $altis);
          $titleis=str_replace("'", "`", $titleis);
       //echo str_replace(">", "&gt;", str_replace("<", "&lt;", $titleis . " ... " . $altis));
       //exit;
        } else if ($altis == "" || $altis == $titleis) {
          $altis=str_replace(">", "&gt;", str_replace("<", "&lt;", str_replace("</span", "", $postabits[$iijj])));
          if ($altis == "") $altis=$titleis;
          $altis=str_replace("'", "`", $altis);
          $titleis=str_replace("'", "`", $titleis);
       //echo str_replace(">", "&gt;", str_replace("<", "&lt;", $titleis . " .. " . $altis));
       //exit;
        }
        if (1 == 2) echo "\n<td>" . str_replace(">", "&gt;", str_replace("<", "&lt;", str_replace("</span", "", $postabits[$iijj]))) . "</td>";
	   }
	  //}
	 //}
    }
    for ($iijj=1; $iijj<sizeof($postabits); $iijj++) {
     if (strpos($postabits[$iijj], ' src="') !== false || strpos($postabits[$iijj], '<') === false || (strpos($postabits[$iijj], ".") !== false && (strpos($postabits[$iijj], "°S") !== false || strpos($postabits[$iijj], "°N") !== false || strpos($postabits[$iijj], "°E") !== false || strpos($postabits[$iijj], "°W") !== false))) {
      // For "still within interesting cells" within table row ...
      if ($isok) {
       // For decimal latitude, longitude content cells ...
       if (strpos($postabits[$iijj], "°") !== false && 1 == 1) {
        $xpostabits=explode("°", $postabits[$iijj]);  
        for ($iijjk=1; $iijjk<sizeof($xpostabits); $iijjk++) {
         //if (substr($xpostabits[$iijjk], 0, 1) == "N") $latis="+" . $xpostabits[$iijjk - 1]; // . "</td>";
         //if (substr($xpostabits[$iijjk], 0, 1) == "S") $latis="-" . $xpostabits[$iijjk - 1]; // . "</td>";
         //if (substr($xpostabits[$iijjk], 0, 1) == "E") $longis="+" . trim(str_replace("S", "", str_replace("N", "", str_replace("\n", "", $xpostabits[$iijjk - 1])))); // . "</td>";
         //if (substr($xpostabits[$iijjk], 0, 1) == "W") $longis="-" . trim(str_replace("S", "", str_replace("N", "", str_replace("\n", "", $xpostabits[$iijjk - 1])))); // . "</td>";
         if (strpos($postabits[$iijjk] . " "," S ") !== false) {  // 35°26'49.2"S
           $wls=explode(" ",str_replace('"',"",str_replace("°"," ",str_replace("'"," ",str_replace(" S","",$postabits[$iijjk])))));
           $val=(0.0 - $wls[0]);
           $div=60.0;
           for ($iwls=1; $iwls<sizeof($wls); $iwls++) {
             if (("" . $wls[$iwls]) != "") {
             $wlsiwls=ltrim($wls[$iwls], '0');
             if (("" . $wlsiwls) != "") $val-=($wlsiwls / $div);
             $div*=60;
             }
           }
           $latis="" . $val;
           
         }
         if (strpos($postabits[$iijjk] . " "," N ") !== false) {  // 35°26'49.2"S
           $wls=explode(" ",str_replace('"',"",str_replace("°"," ",str_replace("'"," ",str_replace(" N","",$postabits[$iijjk])))));
           $val=(0.0 + $wls[0]);
           $div=60.0;
           for ($iwls=1; $iwls<sizeof($wls); $iwls++) {
             if (("" . $wls[$iwls]) != "") {
             $wlsiwls=ltrim($wls[$iwls], '0');
             if (("" . $wlsiwls) != "") $val+=($wlsiwls / $div);
             $div*=60;
             }
           }
           $latis="+" . $val;
         }
         if (strpos($tbits[$i]," E</td>") !== false) {  // 35°26'49.2"S
           $postabitsiijjk=explode(">",explode(" E</td>",$tbits[$i])[0])[-1 + sizeof(explode(">",explode(" E</td>",$tbits[$i])[0]))];
           $wls=explode(" ",str_replace('"',"",str_replace("°"," ",str_replace("'"," ",str_replace(" E","",$postabitsiijjk)))));
           $val=(0.0 + $wls[0]);
           $div=60.0;
           $lp=$val;
           for ($iwls=1; $iwls<sizeof($wls); $iwls++) {
             if (("" . $wls[$iwls]) != "") {
             $wlsiwls=ltrim($wls[$iwls], '0');
             if (("" . $wlsiwls) != "") $val+=($wlsiwls / $div);
             $lp.=' ... ' . $postabits[1 + $iijjk] . ' to ' . $wls[$iwls] . ' of ' . $iwls . '(' . $wlsiwls . '/' . $div . ") = " . $val;
             //if (strpos($tbits[$i], "Bermagui") !== false) {
             //  echo $wlsiwls . "/ " . $div . " made value go to " . $val;
             //  exit;
             //}
             $div*=60;
             }
           }
           $longis="+" . $val;
           $lp.=$longis;
         }
         if (strpos($tbits[$i]," W</td>") !== false) {  // 35°26'49.2"S
           $postabitsiijjk=explode(">",explode(" W</td>",$tbits[$i])[0])[-1 + sizeof(explode(">",explode(" W</td>",$tbits[$i])[0]))];
           $wls=explode(" ",str_replace('"',"",str_replace("°"," ",str_replace("'"," ",str_replace(" W","",$postabitsiijjk)))));
           $val=(0.0 - $wls[0]);
           $div=60.0;
           for ($iwls=1; $iwls<sizeof($wls); $iwls++) {
             if (("" . $wls[$iwls]) != "") {
             $wlsiwls=ltrim($wls[$iwls], '0');
             if (("" . $wlsiwls) != "") $val-=($wlsiwls / $div);
             $div*=60;
             }
           }
           $longis="" . $val;
         }
        }
        $altis=trim(str_replace("'", "`", $altis));
        $titleis=trim(str_replace("'", "`", $titleis));
        if (substr(($altis . "A"),0,1) < "A") $altis="";
        if (substr(($titleis . "A"),0,1) < "A") $titleis="";
        if ($altis == $titleis) $altis="";
        if ($imgbit == "" && 1 == 1) $imgbit="</a>";
        if ($imgbit == "" && 1 == 2) $imgbit=$altis . ", " . $titleis;
        if ($simgbit == "" && 1 == 1) $simgbit="</a>";
        if ($simgbit == "" && 1 == 2) $simgbit=$altis . ", " . $titleis;
        if ($seimgbit == "" && 1 == 1) $seimgbit=urlencode(">" . $altis . ", " . $titleis) . "%3C/a%3E";
        if ($seimgbit == "" && 1 == 2) $seimgbit=">" . $altis . ", " . $titleis . "</a>";
        // Write out cell of information for one dam ...
        
        if (trim($altis . $titleis) != "") {
         if (trim($altis) == "") {
          if (!$tdzd) {
          if (strpos($listsofar, ";" . $titleis . ";") === false) {
          $listsofar.=$titleis . ";";
          $tdzdone=1;
          $tdzd=true;
          echo "\n<td id=td0 title=Animate><a onclick=startorstop(); style=text-decoration:none;cursor:pointer;>&#127902;</a></td><td id=td" . $tdzdone . "><input title=\"YouTube embedded videos for " . $titleis . " ... thanks\" type=button onclick=\"document.getElementById('my_video').style.display='inline-block'; document.getElementById('my_video').src='//www.rjmprogramming.com.au/HTMLCSS/karaoke_youtube_api.htm?emoji=on&nokaraoke=y&youtubeid=%20%20%20%20%20%20%20%20%20%20%20%20%20%20' + encodeURIComponent('" . $titleis . "');\" value='&#128249;'></input>&nbsp;<input style=\"font-size:48px;\" title=\"Australian Government website look for " . $titleis . " ... Thanks\" type=button onclick=\"window.open('HTTP://www.australia.gov.au/search/site/" . urlencode($titleis) . "?f[0]=sm_field_creator%3Anode%3A207','_blank');\" value='&#127966;'></input>&nbsp;<input title=\"Bonzle Digital Map look for " . $titleis . " ... Thanks\" type=button onclick=\"window.open('HTTP://www.bonzle.com/c/a?a=ps&s=" . urlencode($titleis) . "','_blank');\" value='&#128506;'></input>&nbsp;<a title='" . $titleis . "' target=_blank href='https://maps.google.com.au/maps?" . "z=15&t=m&q=loc:" . $latis . $longis . "'>" . $titleis . $imgbit . "</td>";
          }
          } else {
          if (strpos($listsofar, ";" . $titleis . ";") === false) {
          $tdzdone++;
          $listsofar.=$titleis . ";";
          echo "\n<td id=td" . $tdzdone . "><input title=\"YouTube embedded videos for " . $titleis . " ... thanks\" type=button onclick=\"document.getElementById('my_video').style.display='inline-block'; document.getElementById('my_video').src='//www.rjmprogramming.com.au/HTMLCSS/karaoke_youtube_api.htm?emoji=on&nokaraoke=y&youtubeid=%20%20%20%20%20%20%20%20%20%20%20%20%20%20' + encodeURIComponent('" . $titleis . "');\" value='&#128249;'></input>&nbsp;<input style=\"font-size:48px;\" title=\"Australian Government website look for " . $titleis . " ... Thanks\" type=button onclick=\"window.open('HTTP://www.australia.gov.au/search/site/" . urlencode($titleis) . "?f[0]=sm_field_creator%3Anode%3A207','_blank');\" value='&#127966;'></input>&nbsp;<input title=\"Bonzle Digital Map look for " . $titleis . " ... Thanks\" type=button onclick=\"window.open('HTTP://www.bonzle.com/c/a?a=ps&s=" . urlencode($titleis) . "','_blank');\" value='&#128506;'></input>&nbsp;<a title='" . $titleis . "' target=_blank href='https://maps.google.com.au/maps?" . "z=15&t=m&q=loc:" . $latis . $longis . "'>" . $titleis . $imgbit . "</td>";
          }
          }
             //if (strpos($tbits[$i], "Bermagui") !== false) {
             //   echo $lp . " " . $latis . $longis;
             //   exit;
             //}
        if (1 == 2) $thisdata = ",[" . str_replace("+","",$latis) . "," . str_replace("+","",$longis) . "," . "%22A%20Wikipedia%20image%20(thanks)%20and%20clicking%20link%20for%20Google%20Map%20based%20on%20latitude%20and%20longitude%20of%20%3Ca%20target=_blank%20href=\\\\\"https://maps.google.com.au/maps?" . urlencode("z=15&t=m&q=loc:" . $latis . $longis) . "\\\\\"" . "%3E" . urlencode($titleis) . "%3C/a%3E%22,~" . urlencode(str_replace(' Harbour','',$titleis)) . "~]";
        $thisdata = ",[" . str_replace("+","",$latis) . "," . str_replace("+","",$longis) . "," . "%22A%20Wikipedia%20image%20(thanks)%20and%20clicking%20link%20for%20Google%20Map%20based%20on%20latitude%20and%20longitude%20of%20%3Ca%20target=_blank%20href=\\\\\"https://maps.google.com.au/maps?" . urlencode("z=15&t=m&q=loc:" . $latis . $longis) . "\\\\\"" . $seimgbit . "%22,~" . urlencode(str_replace(' Harbour','',$titleis)) . "~]";
         } else {
          if (!$tdzd) {
          if (strpos($listsofar, ";" . $altis . ";") === false) {
          $listsofar.=$altis . ";";
          $tdzdone=1;
          $tdzd=true;
          echo "\n<td id=td0 title=Animate><a onclick=startorstop(); style=text-decoration:none;cursor:pointer;>&#127902;</a></td><td id=td" . $tdzdone . "><input title=\"YouTube embedded videos for " . $altis . " ... thanks\" type=button onclick=\"document.getElementById('my_video').style.display='inline-block'; document.getElementById('my_video').src='//www.rjmprogramming.com.au/HTMLCSS/karaoke_youtube_api.htm?emoji=on&nokaraoke=y&youtubeid=%20%20%20%20%20%20%20%20%20%20%20%20%20%20' + encodeURIComponent('" . $altis . "');\" value='&#128249;'></input>&nbsp;<input style=\"font-size:48px;\" title=\"Australian Government website look for " . $altis . " ... Thanks\" type=button onclick=\"window.open('HTTP://www.australia.gov.au/search/site/" . urlencode($altis) . "?f[0]=sm_field_creator%3Anode%3A207','_blank');\" value='&#127966;'></input>&nbsp;<input title=\"Bonzle Digital Map look for " . $altis . " ... thanks\" type=button onclick=\"window.open('HTTP://www.bonzle.com/c/a?a=ps&s=" . urlencode($altis) . "','_blank');\" value='&#128506;'></input>&nbsp;<a title='" . $altis . "' target=_blank href='https://maps.google.com.au/maps?" . "z=15&t=m&q=loc:" . $latis . $longis . "'>" . $altis . $imgbit . "</td>";
          }
          } else {
          $tdzdone++;
          if (strpos($listsofar, ";" . $altis . ";") === false) {
          $listsofar.=$altis . ";";
          echo "\n<td id=td" . $tdzdone . "><input title=\"YouTube embedded videos for " . $altis . " ... thanks\" type=button onclick=\"document.getElementById('my_video').style.display='inline-block'; document.getElementById('my_video').src='//www.rjmprogramming.com.au/HTMLCSS/karaoke_youtube_api.htm?emoji=on&nokaraoke=y&youtubeid=%20%20%20%20%20%20%20%20%20%20%20%20%20%20' + encodeURIComponent('" . $altis . "');\" value='&#128249;'></input>&nbsp;<input style=\"font-size:48px;\" title=\"Australian Government website look for " . $altis . " ... Thanks\" type=button onclick=\"window.open('HTTP://www.australia.gov.au/search/site/" . urlencode($altis) . "?f[0]=sm_field_creator%3Anode%3A207','_blank');\" value='&#127966;'></input>&nbsp;<input title=\"Bonzle Digital Map look for " . $altis . " ... thanks\" type=button onclick=\"window.open('HTTP://www.bonzle.com/c/a?a=ps&s=" . urlencode($altis) . "','_blank');\" value='&#128506;'></input>&nbsp;<a title='" . $altis . "' target=_blank href='https://maps.google.com.au/maps?" . "z=15&t=m&q=loc:" . $latis . $longis . "'>" . $altis . $imgbit . "</td>";
          }
          }
             //if (strpos($tbits[$i], "Bermagui") !== false) {
             //   echo $lp . " " . $latis . $longis;
             //   exit;
             //}
        if (1 == 2) $thisdata = ",[" . str_replace("+","",$latis) . "," . str_replace("+","",$longis) . "," . "%22A%20Wikipedia%20image%20(thanks)%20and%20clicking%20link%20for%20Google%20Map%20based%20on%20latitude%20and%20longitude%20of%20%3Ca%20target=_blank%20href=\\\\\"https://maps.google.com.au/maps?" . urlencode("z=15&t=m&q=loc:" . $latis . $longis) . "\\\\\"" . "%3E" . urlencode($altis) . "%3C/a%3E%22,~" . urlencode(str_replace(' Harbour','',$altis)) . "~]";
        $thisdata = ",[" . str_replace("+","",$latis) . "," . str_replace("+","",$longis) . "," . "%22A%20Wikipedia%20image%20(thanks)%20and%20clicking%20link%20for%20Google%20Map%20based%20on%20latitude%20and%20longitude%20of%20%3Ca%20target=_blank%20href=\\\\\"https://maps.google.com.au/maps?" . urlencode("z=15&t=m&q=loc:" . $latis . $longis) . "\\\\\"" . $seimgbit . "%22,~" . urlencode(str_replace(' Harbour','',$altis)) . "~]";
         }
        }
        // Write out Javascript to populate textarea and rest of form data that will be posted to iframe ...
        $ourscript .= "\n document.getElementById('data').value+=decodeURIComponent('" . $thisdata . "'); ";
        $ourscript .= "\n document.getElementById('data').innerHTML+=decodeURIComponent('" . $thisdata . "'); ";
        $ourdata .= $thisdata;
        //$titleis="";
        //$altis="";
        $imgbit="";
        $simgbit="";
        $seimgbit="";
       // For image cells ...
       } else if (strpos($postabits[$iijj], "<img ") !== false) {
        $imgbit=str_replace("//", "https://", str_replace("</span", "", str_replace('"', "'", $postabits[$iijj]))) . "></a>";
        
        if (strpos($imgbit, ' src=') !== false) {
          $ibits=explode(' src=', $imgbit);
          $jbits=explode(' ', $ibits[1]);
          $simgbit = " onclick=\" window.open(" . $jbits[0] . ", '" . $altis . "'); \">" . $altis . ", " . $titleis . "</a>";
          $seimgbit = urlencode(" onclick=\\\" window.open(" . $jbits[0] . ", '" . $altis . "','left=200,top=200,width=300,height=300'); \\\">" . $altis . ", " . $titleis . "</a>");
        } else {
          $simgbit="";
          $seimgbit="";
        }
       // For other cells ...
       } else if (1 == 2)  {
        if ($titleis == "") {
          $titleis=str_replace(">", "&gt;", str_replace("<", "&lt;", str_replace("</span", "", $postabits[$iijj])));
          $altis=$titleis;
          $altis=str_replace("'", "`", $altis);
          $titleis=str_replace("'", "`", $titleis);
        } else if ($altis == "" || $altis == $titleis) {
          $altis=str_replace(">", "&gt;", str_replace("<", "&lt;", str_replace("</span", "", $postabits[$iijj])));
          if ($altis == "") $altis=$titleis;
          $altis=str_replace("'", "`", $altis);
          $titleis=str_replace("'", "`", $titleis);
        }
        if (1 == 2) echo "\n<td>" . str_replace(">", "&gt;", str_replace("<", "&lt;", str_replace("</span", "", $postabits[$iijj]))) . "</td>";
	   }
      }
      // Check for end of significant information in this table row ...
      if (strpos($postabits[$iijj], ".") !== false && (strpos($postabits[$iijj], "°S") !== false || strpos($postabits[$iijj], "°N") !== false || strpos($postabits[$iijj], "°E") !== false || strpos($postabits[$iijj], "°W") !== false)) $isok=false;
     }
    }
   }
   // Reset to look for interesting cells in program ...
   $isok=true;
  }
  $titleis="";
  $altis="";
  $imgbit="";
  $simgbit="";
  $seimgbit="";
 }
 // Write out end of HTML including end of row and end of table and form (method=POST with a submit button programmatically clicked via setInterval() at body onload event) and Javascript code and Google Chart Map Chart map.php iframe.
 echo "\n</tr></table>" . $ourform . $ourscript . "\n if (1 == 1) { setTimeout(after, 2000); } \n } \n</" . "script><br><br><div align='center' style='margin-top:-16px;vertical-align:top;'><iframe name='my_video' id='my_video' src='javascript:none' width=63% height=800 style='display:none;'></iframe><iframe name='my_iframe' id='my_iframe' src='javascript:none' width=750 height=500 style='display:none;'></iframe></div></body></html>";
 }
?>
