<?php
header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" );
header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' ); 
require('../php_database.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;
  }
  
    // 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/PieChart/pie_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&task=", "&desc=", "&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("_", " ", $bitsap[$iuy]) . "'></input>", $proposedform);
      $urlbase.=$bitsbetween[$iuy] . '' . urlencode(str_replace("_", "%20", $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'])); }
  
$bdivstart="";
$bdivend="";
$cdivc="background-color: yellow;";
  
$amwv=false;
if ((strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile/') !== false) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari/') == false)) {
  $amwv=true;
}

  $fraction_game_template="";
  $myfnameis="ismapp";
  $mobilebits=explode("&" . $myfnameis . "=", ("" . $_SERVER['QUERY_STRING']));
  $dbval="";
  if (sizeof($mobilebits) > 1) {
   $dbval = include_get_params(dirname(__FILE__) . '/../php_database.php?' . $myfnameis . '=' . explode("&", ($mobilebits[1] . "&"))[0]);    
  }
  $dbval = include_get_params(dirname(__FILE__) . '/../php_database.php?' . $myfnameis . '=');  
  
  
  if (($dbval != "" && isset($_GET['fraction']))) {
   $fraction_game_template="https://www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php?title=Fraction%201/4&task=Part&desc=Percentage&onclick=y&data=,%20[~1/4~,25]%20,%20[~1/4~,25]%20,%20[~1/4~,25]%20,%20[~1/4~,25]";
  }
  
$select_prefix="";
$button_prefix="";
  
if ($dbval != "") {
   $njsuff="";
   if (strpos($_SERVER['QUERY_STRING'], "nojwin") !== false) $njsuff="&nojwin=Y";
   $button_prefix="<input style='font-size:18px;' height=80 type='button' onclick=\" window.top.location.href='//www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php?fraction=game" . $njsuff . "'; \" value='Pie Chart Fraction Game'></input>&nbsp;&nbsp;"; 
   $button_prefix.="<input style='font-size:18px;' height=80 type='button' onclick=\" window.top.location.href='//www.rjmprogramming.com.au/PHP/HistogramChart/histogram_chart.php?tally=poll" . $njsuff . "'; \" value='Histogram Chart Tallying'></input>&nbsp;&nbsp;"; 
   $select_prefix="<option value='//www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php?fraction=game" . $njsuff . "'>Pie Chart Fraction Game</option>";
   $select_prefix.="<option value='//www.rjmprogramming.com.au/PHP/HistogramChart/histogram_chart.php?tally=poll" . $njsuff . "'>Histogram Chart Tallying</option>";
}

function tzl($inwith) {
   $inwithtz=urldecode($inwith);
   if (strpos($inwithtz, "~http;") !== false) { // co-ordinates via net
     $inwithtz=read_and_array("http;" . explode("~",explode("~http;", $inwithtz)[1])[0], str_replace('pie_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])));
   } else if (strpos($inwithtz, "~Http;") !== false) { // co-ordinates via net
     $inwithtz=read_and_array("http;" . explode("~",explode("~Http;", $inwithtz)[1])[0], str_replace('pie_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])));
   } else if (strpos($inwithtz, "~HTTP;") !== false) { // co-ordinates via net
     $inwithtz=read_and_array("http;" . explode("~",explode("~HTTP;", $inwithtz)[1])[0], str_replace('pie_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])));
   } else if (strpos($inwithtz, "~https;") !== false) { // co-ordinates via net
     $inwithtz=read_and_array("http;" . explode("~",explode("~https;", $inwithtz)[1])[0], str_replace('pie_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])));
   } else if (strpos($inwithtz, "~Https;") !== false) { // co-ordinates via net
     $inwithtz=read_and_array("http;" . explode("~",explode("~Https;", $inwithtz)[1])[0], str_replace('pie_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])));
   } else if (strpos($inwithtz, "~HTTPS;") !== false) { // co-ordinates via net
     $inwithtz=read_and_array("http;" . explode("~",explode("~HTTPS;", $inwithtz)[1])[0], str_replace('pie_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])));
   } else if (strpos($inwithtz, "~http") !== false) { // co-ordinates via net
     $inwithtz=read_and_array("http" . explode("~",explode("~http", $inwithtz)[1])[0], str_replace('pie_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])));
   } else if (strpos($inwithtz, "~Http") !== false) { // co-ordinates via net
     $inwithtz=read_and_array("http" . explode("~",explode("~Http", $inwithtz)[1])[0], str_replace('pie_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])));
   } else if (strpos($inwithtz, "~HTTP") !== false) { // co-ordinates via net
     $inwithtz=read_and_array("HTTP" . explode("~",explode("~HTTP", $inwithtz)[1])[0], str_replace('pie_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])));
   } else if (strpos(str_replace("https;","http;",substr(strtolower($inwithtz . "      "),0,6)), "http;") !== false) { // co-ordinates longhand via prompt
     $inwithtz=read_and_array($inwithtz, str_replace('pie_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])));
   } else if (strpos(str_replace("https:","http:",substr(strtolower($inwithtz . "      "),0,6)), "http:") !== false) { // co-ordinates via URL via net
     $inwithtz=read_and_array($inwithtz, str_replace('pie_chart.php','pie_chart.php',str_replace('index.php','pie_chart.php',$_SERVER['REQUEST_URI'])));
   } else {
     if (isset($_POST['data'])) {
        echo "\n pardata=\"" . str_replace("+","%20",urlencode($inwith)) . "\"; \n";
        echo "\n paramdata=\"" . str_replace('"','" + String.fromCharCode(34) + "',urldecode(str_replace("+","%20",$inwith))) . "\"; \n";
     }
     return $inwith;
   }
   echo "\n pardata=\"" . urlencode($inwithtz) . "\"; ";
   echo "\n paramdata=\"" . str_replace('"','" + String.fromCharCode(34) + "',urldecode(str_replace("+","%20",$inwithz))) . "\"; \n";   // decodeURIComponent(pardata); \n";
   return $inwithtz;
}
?>

<html>
  <head> 
  <script type="text/javascript" src="//www.rjmprogramming.com.au/PHP/PieChart/gchartgen.js?x=xfdrddfgfd"></script>
  <!--script type="text/javascript" src="http://localhost:8888/PHP/PieChart/gchartgen.js"></script-->
    <title>Pie 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">
    <script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
    
    var documentURL = document.URL , locationhref='', etodi='emailee', etodicc='EmailCC', etodibcc='EmailBCC', etodisubject='EmailSubject';
    documentURL=documentURL.split('#')[0];
    
    <?php
      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] + \"" . $appval . "\";   \n";
      }
      
      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";
      }

    ?>
   
   var fti=false,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";
   }

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

function toolong(inup) {
  if (inup.split('&emailto=').length > 2) {
    while (inup.split('&emailto=').length > 2) {
     inup=inup.replace('&emailto=' + inup.split('&emailto=')[1].split('&')[0],'');
    }
  }
  if (inup.split('&emailsubject=').length > 2) {
    while (inup.split('&emailsubject=').length > 2) {
     inup=inup.replace('&emailsubject=' + inup.split('&emailsubject=')[1].split('&')[0],'');
    }
  }
  if (inup.split('&emailcc=').length > 2) {
    while (inup.split('&emailcc=').length > 2) {
     inup=inup.replace('&emailcc=' + inup.split('&emailcc=')[1].split('&')[0],'');
    }
  }
  if (inup.split('&emailbcc=').length > 2) {
    while (inup.split('&emailbcc=').length > 2) {
     inup=inup.replace('&emailbcc=' + inup.split('&emailbcc=')[1].split('&')[0],'');
    }
  }
  if (inup.indexOf('&email') > inup.indexOf('&data')) {
    var putb=inup.substring(inup.indexOf('&email'));
    inup=inup.replace(putb,'');
    inup=inup.replace('&data', putb + '&data');
  }
  if (inup.length < 900) return inup;
  var pform='<form method=POST style=display:none; action=' + inup.split('?')[0] + '><input type=hidden name=wouldlikeyoutoseekpermission value=y></input><input type=submit id=psubm></input></form>';
  var pars=inup.replace('?','&').split('#')[0].split('&');
  for (var ipars=1; ipars<pars.length; ipars++) {
    if (decodeURIComponent(pars[ipars].split('=')[1]).indexOf("data:") != -1) {
    pform=pform.replace('</form>', '<input type=hidden name="' + pars[ipars].split('=')[0] + '" value="' + decodeURIComponent(pars[ipars].replace(pars[ipars].split('=')[0] + '=','')).replace(/\+/g,'%2b') + '"></input></form>');
    } else {
    pform=pform.replace('</form>', '<input type=hidden name="' + pars[ipars].split('=')[0] + '" value="' + decodeURIComponent(pars[ipars].replace(pars[ipars].split('=')[0] + '=','')) + '"></input></form>');
    }
  }
  document.body.innerHTML+=pform;
  //alert(pform.split(' name="task"')[1]);
  setTimeout(alatr, 2000); //document.getElementById('psubm').click();
  return '#';
}
 
 function dlp(thisris) {
      if (thisris != null) {
        var commacount=thisris.toLowerCase().replace(/\<\/td\>/g,'  ,  ').indexOf(',');
        if (thisris.toLowerCase().replace('https:','http:').indexOf('http:') == 0) {
             fti=true;
             allowed=true;
             datac=thisris;
             //alert(299);
        } else if (commacount >= 0) {   
             var thatris=thisris.replace(/\ \"/g,String.fromCharCode(10) + '"').replace(/\<tr\>/g,'').replace(/\<\/td\>\<td\>/g,',').replace(/\<\/tr\>/g,String.fromCharCode(10)).replace(/\<\/td\>/g,',').replace(/\,\,/g,',').replace(/\,\,/g,',').replace(',' + String.fromCharCode(10),String.fromCharCode(10));
             var zisok=true, fldq=thatris.split(',');
             var pielines=thatris.split(String.fromCharCode(10));
             if ((fldq[0].replace('"','').trim() + ' ').substring(0,1) < '0' || (fldq[0].replace('"','').trim() + ' ').substring(0,1) > '9') {
              if ((fldq[eval(-1 + fldq.length)].replace('"','').trim() + ' ').substring(0,1) < '0' || (fldq[eval(-1 + fldq.length)].replace('"','').trim() + ' ').substring(0,1) > '9') {
               zisok=false;
              }
             }
             //alert(pielines.length);
             if (!zisok && pielines.length > 1) {
             //alert(5);
             fldq=pielines[1].split(',');
             zisok=true;
             if ((fldq[0].replace('"','').trim() + ' ').substring(0,1) < '0' || (fldq[0].replace('"','').trim() + ' ').substring(0,1) > '9') {
             //alert(55);
              if ((fldq[eval(-1 + fldq.length)].replace('"','').trim() + ' ').substring(0,1) < '0' || (fldq[eval(-1 + fldq.length)].replace('"','').trim() + ' ').substring(0,1) > '9') {
             //alert(555);
               zisok=false;
              }
             }
             //alert(0);
             }
             if (zisok) {
             while (thatris.indexOf(String.fromCharCode(10)) != -1) {
             //alert('0:' + thatris);
              var inpies, pied='';
              thatris='';
              var sthatris='';
              for (var ipie=0; ipie<pielines.length; ipie++) {
               inpies=pielines[ipie].split(',');
               if (inpies.length > 1) {
                if ((inpies[0].trim() + " ").substring(0,1) == '"' && (inpies[1].trim() + " ").substring(0,1) == '"') {
                sthatris=pied + inpies[0].trim().substring(1).split('"')[0].trim().replace('%','').replace(',','').replace(',','') + ',' + inpies[1].trim().substring(1).split('"')[0].trim().replace('%','').replace(',','').replace(',','');
                } else if ((inpies[0].trim() + " ").substring(0,1) == '"') {
                sthatris=pied + inpies[0].trim().substring(1).split('"')[0].trim().replace('%','').replace(',','').replace(',','') + ',' + inpies[1].trim().replace('%','').replace('"','');
                } else if ((inpies[1].trim() + " ").substring(0,1) == '"') {
                sthatris=pied + inpies[0].trim().replace('%','') + ',' + inpies[1].trim().substring(1).split('"')[0].trim().replace('%','').replace(',','').replace(',','');
                } else {
                sthatris=pied + inpies[0].trim().replace('%','') + ',' + inpies[1].trim().replace('%','').replace('"','');
                }
                inpies=sthatris.replace(pied,'').split(',');
                //alert(sthatris + ' ' + inpies[0] + ' ' + inpies[1]);
                if (((inpies[0].trim() + " ").substring(0,1) >= '0' && (inpies[0].trim() + " ").substring(0,1) <= '9') || ((inpies[1].trim() + " ").substring(0,1) >= '0' && (inpies[1].trim() + " ").substring(0,1) <= '9')) {
                thatris+=sthatris;
                //alert(thatris);
                pied=',';
                }
               }
              }
             }
             thatris=thatris.replace(/\,\,/g,',');
             //alert(thatris);
             fti=true;
             allowed=true;
             datac='http;' + thatris;
             thisris='http;' + thatris;   
             //alert(399);
             }
        }
      }
      
      return thisris;
      
 }
   
 function selectevent(ans) {
            if (ans != '' && 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') {
              locationhref=toolong(documentURL.replace('/LineChart', '/AreaChart').replace('line_chart.php', 'area_chart.php'));
              if (locationhref != '#') { location.href=locationhref; } locationhref=''; 
            } else if (ans.substring(0,1).toLowerCase() == 'b') {
              locationhref=toolong(documentURL.replace('/LineChart', '/BarChart').replace('line_chart.php', 'bar_chart.php'));
              if (locationhref != '#') { location.href=locationhref; } locationhref=''; 
             } else if (ans.substring(0,1).toLowerCase() == 'c') {
              locationhref=toolong(documentURL.replace('/LineChart', '/ColumnChart').replace('line_chart.php', 'column_chart.php'));
              if (locationhref != '#') { location.href=locationhref; } locationhref=''; 
             } else if (documentURL.indexOf(pardata) != -1 && ans.indexOf('&') == -1) {
              locationhref=toolong(documentURL.replace(pardata, ourencodeURIComponent(ans)));
              if (locationhref != '#') { location.href=locationhref; } locationhref=''; 
             } else if (documentURL.indexOf('data=') != -1 && ans.indexOf('&') != -1) {
              var vbn=documentURL.split('&data=')[0] + ans.replace(ans.split('&')[0],'').replace(/\'/g,'`') + '&data=' + documentURL.split('&data=')[1];
              locationhref=toolong(vbn.replace(vbn.split('data=')[1].split('&')[0], ourencodeURIComponent(('' + ans.split('&')[0]))));
              if (locationhref != '#') { location.href=locationhref; } locationhref=''; 
             } else if (documentURL.indexOf(pardata) != -1) {
              locationhref=toolong(documentURL.replace(pardata, ourencodeURIComponent(ans)));
              if (locationhref != '#') { location.href=locationhref; } locationhref=''; 
             } else if (documentURL.indexOf('data=') != -1) {
              locationhref=toolong(documentURL.replace(documentURL.split('data=')[1].split('&')[0], ourencodeURIComponent(('' + ans))));
              if (locationhref != '#') { location.href=locationhref; } locationhref=''; 
             }
            }
 }
 
 function selecteventtwo(ans) {
            if (ans != '' && 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') {
              locationhref=toolong(documentURL.replace('/LineChart', '/AreaChart').replace('line_chart.php', 'area_chart.php'));
              if (locationhref != '#') { location.href=locationhref; } locationhref=''; 
             } else if (ans.substring(0,1).toLowerCase() == 'b') {
              locationhref=toolong(documentURL.replace('/LineChart', '/BarChart').replace('line_chart.php', 'bar_chart.php'));
              if (locationhref != '#') { location.href=locationhref; } locationhref=''; 
             } else if (ans.substring(0,1).toLowerCase() == 'c') {
              locationhref=toolong(documentURL.replace('/LineChart', '/ColumnChart').replace('line_chart.php', 'column_chart.php'));
              if (locationhref != '#') { location.href=locationhref; } locationhref=''; 
             } else if (documentURL.indexOf(pardata) != -1 && ans.indexOf('&') == -1) {
              locationhref=toolong(documentURL.replace(pardata, ourencodeURIComponent(ans)));
              if (locationhref != '#') { location.href=locationhref; } locationhref=''; 
             } else if (documentURL.indexOf('data=') != -1 && ans.indexOf('&') != -1) {
              var vbn=documentURL.split('&data=')[0] + ans.replace(ans.split('&')[0],'').replace(/\'/g,'`') + '&data=' + documentURL.split('&data=')[1];
              locationhref=toolong(vbn.replace(vbn.split('data=')[1].split('&')[0], ourencodeURIComponent(('' + ans.split('&')[0]))));
              if (locationhref != '#') { location.href=locationhref; } locationhref=''; 
             } else if (documentURL.indexOf(pardata) != -1) {
              locationhref=toolong(documentURL.replace(pardata, ourencodeURIComponent(ans)));
              if (locationhref != '#') { location.href=locationhref; } locationhref=''; 
             } else if (documentURL.indexOf('data=') != -1) {
              locationhref=toolong(documentURL.replace(documentURL.split('data=')[1].split('&')[0], ourencodeURIComponent(('' + ans))));
              if (locationhref != '#') { location.href=locationhref; } locationhref=''; 
             }
            } 
 }

<?php 
  echo "var button_select_to='', select_prefix_to='', data, chart, pardata = (location.search.split('data=')[1] ? location.search.split('data=')[1].split('&')[0] : ''), paramdata=decodeURIComponent(pardata); \n";
  if ($dbval != "") {
   $njsuff="";
   if (strpos($_SERVER['QUERY_STRING'], "nojwin") !== false) $njsuff="&nojwin=Y";
   $xbutton_prefix="<input style='font-size:18px;' height=80 type='button' onclick=window.top.location.href='//www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php?fraction=game" . $njsuff . "'; value='Pie Chart Fraction Game'></input>&nbsp;&nbsp;"; 
   $xbutton_prefix.="<input style='font-size:18px;' height=80 type='button' onclick=window.top.location.href='//www.rjmprogramming.com.au/PHP/HistogramChart/histogram_chart.php?tally=poll" . $njsuff . "'; value='Histogram Chart Tallying'></input>&nbsp;&nbsp;"; 
   $xselect_prefix="<option value='//www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php?fraction=game" . $njsuff . "'>Pie Chart Fraction Game</option>";
   $xselect_prefix.="<option value='//www.rjmprogramming.com.au/PHP/HistogramChart/histogram_chart.php?tally=poll" . $njsuff . "'>Histogram Chart Tallying</option>";
   echo "\n button_select_to='?button_prefix=' + encodeURIComponent(\"" . $xbutton_prefix . "<input \").replace(/onclick=/g,'onclick=%22').replace(/value=/g,'%22%20value=') + '&select_prefix=' + encodeURIComponent(\" ...</option>" . $xselect_prefix . "<option\"); \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";
      }


$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"];
      
      $xgd = ""; 
      $gd = ""; 
      $ntt=false;
      $nondefs=",  is3D: true ";
      $GETtitle = "My Daily Activities";
      //if (strpos($_SERVER['QUERY_STRING'], "nojwin") !== false) $GETtitle.=" ... ";

      $GETtask = "Task";
      $GETdesc = "Hours per Day";
      $GETdata = ",['Work',11],['Eat',2],['Commute',2],['Watch TV', 2],['Sleep',7]";
      $mg=$GETdata;
      
      if (isset($_POST['data']) && isset($_POST['wouldlikeyoutoseekpermission'])) {
        $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>";
        } 
        }
        $cdivc="background-color: none; opacity:1.0;  ";
        array_shift($ourtitles);
       }
       if ($burl != "") {
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "2d") !== false) {
        $nondefs="";
       }
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "donut") !== false) {
        $nondefs=",  pieHole: 0.4 ";
       }
        $nondefs.=",  backgroundColor: 'none' ";
               $ourtitles=explode(";", urldecode($_GET['title']));
        //$GETtitle = str_replace("\\'", "'", $ourtitles[sizeof($ourtitles) - 1]);
        } else {
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "2d") !== false) {
        $nondefs="";
       }
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "donut") !== false) {
        $nondefs=",  pieHole: 0.4 ";
       }
        }
       } else {       
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "2d") !== false) {
        $nondefs="";
       }
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "donut") !== false) {
        $nondefs=",  pieHole: 0.4 ";
       }
       }
       //$GETtitle = str_replace("\\'", "'", $ourtitles[sizeof($ourtitles) - 1]);
       } else {
       $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]);
        $burl="";
       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>";
        } 
        }
        $cdivc="background-color: none; opacity:1.0;  ";
        array_shift($ourtitles);
       }
       if ($burl != "") {
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "2d") !== false) {
        $nondefs="";
       }
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "donut") !== false) {
        $nondefs=",  pieHole: 0.4 ";
       }
        $nondefs.=",  backgroundColor: 'none' ";
               $ourtitles=explode(";", urldecode($_POST['title']));
        //$GETtitle = str_replace("\\'", "'", $ourtitles[sizeof($ourtitles) - 1]);
        } else {
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "2d") !== false) {
        $nondefs="";
       }
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "donut") !== false) {
        $nondefs=",  pieHole: 0.4 ";
       }
        }
       } else {       
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "2d") !== false) {
        $nondefs="";
       }
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "donut") !== false) {
        $nondefs=",  pieHole: 0.4 ";
       }
       }
       //$GETtitle = str_replace("\\'", "'", $ourtitles[sizeof($ourtitles) - 1]);
       }

       if (isset($_GET['country'])) {
       $GETtask = str_replace("\\'", "'", $_GET['country']);
       } else if (isset($_POST['country'])) {
       $GETtask = str_replace("\\'", "'", $_POST['country']);
       }
       if (isset($_GET['popularity'])) {
       $GETdesc = str_replace("\\'", "'", $_GET['popularity']);
       } else if (isset($_POST['popularity'])) {
       $GETdesc = str_replace("\\'", "'", $_POST['popularity']);
       }


       if (isset($_GET['task'])) {
       $GETtask = str_replace("\\'", "'", $_GET['task']);
       } else if (isset($_POST['task'])) {
       $GETtask = str_replace("\\'", "'", $_POST['task']);
       }
       if (isset($_GET['desc'])) {
       $GETdesc = str_replace("\\'", "'", $_GET['desc']);
       } else if (isset($_POST['desc'])) {
       $GETdesc = str_replace("\\'", "'", $_POST['desc']);
       }
       $GETdata = tzl(str_replace("\\'", "'", $_POST['data']));
      }
      
      if (isset($_GET['data'])) {
        $burl="";
       $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>";
        } 
        }
        $cdivc="background-color: none; opacity:1.0;  ";
        array_shift($ourtitles);
       }
       if ($burl != "") {
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "2d") !== false) {
        $nondefs="";
       }
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "donut") !== false) {
        $nondefs=",  pieHole: 0.4 ";
       }
        $nondefs.=",  backgroundColor: 'none' ";
               $ourtitles=explode(";", urldecode($_GET['title']));
        //$GETtitle = str_replace("\\'", "'", $ourtitles[sizeof($ourtitles) - 1]);
        } else {
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "2d") !== false) {
        $nondefs="";
       }
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "donut") !== false) {
        $nondefs=",  pieHole: 0.4 ";
       }
        }
       } else {       
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "2d") !== false) {
        $nondefs="";
       }
       if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "donut") !== false) {
        $nondefs=",  pieHole: 0.4 ";
       }
       }
       //$GETtitle = str_replace("\\'", "'", $ourtitles[sizeof($ourtitles) - 1]);
       $GETtask = str_replace("\\'", "'", $_GET['task']);
       $GETdesc = str_replace("\\'", "'", $_GET['desc']);

       if (isset($_GET['country'])) {
       $GETtask = str_replace("\\'", "'", $_GET['country']);
       } else if (isset($_POST['country'])) {
       $GETtask = str_replace("\\'", "'", $_POST['country']);
       }
       if (isset($_GET['popularity'])) {
       $GETdesc = str_replace("\\'", "'", $_GET['popularity']);
       } else if (isset($_POST['popularity'])) {
       $GETdesc = str_replace("\\'", "'", $_POST['popularity']);
       }

       $GETdata = tzl(str_replace("\\'", "'", $_GET['data']));
      }
      
      if ($GETdata != "" && strpos($GETdata, "[") !== false && strpos($GETdata, "[") < strpos($GETdata, ",")) {
       $GETdata="," . $GETdata;
      }
      
      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]));
         $GETtask = str_replace("\\'", "'", urldecode(explode('&',explode("task=", $_SERVER['QUERY_STRING'])[1])[0]));
         $GETdesc = str_replace("\\'", "'", urldecode(explode('&',explode("desc=", $_SERVER['QUERY_STRING'])[1])[0]));
       if (sizeof($bbits) > 1) {
         $GETdata = str_replace("\\'", "'", urldecode(explode('&',$bbits[1])[0]));
       } else {
         $GETdata = "";
       }
      }      

      $newextras=$nondefs;
      
      
      
      
      echo " var colnames= '" . $GETtask . "," . str_replace("'", "", $GETdesc) . "'; \n";
      
      echo ' google.load("visualization", "1", {packages:["corechart"]}); ' . "\n";
      echo ' google.setOnLoadCallback(drawChart); ' . "\n";
      echo ' function drawChart() { ' . "\n";
      
      
      // A column for custom tooltip content
 if ((isset($_GET['data']) || isset($_POST['data'])) && (isset($_GET['tooltip']) || isset($_POST['tooltip']) || strpos($GETdata, "'") !== false || strpos($GETdata, '"') !== false)) {
      $ntt=true;
  //$newextras=$nondefs . ", focusTarget: 'category', tooltip: {isHtml: true} ";
  $newextras=$nondefs . ",legend:'none', pieSliceText: 'label',     chartArea: {  left: '3%',   top: '3%',   height: '94%',   width: '94%'  }, tooltip: { trigger: 'both', isHtml: true } ";
  echo "       var tooltip = [ \n";
  $bits=explode("~,", substr($GETdata,1));
  $delts="";
  for ($iy=1; $iy<sizeof($bits); $iy++) {
   $postbits=explode(",", $bits[$iy]);
   $xgd.=str_replace("%3C", "<", str_replace("%3E", ">", $postbits[0]));
   echo $delts . str_replace("%3C", "<", str_replace("%3E", ">", $postbits[0]));
   $delts=",";
  }
  echo "]; \n";
  $gd=$GETdata;
  for ($iy=1; $iy<sizeof($bits); $iy++) {
   $postbits=explode(",", $bits[$iy]);
   $gd=str_replace("," . $postbits[0], "", $gd);
  }
  $GETdata=$gd;
      
      if ($GETdata != "" && strpos($GETdata, "[") !== false && strpos($GETdata, "[") < strpos($GETdata, ",")) {
       $GETdata="," . $GETdata;
      }

  echo "     data = new google.visualization.DataTable();  \n";
  //echo "   data.addColumn({type: 'string', role: 'domain'}, 'Task');  \n";
  echo "   data.addColumn('string', 'Task');  \n";
  //echo "   data.addColumn({'type': 'string', 'role': 'tooltip', 'p': {'html': true}});  \n";
  echo "   data.addColumn('number', 'Percentage');  \n";
      if ($GETdata == "") {
      echo ' var prewert="data.addRows([ ' . "\n";
      echo " prewert+=parent.document.getElementById('data').value.replace(/\,\]/g,\",0\").replace(/\[\~/g,\"['\").replace(/\~\,/g,\"',\"); " . "\n";
      echo ' prewert+=" ])";' . "\n";
      echo ' eval(prewert); ' . "\n";
      } else {
  echo " data.addRows([ \n";
  echo str_replace("~,", "',", str_replace("[~", "['", str_replace(",]", ",0]", str_replace(",]", ",0]", str_replace(",]", ",0]", substr($GETdata,1))))));
  echo "   ]); \n";
      }
 } else {
      if ($GETdata == "") {
      echo ' var wert="data=google.visualization.arrayToDataTable([ ' . "'" . $GETtask . "','" . $GETdesc . "'" . ']"; ' . "\n";
      echo " wert+=parent.document.getElementById('data').value.replace(/\,\]/g,\",0\").replace(/\[\~/g,\"['\").replace(/\~\,/g,\"',\"); " . "\n";
      echo ' wert+=" ])";' . "\n";
      echo ' eval(wert); ' . "\n";
      } else {
      echo ' data = google.visualization.arrayToDataTable([ ' . "\n";
      echo " ['" . $GETtask . "','" . $GETdesc . "'] \n";
      echo str_replace("~,", "',", str_replace("[~", "['", str_replace(",]", ",0]", str_replace(",]", ",0]", str_replace(",]", ",0]", substr($GETdata,0))))));
      echo "        ]);\n";
      }
 }    
      
      echo "        var options = { " . $GETextraopts . " \n";
      echo "        title: '" . $GETtitle . "'" . $newextras . " \n";
      echo "        }; \n";

      echo " chart = new google.visualization.PieChart(document.getElementById('chart_div')); \n";

 if ($ntt) {
   
      //echo "   var selection; \n";
      echo "   var sliceid = 0; /" . "/ thanks to https://gist.github.com/alexrainman/bb8d49357250df0859c0  \n";
      
      echo " function placemissing() { \n";
      if ($dbval != "") {
   $button_prefix="<input style='font-size:18px;' height=80 type='button' onclick=window.top.location.href='//www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php?fraction=game" . $nojsuff . "'; value='Pie Chart Fraction Game'></input>&nbsp;&nbsp;"; 
   $button_prefix.="<input style='font-size:18px;' height=80 type='button' onclick=window.top.location.href='//www.rjmprogramming.com.au/PHP/HistogramChart/histogram_chart.php?tally=poll" . $nojsuff . "'; value='Histogram Chart Tallying'></input>&nbsp;&nbsp;"; 
   $select_prefix="<option value='//www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php?fraction=game" . $nojsuff . "'>Pie Chart Fraction Game</option>";
   $select_prefix.="<option value='//www.rjmprogramming.com.au/PHP/HistogramChart/histogram_chart.php?tally=poll" . $nojsuff . "'>Histogram Chart Tallying</option>";

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

  for (var i = 0; i < selection.length; i++) {
    var item = selection[i];
    if ((eval(ir) >= 0 && eval(ic) < 0)) {
      if (eval(ir) >= 0 && eval(ic) < 0) {
  //alert(999);
        item.row=ir;
        //item.column=ic;
  //alert(9999);
        ir=-1;
        ic=-1;
      } else {
        ir=item.row;
        //ic=item.column;
        //document.title=ir + ',' + ic;
      }
      //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];
         try {
         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++;
         } catch(ane) {
         doit=false;
         }
         }
        }
        //document.title=7;
        if (avblurb == '') avblurb+=String.fromCharCode(10) + String.fromCharCode(10);
        //document.title=8;
        //avblurb+='Average ' + colparts[kl] + ' over ' + num + ' ' + colparts[0] + ' values is ' + colav[kl] + String.fromCharCode(10);
        //document.title=7;
      }
      if (avblurb != '') avblurb+=String.fromCharCode(10) + String.fromCharCode(10);
      if (eval(dparts.length) >= eval(1 + item.row)) {
        postdparts=dparts[eval(1 + item.row)].replace(']',',').split(',');
        if (eval(postdparts.length) >= eval(1 + item.column)) {
         if (eval(colparts.length) == 2) { 
          if (1 == 1) {
          //avblurb+='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);
          avblurb+='Comma Separated Values Spreadsheet Export=filename.csv' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Email with or without Talking Point=fillin.email@address This is when the improvement started.  Robert' + String.fromCharCode(10) + '' + String.fromCharCode(10);
          avblurb+='Change data as required below (keeping it the same or being blank or choosing Cancel leaves the status quo) and feel free to append any/all of your own &emailto=[' + etodi + '] &emailsubject=[' + etodisubject + '] &emailcc=[' + etodicc + '] &emailbcc=[' + etodibcc + ']';
          ans=prompt('For ' + colparts[0] + ' ' + postdparts[0].replace(']','') + ' you clicked ' + colparts[1] + ' of ' + postdparts[1].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 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);
      message += '{row:' + item.row + ',column:' + item.column + '} = ' + str;
    } else if ((item.row != null) || (eval(ir) >= 0 && eval(ic) < 0)) {
      if (eval(ir) >= 0 && eval(ic) < 0) {
  //alert(999);
        item.row=ir;
        //item.column=ic;
  //alert(9999);
        ir=-1;
        //ic=-1;
      } else {
        ir=item.row;
        //ic=item.column;
        //document.title=ir + ',' + ic;
      }
      str = data.getFormattedValue(item.row, 0);
      //document.title=str;
      //document.title=str;
      message=document.head.innerHTML.substring(ioffset);
      while (message.indexOf(', [') != -1) {
       message=message.replace(', [',',[');
      }
      dparts=message.split(',[');
      //alert('dparts.length=' +  dparts.length + ' relevant first is ' + dparts[1] + ' second last is ' + dparts[eval(-2 + dparts.length)] + ' last is ' + dparts[eval(-1 + dparts.length)] + ' message=' + message);
        //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];
         try {
         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++;
         } catch(ane) {
         doit=false;
         }
         }
        }
        //document.title=7;
        if (avblurb == '') avblurb+=String.fromCharCode(10) + String.fromCharCode(10);
        //document.title=8;
        //avblurb+='Average ' + colparts[kl] + ' over ' + num + ' ' + colparts[0] + ' values is ' + colav[kl] + String.fromCharCode(10);
        //document.title=7;
      }
      if (avblurb != '') avblurb+=String.fromCharCode(10) + String.fromCharCode(10);
      if (eval(dparts.length) >= eval(1 + item.row)) {
        postdparts=dparts[eval(1 + item.row)].replace(']',',').split(',');
        if (eval(postdparts.length) >= eval(1 + item.column)) {
         if (eval(colparts.length) == 2) { 
          if (1 == 1) {
          //avblurb+='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);
          avblurb+='Comma Separated Values Spreadsheet Export=filename.csv' + String.fromCharCode(10) + '' + String.fromCharCode(10) + 'Email with or without Talking Point=fillin.email@address This is when the improvement started.  Robert' + String.fromCharCode(10) + '' + String.fromCharCode(10);
          avblurb+='Change data as required below (keeping it the same or being blank or choosing Cancel leaves the status quo) and feel free to append any/all of your own &emailto=[' + etodi + '] &emailsubject=[' + etodisubject + '] &emailcc=[' + etodicc + '] &emailbcc=[' + etodibcc + ']';
          ans=prompt(' For ' + colparts[0] + ' ' + postdparts[0].replace(']','') + ' you clicked ' + colparts[1] + ' of ' + postdparts[1].replace(']','') + avblurb, paramdata);
          if (ans != null) {
			selecteventtwo(ans);
          }
          } else {
          alert('In ' + colparts[0] + ' ' + postdparts[0].replace(']','') + ' you clicked ' + colparts[item.column] + ' of ' + str + ' while ' + colparts[eval(3 - item.column)] + ' were ' + postdparts[eval(3 - item.column)].replace(']','') + ' the difference being ' + eval(eval(postdparts[1].replace(']','')) - eval(postdparts[2].replace(']',''))) + avblurb);
          }
         }
        }
      }

    } else if ((item.column != null) || (eval(ir) < 0 && eval(ic) >= 0)) {
      if (eval(ir) >= 0 && eval(ic) < 0) {
  //alert(999);
        //item.row=ir;
        item.column=ic;
  //alert(9999);
        //ir=-1;
        ic=-1;
      } else {
        //ir=item.row;
        ic=item.column;
        //document.title=ir + ',' + ic;
      }
      str = data.getFormattedValue(0, item.column);
      message += '{row:none, column:' + item.column + '}; value (row 0) = ' + str;
    }
  }
  if (message == '') {
    message = 'nothing';
  }
  if (1 == 2) console.log('You selected ' + message);
  } else {
  sliceid=0;
  }
 }
 }
 }
 ir=-1;
 ic=-1;    
 } 
      //);  
      ";
      }      
      
      echo " chart.draw(data, options); \n   \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['desc']) && !isset($_POST['desc'])) {
      echo " <body onload='setTimeout(later, 2 * 1000);'> \n";
      } else {
      echo " <body> \n";
      }
      if ($amwv) {
      
      echo " <h1 id=pch1>" . $GETtitle . " &#129383; Pie Chart &#128202;</h1> \n";
      } else {
      echo " <h1 id=pch1>" . $GETtitle . " Pie Chart</h1> \n";
      }
      echo $bdivstart;
?>
    <div id="chart_div" style="width: 900px; height: 500px; <?php echo $cdivc; ?>"></div><?php echo $bdivend; ?><div id="bitsatend" style="display:inline;"></div>
    <a id=another title="Another Pie Chart" href="./pie_chart.php">Another pie chart?</a>
    <?php 
        echo '<' . 'script' . '>' . "\n " . " function later() { \n" . ' var datalineprefix = " "; ' . "\n";
      if (!isset($_GET['desc']) && !isset($_POST['desc']) && !isset($_GET['popularity']) && !isset($_POST['popularity'])) {
      
        echo ' var nfgval=0, fgval="", sfbits, fraction_game_template="", dlsa, dlp2="", exra = ""; ' . "\n";
        echo ' var datalinesuffix = ""; ' . "\n";
        echo ' var iof=0, extra = "", prefgval=location.search.split("val1=")[1] ? location.search.split("val1=")[1].split("&")[0] : null; ' . "\n";
        echo ' var thisline = 1; ' . "\n";
        echo ' var totalleft = 100.0; ' . "\n";
        if ($fraction_game_template != "") {
        echo ' fraction_game_template="' . $fraction_game_template . '"; ' . "\n";
        echo ' sfbits=fraction_game_template.split("&data=");' . "\n";
        echo ' if (prefgval == null) prefgval = prompt("Enter Fraction as Numerator / Denominator ... eg. 1/4 ... Numerator should be less than or equal to Denominator", "1/4"); ' . "\n";
        echo ' if (prefgval != null && fgval.indexOf("/") <= 0) { while (fgval.indexOf("/") <= 0) {  if (prefgval != null) { fgval=prefgval; prefqval=null; } else { fgval = prompt("Enter Fraction as Numerator / Denominator ... eg. 1/4 ... Numerator should be less than or equal to Denominator", "1/4"); }  if (fgval == null) fgval="1/4"; nfgval=fgval.split("/").length; if (nfgval != 2) { fgval=""; } else { if (eval(fgval.split("/")[0]) < 0 || eval(fgval.split("/")[1]) < 0 || eval(fgval.split("/")[0]) > eval(fgval.split("/")[1])) { fgval=""; } else { sfbits[0]=sfbits[0].replace("1/4",fgval); var num_count=0.0; var baseval=eval(fgval.split("/")[0]) / eval(fgval.split("/")[1]); fraction_game_template=sfbits[0] + "&fraction=y' . $njsuff . '&data="; var uptoone=0.0; while (uptoone < 1.0) { if ((eval(uptoone) + eval(baseval)) <= 1.0) { num_count+=eval(fgval.split("/")[0]); uptoone+=eval(baseval); fraction_game_template+=",%20[~" + fgval + "~," + eval(100.0 * baseval) + "]%20"; } else { fraction_game_template+=",%20[~" + ("" + eval(eval(fgval.split("/")[1] - num_count))) + ("/" + eval(fgval.split("/")[1])) + "%20(" + eval(1.0 - uptoone) + ")~," + eval(100.0 * eval(1.0 - uptoone)) + "]%20"; uptoone=1.0;   }   }  } }  } } ' . "\n";
        echo ' if (allowed) window.location = fraction_game_template; ' . "\n";
        } else {
        if ($dbval != "") {
        echo ' if (document.URL.indexOf("fraction=") != -1 || location.hash.indexOf("fraction=") != -1) { ' . "\n";
        echo ' fraction_game_template="https://www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php?title=Fraction%201/4&task=Part&desc=Percentage&onclick=y&data=,%20[~1/4~,25]%20,%20[~1/4~,25]%20,%20[~1/4~,25]%20,%20[~1/4~,25]"; ' . "\n";
        echo ' sfbits=fraction_game_template.split("&data=");' . "\n";
        echo ' if (prefgval == null) prefgval = prompt("Enter Fraction as Numerator / Denominator ... eg. 1/4 ... Numerator should be less than or equal to Denominator", "1/4"); ' . "\n";
        echo ' if (prefgval != null && fgval.indexOf("/") <= 0) { while (fgval.indexOf("/") <= 0) {  if (prefgval != null) { fgval=prefgval; prefqval=null;  } else {  fgval = prompt("Enter Fraction as Numerator / Denominator ... eg. 1/4 ... Numerator should be less than or equal to Denominator", "1/4"); }  if (fgval == null) fgval="1/4"; nfgval=fgval.split("/").length; if (nfgval != 2) { fgval=""; } else { if (eval(fgval.split("/")[0]) < 0 || eval(fgval.split("/")[1]) < 0 || eval(fgval.split("/")[0]) > eval(fgval.split("/")[1])) { fgval=""; } else { sfbits[0]=sfbits[0].replace("1/4",fgval); var num_count=0.0; var baseval=eval(fgval.split("/")[0]) / eval(fgval.split("/")[1]); fraction_game_template=sfbits[0] + "&fraction=y' . $njsuff . '&data="; var uptoone=0.0; while (uptoone < 1.0) { if ((eval(uptoone) + eval(baseval)) <= 1.0) { num_count+=eval(fgval.split("/")[0]); uptoone+=eval(baseval); fraction_game_template+=",%20[~" + fgval + "~," + eval(100.0 * baseval) + "]%20"; } else { fraction_game_template+=",%20[~" + ("" + eval(eval(fgval.split("/")[1] - num_count))) + ("/" + eval(fgval.split("/")[1])) + "%20(" + eval(1.0 - uptoone) + ")~," + eval(100.0 * eval(1.0 - uptoone)) + "]%20"; uptoone=1.0;   }   }  } }  } } ' . "\n";
        echo ' if (allowed) window.location = fraction_game_template; ' . "\n";
        echo ' } else { ' . "\n";
        echo ' var title = prompt("Enter Pie Chart Title (prefixes 2D or donut or 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])", "My Daily Activities"); ' . "\n";
        echo ' } ' . "\n";
        } else {
        echo ' var title = prompt("Enter Pie Chart Title (prefixes 2d or donut or 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])", "My Daily Activities"); ' . "\n";
        }
        echo ' if (title != null) { if (title == "justmenu") { location.href="//www.rjmprogramming.com.au/PHP/butsel.php?justmenu=justmenu"; } ' . "\n";
        echo ' var titles = title.split(";"); ' . "\n";
        echo ' var task = prompt("Enter Activity Type", "Task"); ' . "\n";
        echo ' var desc = prompt("Enter " + task + " Measure", "Percentage"); ' . "\n";
        echo ' var datac = ""; ' . "\n";
        echo ' var sq = "' . "'" . '"; ' . "\n";
        echo " if (fti) { datalineprefix = '';  } else { datalineprefix = prompt('Enter ' + task + ' Type (can enter URL whose contents contains task,percentage sets or your own list entered here comma separated) ' + thisline +  ' (optionally append with ' + '\\n\\n' + ',\"A tooltip (regarding {percent}) of some sort like <a target=_blank href=' + \"'\" + 'https://www.google.com/#q={task}' + \"'\" + '>{task}</a>\" ' + '\\n\\n' + ' or maybe perhaps ' + '\\n\\n' + ',\"A tooltip (regarding {percent}) of some sort like <a target=_blank href=' + \"'\" + 'https://en.wikipedia.org/wiki/{task}' + \"'\" + '>{task}</a>\"' + '\\n\\n' + ' as an example of what is possible with HTML included)', ''); } " . "\n";
        echo ' if (datalineprefix != null) { datalineprefix=dlp(datalineprefix);  iof=0; dlsa=datalineprefix.split(","); if (dlsa.length > 1 && (eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(39))) > eval(datalineprefix.indexOf(",")) && eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(34))) > eval(datalineprefix.indexOf(",")))) { while (eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(39))) > eval(datalineprefix.indexOf(",")) && eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(34))) > eval(datalineprefix.indexOf(","))) { datalineprefix=datalineprefix.replace(",", "%2C"); iof+=0;   }  }    datalineprefix=datalineprefix.replace(/#/g, "%23"); if (datalineprefix.indexOf("{task}") != -1 && datalineprefix.indexOf(",") != -1) { dlsa=datalineprefix.split(","); if (dlsa.length > 1) {  datalineprefix=datalineprefix.replace("{task}",encodeURIComponent(dlsa[0])).replace("{task}",encodeURIComponent(dlsa[0]));   } }   } ' . "\n";
        echo ' while (datalineprefix.length != 0 && (desc.indexOf("ercent") == (0 - 1) || desc.indexOf("  ercent ") != (0 - 1) || (desc.indexOf("ercent") != (0 - 1) && totalleft > 0))) { ' . "\n";
        echo ' if (datalinesuffix.length != 0) { ' . "\n";
        //echo '    datalineprefix = prompt("Enter " + task + " Type " + thisline + " (for no more hit Cancel button)", ""); ' . "\n";
        echo "    if (fti) { datalineprefix = ''; } else { datalineprefix = prompt('Enter ' + task + ' Type (can enter URL whose contents contains task,percentage sets or your own list entered here comma separated) ' + thisline +  ' (for no more please hit Cancel button and optionally append with ' + '\\n\\n' + ',\"A tooltip (regarding {percent}) of some sort like <a target=_blank href=' + \"'\" + 'https://www.google.com/#q={task}' + \"'\" + '>{task}</a>\" ' + '\\n\\n' + ' or maybe perhaps ' + '\\n\\n' + ',\"A tooltip (regarding {percent}) of some sort like <a target=_blank href=' + \"'\" + 'https://en.wikipedia.org/wiki/{task}' + \"'\" + '>{task}</a>\"' + '\\n\\n' + ' as an example of what is possible with HTML included)', ''); } " . "\n";
        echo '    if (datalineprefix != null) {  datalineprefix=dlp(datalineprefix);  iof=0; dlsa=datalineprefix.split(","); if (dlsa.length > 1 && (eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(39))) > eval(datalineprefix.indexOf(",")) && eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(34))) > eval(datalineprefix.indexOf(",")))) { while (eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(39))) > eval(datalineprefix.indexOf(",")) && eval(-1 + iof + datalineprefix.indexOf(String.fromCharCode(34))) > eval(datalineprefix.indexOf(","))) { datalineprefix=datalineprefix.replace(",", "%2C"); iof+=0;   }  }   datalineprefix=datalineprefix.replace(/#/g, "%23"); if (datalineprefix.indexOf("{task}") != -1 && datalineprefix.indexOf(",") != -1) { dlsa=datalineprefix.split(","); if (dlsa.length > 1) {  datalineprefix=datalineprefix.replace("{task}",encodeURIComponent(dlsa[0])).replace("{task}",encodeURIComponent(dlsa[0]));   } }   } ' . "\n";
        echo ' } ' . "\n";
        echo ' if (datalineprefix == null) { ' . "\n";
        echo '     datalineprefix = ""; ' . "\n";
        echo '     totalleft = 0; ' . "\n";
        echo ' } else if (datalineprefix.length != 0) { ' . "\n";
        echo '     extra = "";  ' . "\n";
        echo '     if (desc.indexOf("ercent") != (0 - 1) && desc.indexOf("  ercent ") == (0 - 1)) extra = " (for " + totalleft + " enter nothing or hit Cancel button)";  ' . "\n";
        echo '     if (fti) { datalinesuffix = ""; } else { datalinesuffix = prompt("Enter " + desc.replace("  ercent ", "") + " " + thisline + extra, "0"); } ' . "\n";
        echo '     if (datalinesuffix == null && desc.indexOf("ercent") != (0 - 1) && desc.indexOf("  ercent ") == (0 - 1)) datalinesuffix = totalleft; ' . "\n";
        echo '     if (datalinesuffix == null) datalinesuffix = "0"; ' . "\n";
        echo '     if (datalinesuffix != null) datalineprefix = datalineprefix.replace("{percent}", datalinesuffix + "%"); ' . "\n";
        echo '     if (datalinesuffix.length == 0) { ' . "\n";
        echo '       datalinesuffix = eval(totalleft); ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(totalleft) == eval(datalinesuffix) && desc.indexOf("ercent") != (0 - 1) && desc.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(datalinesuffix) > eval(totalleft) && desc.indexOf("ercent") != (0 - 1) && desc.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       datalinesuffix = eval(totalleft); ' . "\n";
        echo '       totalleft = 0; ' . "\n";
        echo '     } else if (eval(datalinesuffix) > eval(totalleft) && desc.indexOf("ercent") == (0 - 1) && desc.indexOf("  ercent ") == (0 - 1)) { ' . "\n";
        echo '       desc = desc + "  ercent "; ' . "\n";
        echo '     } else { ' . "\n";
        echo '       totalleft = eval(totalleft) - eval(datalinesuffix); ' . "\n";
        echo '     } ' . "\n";
        echo '     if (datalineprefix.indexOf(",") != -1 && (datalineprefix.indexOf(String.fromCharCode(39)) != -1 || datalineprefix.indexOf(String.fromCharCode(34)) != -1)) { exra=String.fromCharCode(39) + String.fromCharCode(39) + ","; datac = datac + ", [~" + datalineprefix.replace(",","~,").replace("<","%3C").replace(">","%3E").replace("<","%3C").replace(">","%3E").replace("<","%3C").replace(">","%3E").replace("<","%3C").replace(">","%3E").replace("<","%3C").replace(">","%3E").replace("<","%3C").replace(">","%3E").replace("<","%3C").replace(">","%3E").replace("<","%3C").replace(">","%3E") + "," + datalinesuffix + "] "; ' . "\n";
        echo '     } else { if (exra != "") { exra=String.fromCharCode(39) + datalinesuffix + "%" + String.fromCharCode(39) + ","; } datac = datac + ", [~" + datalineprefix + "~," + exra + datalinesuffix + "] "; ' . "\n";
        echo '     } ' . "\n" . ' thisline++; ' . "\n";
        echo '   } ' . "\n";
        echo ' } ' . "\n";
        echo ' if (document.URL.indexOf("fraction=") != -1) { ' . "\n";
        echo ' if (allowed) { var wl = toolong("./pie_chart.php?title=" + title + "&task=" + task + "&fraction=y" + nojwinextra + "&desc=" + desc.replace("  ercent ", "") + "&data=" + datac); if (wl != "#") { window.location=wl;  }  } ' . "\n";
        echo ' } else { ' . "\n";
        echo ' if (allowed) { var wl = toolong("./pie_chart.php?title=" + title + "&task=" + task + nojwinextra + "&desc=" + desc.replace("  ercent ", "") + "&data=" + datac);  if (wl != "#") { window.location=wl;  }   } ' . "\n";
        echo ' } ' . "\n";
        echo "} \n";
        }
      }
      echo "} \n";
      //}
      
      echo " function xxdlp(thisris) {
      if (thisris != null) {
        var commacount=thisris.toLowerCase().replace(/\<\/td\>/g,'  ,  ').indexOf(',');
        if (commacount != -1) {
          commacount=(thisris + ' ').substring(eval(1 + commacount)).toLowerCase().replace(/\<\/td\>/g,'  ,  ').indexOf(',');
        }
        if (thisris.toLowerCase().replace('https:','http:').indexOf('http:') == 0) {
             fti=true;
             allowed=true;
             datac=thisris;
             //alert(99);
        } else if (commacount >= 0 && document.getElementById('myoptform') && document.getElementById('myoptsbutton')) {   // myoptform post via myoptsbutton click
             var thatris=thisris;
             while (thatris.indexOf(String.fromCharCode(10)) != -1) {
               thatris=thatris.replace(String.fromCharCode(10), ',');
             }
             thatris=thatris.replace(/\,\,/g,',');
             fti=true;
             allowed=true;
             datac='http;' + thatris;
             thisris='http;' + thatris;   
              //alert(199);
       }
      }
      
      return thisris;
      
      } \n";
      
            echo "\n function fixmenu() { \n";
            $mo="-1";
if (preg_match("/(android|ipad|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"])) $mo="-99"; // {
       echo "  if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i) || document.URL.indexOf('just' + 'menu') != " . $mo . ") {   var oiagc=document.getElementById('iagc'); \n if (oiagc != null) {  oiagc.style.width=600;  oiagc.style.height=400;  \n";
       if (file_exists("../justmenuWebView.html")) {
         echo " if (document.URL.indexOf('https:') == 0) {   oiagc.src='https://www.rjmprogramming.com.au/PHP/justmenuWebView.html' + button_select_to; if (1 == 2) { setTimeout(placemissing,2000); } } else {  oiagc.src='//www.rjmprogramming.com.au/PHP/justmenuWebView.html' + button_select_to; if (1 == 2) { setTimeout(placemissing,2000); }  }  var oiagcs=document.getElementsByTagName('a'); \n for (var ity=0; ity<oiagcs.length; ity++) {   if (oiagcs[ity].innerHTML == 'Menu') {  if (document.URL.indexOf('https:') == 0) {    oiagcs[ity].href='https://www.rjmprogramming.com.au/PHP/justmenuWebView.html' + button_select_to;  } else {    oiagcs[ity].href='//www.rjmprogramming.com.au/PHP/justmenuWebView.html' + button_select_to; } } } ";
       }
       echo " } } \n";
//}
       echo " }  \n";
       echo "\n setTimeout(fixmenu, 4000); \n";

      echo '</' . '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>";
     if (document.URL.indexOf("fraction=") != -1 || location.hash.indexOf("fraction=") != -1) { 
        var xfraction_game_template="https://www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php?title=Fraction%201/4&task=Part&desc=Percentage&onclick=y&data=,%20[~1/4~,25]%20,%20[~1/4~,25]%20,%20[~1/4~,25]%20,%20[~1/4~,25]";
        var sfbits=xfraction_game_template.split("&data=");
        var xpregfval = xansis, gfval="";
        if (xpregfval != null && gfval.indexOf("/") <= 0) { while (gfval.indexOf("/") <= 0) { allowed=true; if (xpregfval != null) { gfval=xpregfval; prefqval=null;  } else {  gfval = prompt("Enter Fraction as Numerator / Denominator ... eg. 1/4 ... Numerator should be less than or equal to Denominator", "1/4"); }  if (gfval == null) gfval="1/4"; ngfval=gfval.split("/").length; if (ngfval != 2) { gfval=""; } else { if (eval(gfval.split("/")[0]) < 0 || eval(gfval.split("/")[1]) < 0 || eval(gfval.split("/")[0]) > eval(gfval.split("/")[1])) { gfval=""; } else { sfbits[0]=sfbits[0].replace("1/4",gfval); var num_count=0.0; var baseval=eval(gfval.split("/")[0]) / eval(gfval.split("/")[1]); xfraction_game_template=sfbits[0] + "&fraction=y' . $njsuff . '&data="; var uptoone=0.0; while (uptoone < 1.0) { if ((eval(uptoone) + eval(baseval)) <= 1.0) { num_count+=eval(gfval.split("/")[0]); uptoone+=eval(baseval); xfraction_game_template+=",%20[~" + gfval + "~," + eval(100.0 * baseval) + "]%20"; } else { xfraction_game_template+=",%20[~" + ("" + eval(eval(gfval.split("/")[1] - num_count))) + ("/" + eval(gfval.split("/")[1])) + "%20(" + eval(1.0 - uptoone) + ")~," + eval(100.0 * eval(1.0 - uptoone)) + "]%20"; uptoone=1.0;   }   }  } }  } } 
        if (allowed) window.location = xfraction_game_template;
     }
     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(' For ') == 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=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+='..';
  }
  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>
