<?php
  if (file_exists("csv.php")) {
    include "csv.php";
  } else if (file_exists("../csv.php")) { 
    include "../csv.php";
  }
  function retval($inv) {
    if (strpos($inv, "E-") !== false) return "0";
    return $inv;
  }
?>
<html>
  <head> 
    <title>Map - RJM Programming - http://www.rjmprogramming.com.au (Copyright &copy; 2013 rjmprogramming.com.au all rights reserved.)</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">

   var x=-1, y=-1, elemLeft=0, elemTop=0, ir=-1, ic=-1, talkingpoint='';   

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

<?php       
 
      $GETtp="";
      if (isset($_GET['tp'])) $GETtp = urldecode($_GET['tp']);
      if (isset($_POST['tp'])) $GETtp = urldecode($_POST['tp']);
      if ($GETtp != "") echo "\n talkingpoint=String.fromCharCode(10) + String.fromCharCode(10) + " . '"' . str_replace("`", '" + String.fromCharCode(10) + "', str_replace("\n", '" + String.fromCharCode(10) + "', $GETtp)) . '"' . " + String.fromCharCode(10) + String.fromCharCode(10); \n";

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

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

      $GETtitle = "Places";
      $GETlabel = "['Lat',";
      $GETvalue = "'Lon', 'Name']";
      $GETdata = ",[37.4232, -122.0853, 'Work'],[37.4289, -122.1697, 'University'],[37.6153, -122.3900, 'Airport'],[37.4422, -122.1731, 'Shopping']";
            
      if (isset($_GET['value'])) {
       $GETtitle = $_GET['title'];
       $GETlabel = str_replace("\\","",$_GET['label']);
       $GETvalue = str_replace("\\","",$_GET['value']);
       $GETdata = $_GET['data'];
      } else if (isset($_POST['value']) && isset($_POST['wouldlikeyoutoseekpermission'])) {
       $GETtitle = urldecode($_POST['title']);
       $GETlabel = str_replace("\\","",urldecode($_POST['label']));
       $GETvalue = str_replace("\\","",urldecode($_POST['value']));
       $GETdata = urldecode($_POST['data']);
      }
      
      $hdgs = split(",", $GETvalue);
      $GETval = "";
      if (isset($hdgs[0])) $GETval = "'" . str_replace("'", "", $hdgs[0]) . "'";
      if (isset($hdgs[1])) $GETval .= ",'" . str_replace("'", "", $hdgs[1]) . "'";
      if (isset($hdgs[2])) $GETval .= ",'" . str_replace("'", "", $hdgs[2]) . "'";
      if (isset($hdgs[3])) $GETval .= ",'" . str_replace("'", "", $hdgs[3]) . "'";
      
      echo "var data, chart, pardata = (location.search.split('data=')[1] ? location.search.split('data=')[1].split('&')[0] : ''), paramdata=decodeURIComponent(pardata);\n";
      $GETonclick = "";
      if (isset($_GET['onclick'])) $GETonclick = urldecode($_GET['onclick']);
      if (isset($_POST['onclick'])) $GETonclick = urldecode($_POST['onclick']);
      echo " var selonclick='" . $GETonclick . "';\n";
      echo " google.load('visualization', '1', {packages:['map']}); " . "\n";
      echo ' google.setOnLoadCallback(drawChart); ' . "\n";
      echo ' function drawChart() { ' . "\n";
 if ((isset($_GET['value']) || isset($_POST['value'])) && (isset($_GET['tooltip']) || isset($_POST['tooltip']) || strpos($GETdata, "'") !== false || strpos($GETdata, '"') !== false)) {
  echo "     data = new google.visualization.DataTable(); /" . "/" . $GETlabel . $GETvalue . " \n";
  echo "   data.addColumn('number', '" . str_replace("'","",str_replace(",","",str_replace("['","",$GETlabel))) . "');  \n";
  //echo "   data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}});  \n";
  echo "   data.addColumn('number', " . str_replace(",", "); data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}}); data.addColumn('string', ", str_replace("]","",$GETvalue)) . ");  \n";
  echo " data.addRows([ \n";
      echo str_replace("''" . "''", "''", str_replace("~", "'", substr($GETdata,1)));
  echo "   ]); \n";
 } else {
      echo ' data = google.visualization.arrayToDataTable([ ' . "\n";
      echo " " . $GETlabel . $GETvalue . " \n";
      echo str_replace("''" . "''", "''", str_replace("~", "'", $GETdata));
      echo "        ]);\n";
 }
      
      //echo "        var options = { \n";
      //if (isset($hdgs[3])) {
      //echo "        title: '" . $GETtitle . "', \n";
      //echo "        hAxis: {title: '" . $hdgs[0] . "'}," . " \n";
      //echo "        vAxis: {title: '" . $hdgs[1] . "'}," . " \n";
      //echo "        Map: {textStyle: {fontSize: 11}} \n";
      //} else {
      //echo "        colorAxis: {colors: ['yellow', 'red']} \n";
      //}
      //echo "       }; \n";


      echo " chart = new google.visualization.Map(document.getElementById('chart_div')); \n";
      //echo " chart.draw(data, {showTip: true, focusTarget: 'category', tooltip: {isHtml: true}}); \n } \n";
      //echo " chart.draw(data, {focusTarget: 'category',  tooltip: {isHtml: true}, showTip: true}); \n } \n";
      //echo " chart.draw(data, {focusTarget: 'category',  tooltip.isHtml: true, showTip: true}); \n } \n";
      //echo " chart.draw(data, { tooltip: {isHtml: true}, showTip: true }); \n } \n";
      $GEToptions = "";
      if (isset($_GET['options'])) $GEToptions = urldecode($_GET['options']);
      if (isset($_POST['options'])) $GEToptions = urldecode($_POST['options']);
      echo " chart.draw(data, { useMapTypeControl:true, tooltip: {isHtml: true}" . $GEToptions . ", showTip: true  }); \n"; // } \n";
  $cssis="";
      if ($GETr != "" && $GETc == "") $cssis=" if (1 == 2) { chart.setSelection([{'row': " . $GETr . "}]); } setTimeout(selectHandler,4100); \n";
      if ($GETr == "" && $GETc != "") $cssis=" if (1 == 2) { chart.setSelection([{'column': " . $GETc . "}]); }  setTimeout(selectHandler,4100); \n";
      if ($GETr != "" && $GETc != "") $cssis=" if (1 == 2) { chart.setSelection([{'row': " . $GETr . ", 'column': " . $GETc . "}]); }  setTimeout(selectHandler,4100); \n";

echo "
 if (selonclick != '') { " . $cssis . "
  google.visualization.events.addListener(chart, 'select', selectHandler);
 }
}
function selectHandler() {
  var relist=['remail',''],ire,andthen='', str, oplace='', numthing='4', ansbits,avblurb=talkingpoint,ans='';
  var selection = chart.getSelection();
  var jj=eval(selection.length);
  if (jj == 0 && (eval(ir) >= 0 || eval(ic) >= 0)) jj=1;
  var clong, message = '', olat='-190.0', olong='-190.0', latlongs, delim='',ij;
  for (var i = 0; i < jj; i++) {
    var item = selection[i];
    if ((eval(ir) >= 0 && eval(ic) < 0)) {
      str = data.getFormattedValue(ir, 0);
      latlongs=document.head.innerHTML.replace(/, \[/g,',[').split(',['); // + str + ',');
      olat=eval(str);
      if (1 == 1) {
        clong=latlongs[eval(1 + ir)].replace(str + ',', '').replace(']',',').split(',');
        olong=eval(clong[0]);
        oplace=clong[1].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'');
      } else if (eval(eval(latlongs.length) - eval(ir)) == 2) {
        clong=latlongs[eval(1 + ir)].replace(']',',').split(',');
        olong=eval(clong[0]);
        oplace=clong[1].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'');
      } else if (eval(eval(latlongs.length) - eval(ir)) > 2) {
        olong='';
        oplace='()';
        for (ij=1; ij<latlongs.length; ij++) {
         clong=latlongs[ij].replace(']',',').split(',');
         olong+=(delim + eval(clong[0]));
         oplace=oplace.replace(')',(delim + (clong[1].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'')) + ')'));
         if (delim == '' && selonclick.length > 0 && eval(olong) >= -180.0 && eval(olong) <= 180.0 && eval(olat) >= -90.0 && eval(olat) <= 90.0) {
          andthen=' ';
         } else if (delim == '') {
          oplace='';
         }
         delim=',';
        }
        if (andthen == ' ') {
         andthen='';
         clong=olong.split(',');
         andthen=prompt('Is there something you want to try with Latitude ' + olat + ' and one of Longitudes ' + ('(' + olong + ')').replace('(','([').replace(',','],') + '' + oplace.replace('(','([').replace(',','],') + ' ? ' + String.fromCharCode(10) + '' + String.fromCharCode(10) + avblurb + '' + 'Google Map=G (optional, plus zoom factor[10])' + String.fromCharCode(10) + '' + 'Sun Angle at Noon=S' + String.fromCharCode(10) + 'Moon Angle at Noon=M' + String.fromCharCode(10) + 'Coriolis Force=C' + String.fromCharCode(10) + '' + 'Nearest Airports=A (optional, plus number of nearest airports[4])' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Comma Separated Values Spreadsheet Export=filename.csv' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Email with or without Talking Point=fillin.email@address This is when the improvement started.  Robert' + String.fromCharCode(10) + '' + String.fromCharCode(10) + '' + '... and please suffix answer by comma and preferred Longitude to use, else leave as blank or as is or choose Cancel to leave the status quo.', paramdata);
         if (andthen == null) andthen='';
         if (andthen.indexOf(',') == -1 && andthen != '') {
           olong=eval(clong[0]);
         } else if (andthen != '') {
           clong=andthen.split(',');
           olong=eval(clong[1]);
           andthen=clong[0];
         }
        }
      }
    } else if ((item.row != null && item.column != null) || (eval(ir) >= 0 && eval(ic) >= 0)) {
      if (eval(ir) >= 0 && eval(ic) >= 0) {
  //alert(999);
        item.row=ir;
        item.column=ic;
  //alert(9999);
        ir=-1;
        ic=-1;
      } else {
        ir=item.row;
        ic=item.column;
        //document.title=ir + ',' + ic;
      }
      str = data.getFormattedValue(item.row, item.column);
      clong = str.replace('[','').replace(']','').replace('{','').replace('}','').split(',');
      olat=eval(clong[0]);
      olong=eval(clong[1]);
    } else if ((item.row != null) || (eval(ir) >= 0 && eval(ic) < 0)) {
      if (eval(ir) >= 0 && eval(ic) < 0) {
  //alert(999);
        item.row=ir;
        //item.column=ic;
  //alert(9999);
        ir=-1;
        //ic=-1;
      } else {
        ir=item.row;
        //ic=item.column;
        //document.title=ir + ',' + ic;
      }
      str = data.getFormattedValue(item.row, 0);
      latlongs=document.head.innerHTML.replace(/, \[/g,',[').split(',['); // + str + ',');
      olat=eval(str);
      if (1 == 1) {
        clong=latlongs[eval(1 + item.row)].replace(str + ',', '').replace(']',',').split(',');
        olong=eval(clong[0]);
        oplace=clong[1].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'');
      } else if (eval(eval(latlongs.length) - eval(item.row)) == 2) {
        clong=latlongs[eval(1 + item.row)].replace(']',',').split(',');
        olong=eval(clong[0]);
        oplace=clong[1].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'');
      } else if (eval(eval(latlongs.length) - eval(item.row)) > 2) {
        olong='';
        oplace='()';
        for (ij=1; ij<latlongs.length; ij++) {
         clong=latlongs[ij].replace(']',',').split(',');
         olong+=(delim + eval(clong[0]));
         oplace=oplace.replace(')',(delim + (clong[1].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'')) + ')'));
         if (delim == '' && selonclick.length > 0 && eval(olong) >= -180.0 && eval(olong) <= 180.0 && eval(olat) >= -90.0 && eval(olat) <= 90.0) {
          andthen=' ';
         } else if (delim == '') {
          oplace='';
         }
         delim=',';
        }
        if (andthen == ' ') {
         andthen='';
         clong=olong.split(',');
         andthen=prompt('Is there something you want to try with Latitude ' + olat + ' and one of Longitudes ' + ('(' + olong + ')').replace('(','([').replace(',','],') + '' + oplace.replace('(','([').replace(',','],') + ' ? ' + String.fromCharCode(10) + '' + String.fromCharCode(10) + avblurb + '' + 'Google Map=G (optional, plus zoom factor[10])' + String.fromCharCode(10) + '' + 'Sun Angle at Noon=S' + String.fromCharCode(10) + 'Moon Angle at Noon=M' + String.fromCharCode(10) + 'Coriolis Force=C' + String.fromCharCode(10) + '' + 'Nearest Airports=A (optional, plus number of nearest airports[4])' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Comma Separated Values Spreadsheet Export=filename.csv' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Email with or without Talking Point=fillin.email@address This is when the improvement started.  Robert' + String.fromCharCode(10) + '' + String.fromCharCode(10) + '' + '... and please suffix answer by comma and preferred Longitude to use, else leave as blank or as is or choose Cancel to leave the status quo.', paramdata);
         if (andthen == null) andthen='';
         if (andthen.indexOf(',') == -1 && andthen != '') {
           olong=eval(clong[0]);
         } else if (andthen != '') {
           clong=andthen.split(',');
           olong=eval(clong[1]);
           andthen=clong[0];
         }
        }
      }
    } else if ((item.column != null) || (eval(ir) < 0 && eval(ic) >= 0)) {
      if (eval(ir) >= 0 && eval(ic) < 0) {
  //alert(999);
        //item.row=ir;
        item.column=ic;
  //alert(9999);
        //ir=-1;
        ic=-1;
      } else {
        //ir=item.row;
        ic=item.column;
        //document.title=ir + ',' + ic;
      }
      str = data.getFormattedValue(0, item.column);
      latlongs=document.head.innerHTML.split(',' + str + ',');
      olong=eval(str);
      if (eval(latlongs.length) == 2) {
        clong=latlongs[0].split('[');
        olat=eval(clong[eval(-1 + clong.length)]);
        clong=latlongs[1].split(']');
        oplace=clong[0].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'');
      } else if (eval(latlongs.length) > 2) {
        olat='';
        oplace='()';
        for (ij=1; ij<latlongs.length; ij++) {
         clong=latlongs[ij].replace(']',',').split(',');
         oplace=oplace.replace(')',(delim + (clong[0].replace(String.fromCharCode(39),'').replace(String.fromCharCode(39),'')) + ')'));
         clong=latlongs[eval(-1 + ij)].replace(']',',').split('[');
         olat+=(delim + eval(clong[eval(-1 + clong.length)]));
         if (delim == '' && selonclick.length > 0 && eval(olong) >= -180.0 && eval(olong) <= 180.0 && eval(olat) >= -90.0 && eval(olat) <= 90.0) {
          andthen=' ';
         } else if (delim == '') {
          oplace='';
         }
         delim=',';
        }
        if (andthen == ' ') {
         andthen='';
         clong=olat.split(',');
         andthen=prompt('Is there something you want to try with one of Latitudes ' + ('(' + olat + ')').replace('(','([').replace(',','],') + ' and Longitude ' + olong + ' ' + oplace.replace('(','([').replace(',','],') + ' ? ' + String.fromCharCode(10) + '' + String.fromCharCode(10) + avblurb + '' + 'Google Map=G (optional, plus zoom factor[10])' + String.fromCharCode(10) + '' + 'Sun Angle at Noon=S' + String.fromCharCode(10) + 'Moon Angle at Noon=M' + String.fromCharCode(10) + 'Coriolis Force=C' + String.fromCharCode(10) + '' + 'Nearest Airports=A (optional, plus number of nearest airports[4])' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Comma Separated Values Spreadsheet Export=filename.csv' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Email with or without Talking Point=fillin.email@address This is when the improvement started.  Robert' + String.fromCharCode(10) + '' + String.fromCharCode(10) + '' + '... and please suffix answer by comma and preferred Latitude to use, else leave as blank or as is or choose Cancel to leave the status quo.', paramdata);
         if (andthen == null) andthen='';
         if (andthen.indexOf(',') == -1 && andthen != '') {
           olat=eval(clong[0]);
         } else if (andthen != '') {
           clong=andthen.split(',');
           olat=eval(clong[1]);
           andthen=clong[0];
         }
        }
      }
    }
  }
  if (selonclick.length > 0 && eval(olong) >= -180.0 && eval(olong) <= 180.0 && eval(olat) >= -90.0 && eval(olat) <= 90.0) {
    if (andthen == '') andthen=prompt('Is there something you want to try with Latitude ' + olat + ' and Longitude ' + olong + ' ' + oplace + ' ? ' + String.fromCharCode(10) + '' + String.fromCharCode(10) + avblurb + '' + 'Google Map=G (optional, plus zoom factor[10])' + String.fromCharCode(10) + '' + 'Sun Angle at Noon=S' + String.fromCharCode(10) + 'Moon Angle at Noon=M' + String.fromCharCode(10) + 'Coriolis Force=C' + String.fromCharCode(10) + '' + 'Nearest Airports=A (optional, plus number of nearest airports[4])' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Comma Separated Values Spreadsheet Export=filename.csv' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Email with or without Talking Point=fillin.email@address This is when the improvement started.  Robert' + String.fromCharCode(10) + '' + String.fromCharCode(10) + '' + '...  else leave as blank or as is or choose Cancel to leave the status quo.', paramdata);
    if (andthen == null) andthen='';
  }
  
  if (andthen.length > 0) {
    if ((andthen.toLowerCase() + '~').indexOf('.csv~') != -1 && andthen.toLowerCase().indexOf('&') == -1) andthen=paramdata + '&csv=' + andthen;
    ans=andthen;
    ansbits=ans.split(' ');
    
                  if (document.getElementById('altemail')) {
              document.getElementById('altemail').value=ansbits[0];
              document.getElementById('remail').href=document.getElementById('remail').href.replace('mt=','mt=' + ansbits[0] + '&junk=youshallneverfindthis').replace('get=','mt=' + ansbits[0] + '&junk=youshallneverfindthis');
              }
              if (document.getElementById('email')) relist[1]='email';

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

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


        echo ' var title = prompt("Enter Map Title (suffix by &onclick=y for added onclick functionality)", "' . $GETtitle . '"); ' . "\n";
        echo ' if (title != null) { ' . "\n";
        echo ' var label = "' . $GETlabel . '"; ' . "\n";
        echo ' if (label == null) label = ""; ' . "\n";
        echo ' var xlabel = "' . "'" . '" + label.replace("' . "'" . '","") + "' . "'" . '"; ' . "\n";
        //echo ' var value = prompt("Enter Map " + xlabel + " Criteria (separated by ,) ...  decimal latitude and longitude ", "' . $GETvalue . '"); ' . "\n";
        echo ' var value = "' . $GETvalue . '"; ' . "\n";


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


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


        echo ' while (datalineprefix.length != 0 && (value.indexOf("ercent") == (0 - 1) || value.indexOf("  ercent ") != (0 - 1) || (value.indexOf("ercent") != (0 - 1) && totalleft > 0))) { ' . "\n";
        echo ' datalineprefix = "' . "''" . '";' . "\n";
        echo ' if (datalinesuffix.length != 0 && label.length != 0) { datalineprefix = prompt("Enter ' . " " . $GETtitle . ' Name' . " " . ' " + thisline + " (for no more hit Cancel button)", ""); if (datalineprefix != null) { dlp2=datalineprefix; } } ' . "\n";
        echo ' if (datalineprefix == null) { ' . "\n";
        echo '     datalineprefix = ""; ' . "\n";
        echo '     totalleft = 0; ' . "\n";
        echo ' } else if (datalineprefix.length != 0) { ' . "\n";
        echo '     extra = "";  ' . "\n";
        echo '     if (value.indexOf("ercent") != (0 - 1) && value.indexOf("  ercent ") == (0 - 1)) extra = " (for " + totalleft + " enter nothing or hit Cancel button)";  ' . "\n";
        echo "     datalinesuffix = prompt('Enter decimal Latitude,Longitude ' + thisline + extra +  ' (for no more hit Cancel button and append with ' + '\\n\\n' + ',\"A tooltip and clicking link for Google Map of <a target=_blank href=' + \"'\" + 'https://www.google.com.au/maps/place/' + encodeURIComponent(dlp2) + \"'\" + '>' + dlp2 + '</a>\" ' + '\\n\\n' + ' or maybe perhaps ' + '\\n\\n' + ',\"A tooltip and clicking link for Google Map based on latitude and longitude of <a target=_blank href=' + \"'\" + 'https://maps.google.com.au/maps?' + encodeURIComponent('z=15&t=m&q=loc:') + '{latitude}{longitude}' + \"'\" + '>' + dlp2 + '</a>\"' + '\\n\\n' + ' optionally (as (just) two examples of what is possible with HTML included (activates with onclick bit not onmouseover))', thisdef); " . "\n";
        echo '     if (datalinesuffix != null) { datalinesuffix=datalinesuffix.replace(/#/g, "%23");  if (datalinesuffix.indexOf("{latitude}") != -1) { dlsa=datalinesuffix.split(","); if (dlsa[0].indexOf(".") == -1) { dlsa[0]=dlsa[0]+".0";  } if (dlsa[0].indexOf("-") == -1) { datalinesuffix=datalinesuffix.replace("{latitude}",encodeURIComponent("" + dlsa[0]));  } else { datalinesuffix=datalinesuffix.replace("{latitude}",encodeURIComponent(dlsa[0]));  }  } if (datalinesuffix.indexOf("{longitude}") != -1) { dlsa=datalinesuffix.split(","); if (dlsa.length > 1) {  if (dlsa[0].indexOf(".") == -1) { dlsa[0]=dlsa[0]+".0";  }  if (dlsa[1].indexOf(".") == -1) { dlsa[1]=dlsa[1]+".0";  } if (dlsa[1].indexOf("-") == -1) { datalinesuffix=datalinesuffix.replace("{longitude}",encodeURIComponent("+" + dlsa[1]));  } else { datalinesuffix=datalinesuffix.replace("{longitude}","+" + encodeURIComponent(dlsa[1])); }  }  }  datalinesuffix=("@!@" + datalinesuffix).replace(/loc:+/g, "loc:").replace(/,0,/g, ",0.00000001,").replace(/@!@0,/g, "0.00000001,").replace(/@!@/g, "");    } ' . "\n";
        echo '     if (datalinesuffix == null && value.indexOf("ercent") != (0 - 1) && value.indexOf("  ercent ") == (0 - 1)) datalinesuffix = totalleft; ' . "\n";
        echo '     if (datalinesuffix == null) break; ' . "\n";
        echo '     if (datalinesuffix == null) datalinesuffix = "0,0"; ' . "\n";
        echo '     if (datalinesuffix.length == 0) { ' . "\n";
        echo '       datalinesuffix = eval(totalleft); ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(totalleft) == eval(datalinesuffix) && value.indexOf("ercent") != (0 - 1) && value.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(datalinesuffix) > eval(totalleft) && value.indexOf("ercent") != (0 - 1) && value.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       datalinesuffix = eval(totalleft); ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(datalinesuffix) > eval(totalleft) && value.indexOf("ercent") == (0 - 1) && value.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       value = value + "  ercent "; ' . "\n";
        echo '     } else { ' . "\n";
        echo '       totalleft = eval(totalleft) - eval(datalinesuffix); ' . "\n";
        echo '     } ' . "\n";
        echo '     if (datalineprefix2 != "") datalineprefix = datalineprefix2; ' . "\n";
        echo '     if (datalinesuffix.indexOf("' . "'" . '") == -1) datac = datac + ", [" + datalinesuffix + ",~" + datalineprefix + "~] "; ' . "\n";
        echo '     if (datalinesuffix.indexOf("' . "'" . '") != -1) datac = datac + ", [" + datalinesuffix + ",' . "'" . '" + datalineprefix + "~] "; ' . "\n";
        echo '     dataprefix2 = ""; ' . "\n";
        echo '     thisline++; ' . "\n";
        echo '   } ' . "\n";
        echo ' } ' . "\n";
        echo ' window.location = "./map.php?title=" + title + "&label=" + label + "&value=" + value.replace("  ercent ", "") + "&data=" + datac; ' . "\n";
        echo "} \n"; 
      } 
      echo "} \n" . '</' . 'script' . '>' . "\n";
    ?>
  <a title='menu' href='http://www.rjmprogramming.com.au/PHP/butsel.php?justmenu=justmenu'>Menu</a>
  <div id='cdiv'></div></body>
</html>
