<?php
  // line_chart.php
  // Google Line Chart supervisor
  // RJM Programming
  // January, 2016
  // 
  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";
  }
  
  
    // Command line Korn Shell interfacing code
    if (!isset($_GET['data']) && !isset($_POST['data'])) {
    if (strpos(strtolower(('' . $_SERVER['QUERY_STRING'])), 'listis=') !== false) {
    $urlbase="https://www.rjmprogramming.com.au/PHP/LineChart/line_chart.php";
    $proposedform="<html><body onload=\"document.getElementById('clickme').click();\"><form id=myf style=display:none; target=_self action='" . $urlbase . "' method=POST><input type=hidden name=onclick value=y></input><input type=hidden name=wouldlikeyoutoseekpermission value=y></input><input id=clickme type=submit value=Submit></input></form></body></html>";
    $datavalis=explode("=", ('' . $_SERVER['QUERY_STRING']))[1];
    $bitsbetween=["?title=", "&onclick=y&label=", "&value=", "&data="];
    $bitsap=explode("__", explode("=", explode("?", ('?' . $_SERVER['QUERY_STRING']))[1])[0]);
    for ($iuy=0; $iuy<sizeof($bitsap); $iuy++) {
      if (strtolower(str_replace("_", "%20", $bitsap[$iuy])) == "listis") {
      $proposedform=str_replace(" method=POST>", " method=POST><input type=hidden name='" . explode("=", explode("&", substr($bitsbetween[$iuy],1))[-1 + sizeof(explode("&", substr($bitsbetween[$iuy],1)))])[0] . "' value='" . str_replace("+"," ",urldecode($datavalis)) . "'></input>", $proposedform);
      $urlbase.=$bitsbetween[$iuy] . '' .  str_replace(" ", "%20", str_replace("+"," ",urldecode($datavalis)));
      } else {
      $proposedform=str_replace(" method=POST>", " method=POST><input type=hidden name='" . explode("=", explode("&", substr($bitsbetween[$iuy],1))[-1 + sizeof(explode("&", substr($bitsbetween[$iuy],1)))])[0] . "' value='" . str_replace("%2C", ",", str_replace("_", " ", $bitsap[$iuy])) . "'></input>", $proposedform);
      $urlbase.=$bitsbetween[$iuy] . '' . str_replace("%2C", ",", str_replace("_", "%20", urlencode($bitsap[$iuy])));
      }
    }
    
    if (strlen($urlbase) > 800) {
    echo $proposedform;
    } else {
    header('Location: ' . $urlbase);   
    }
    exit; 
    }
    }


      $GETextraopts = "";
      if (isset($_GET['extraopts'])) { $GETextraopts = str_replace("+"," ",urldecode($_GET['extraopts'])); }
      if (isset($_POST['extraopts'])) { $GETextraopts = str_replace("+"," ",urldecode($_POST['extraopts'])); }

$https = "http://";
$portbit = ":" . $_SERVER['SERVER_PORT'];
if(isset($_SERVER['HTTPS'])) {
    if ($_SERVER['HTTPS'] == "on") {
        $https = "https://";
        $portbit = "";
    }
} else if ($portbit == ":80") {
        $portbit = "";
}
  
$superimposition="";
$overlay="";
$bdivstart="";
$bdivend="";
$cdivc="background-color: yellow;";
$nondefs="";
$op="0.5";
$tpy="0";
$lfx="0";

$types = ["audio/wav","audio/x-wav","audio/x-pn-realaudio","audio/x-mpegurl","audio/x-aiff","audio/x-aifc","audio/mpeg","audio/mid",
      "audio/basic","audio/ogg","video/x-sgi-movie","video/x-msvideo","video/quicktime","audio/mp3","video/mp4","video/mpeg",
      "video/x-la-asf","video/ogg","video/webm","audio/mp4", "image/jpeg", "image/jpeg", "image/png", "image/gif", "image/bmp", "image/tif",
      "text/html", "text/html", "text/html", "text/javascript", "text/css", "text/plain", "text/xml", "text/csv",
      "application/vnd.ms-word", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/x-php", "application/pdf",
      "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.ms-powerpoint",
      "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];
$exts = [".wav",".wav",".ram",".m3u",".aiff",".aifc",".mp3",".rmi",
      ".snd",".ogg",".movie",".avi",".mov",".mp3",".m4v",".mpeg",
      ".lsx",".ogv",".webm",".m4a", ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tif",
      ".htm", ".html", ".htmls", ".js", ".css", ".txt", ".xml", ".csv",
      ".doc", ".docx", ".php", ".pdf",
      ".pptx", ".ppt",
      ".xls", ".xlsx"];
  
$amwv=false;
if ((strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile/') !== false) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari/') == false)) {
  $amwv=true;
}

  function retval($inv) {
    if (strpos($inv, "E-") !== false) return "0";
    return $inv;
  }
?>
<!doctype html><html>
  <head><style> body,h1 { margin: 0px 0px 0px 0px; } </style> <script type="text/javascript" src="//www.rjmprogramming.com.au/gchartgen.js?x=d"></script>
    <title>Line Chart - RJM Programming - //www.rjmprogramming.com.au (Copyright &copy; 2013 rjmprogramming.com.au all rights reserved.)</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=0.5, maximum-scale=4, user-scalable=yes" />
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
   
    
<?php
    echo "     if (window.top) { if (parent.document.getElementById('lhashis')) { if (decodeURIComponent(('' + parent.document.getElementById('lhashis').value)).indexOf(',') != -1) { location.hash=parent.document.getElementById('lhashis').value; } } } \n   var documentURL='' , locationhref='', returl='', dccnt=0, topmou='', etodi='emailee', etodicc='EmailCC', etodibcc='EmailBCC', etodisubject='EmailSubject';
    if (document.URL.indexOf('file:') != 0) {
    documentURL=document.URL;
    documentURL=documentURL.split('#')[0];
    }
    ";
    
    
      $appval=$_SERVER['QUERY_STRING'];
      if ($appval != '' && strpos($appval, '?') === false) {
        $appval='?' . $_SERVER['QUERY_STRING'];
      }
      if (isset($_POST['data'])) {
        $appval="";
        $appvald="?";
        if (strlen($_SERVER['QUERY_STRING']) > 1) $appvald="&";
        foreach ($_POST as $name => $val) {
          if ($name != "wouldlikeyouto" . "seekpermission") {
            $appval.=$appvald . htmlspecialchars($name) . "=" . str_replace("+","%20",urlencode(htmlspecialchars($val)));
            $appvald="&";
          }
        }
        echo "\n documentURL=document.URL.split('#')[0] + \"" . str_replace("\n", " ", $appval) . "\";   \n";
      }

if (isset($_GET['overlay'])) {
  $op="0.5";
  $tpy="0";
  if (isset($_GET['top'])) {
    $tpy=str_replace("px"," ",str_replace("+"," ",strtolower(urldecode($_GET['top']))));
    if (substr(($tpy . " "),0,1) >= "1" && substr(($tpy . " "),0,1) <= "9") {
    if ($tpy >= 240) {
    $op="1.0";
    }
    }
  }
  $lfx="0";
  if (isset($_GET['left'])) {
    $lfx=str_replace("px"," ",str_replace("+"," ",strtolower(urldecode($_GET['left']))));
    if (substr(($lfx . " "),0,1) >= "1" && substr(($lfx . " "),0,1) <= "9") {
    if ($lfx >= 500) {
    $op="1.0";
    }
    }
  }
  if (isset($_GET['opacity'])) {
    $op=str_replace("+"," ",urldecode($_GET['overlay']));
  }
  if (substr(strtolower($_GET['overlay'] . " "),0,1) == 'b') {
    if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_GET['overlay'])) . " "),1), ",") !== false) {
    $superimposition=' locationhref="' . $https . 'www.rjmprogramming.com.au/PHP/BarChart/bar_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_GET['overlay'])))[0],'',str_replace('+',' ',urldecode($_GET['overlay'])))) . '"; documentURL=locationhref.replace("overlay=","overXlay=").replace("top=","toXp=").replace("left=","leXft="); returl=documentURL;  locationhref=documentURL;   ';
    $superimposition.=' document.getElementById("aobar").click();  document.getElementById("aobar").click(); ';
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/BarChart/bar_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_GET['overlay'])))[0],'',str_replace('+',' ',urldecode($_GET['overlay']))))  . '"></iframe>';
    } else {
    $superimposition='  document.getElementById("aobar").click();  document.getElementById("aobar").click(); ';
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/BarChart/bar_chart.php' . $appval . '"></iframe>';
    }
    $cdivc.='opacity:' . $op . ';';
  } else if (substr(strtolower($_GET['overlay'] . " "),0,1) == 'c') {
    if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_GET['overlay'])) . " "),1), ",") !== false) {
    $superimposition=' locationhref="' . $https . 'www.rjmprogramming.com.au/PHP/ColumnChart/column_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_GET['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_GET['overlay'])))) . '"; documentURL=locationhref.replace("overlay=","overXlay=").replace("top=","toXp=").replace("left=","leXft="); returl=documentURL;  locationhref=documentURL;    ';
    $superimposition.=' document.getElementById("aocolumn").click();  document.getElementById("aocolumn").click();  ';
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/ColumnChart/column_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_GET['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_GET['overlay']))))  . '"></iframe>';
    } else {
    $superimposition='  document.getElementById("aocolumn").click();  document.getElementById("aocolumn").click();  ';
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/ColumnChart/column_chart.php' . $appval . '"></iframe>';
    }
    $cdivc.='opacity:' . $op . ';';
  } else if (substr(strtolower($_GET['overlay'] . " "),0,1) == 'l') {
    if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_GET['overlay'])) . " "),1), ",") !== false) {
    $superimposition=' locationhref="' . $https . 'www.rjmprogramming.com.au/PHP/LineChart/line_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_GET['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_GET['overlay'])))) . '"; documentURL=locationhref.replace("overlay=","overXlay=").replace("top=","toXp=").replace("left=","leXft="); returl=documentURL;  locationhref=documentURL;   ';
    $superimposition.=' goother(null);  goother(null); ';
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/LineChart/line_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_GET['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_GET['overlay']))))  . '"></iframe>';
    } else {
    $superimposition=' goother(null);  goother(null); ';
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/LineChart/line_chart.php' . $appval . '"></iframe>';
    }
    $cdivc.='opacity:' . $op . ';';
  } else if (substr(strtolower($_GET['overlay'] . " "),0,1) == 'a') {
    if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_GET['overlay'])) . " "),1), ",") !== false) {
    $superimposition=' locationhref="' . $https . 'www.rjmprogramming.com.au/PHP/AreaChart/area_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_GET['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_GET['overlay'])))) . '"; documentURL=locationhref.replace("overlay=","overXlay=").replace("top=","toXp=").replace("left=","leXft="); returl=documentURL;  locationhref=documentURL;   ';
    $superimposition.=' document.getElementById("aoarea").click();  document.getElementById("aoarea").click(); ';
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/AreaChart/area_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_GET['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_GET['overlay']))))  . '"></iframe>';
    } else {
    $superimposition=' document.getElementById("aoarea").click();  document.getElementById("aoarea").click(); ';
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/AreaChart/area_chart.php' . $appval . '"></iframe>';
    }
    $cdivc.='opacity:' . $op . ';';
  } else if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_GET['overlay'])) . " "),0), ",") !== false) {
    $superimposition=' locationhref="' . $https . 'www.rjmprogramming.com.au/PHP/LineChart/line_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_GET['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_GET['overlay'])))) . '"; documentURL=locationhref.replace("overlay=","overXlay=").replace("top=","toXp=").replace("left=","leXft="); returl=documentURL;  locationhref=documentURL;   ';
    $superimposition.=' goother(null);  goother(null); ';
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/LineChart/line_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_GET['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_GET['overlay']))))  . '"></iframe>';
    $cdivc.='opacity:' . $op . ';';
  }
} else if (isset($_POST['overlay'])) {  
  $op="0.5";
  $tpy="0";
  if (isset($_POST['top'])) {
    $tpy=str_replace("px"," ",str_replace("+"," ",strtolower(urldecode($_POST['top']))));
    if (substr(($tpy . " "),0,1) >= "1" && substr(($tpy . " "),0,1) <= "9") {
    if ($tpy >= 240) {
    $op="1.0";
    }
    }
  }
  $lfx="0";
  if (isset($_POST['left'])) {
    $lfx=str_replace("px"," ",str_replace("+"," ",strtolower(urldecode($_POST['left']))));
    if (substr(($lfx . " "),0,1) >= "1" && substr(($lfx . " "),0,1) <= "9") {
    if ($lfx >= 500) {
    $op="1.0";
    }
    }
  }
  if (isset($_POST['opacity'])) {
    $op=str_replace("+"," ",urldecode($_POST['overlay']));
  }
  if (substr(strtolower($_POST['overlay'] . " "),0,1) == 'b') {
    $superimposition=' locationhref="' . $https . 'www.rjmprogramming.com.au/PHP/BarChart/bar_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_POST['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_POST['overlay'])))) . '"; documentURL=locationhref.replace("overlay=","overXlay=").replace("top=","toXp=").replace("left=","leXft="); returl=documentURL;  locationhref=documentURL;   ';
    $superimposition.=' document.getElementById("aobar").click();  document.getElementById("aobar").click(); ';
    if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_POST['overlay'])) . " "),1), ",") !== false) {
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/BarChart/bar_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_POST['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_POST['overlay']))))  . '"></iframe>';
    } else {
    $superimposition=' document.getElementById("aobar").click();  document.getElementById("aobar").click(); ';
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/BarChart/bar_chart.php' . $appval . '"></iframe>';
    }
    $cdivc.='opacity:' . $op . ';';
  } else if (substr(strtolower($_POST['overlay'] . " "),0,1) == 'c') {
    $superimposition=' locationhref="' . $https . 'www.rjmprogramming.com.au/PHP/ColumnChart/column_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_POST['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_POST['overlay'])))) . '"; documentURL=locationhref.replace("overlay=","overXlay=").replace("top=","toXp=").replace("left=","leXft="); returl=documentURL;  locationhref=documentURL;   ';
    $superimposition.=' document.getElementById("aocolumn").click();  document.getElementById("aocolumn").click();  ';
    if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_POST['overlay'])) . " "),1), ",") !== false) {
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/ColumnChart/column_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_POST['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_POST['overlay']))))  . '"></iframe>';
    } else {
    $superimposition=' document.getElementById("aocolumn").click();  document.getElementById("aocolumn").click();  ';
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/ColumnChart/column_chart.php' . $appval . '"></iframe>';
    }
    $cdivc.='opacity:' . $op . ';';
  } else if (substr(strtolower($_POST['overlay'] . " "),0,1) == 'l') {
    $superimposition=' locationhref="' . $https . 'www.rjmprogramming.com.au/PHP/LineChart/line_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_POST['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_POST['overlay'])))) . '"; documentURL=locationhref.replace("overlay=","overXlay=").replace("top=","toXp=").replace("left=","leXft="); returl=documentURL;  locationhref=documentURL;   ';
    $superimposition.=' document.getElementById("aoline").click();  document.getElementById("aoline").click(); ';
    if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_POST['overlay'])) . " "),1), ",") !== false) {
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/LineChart/line_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_POST['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_POST['overlay']))))  . '"></iframe>';
    } else {
    $superimposition=' document.getElementById("aoline").click();  document.getElementById("aoline").click(); ';
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/LineChart/line_chart.php' . $appval . '"></iframe>';
    }
    $cdivc.='opacity:' . $op . ';';
  } else if (substr(strtolower($_POST['overlay'] . " "),0,1) == 'a') {
    $superimposition=' locationhref="' . $https . 'www.rjmprogramming.com.au/PHP/AreaChart/area_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_POST['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_POST['overlay'])))) . '"; documentURL=locationhref.replace("overlay=","overXlay=").replace("top=","toXp=").replace("left=","leXft="); returl=documentURL;  locationhref=documentURL;   ';
    $superimposition.=' goother(null);  goother(null); ';
    if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_POST['overlay'])) . " "),1), ",") !== false) {
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/AreaChart/area_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_POST['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_POST['overlay']))))  . '"></iframe>';
    } else {
    $superimposition=' goother(null);  goother(null); ';
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/AreaChart/area_chart.php' . $appval . '"></iframe>';
    }
    $cdivc.='opacity:' . $op . ';';
  } else if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_POST['overlay'])) . " "),0), ",") !== false) {
    $superimposition=' locationhref="' . $https . 'www.rjmprogramming.com.au/PHP/LineChart/line_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_POST['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_POST['overlay'])))) . '"; documentURL=locationhref.replace("overlay=","overXlay=").replace("top=","toXp=").replace("left=","leXft="); returl=documentURL;  locationhref=documentURL;   ';
    $superimposition.=' goother(null);  goother(null); ';
    $overlay='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:0.5;z-index:9;position:absolute;top:' . $tpy . 'px;left:' . $lfx . 'px;" src="' . $https . 'www.rjmprogramming.com.au/PHP/LineChart/line_chart.php' . explode("data=",$appval)[0] . 'data=' . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_POST['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_POST['overlay']))))  . '"></iframe>';
    $cdivc.='opacity:' . $op . ';';
  }
}
      
      if (isset($_POST['emailto'])) {
        echo "\n etodi='" . urldecode($_POST['emailto']) . "'; \n";
        if (isset($_POST['emailcc'])) echo "\n etodicc='" . urldecode($_POST['emailcc']) . "'; \n";
        if (isset($_POST['emailbcc'])) echo "\n etodibcc='" . urldecode($_POST['emailbcc']) . "'; \n";
        if (isset($_POST['emailsubject'])) echo "\n etodisubject='" . urldecode($_POST['emailsubject']) . "'; \n";
      } else if (isset($_GET['emailto'])) {
        echo "\n etodi='" . urldecode($_GET['emailto']) . "'; \n";
        if (isset($_GET['emailcc'])) echo "\n etodicc='" . urldecode($_GET['emailcc']) . "'; \n";
        if (isset($_GET['emailbcc'])) echo "\n etodibcc='" . urldecode($_GET['emailbcc']) . "'; \n";
        if (isset($_GET['emailsubject'])) echo "\n etodisubject='" . urldecode($_GET['emailsubject']) . "'; \n";
      }

?>
      
    function delayurl() {
     if (dccnt < 2) {
      dccnt=0;
      topmou='';
      locationhref=toolongcheck(returl);
      if ((locationhref + ' ').substring(0,1) != '#') { location.href=locationhref;  } 
     }
    }
    
    function prepareiframe(formidis) {
     var rect;
     if (document.getElementById('thedivoverlay') && topmou != '') {
      if (document.getElementById('thedivoverlay').innerHTML == '' || !document.getElementById('thedivoverlayi')) {
        if (formidis != '') {
         rect = document.body.getBoundingClientRect();
         document.getElementById('thedivoverlay').innerHTML='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:<?php echo $op; ?>;z-index:9;position:absolute;top:<?php echo $tpy; ?>px;left:<?php echo $lfx; ?>px;width:' + eval(rect.right - rect.left) + 'px;height:' + eval(rect.bottom - rect.top) + 'px;" src="' + 'about:blank' + '"></iframe>';
         document.getElementById(formidis).target='thedivoverlayi';
        } else {
         rect = document.body.getBoundingClientRect();
         document.getElementById('thedivoverlay').innerHTML='<iframe id=thedivoverlayi name=thedivoverlayi style="opacity:<?php echo $op; ?>;z-index:9;position:absolute;top:<?php echo $tpy; ?>px;left:<?php echo $lfx; ?>px;width:' + eval(rect.right - rect.left) + 'px;height:' + eval(rect.bottom - rect.top) + 'px;" src="' + locationhref + '"></iframe>';
        }
      } else if (document.getElementById('thedivoverlayi') && formidis != '') {
        document.getElementById(formidis).target='thedivoverlayi';
      } else if (document.getElementById('thedivoverlayi') && formidis == '') {
        document.getElementById('thedivoverlayi').src=locationhref;
      }
     }
    }
    
    function yesoverlay(ovwhaturl) {
     if (document.getElementById('thedivoverlay') && topmou != '') {
       locationhref=ovwhaturl;
       document.getElementById('chart_div').style.opacity='0.5';
       prepareiframe('');
       setTimeout(resetov, 2500);
     } else {
       location.href=ovwhaturl;
     }
    }
    
    function resetov() {
       dccnt=0;
       topmou='';
    }

    function goother(aothis) {
      var fromone='/LineChart';
      var fromtwo='line_chart.php';
      var returl=documentURL.split('#')[0];
      if (!aothis) {
       if (dccnt != 0) topmou='LineChart/line_chart.php';
<?php
       if (isset($_GET['overlay'])) {
       if (substr(strtolower(str_replace('+',' ',urldecode($_GET['overlay'])) . " "),0,1) == ',') {
       echo "\n returl=returl.split('data=')[0] + 'data=" . urlencode(str_replace('+',' ',urldecode($_GET['overlay']))) . "'; \n";
       } else if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_GET['overlay'])) . " "),0), ",") !== false) {
       echo "\n returl=returl.split('data=')[0] + 'data=" . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_GET['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_GET['overlay'])))) . "'; \n";
       }
       } else if (isset($_POST['overlay'])) {
       if (substr(strtolower(str_replace('+',' ',urldecode($_POST['overlay'])) . " "),0,1) == ',') {
       echo "\n returl=returl.split('data=')[0] + 'data=" . urlencode(str_replace('+',' ',urldecode($_POST['overlay']))) . "'; \n";
       } else if (strpos(substr(strtolower(str_replace('+',' ',urldecode($_POST['overlay'])) . " "),0), ",") !== false) {
       echo "\n returl=returl.split('data=')[0] + 'data=" . urlencode(',' . str_replace(explode(",",str_replace('+',' ',urldecode($_POST['overlay'])))[0] . ',','',str_replace('+',' ',urldecode($_POST['overlay'])))) . "'; \n";
       }
       }
?>
      } else if (aothis.innerHTML.toLowerCase().indexOf('area') != -1) {
       if (dccnt != 0) topmou='AreaChart/area_chart.php';
       returl=returl.replace(fromone,'/AreaChart').replace(fromtwo,'area_chart.php').replace('index.php','area_chart.php');
      } else if (aothis.innerHTML.toLowerCase().indexOf('bar') != -1) {
       if (dccnt != 0) topmou='BarChart/bar_chart.php';
       returl=returl.replace(fromone,'/BarChart').replace(fromtwo,'bar_chart.php').replace('index.php','bar_chart.php');
      } else if (aothis.innerHTML.toLowerCase().indexOf('column') != -1) {
       if (dccnt != 0) topmou='ColumnChart/column_chart.php';
       returl=returl.replace(fromone,'/ColumnChart').replace(fromtwo,'column_chart.php').replace('index.php','column_chart.php');
      } else if (aothis.innerHTML.toLowerCase().indexOf('line') != -1) {
       if (dccnt != 0) topmou='LineChart/line_chart.php';
       returl=returl.replace(fromone,'/LineChart').replace(fromtwo,'line_chart.php').replace('index.php','line_chart.php');
      } 
      postgoother(returl); 
      return returl;
    }
    
    function postgoother(retl) {
      returl=retl;
      if (dccnt == 0) {
        setTimeout(delayurl, 2000);
        dccnt=1;
      } else {
        dccnt=2;
        locationhref=toolongcheck(returl);
        if ((locationhref + ' ').substring(0,1) != '#') { if (1 == 1) { yesoverlay(locationhref); } else { location.href=locationhref; }  } 
        setTimeout(resetov, 2500);
      }
    }
            
    function toolongcheck(instis) {
      if (instis.length > 900) {
        prepareiframe('thisfcc');
        document.getElementById('thisfcc').action=instis.split('?')[0];
        //alert(instis.split('?')[0]);
        var insti=instis.split('#')[0] + '&';
        var getpis=insti.split('value=')[1].split('&')[0];
        if (getpis.indexOf('%') != -1) {
          document.getElementById('fvalue').value=decodeURIComponent(getpis);
        } else {
          document.getElementById('fvalue').value=getpis;
        }
        getpis=insti.split('mode=')[1].split('&')[0];
        if (getpis.indexOf('%') != -1) {
          document.getElementById('fmode').value=decodeURIComponent(getpis);
        } else {
          document.getElementById('fmode').value=getpis;
        }
        getpis=insti.split('label=')[1].split('&')[0];
        if (getpis.indexOf('%') != -1) {
          document.getElementById('flabel').value=decodeURIComponent(getpis);
        } else {
          document.getElementById('flabel').value=getpis;
        }
        getpis=insti.split('onclick=')[1].split('&')[0];
        if (getpis.indexOf('%') != -1) {
          document.getElementById('fonclick').value=decodeURIComponent(getpis);
        } else {
          document.getElementById('fonclick').value=getpis;
        }
        getpis=insti.split('data=')[1].split('&')[0];
        if (getpis.indexOf('%') != -1) {
          document.getElementById('fdata').value=decodeURIComponent(getpis);
        } else {
          document.getElementById('fdata').value=getpis;
        }
        //alert(98);
        document.getElementById('fcsubmit').click();
        return '#igchart'; //'#igchart';
      } else {
        return instis;
      }  
    }
   
   function fillindata() {
     var bed=document.getElementById('bdataval');
     if (bed == null) {
       document.getElementById('bitsatend').innerHTML+='<input type="hidden" id="bdataval" value="' + encodeURIComponent(paramdata) + '"></input>';
     }
   }
   
   function filldata() {
     var bed=document.getElementById('bedata');
     if (bed != null) {
       if (bed.value == '') {
         bed.value=encodeURIComponent(paramdata);
       }
     }
   }

   var ready=false, x=-1, y=-1, elemLeft=0, elemTop=0, ir=-1, ic=-1, talkingpoint='';  
    
   var xpnum=1; // done here at supervisor
   var allowed=true; // done here at supervisor
   var nojwinextra=""; // done here at supervisor
<?php
  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';
     }
   }
   ";
  }
?>
   if (document.URL.indexOf('nojwin') != -1 || navigator.userAgent.match(/iPhone|iPad/i)) {
     nojwinextra="&nojwinyes=Y";
   }

<?php
 echo "
  function selectevent(ans) {
            if (ans.replace('null','') != '' && ans != paramdata) {
            document.title=ans;
             if ((ans.toLowerCase() + '~').indexOf('.csv~') != -1 && ans.toLowerCase().indexOf('&') == -1) ans=paramdata + '&csv=' + ans;
             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 (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() == 'a') {
              if (ans.length > 1) {
                if (ans.substring(1,2) == '+') {
                  topmou='/AreaChart/area_chart.php';
                  postgoother(documentURL.replace('/LineChart', '/AreaChart').replace('line_chart.php', 'area_chart.php'));
                  postgoother(documentURL.replace('/LineChart', '/AreaChart').replace('line_chart.php', 'area_chart.php'));
                }
              }
              if (pardata == '' && topmou == '') {
              locationhref=iftoobig(mou,(document.URL + '?title=" . urlencode(str_replace(",","`",$GETtitle)) . '&label=' . urlencode($GETlabel) . '&onclick=y&value=' . urlencode($GETvalue) . "&data=' + ourencodeURIComponent(paramdata)).replace('/LineChart', '/AreaChart').replace('line_chart.php', 'area_chart.php'));
              if ((locationhref + ' ').substring(0,1) != '#') { location.href=locationhref;  } 
              } else if (topmou == '') {
              location.href=ifoverlay(mou,documentURL.replace('/LineChart', '/AreaChart').replace('line_chart.php', 'area_chart.php'));
              }
             } else if (ans.substring(0,1).toLowerCase() == 'b') {
              if (ans.length > 1) {
                if (ans.substring(1,2) == '+') {
                  topmou='/BarChart/bar_chart.php';
                  postgoother(documentURL.replace('/LineChart', '/BarChart').replace('line_chart.php', 'bar_chart.php'));
                  postgoother(documentURL.replace('/LineChart', '/BarChart').replace('line_chart.php', 'bar_chart.php'));
                }
              }
              if (pardata == '' && topmou == '') {
              locationhref=iftoobig(mou,(document.URL + '?title=" . urlencode(str_replace(",","`",$GETtitle)) . '&label=' . urlencode($GETlabel) . '&onclick=y&value=' . urlencode($GETvalue) . "&data=' + ourencodeURIComponent(paramdata)).replace('/LineChart', '/BarChart').replace('line_chart.php', 'bar_chart.php'));
              if ((locationhref + ' ').substring(0,1) != '#') { location.href=locationhref;  } 
              } else if (topmou == '') {
              location.href=ifoverlay(mou,document.URL.replace('/LineChart', '/BarChart').replace('line_chart.php', 'bar_chart.php'));
              }
             } else if (ans.substring(0,1).toLowerCase() == 'c') {
              if (ans.length > 1) {
                if (ans.substring(1,2) == '+') {
                  topmou='/ColumnChart/column_chart.php';
                  postgoother(documentURL.replace('/LineChart', '/ColumnChart').replace('line_chart.php', 'column_chart.php'));
                  postgoother(documentURL.replace('/LineChart', '/ColumnChart').replace('line_chart.php', 'column_chart.php'));
                }
              }
              if (pardata == '' && topmou == '') {
              locationhref=iftoobig(mou,(document.URL + '?title=" . urlencode(str_replace(",","`",$GETtitle)) . '&label=' . urlencode($GETlabel) . '&onclick=y&value=' . urlencode($GETvalue) . "&data=' + ourencodeURIComponent(paramdata)).replace('/LineChart', '/ColumnChart').replace('line_chart.php', 'column_chart.php'));
              if ((locationhref + ' ').substring(0,1) != '#') { location.href=locationhref;  } 
              } else if (topmou == '') {
              location.href=ifoverlay(mou,document.URL.replace('/LineChart', '/ColumnChart').replace('line_chart.php', 'column_chart.php'));
              }
             } else if (ans.indexOf(String.fromCharCode(43)) != -1) {
              topmou='/LineChart/line_chart.php';
              postgoother(documentURL.split('&data=')[0] + '&data=' + ourencodeURIComponent(ans.replace(String.fromCharCode(43),'').replace(String.fromCharCode(43),'').replace(String.fromCharCode(43),'')));
              postgoother(documentURL.split('&data=')[0] + '&data=' + ourencodeURIComponent(ans.replace(String.fromCharCode(43),'').replace(String.fromCharCode(43),'').replace(String.fromCharCode(43),'')));
             } else if (pardata == '') {
              //alert(document.URL + '?title=" . urlencode(str_replace(",","`",$GETtitle)) . '&label=' . urlencode($GETlabel) . '&onclick=y&value=' . urlencode($GETvalue) . "&data=' + ourencodeURIComponent(ans));
              locationhref=iftoobig('',document.URL + '?title=" . urlencode(str_replace(",","`",$GETtitle)) . '&label=' . urlencode($GETlabel) . '&onclick=y&value=' . urlencode($GETvalue) . "&data=' + ourencodeURIComponent(ans));
              if ((locationhref + ' ').substring(0,1) != '#') { location.href=locationhref;  } 
             } else {
              locationhref=iftoobig('',document.URL.replace(pardata, ourencodeURIComponent(ans)));
              //location.href=document.URL.replace(pardata, ourencodeURIComponent(ans));
              if ((locationhref + ' ').substring(0,1) != '#') { location.href=locationhref;  } 
             }
            }
          }  
          
    function selecteventtwo(ans) {
            if (ans.replace('null','') != '' && ans != paramdata) {
             if ((ans.toLowerCase() + '~').indexOf('.csv~') != -1 && ans.toLowerCase().indexOf('&') == -1) ans=paramdata + '&csv=' + ans;
             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 (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() == 'a') {
              if (ans.length > 1) {
                if (ans.substring(1,2) == '+') {
                  topmou='/AreaChart/area_chart.php';
                  postgoother(documentURL.replace('/LineChart', '/AreaChart').replace('line_chart.php', 'area_chart.php'));
                  postgoother(documentURL.replace('/LineChart', '/AreaChart').replace('line_chart.php', 'area_chart.php'));
                }
              }
              if (pardata == '' && topmou == '') {
              locationhref=iftoobig(mou,(document.URL + '?title=" . urlencode(str_replace(",","`",$GETtitle)) . '&label=' . urlencode($GETlabel) . '&onclick=y&value=' . urlencode($GETvalue) . "&data=' + ourencodeURIComponent(paramdata)).replace('/LineChart', '/AreaChart').replace('line_chart.php', 'area_chart.php'));
              if ((locationhref + ' ').substring(0,1) != '#') { location.href=locationhref;  } 
              } else if (topmou == '') {
              location.href=ifoverlay(mou,documentURL.replace('/LineChart', '/AreaChart').replace('line_chart.php', 'area_chart.php'));
              }
             } else if (ans.substring(0,1).toLowerCase() == 'b') {
              if (ans.length > 1) {
                if (ans.substring(1,2) == '+') {
                  topmou='/BarChart/bar_chart.php';
                  postgoother(documentURL.replace('/LineChart', '/BarChart').replace('line_chart.php', 'bar_chart.php'));
                  postgoother(documentURL.replace('/LineChart', '/BarChart').replace('line_chart.php', 'bar_chart.php'));
                }
              }
              if (pardata == '' && topmou == '') {
              locationhref=iftoobig(mou,(document.URL + '?title=" . urlencode(str_replace(",","`",$GETtitle)) . '&label=' . urlencode($GETlabel) . '&onclick=y&value=' . urlencode($GETvalue) . "&data=' + ourencodeURIComponent(paramdata)).replace('/LineChart', '/BarChart').replace('line_chart.php', 'bar_chart.php'));
              if ((locationhref + ' ').substring(0,1) != '#') { location.href=locationhref;  } 
              } else if (topmou == '') {
              location.href=ifoverlay(mou,document.URL.replace('/LineChart', '/BarChart').replace('line_chart.php', 'bar_chart.php'));
              }
             } else if (ans.substring(0,1).toLowerCase() == 'c') {
              if (ans.length > 1) {
                if (ans.substring(1,2) == '+') {
                  topmou='/ColumnChart/column_chart.php';
                  postgoother(documentURL.replace('/LineChart', '/ColumnChart').replace('line_chart.php', 'column_chart.php'));
                  postgoother(documentURL.replace('/LineChart', '/ColumnChart').replace('line_chart.php', 'column_chart.php'));
                }
              }
              if (pardata == '' && topmou == '') {
              locationhref=iftoobig(mou,(document.URL + '?title=" . urlencode(str_replace(",","`",$GETtitle)) . '&label=' . urlencode($GETlabel) . '&onclick=y&value=' . urlencode($GETvalue) . "&data=' + ourencodeURIComponent(paramdata)).replace('/LineChart', '/ColumnChart').replace('line_chart.php', 'column_chart.php'));
              if ((locationhref + ' ').substring(0,1) != '#') { location.href=locationhref;  } 
              } else if (topmou == '') {
              location.href=ifoverlay(mou,document.URL.replace('/LineChart', '/ColumnChart').replace('line_chart.php', 'column_chart.php'));
              }
             } else if (ans.indexOf(String.fromCharCode(43)) != -1) {
              topmou='/LineChart/line_chart.php';
              postgoother(documentURL.split('&data=')[0] + '&data=' + ourencodeURIComponent(ans.replace(String.fromCharCode(43),'').replace(String.fromCharCode(43),'').replace(String.fromCharCode(43),'')));
              postgoother(documentURL.split('&data=')[0] + '&data=' + ourencodeURIComponent(ans.replace(String.fromCharCode(43),'').replace(String.fromCharCode(43),'').replace(String.fromCharCode(43),'')));
             } else if (pardata == '') {
              //alert(document.URL + '?title=" . urlencode(str_replace(",","`",$GETtitle)) . '&label=' . urlencode($GETlabel) . '&onclick=y&value=' . urlencode($GETvalue) . "&data=' + ourencodeURIComponent(ans));
              locationhref=iftoobig('',document.URL + '?title=" . urlencode(str_replace(",","`",$GETtitle)) . '&label=' . urlencode($GETlabel) . '&onclick=y&value=' . urlencode($GETvalue) . "&data=' + ourencodeURIComponent(ans));
              if ((locationhref + ' ').substring(0,1) != '#') { location.href=locationhref;  } 
             } else {
              locationhref=iftoobig('',document.URL.replace(pardata, ourencodeURIComponent(ans)));
              //location.href=document.URL.replace(pardata, ourencodeURIComponent(ans));
              if ((locationhref + ' ').substring(0,1) != '#') { location.href=locationhref;  } 
             }
            }
        }
    ";
?>
<?php 
  echo "var data, chart, pardata = (location.search.split('data=')[1] ? location.search.split('data=')[1].split('&')[0] : ''), paramdata=decodeURIComponent(pardata); \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 != "") 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 = "Company Performance";
      $GETlabel = "Year";
      $GETvalue = "Sales,Expenses";
      $GETdata = ",['2004',1000,400],['2005',1170,460],['2006',660,1120],['2007',1030,540]";
      
 
      if (isset($_POST['data'])) {
       //$nineh="1200";
       //$twoh="430";
       $GETdata = str_replace("~", "'", str_replace("\\'", "'", urldecode(checkdatadata0('POST',$_POST['data']))));
       //echo "\n pardata = " . '"' . $_POST['data'] . '"; ' . " \n";
       echo "\n paramdata='" .  str_replace("'",'~',$GETdata) . "'; \n setTimeout(fillindata, 300); \n setTimeout(filldata, 3000); \n"; // = decodeURIComponent(pardata); " . " \n";
       
      } else if (isset($_GET['data'])) {
      $getdata=$_GET['data'];
      if (strpos($getdata, "%") !== false) $getdata=str_replace('+',' ',urldecode($getdata));
      if (strpos($getdata, "%") !== false) $getdata=str_replace('+',' ',urldecode($getdata));
      if (strpos($getdata, "%") !== false) $getdata=str_replace('+',' ',urldecode($getdata));
      if (strpos($getdata, "%") !== false) $getdata=str_replace('+',' ',urldecode($getdata));
      if (strpos($getdata, "%") !== false) $getdata=str_replace('+',' ',urldecode($getdata));
      $GETdata = $getdata;
      }
     
      if (isset($_GET['value'])) {
       $GETtitle = $_GET['title'];
        $burl="";
       if (isset($_GET['title'])) {
       $ourtitles=explode(";", str_replace(";base64","|base64",urldecode($_GET['title'])));
       for ($ipa=0; $ipa<sizeof($ourtitles); $ipa++) {
       $ourtitles[$ipa]=str_replace("|base64",";base64",$ourtitles[$ipa]);
       }
       $GETtitle = str_replace("\\'", "'", $ourtitles[sizeof($ourtitles) - 1]);
       if (sizeof($ourtitles) > 1 && (strpos(strtolower($ourtitles[0]), "//") !== false || strpos(strtolower($ourtitles[0]), "data:") !== false)) {
       while (sizeof($ourtitles) > 1 && (strpos(strtolower($ourtitles[0]), "//") !== false || strpos(strtolower($ourtitles[0]), "data:") !== false)) {
        $burl="";
        // Thanks to https://stackoverflow.com/questions/8828076/how-can-i-hack-a-background-image-into-google-chart-tools-dynamic-javascript-s
        if (strpos($ourtitles[0], "data:") !== false) {
          $burl=str_replace("%2b","+","data:" . explode(" ", explode("data:", substr($ourtitles[0],0,20) . explode(";",substr($ourtitles[0],20))[0] . " "   )[1])[0]);
        } else if (strpos($ourtitles[0], "DATA:") !== false) {
          $burl=str_replace("%2b","+","data:" . explode(" ", explode("DATA:", substr($ourtitles[0],0,20) . explode(";",substr($ourtitles[0],20))[0] . " "   )[1])[0]);
        } else if (strpos($ourtitles[0], "Data:") !== false) {
          $burl=str_replace("%2b","+","data:" . explode(" ", explode("Data:", substr($ourtitles[0],0,20) . explode(";",substr($ourtitles[0],20))[0] . " "   )[1])[0]);
        } else if (strpos($ourtitles[0], "https://") !== false) {
          $burl="https://" . explode(" ", explode("https://", $ourtitles[0])[1])[0];
        } else if (strpos($ourtitles[0], "Https://") !== false) {
          $burl="Https://" . explode(" ", explode("Https://", $ourtitles[0])[1])[0];
        } else if (strpos($ourtitles[0], "HTTPS://") !== false) {
          $burl="HTTPS://" . explode(" ", explode("HTTPS://", $ourtitles[0])[1])[0];
        } else if (strpos($ourtitles[0], "http://") !== false) {
          $burl="http://" . explode(" ", explode("http://", $ourtitles[0])[1])[0];
        } else if (strpos($ourtitles[0], "Http://") !== false) {
          $burl="Http://" . explode(" ", explode("Http://", $ourtitles[0])[1])[0];
        } else if (strpos($ourtitles[0], "HTTP://") !== false) {
          $burl="HTTP://" . explode(" ", explode("HTTP://", $ourtitles[0])[1])[0];
        } else {
          $burl="//" . explode(" ", explode("//", $ourtitles[0])[1])[0];
        }
        if ($burl != "") {
        $ourmimetype="";
        if (strpos($burl, "data:") === false) {
        $ourext=explode(".", $burl)[-1 + sizeof(explode(".", $burl))];
        for ($im=0; $im<sizeof($exts); $im++) {
         if (strtolower("." . $ourext) == strtolower($exts[$im])) $ourmimetype=$types[$im] . ";";
        }
        }
        if (strpos($burl, "audio/") !== false || strpos($ourmimetype, "audio/") !== false) {
        if ($bdivstart == "") $bdivstart="<div id='bkcol'>";
        if ($bdivend == "") {
        $bdivend="</div><audio type='audio/" . explode(';', explode('audio/', $ourmimetype . $burl)[1])[0] . "' controls autoplay><source src=" . $burl . "></source></audio>";
        } else {
        $bdivend=str_replace("</div>", "</div><audio type='audio/" . explode(';', explode('audio/', $ourmimetype . $burl)[1])[0] . "' controls autoplay><source src=" . $burl . "></source></audio>", $bdivend);
        }
        } else if (strpos($burl, "video/") !== false || strpos($ourmimetype, "video/") !== false) {
        if ($bdivstart == "") $bdivstart="<div id='bkcol'>";
        if ($bdivend == "") {
        $bdivend="</div><video type='video/" . explode(';', explode('video/', $ourmimetype . $burl)[1])[0] . "' controls autoplay><source src=" . $burl . "></source></video>";
        } else {
        $bdivend=str_replace("</div>", "</div><video type='video/" . explode(';', explode('video/', $ourmimetype . $burl)[1])[0] . "' controls autoplay><source src=" . $burl . "></source></video>", $bdivend);
        }
        } else if ($burl != "") {
        $bdivstart="<div id='bkcol' style=\"background: linear-gradient(rgba(255,255,255,0.4),rgba(255,255,255,0.4)),url('" . $burl . "'); background-repeat: repeat;\">";
        if ($bdivend == "") $bdivend="</div>";
        } 
        }
        if (strpos($cdivc,"opacity") !== false) {
        $cdivc=str_replace("yellow","none", $cdivc);
        } else {
        $cdivc="background-color: none; opacity:1.0;  ";
        }
        array_shift($ourtitles);
       }
       if ($burl != "") {
        $nondefs.=",  backgroundColor: 'none' ";
        $ourtitles=explode(";", urldecode($_GET['title']));
        } else {
        $nondefs=$nondefs;
        }
       }
       }
       
       
        
       $GETlabel = str_replace("+"," ",urldecode($_GET['label']));
       $GETvalue = str_replace("+"," ",urldecode($_GET['value']));
       //$GETdata = $_GET['data'];
      } else if (isset($_POST['value'])) {
       $GETtitle = $_POST['title'];
        $burl="";
       if (isset($_POST['title'])) {
       $ourtitles=explode(";", str_replace(";base64","|base64",urldecode($_POST['title'])));
       for ($ipa=0; $ipa<sizeof($ourtitles); $ipa++) {
       $ourtitles[$ipa]=str_replace("|base64",";base64",$ourtitles[$ipa]);
       }
       $GETtitle = str_replace("\\'", "'", $ourtitles[sizeof($ourtitles) - 1]);
       if (sizeof($ourtitles) > 1 && (strpos(strtolower($ourtitles[0]), "//") !== false || strpos(strtolower($ourtitles[0]), "data:") !== false)) {
       while (sizeof($ourtitles) > 1 && (strpos(strtolower($ourtitles[0]), "//") !== false || strpos(strtolower($ourtitles[0]), "data:") !== false)) {
        $burl="";
        // Thanks to https://stackoverflow.com/questions/8828076/how-can-i-hack-a-background-image-into-google-chart-tools-dynamic-javascript-s
        if (strpos($ourtitles[0], "data:") !== false) {
          $burl=str_replace("%2b","+","data:" . explode(" ", explode("data:", substr($ourtitles[0],0,20) . explode(";",substr($ourtitles[0],20))[0] . " "   )[1])[0]);
        } else if (strpos($ourtitles[0], "DATA:") !== false) {
          $burl=str_replace("%2b","+","data:" . explode(" ", explode("DATA:", substr($ourtitles[0],0,20) . explode(";",substr($ourtitles[0],20))[0] . " "   )[1])[0]);
        } else if (strpos($ourtitles[0], "Data:") !== false) {
          $burl=str_replace("%2b","+","data:" . explode(" ", explode("Data:", substr($ourtitles[0],0,20) . explode(";",substr($ourtitles[0],20))[0] . " "   )[1])[0]);
        } else if (strpos($ourtitles[0], "https://") !== false) {
          $burl="https://" . explode(" ", explode("https://", $ourtitles[0])[1])[0];
        } else if (strpos($ourtitles[0], "Https://") !== false) {
          $burl="Https://" . explode(" ", explode("Https://", $ourtitles[0])[1])[0];
        } else if (strpos($ourtitles[0], "HTTPS://") !== false) {
          $burl="HTTPS://" . explode(" ", explode("HTTPS://", $ourtitles[0])[1])[0];
        } else if (strpos($ourtitles[0], "http://") !== false) {
          $burl="http://" . explode(" ", explode("http://", $ourtitles[0])[1])[0];
        } else if (strpos($ourtitles[0], "Http://") !== false) {
          $burl="Http://" . explode(" ", explode("Http://", $ourtitles[0])[1])[0];
        } else if (strpos($ourtitles[0], "HTTP://") !== false) {
          $burl="HTTP://" . explode(" ", explode("HTTP://", $ourtitles[0])[1])[0];
        } else {
          $burl="//" . explode(" ", explode("//", $ourtitles[0])[1])[0];
        }
        if ($burl != "") {
        $ourmimetype="";
        if (strpos($burl, "data:") === false) {
        $ourext=explode(".", $burl)[-1 + sizeof(explode(".", $burl))];
        for ($im=0; $im<sizeof($exts); $im++) {
         if (strtolower("." . $ourext) == strtolower($exts[$im])) $ourmimetype=$types[$im] . ";";
        }
        }
        if (strpos($burl, "audio/") !== false || strpos($ourmimetype, "audio/") !== false) {
        if ($bdivstart == "") $bdivstart="<div id='bkcol'>";
        if ($bdivend == "") {
        $bdivend="</div><audio type='audio/" . explode(';', explode('audio/', $ourmimetype . $burl)[1])[0] . "' controls autoplay><source src=" . $burl . "></source></audio>";
        } else {
        $bdivend=str_replace("</div>", "</div><audio type='audio/" . explode(';', explode('audio/', $ourmimetype . $burl)[1])[0] . "' controls autoplay><source src=" . $burl . "></source></audio>", $bdivend);
        }
        } else if (strpos($burl, "video/") !== false || strpos($ourmimetype, "video/") !== false) {
        if ($bdivstart == "") $bdivstart="<div id='bkcol'>";
        if ($bdivend == "") {
        $bdivend="</div><video type='video/" . explode(';', explode('video/', $ourmimetype . $burl)[1])[0] . "' controls autoplay><source src=" . $burl . "></source></video>";
        } else {
        $bdivend=str_replace("</div>", "</div><video type='video/" . explode(';', explode('video/', $ourmimetype . $burl)[1])[0] . "' controls autoplay><source src=" . $burl . "></source></video>", $bdivend);
        }
        } else if ($burl != "") {
        $bdivstart="<div id='bkcol' style=\"background: linear-gradient(rgba(255,255,255,0.4),rgba(255,255,255,0.4)),url('" . $burl . "'); background-repeat: repeat;\">";
        if ($bdivend == "") $bdivend="</div>";
        } 
        }
        if (strpos($cdivc,"opacity") !== false) {
        $cdivc=str_replace("yellow","none", $cdivc);
        } else {
        $cdivc="background-color: none; opacity:1.0;  ";
        }
        array_shift($ourtitles);
       }
       if ($burl != "") {
        $nondefs.=",  backgroundColor: 'none' ";
        $ourtitles=explode(";", urldecode($_POST['title']));
        } else {
        $nondefs=$nondefs;
        }
       }
       }
       $GETlabel = str_replace("+"," ",urldecode($_POST['label']));
       $GETvalue = str_replace('%20',' ',str_replace("+"," ",urldecode($_POST['value'])));
      }
      
      if (!isset($_GET['data']) && !isset($_POST['data']) && strpos($_SERVER['QUERY_STRING'],"title=") !== false) {
       $bbits = explode("data=", file_get_contents('php://input'));
         $GETtitle = str_replace("\\'", "'", urldecode(explode('&',explode("title=", $_SERVER['QUERY_STRING'])[1])[0]));
         $GETlabel = str_replace("\\'", "'", urldecode(explode('&',explode("label=", $_SERVER['QUERY_STRING'])[1])[0]));
         $GETvalue = str_replace("\\'", "'", urldecode(explode('&',explode("value=", $_SERVER['QUERY_STRING'])[1])[0]));
       if (sizeof($bbits) > 1) {
         $GETdata = str_replace("\\'", "'", urldecode(explode('&',$bbits[1])[0]));
       } else {
         $GETdata = "";
       }
      }      
      
      echo " var colnames= '" . $GETlabel . "," . str_replace("'", "", $GETvalue) . "'; \n";
      
      echo " google.load('visualization', '1', {packages:['corechart']}); " . "\n";
      echo ' google.setOnLoadCallback(drawChart); ' . "\n";
      echo ' function drawChart() { ' . "\n";
      if ($GETdata == "") {
      echo ' var wert="data=google.visualization.arrayToDataTable([ [' . "'" . $GETlabel . "','" . str_replace(",", "','", str_replace("'", "", $GETvalue)) . "'" . '],"; ' . "\n";
      echo " wert+=parent.document.getElementById('data').value.replace(/\,\]/g,\",0\").replace(/\,\,/g,\",0,\").replace(/\,\]/g,\",0]\").replace(/\[\~/g,\"['\").replace(/\~\,/g,\"',\"); " . "\n";
      echo ' wert+=" ])";' . "\n";
      echo ' eval(wert); ' . "\n";
      } else {
      echo ' if (decodeURIComponent(("" + location.hash).replace(/^undefined/g,"")).trim().indexOf(",") != -1) { ' . "\n";
      echo ' var xwert="data=google.visualization.arrayToDataTable([ [' . "'" . $GETlabel . "','" . str_replace(",", "','", str_replace("'", "", $GETvalue)) . "'" . '],"; ' . "\n";
      echo " xwert+=\"" . str_replace("~,", "',", str_replace("[~", "['", str_replace(",]", ",0]", str_replace(",,", ",0,", str_replace(",]", ",0]", $GETdata))))) . "\" + ('' + location.hash).replace(/\%20/g,' ').replace(/^\#/g,'').replace(/\%20/g,'').replace(/\,\]/g,\",0\").replace(/\[\~/g,\"['\").replace(/\~\,/g,\"',\"); " . "\n";
      echo ' xwert+=" ])"; xwert=xwert.replace(",,",","); ' . "\n";
      echo ' eval(xwert); ' . "\n";
      echo ' } else { ' . "\n";
      echo ' data = google.visualization.arrayToDataTable([ ' . "\n";
      echo " ['" . $GETlabel . "','" . str_replace(",", "','", str_replace("'", "", $GETvalue)) . "'] \n";
      echo str_replace("~,", "',", str_replace("[~", "['", str_replace(",]", ",0]", str_replace(",,", ",0,", str_replace(",]", ",0]", $GETdata)))));
      echo "        ]);\n";
      echo " } \n";
      }
      if (trim($GETextraopts) != '') { $GETextraopts=str_replace(',,',',',trim($GETextraopts) . ',');   }
      echo "        var options = { " . $GETextraopts . " \n";
      echo "        title: '" . $GETtitle . "', \n";
      echo "        hAxis: {title: '" . $GETlabel . "',  titleTextStyle: {color: 'red'}}" . $nondefs . " \n";
      echo "       }; \n";


      echo " chart = new google.visualization.LineChart(document.getElementById('chart_div')); \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;
  var selection = chart.getSelection();
  for (var i = 0; i < selection.length; i++) {
    var item = selection[i];
    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;
      }
      var str = data.getFormattedValue(item.row, item.column);
      //document.title=str;
      message=document.head.innerHTML.substring(ioffset);
      while (message.indexOf(', [') != -1) {
       message=message.replace(', [',',[');
      }
      dparts=message.split(',[');
        //document.title='';
        colav.push(0.0);
      for (kl=1; kl<colparts.length; kl++) {
        //document.title=1;
        colav.push(0.0);
        doit=true;
        num=1;
        for (lk=1; lk<dparts.length; lk++) {
         if (doit) {
        //document.title=3;
         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++;
         }
        }
        //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) == 3) { 
          if (1 == 1) {
          avblurb+='With A B C and changed data options below to append + causes superimposition ... ' + String.fromCharCode(10) + String.fromCharCode(10);
          avblurb+='Show this as Area Chart=A' + String.fromCharCode(10);
          avblurb+='Show this as Bar Chart=B' + String.fromCharCode(10);
          avblurb+='Show this as Column Chart=C' + 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);
          avblurb+='Change data as required below (keeping it the same or being blank or choosing Cancel leaves the status quo)';
          if (document.getElementById('safariform')) { document.getElementById('safariform').style.top='70px';   } 
          ans=prompt('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, paramdata);
          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 {
          predparts=dparts[eval(1 + item.row)].split(']');
          diffvalues=('~' + predparts[0] + '~').replace('~' + postdparts[0].replace(']','') + ',','~');
          if (eval(0 + item.column) == 1) {
            diffvalues=diffvalues.replace('~' + str + ',','').replace(/~/g,'');
          } else if (eval(colparts.length) == eval(1 + item.column)) {
            diffvalues=diffvalues.replace(',' + str + '~','').replace(/~/g,'');
          } else {
            diffvalues=diffvalues.replace(',' + str + ',',',').replace(/~/g,'');
          }
          diffcolnames=('~' + colnames + '~').replace('~' + colparts[0] + ',','~').replace('~' + colparts[eval(0 + item.column)] + ',','').replace(',' + colparts[eval(0 + item.column)] + '~','').replace(',' + colparts[eval(0 + item.column)] + ',',',').replace(/~/g,'');
          if (1 == 1) {
          avblurb+='With A B C and changed data options below to append + causes superimposition ... ' + String.fromCharCode(10) + String.fromCharCode(10);
          avblurb+='Show this as Area Chart=A' + String.fromCharCode(10);
          avblurb+='Show this as Bar Chart=B' + String.fromCharCode(10);
          avblurb+='Show this as Column Chart=C' + 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);
          avblurb+='Change data as required below (keeping it the same or being blank or choosing Cancel leaves the status quo)';
          if (document.getElementById('safariform')) { document.getElementById('safariform').style.top='70px';   } 
          ans=prompt(' In ' + colparts[0] + ' ' + postdparts[0].replace(']','') + ' you clicked ' + colparts[item.column] + ' of ' + str + ' while (' + diffcolnames + ') were (' + diffvalues + ').' + avblurb, paramdata);
          if (ans != null) {
			selecteventtwo(ans);
          }
          } else {
          alert('In ' + colparts[0] + ' ' + postdparts[0].replace(']','') + ' you clicked ' + colparts[item.column] + ' of ' + str + ' while (' + diffcolnames + ') were (' + diffvalues + ').' + avblurb);
          }
         }
        }
      }
      message += '{row:' + item.row + ',column:' + item.column + '} = ' + str;
    } else if (item.row != null) {
      var str = data.getFormattedValue(item.row, 0);
      message += '{row:' + item.row + ', column:none}; value (col 0) = ' + str;
    } else if (item.column != null) {
      var 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);
 }
 }     
      //);  
      ";
      }
      echo " chart.draw(data, options); \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";
      
      echo "</script> \n";
      echo " </head> \n";
      if (!isset($_GET['nojwin']) && !isset($_GET['nojwinyes']) || 1 == 1) {
      echo " <body onload='" . $superimposition . " setTimeout(later, 2 * 1000);' style='background-color: silver;'> \n";
      } else {
      echo " <body onload='" . $superimposition . " later();'> \n";
      }
      echo " <h1>" . $GETtitle . " Line Chart</h1> \n";
      echo $bdivstart;

      echo '<div id="chart_div" style="' . $cdivc . '"></div>' . $bdivend . '<div id="bitsatend" style="display:inline;"></div>' . " \n";
      echo '<a id=another title="Another Line Chart" href="./line_chart.php">Another</a> <a id="aoarea" title="Another Area Chart ... double click for superimposition" style="text-decoration:underline;cursor:pointer;" onclick=goother(this);>area</a>/<a id="aobar" title="Another Bar Chart ... double click for superimposition" style="text-decoration:underline;cursor:pointer;" onclick=goother(this);>bar</a>/<a id="aocolumn" title="Another Column Chart ... double click for superimposition" style="text-decoration:underline;cursor:pointer;" onclick=goother(this);>column</a>/<a id=anothertwo title="Another Line Chart for" href="./line_chart.php">line chart?</a>' . " \n";
      echo '<div id="thedivoverlay"><?php echo $overlay; ?></div>';
      if (!isset($_GET['value']) && !isset($_POST['value'])) {
      
        echo '<' . 'script' . '>' . "\n " . " function later() { \n" . ' var datalineprefix = " "; ' . "\n";
        echo ' if (document.getElementById("safariform")) { document.getElementById("safariform").style.top="70px";   } ' . "\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 Line Chart Title (background image URL or background image data URI ; separated (followed by ;) before title are available options, and suffix by &onclick=y for added onclick functionality,  Email Attachment Title suffixes are &emailto=[emailTo] &emailsubject=[EmailSubject] and &top=[0],  &left=[0], &opacity=[0.5], &overlay=[L] or A or B or C (and appended ,[~2010~,45,67] type data sets of overlay data, can be different to entries later) for superimposition purposes available)", "' . $GETtitle . '"); ' . "\n";
        echo ' if (title != null) { ' . "\n";
        echo ' var label = prompt("Enter Line Concept", "' . $GETlabel . '"); ' . "\n";
        echo ' var value = prompt("Enter Line " + label + " Measure(s) (separated by ,)", "' . $GETvalue . '"); ' . "\n";
        echo ' if (value.indexOf(",") != (0 - 1)) { ' . "\n";
        echo '  for (ii=0; ii<value.length; ii++) { if (value.substring(ii,(ii+1)) == ",") thisdef = thisdef + ",0"; } ' . "\n";
        echo ' } ' . "\n";
        echo ' var datac = ""; ' . "\n";
        echo ' var sq = "' . "'" . '"; ' . "\n";
        echo ' datalineprefix = prompt("Enter " + label + " " + thisline, ""); ' . "\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 ' if (datalinesuffix.length != 0) datalineprefix = prompt("Enter " + label + " " + thisline + " (for no more hit Cancel button)", ""); ' . "\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 " + value.replace("  ercent ", "") + " " + thisline + extra, thisdef); ' . "\n";
        echo '     if (datalinesuffix == null && value.indexOf("ercent") != (0 - 1) && value.indexOf("  ercent ") == (0 - 1)) datalinesuffix = totalleft; ' . "\n";
        echo '     if (datalinesuffix == null) datalinesuffix = "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 '     datac = datac + ", [~" + datalineprefix + "~," + datalinesuffix + "] "; ' . "\n";
        echo '     thisline++; ' . "\n";
        echo '   } ' . "\n";
        echo ' } ' . "\n";
        echo ' if (allowed) { var wl = toolong("./line_chart.php?title=" + title + "&label=" + label + "&value=" + value.replace("  ercent ", "") + nojwinextra + "&data=" + datac);    if (wl != "#") { window.location=wl;  }    } ' . "\n";
        echo "} \n" . "} \n" . '</' . 'script' . '>' . "\n";
      } else {
        echo '<' . 'script' . '>' . "\n " . " function later() { } </" . "script>\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] + "'></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) + "'></input>";
     xpnum++;
     xansis='x';
   } else {
     xansis='';
   }
  }
  var durl=document.URL;
  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(' In ') == 0) {  selecteventtwo(document.getElementById('val" + xpnum + "').value);  } else { selectevent(document.getElementById('val" + xpnum + "').value); } } else if (durl.indexOf('&data=') != -1) { location.href=durl; } 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+='?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>
</body>
</html>
