<?php
  // speech_supervisor.php
  // RJM Programming
  // May, 2018
  // Supervise some https://www.google.com/intl/en/chrome/demos/speech.html Google Speech to Text API interfacings
  //  src="lo_one_new_html_a55d5cbca41d4e81.gif" 

  $maybesaynext="";
  $sayvoices="\n
Alex                en_US\n
Alice               it_IT\n
Alva                sv_SE\n
Amelie              fr_CA\n
Anna                de_DE\n  
Carmit              he_IL\n
Damayanti           id_ID\n
Daniel              en_GB\n
Diego               es_AR\n
Ellen               nl_BE\n
Fiona               en-scotland\n
Fred                en_US\n
Ioana               ro_RO\n
Joana               pt_PT\n
Jorge               es_ES\n
Juan                es_MX\n
Kanya               th_TH\n
Karen               en_AU\n
Kyoko               ja_JP\n
Laura               sk_SK\n
Lekha               hi_IN\n
Luca                it_IT\n
Luciana             pt_BR\n
Maged               ar_SA\n
Mariska             hu_HU\n
Mei-Jia             zh_TW\n
Melina              el_GR\n
Milena              ru_RU\n
Moira               en_IE\n
Monica              es_ES\n
Nora                nb_NO\n
Paulina             es_MX\n
Samantha            en_US\n
Sara                da_DK\n
Satu                fi_FI\n
Sin-ji              zh_HK\n
Tessa               en_ZA\n
Thomas              fr_FR\n
Ting-Ting           zh_CN\n
Veena               en_IN\n
Victoria            en_US\n
Xander              nl_NL\n
Yelda               tr_TR\n
Yuna                ko_KR\n
Yuri                ru_RU\n
Zosia               pl_PL\n
Zuzana              cs_CZ\n
";

  $sayprefix="";
  $togo="<b>Translations from English can happen choosing Language first.</b>";
  $stylestuff="";
  $wsb="";
  $qqhval='';
  $langcode='';
  $langsuffix='';
  $htmltop="<!DOCTYPE html><html lang='en'>";
  $origlangchange=" lang='en'>";
  $langchange=$origlangchange;
  $zt=@file_get_contents("HTTP://www.rjmprogramming.com.au/PHP/ziptest.php");
  file_put_contents("zt.htm", $zt);
  if (isset($_GET['thelang'])) {
    if (strlen($_GET['thelang']) > 0) {
      $langcode=urldecode($_GET['thelang']);
      $sayps=explode(" " . strtolower($langcode) . "_", $sayvoices);
      if (sizeof($sayps) > 1) {
        $sayprefix="-v " . trim(explode("\n", $sayps[0])[-1 + sizeof(explode("\n", $sayps[0]))]) . " ";
      }
      $langsuffix='&thelang=' . $_GET['thelang'];
      $htmltop="<!DOCTYPE html><html lang='" . urldecode($_GET['thelang']) . "'>";
      $langchange=" lang='" . urldecode($_GET['thelang']) . "'>";
      $togo="";
    }
  } else if (isset($_POST['thelang'])) {
    if (strlen($_POST['thelang']) > 0) {
      $langcode=urldecode($_POST['thelang']);
      $sayps=explode(" " . strtolower($langcode) . "_", $sayvoices);
      if (sizeof($sayps) > 1) {
        $sayprefix="-v " . trim(explode("\n", $sayps[0])[-1 + sizeof(explode("\n", $sayps[0]))]) . " ";
      }
      $langsuffix='&thelang=' . $_POST['thelang'];
      $htmltop="<!DOCTYPE html><html lang='" . urldecode($_POST['thelang']) . "'>";
      $langchange=" lang='" . urldecode($_POST['thelang']) . "'>";
      $togo="";
    }
  }
  
  $lot="";
  $sbc=" style=background-color:orange;";
  if (isset($_GET['thetemplate'])) {
    if (strlen($_GET['thetemplate']) > 0) {
      if (strpos(urldecode($_GET['thetemplate']), "Curriculum_Vitae_LibreOffice.html") !== false && strpos(urldecode($_GET['thetemplate']), "rjmprogramming.com.au") !== false) {
      $lot="<a target=_blank title=LibreOffice href=https://www.libreoffice.org/>LibreOffice</a><a target=_blank id=acvemail style='text-decoration:none;' href='mailto:?subject=Curriculum%20Vitae&body=" . httpit(urlencode("http://www.rjmprogramming.com.au/PHP/speech_supervisor.php?fconcept=&ask=Curriculum%20Vitae%20" . $_GET['thetemplate'])) . "'> </a><a onclick=askmyf(); style='text-decoration:underline;cursor:pointer;'>Email</a> Template ";
      } else {
      $lot="<a target=_blank title=LibreOffice href=https://www.libreoffice.org/>LibreOffice</a> Template ";
      }
      $sbc="";
    }
  } else if (isset($_POST['thetemplate'])) {
    if (strlen($_POST['thetemplate']) > 0) {
      if (strpos(urldecode($_POST['thetemplate']), "Curriculum_Vitae_LibreOffice.html") !== false && strpos(urldecode($_POST['thetemplate']), "rjmprogramming.com.au") !== false) {
      $lot="<a target=_blank title=LibreOffice href=https://www.libreoffice.org/>LibreOffice</a><a target=_blank id=acvemail style='text-decoration:none;' href='mailto:?subject=Curriculum%20Vitae&body=" . httpit(urlencode("http://www.rjmprogramming.com.au/PHP/speech_supervisor.php?fconcept=&ask=Curriculum%20Vitae%20" . $_POST['thetemplate'])) . "'> </a><a onclick=askmyf(); style='text-decoration:underline;cursor:pointer;'>Email</a> Template ";
      } else {
      $lot="<a target=_blank title=LibreOffice href=https://www.libreoffice.org/>LibreOffice</a> Template ";
      }
      $sbc="";
    }
  }
  
  function lookup($ptoobig) {
    global $langcode, $maybesaynext;
    $mymc="";
    if (str_replace("en","",$langcode) != '' && strlen(trim($ptoobig)) > 0) {
        $pokay=trim($ptoobig);
        $purl="http://api.mymemory.translated.net/get?q=" . str_replace("+","%20",urlencode($pokay)) . "&langpair=en|" . $langcode;
        // http://api.mymemory.translated.net/get?q=Hello%20World!&langpair=en|it#Ciao Mondo!
        // {"responseData":{"translatedText":"Ciao Mondo!","match":1},"quotaFinished":false,"responseDetails":"","responseStatus":200,"responderId":"242","exception_code":null,"matches":[{"id":"562784765","segment":"Hello World!","translation":"Ciao Mondo!","quality":"74","reference":null,"usage-count":97,"subject":"All","created-by":"MateCat","last-updated-by":"MateCat","create-date":"2018-05-24 22:32:33","last-update-date":"2018-05-24 22:32:33","match":1}]}
        if (file_exists("mym.txt")) $mymc=file_get_contents("mym.txt");
        $findings=explode($purl, $mymc);
        if (sizeof($findings) > 1) {
          if (strlen(explode("\n", $findings[1])[0]) <= 1) {
            return $ptoobig;
          } else {
            $maybesaynext=(html_entity_decode(str_replace('\u','&#x',substr(explode("\n", $findings[1])[0],1)), ENT_QUOTES, "UTF-8"));
            return html_entity_decode(str_replace('\u','&#x',substr(explode("\n", $findings[1])[0],1)), ENT_QUOTES, "UTF-8") . " ";
          } 
        } else {
          $thisf=str_replace("  "," ",file_get_contents($purl));
          if (strpos($thisf, "responseData") !== false) {
            $fndis=false;
            if (strpos(strtolower($thisf), '"segment":"' . strtolower(trim($ptoobig)) . '","translation":"' . strtolower(trim($ptoobig)) . '"') !== false) {
              if (strpos($thisf, '"segment":"' . strtoupper(trim($ptoobig)) . '","translation":"' . strtoupper(trim($ptoobig)) . '"') !== false) {
              $fndis=false;
              } else {
              $fndis=true;
              file_put_contents("mym.txt", $mymc . $purl . "#" . trim($ptoobig) . "\n");
              $maybesaynext=(trim($ptoobig));
              return $ptoobig;
              }
            }
            if (!$fndis) {
            if (strpos($thisf, '{"translatedText":"') !== false) {
              file_put_contents("mym.txt", $mymc . $purl . "#" . explode('"', explode('{"translatedText":"', $thisf)[1])[0] . "\n");
              $maybesaynext=(explode('"', explode('{"translatedText":"', $thisf)[1])[0]);
              return html_entity_decode(str_replace('\u','&#x',explode('"', explode('{"translatedText":"', $thisf)[1])[0]), ENT_QUOTES, "UTF-8") . " ";
            } else if (strpos(strtolower($thisf), '"segment":"' . strtolower(trim($ptoobig)) . '","translation":"') !== false) {
              $fndat=strrpos(strtolower($thisf), '"segment":"' . strtolower(trim($ptoobig)) . '","translation":"') + strlen('"segment":"' . strtolower(trim($ptoobig)) . '","translation":"');
              file_put_contents("mym.txt", $mymc . $purl . "#" . explode('"', substr($thisf, $fndat))[0] . "\n");
              $maybesaynext=(explode('"', substr($thisf, $fndat))[0]);
              return html_entity_decode(str_replace('\u','&#x',explode('"', substr($thisf, $fndat))[0]), ENT_QUOTES, "UTF-8") . " ";
            } else {
              file_put_contents("mym.txt", $mymc . $purl . "\n");
              return $ptoobig;
            }
            } //else {
            //return $ptoobig;
            //}
          } else {
            return $ptoobig;
          }
        }
    }   // \u81ea\u5df1\u7d39\u4ecb 
    return $ptoobig;
  }
  
  function httpit($inu) {
    if (strpos(strtolower(urldecode($inu)), "http") !== false) {
      return $inu;
    } else {
      return urlencode("http:" . urldecode($inu));
    }
  }
  
  function ourstr_replace($froms, $tos, $tstr) {
    global $qqhval;
    $lc="";
    $prevlc="";
    if ($tstr == "") return $tstr;
    $rs=str_replace($froms, $tos, $tstr);
    $xrs=substr($rs,0,1);
    $lc=$xrs;
    for ($ir=1; $ir<strlen($rs); $ir++) {
      if (substr(($rs . "  "),$ir,2) == "of") {
        if (substr($rs,(-1 + $ir),1) >= '0' && substr($rs,(-1 + $ir),1) <= '9') $xrs.=" ";
      } else if (substr($rs,$ir,1) >= '0' && substr($rs,$ir,1) <= '9') {
        if (substr($rs,(-1 + $ir),1) == 'f') $xrs.=" ";
      } else if (substr($rs,$ir,1) >= 'A' && substr($rs,$ir,1) <= 'Z') {
        if (substr($rs,(-1 + $ir),1) != ' ') $xrs.=" ";
      }
      $prevlc=$lc;
      $lc=substr($rs,$ir,1);
      $xrs.=substr($rs,$ir,1);
    }
    if ($lc == " ") {
     if ($prevlc == " ") {
       $qqhval=$qqhval; // more to do
     }
     $qqhval=lookup(str_replace("Translation for English word ","",str_replace("Translation for English words ","",$xrs))); //substr($xrs,0,(strlen($xrs) - 1));
    }
    return $xrs;
  }

  if (!isset($_GET['i0']) && isset($_GET['fconcept'])) {   // Form findings
   $prompt="\n  ans=prompt('What is your Survey and/or Template Form Concept? (optionally suffix by a space then LibreOffice template HTML URL (such as //www.rjmprogramming.com.au/PHP/lo_one_new.html LibreOffice Business Letter template), and/or optionally suffix by a space then email list to have potential for those emailees to redistribute this survey further afield)', 'Survey');   \n";
   if (isset($_GET['ask'])) {
      $prompt="\n ans='" . urldecode($_GET['ask']) . "'; \n";
      if (strpos(strtolower(str_replace('Curriculum Vitae ','',urldecode($_GET['ask']))), 'http') === false) {
      $wsb=explode("<body",explode("</body>",str_replace($origlangchange,$langchange,file_get_contents('http:' . str_replace('Curriculum Vitae ','',urldecode($_GET['ask'])))))[0])[1];
      } else {
      $wsb=explode("<body",explode("</body>",str_replace($origlangchange,$langchange,file_get_contents(str_replace('https:','http:',str_replace('Curriculum Vitae ','',urldecode($_GET['ask']))))))[0])[1];
      }
      $xcvs=explode("<style>", str_replace(' type="text/css"','',explode("</style>", $wsb)[0]));
      if (sizeof($xcvs) > 1) {
       if (strpos($xcvs[1], "&lt;css&gt;") !== false) {
        $huhs=explode("/*", $xcvs[1]);
        if (sizeof($huhs) > 1) {
          $stylestuff="*/ \n" . substr($xcvs[1], 0, (strlen($xcvs[1]) - (2 + strlen($huhs[-1 + sizeof($huhs)])))) . "\n /* ";
        } else {
          $stylestuff="*/ \n" . $xcvs[1] . "\n /* ";
        }
       }
      }
      }
	  $htmlis=$htmltop . "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title>" . str_replace("Survey Survey","Survey",str_replace('+',' ',urldecode($_GET['fconcept'])) . " Survey") . " Form Questions</title>
<scr" . "ipt type='text/javascript'>
 var ilangsuffix=-1,maybesaynext='',langsuffix='" . $langsuffix . "'; 
 var owo=null, say='';
 function askmyf() {
  var ansx=prompt('Optionally enter email list to share this Curriculum Vitae with. A subject to email other than \"Curriculum Vitae\" can be separated after the email list by a space.  Make the email list just uppercase to send email link to form, just lowercase to send a Curriculum Vitae report only. and a mix, both of these.', ''); 
  if (ansx != null) {
    if (ansx.indexOf('@') != -1) {
      var xansx=ansx.split(' ');
      if (ansx[0] == ansx[0].toUpperCase() || ansx[0] != ansx[0].toLowerCase()) {
        if (xansx.length > 1) {
        document.getElementById('acvemail').href=document.getElementById('acvemail').href.replace('mailto:?subject=Curriculum%20Vitae','mailto:' + xansx[0].toLowerCase() + '?subject=' + encodeURIComponent(ansx.replace(xansx[0] + ' ','')));
        } else {
        document.getElementById('acvemail').href=document.getElementById('acvemail').href.replace('mailto:?','mailto:' + xansx[0].toLowerCase() + '?');
        }
        document.getElementById('acvemail').click();
      }
      if (ansx[0] == ansx[0].toLowerCase() || ansx[0] != ansx[0].toUpperCase()) {
      document.getElementById('myf').innerHTML+='<input type=hidden name=theto value=\"' + xansx[0].toLowerCase() + '\"></input>';
      if (xansx.length > 1) {
      document.getElementById('myf').innerHTML+='<input type=hidden name=thesubject value=\"' + ansx.replace(xansx[0] + ' ','') + '\"></input>';
      } else {
      document.getElementById('myf').innerHTML+='<input type=hidden name=thesubject value=\"Curriculum Vitae\"></input>';
      }
      }
    }
  } 
 }
 function tcheckit(iois) {
  var ians=1, dl='';
  if (iois != null) {
    var aconto = (iois.contentWindow || iois.contentDocument);
    if (aconto != null) {
     if (aconto.document) { aconto = aconto.document; }
     if (aconto.body != null) {
      var bih=aconto.body.innerHTML.replace(/\&gt\;/g,'&lt;').replace(/\<p\>/g,'<p contenteditable=true>');
      var abih=bih.split(' src=\"');
      for (var ibih=1; ibih<abih.length; ibih++) {
        bih=bih.replace(' src=\"' + abih[ibih].split('\"')[0], ' src=\"' + '&lt;' + abih[ibih].split('\"')[0] + '&lt;', bih);
      } 
   if (bih.indexOf('&lt;') != -1) {
   var mods=bih.split('&lt;');
   var ans=mods[ians];
   while (ans != null) {
     //ans=prompt('Separate a survey question ' + ians + ' from an optional prompt via ? ... Cancel finishes questions to ask ... eg. What is your favourite colour?Favourite colour', ''); 
     if (ans != null) {
       if (ans != '') {
       document.getElementById('myquestions').value+=dl + '\"' + ans.replace(String.fromCharCode(39),String.fromCharCode(96)).replace(String.fromCharCode(39),String.fromCharCode(96)) + '?' + ans.replace(String.fromCharCode(39),String.fromCharCode(96)).replace(String.fromCharCode(39),String.fromCharCode(96)) + '\"';
       dl=',';
       ians+=2;
       ans=null;
       if (ians < mods.length) ans=mods[ians];
       }
     }
   }
   document.getElementById('mysf').click();
   }
     }
    }
  }
 }
 
 function ask(inc) {
   var ans='';
   var emaillist='';
   var dl='';
   var ians=1;
   var iioff=0;
   var templateis='';
   if (inc == '') { 
    " . $prompt . "
     if (ans != null) {
       if (ans.split(' ').length > 1) {
         if (ans.split(' ')[eval(-1 + ans.split(' ').length)].indexOf('@') != -1) {
           emaillist=ans.split(' ')[eval(-1 + ans.split(' ').length)];
           document.getElementById('theto').value=emaillist;
           ans=ans.replace(' ' + emaillist,'');
           document.getElementById('thesubject').value=(ans + ' Survey').replace('Survey Survey','Survey') + ' Survey (ideally using Google Chrome web browser for audio input via microphone)';
           if (ans.split(' ').length > 2) iioff--;
         }
         iioff--;
         if (ans.split(' ')[eval(-1 + ans.split(' ').length)].toLowerCase().indexOf('http') != -1 || ans.split(' ')[eval(-1 + ans.split(' ').length)].toLowerCase().indexOf('//') != -1) {
           templateis=ans.split(' ')[eval(-1 + ans.split(' ').length)];
           document.getElementById('thetemplate').value=templateis;
           document.getElementById('tiframe').src=templateis;
         }
       }
       document.getElementById('myconcept').value=ans;
     }
   }
   if (templateis != '') {
   document.getElementById('myconcept').value=ans.replace((' ' + templateis),'');
   } else {
   while (ans != null) {
     ans=prompt('Separate a survey question ' + ians + ' from an optional prompt via ? ... Cancel finishes questions to ask ... eg. What is your favourite colour?Favourite colour', ''); 
     if (ans != null) {
       if (ans != '') {
       document.getElementById('myquestions').value+=dl + '\"' + ans + '\"';
       dl=',';
       ians++;
       }
     }
   }
   document.getElementById('mysf').click();
   }
 }
</scr" . "ipt>
</head>
<body" . $sbc . " onload=ask('" . str_replace('+',' ',urldecode($_GET['fconcept'])) . "');>
<h1>" . str_replace("Survey Survey","Survey",urldecode($_GET['fconcept']) . " Survey") . " " . $lot . "Form Questions</h1> ... <a style=\"text-decoration:underline;cursor:pointer;\" onclick=\"window.open(document.URL,'_blank');\">another?</a><br><br>
<form id=myff method=POST action=//www.rjmprogramming.com.au/PHP/speech_supervisor.php>
<!--form id=myff method=POST action=./speech_supervisor.php-->
<input id=mysf type=submit value=Submit style=display:none;></input>
<input type=hidden name=concept id=myconcept value=\"" . urldecode($_GET['fconcept']) . "\"></input>
<input type=hidden name=questions id=myquestions value=''></input>
<input type=hidden name=thesubject id=thesubject value=''></input>
<input type=hidden name=theto id=theto value=''></input>
<input type=hidden name=thelang id=thelang value='" . $langcode . "'></input>
<input type=hidden name=thetemplate id=thetemplate value=\"" . str_replace("+"," ",urldecode($_GET['thetemplate'])) . "\"></input>
</form>
<iframe onload='tcheckit(this);' src='' id='tiframe' style='display:none;'></iframe>
</body>
</html>
";
  echo $htmlis;
  exit;

  } else if (isset($_POST['i0']) && isset($_POST['fconcept'])) {   // Form findings
  $joff=0;
  $defbh="<h1>" . str_replace("Survey Survey","Survey",str_replace('+',' ',urldecode($_POST['fconcept'])) . " Survey") . " " . $lot . "Report</h1> ... <a style=\"text-decoration:underline;cursor:pointer;\" onclick=\"window.open(document.URL.split('#')[0].split('?')[0] + '?fconcept=','_blank');\">another?</a>&nbsp;<a id=aemail href=\"mailto:?subject=" . str_replace("+","%20",urlencode(str_replace("Survey Survey","Survey",urldecode($_POST['fconcept']) . " Survey"))) . "%20Report%20(best%20used%20in%20Google%20Chrome%20web%20browser)&body=\">email?</a><br><br>";
  if (isset($_POST['thetemplate'])) {
    if ($_POST['thetemplate'] != "") {
      if (strpos(strtolower(urldecode($_POST['thetemplate'])), 'http') === false) {
      $wsb=explode("<body",explode("</body>",str_replace($origlangchange,$langchange,file_get_contents('http:' . urldecode($_POST['thetemplate']))))[0])[1];
      } else {
      $wsb=explode("<body",explode("</body>",str_replace($origlangchange,$langchange,file_get_contents(str_replace('https:','http:',urldecode($_POST['thetemplate'])))))[0])[1];
      }
      $xcvs=explode("<style>", str_replace(' type="text/css"','',explode("</style>", $wsb)[0]));
      if (sizeof($xcvs) > 1) {
       if (strpos($xcvs[1], "&lt;css&gt;") !== false) {
        $huhs=explode("/*", $xcvs[1]);
        if (sizeof($huhs) > 1) {
          $stylestuff="*/ \n" . substr($xcvs[1], 0, (strlen($xcvs[1]) - (2 + strlen($huhs[-1 + sizeof($huhs)])))) . "\n /* ";
        } else {
          $stylestuff="*/ \n" . $xcvs[1] . "\n /* ";
        }
       }
      }
      while (substr($wsb,$joff,1) != '>') {
        $joff++;
      }
      $joff++;
      $defbh=str_replace("<p>","<p contenteditable=true>",substr($wsb,$joff));
      if (strpos(urldecode($_POST['thetemplate']), "Curriculum_Vitae_LibreOffice.html") !== false && strpos(urldecode($_POST['thetemplate']), "rjmprogramming.com.au") !== false) {
      $defbh=str_replace("<td ","<td contenteditable=true ",$defbh);
      $defbh=str_replace("<p ","<p contenteditable=true ",$defbh);
      $defbh=str_replace("<h1 ","<h1 contenteditable=true ",$defbh);
      }
      $abih=explode(' src="', $defbh);
      for ($ibih=1; $ibih<sizeof($abih); $ibih++) {
        $defbh=str_replace(' src="' . explode('"',$abih[$ibih])[0], ' src="&lt;' . explode('"',$abih[$ibih])[0] . '&gt;', $defbh);
      } 
    }
  }
  $htmlis=$htmltop . "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title>" . str_replace("Survey Survey","Survey",str_replace('+',' ',urldecode($_POST['fconcept'])) . " Survey") . " Report</title>
<scr" . "ipt type='text/javascript'>
 var ilangsuffix=-1,maybesaynext='',langsuffix='" . $langsuffix . "'; 
 var owo=null, say='';
 var dul=document.URL.split('#')[0].split('?')[0];
 var argis='';
 function askmyf() {
  var ansx=prompt('Optionally enter email list to share this Curriculum Vitae with. A subject to email other than \"Curriculum Vitae\" can be separated after the email list by a space.  Make the email list just uppercase to send email link to form, just lowercase to send a Curriculum Vitae report only. and a mix, both of these.', ''); 
  if (ansx != null) {
    if (ansx.indexOf('@') != -1) {
      var xansx=ansx.split(' ');
      if (ansx[0] == ansx[0].toUpperCase() || ansx[0] != ansx[0].toLowerCase()) {
        if (xansx.length > 1) {
        document.getElementById('acvemail').href=document.getElementById('acvemail').href.replace('mailto:?subject=Curriculum%20Vitae','mailto:' + xansx[0].toLowerCase() + '?subject=' + encodeURIComponent(ansx.replace(xansx[0] + ' ','')));
        } else {
        document.getElementById('acvemail').href=document.getElementById('acvemail').href.replace('mailto:?','mailto:' + xansx[0].toLowerCase() + '?');
        }
        document.getElementById('acvemail').click();
      }
      if (ansx[0] == ansx[0].toLowerCase() || ansx[0] != ansx[0].toUpperCase()) {
      document.getElementById('myf').innerHTML+='<input type=hidden name=theto value=\"' + xansx[0].toLowerCase() + '\"></input>';
      if (xansx.length > 1) {
      document.getElementById('myf').innerHTML+='<input type=hidden name=thesubject value=\"' + ansx.replace(xansx[0] + ' ','') + '\"></input>';
      } else {
      document.getElementById('myf').innerHTML+='<input type=hidden name=thesubject value=\"Curriculum Vitae\"></input>';
      }
      }
    }
  } 
 }
 function initemail() {
   document.getElementById('aemail').href=document.getElementById('aemail').href.replace(/\ /g,'%20').replace(/\+/g,'%20') + encodeURIComponent(dul + '?fconcept=') + encodeURIComponent('" . str_replace("'","' + String.fromCharCode(39) + '",str_replace("Survey Survey","Survey",($_POST['fconcept']) . " Survey")) . " Report&" . "').replace(/\%20/g,'+');  
   fixemail(); 
 }
 function fixemail() {
   var prerest=document.getElementById('aemail').href.split('?subject=')[1].split('&body=')[0];
   var rest=document.getElementById('aemail').href.split('&body=')[1].split('php')[1];
   document.getElementById('aemail').href=document.getElementById('aemail').href.split('?subject=')[0] + '?subject=' + (prerest) + '&body=' + encodeURIComponent('https://www.rjmprogramming.com.au/PHP/speech_supervisor.php') + (rest).replace(/\%20/g,'+');
 }
</scr" . "ipt>
</head>
<body" . $sbc . " onload=\" document.getElementById('preq').innerHTML=dds('" . str_replace("'","' + String.fromCharCode(39) + '",$qone) . "');  initemail();\" dir='auto'>" . $defbh . "</body>
</html>
";
  $ival=0;
  if ($joff == 0) {
  if (isset($_POST['s' . $ival])) {
    $htmlis=str_replace("</body>", "<table cellspacing=2 cellpadding=10 border=40><tbody><tr><th>Label</th><th>Value</th></tr></tbody></table></body>", $htmlis);
  } else {
    $htmlis=str_replace("</body>", "<table cellspacing=2 cellpadding=10 border=40><tbody><tr><th>Value</th></tr></tbody></table></body>", $htmlis);
  }
  }
  while (isset($_POST['i' . $ival])) {
    if ($joff != 0) {
    $farr=explode("&lt;" . str_replace("`","'",str_replace("+"," ",urldecode($_POST['s' . $ival]))) . "&gt;", $htmlis);
    if (sizeof($farr) <= 2) {
    $htmlis=str_replace("&lt;" . str_replace("`","'",str_replace("+"," ",urldecode($_POST['s' . $ival]))) . "&gt;", str_replace("+"," ",urldecode($_POST['i' . $ival])), $htmlis);
    } else {
    $prehtml=$farr[0] . "&lt;" . str_replace("`","'",str_replace("+"," ",urldecode($_POST['s' . $ival]))) . "&gt;";
    $posthtml=str_replace("&lt;" . str_replace("`","'",str_replace("+"," ",urldecode($_POST['s' . $ival]))) . "&gt;", str_replace("+"," ",urldecode($_POST['i' . $ival])), $prehtml);
    $htmlis=str_replace($prehtml, $posthtml, $htmlis);
    }
    } else {
    if (isset($_POST['s' . $ival])) {
      $htmlis=str_replace("</tbody>", "<tr><td>" . urldecode($_POST['s' . $ival]) . "</td><td>" . urldecode($_POST['i' . $ival]) . "</td></tr></tbody>", $htmlis);
      $htmlis=str_replace("function fixemail() {", "function fixemail() { document.getElementById('aemail').href+=encodeURIComponent('s" . $ival . "=" . str_replace("'","' + String.fromCharCode(39) + '",($_POST['s' . $ival])) . "&'); ", $htmlis);
      $htmlis=str_replace("function fixemail() {", "function fixemail() { document.getElementById('aemail').href+=encodeURIComponent('i" . $ival . "=" . str_replace("'","' + String.fromCharCode(39) + '",($_POST['i' . $ival])) . "&'); ", $htmlis);
    } else {
      $htmlis=str_replace("</tbody>", "<tr><td>" . urldecode($_POST['i' . $ival]) . "</td></tr></tbody>", $htmlis);
      $htmlis=str_replace("function fixemail() {", "function fixemail() { document.getElementById('aemail').href+=encodeURIComponent('i" . $ival . "=" . str_replace("'","' + String.fromCharCode(39) + '",($_POST['i' . $ival])) . "&'); ", $htmlis);
    }
    }
    $ival++;
  }
  
  if (isset($_POST['theto'])) {
                if (strpos(urldecode($_POST['theto']), "@") !== false) { // && strpos($htmlis, "</html>") !== false) {

                $eol = PHP_EOL;
                $header = 'From: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
                $header .= 'Reply-To: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
                if (isset($_POST['thecc'])) {
                $header .= 'CC: ' . urldecode($_POST['thecc']) . $eol;
                }
                if (isset($_POST['thebcc'])) {
                $header .= 'BCC: ' . urldecode($_POST['thebcc']) . $eol;
                }

                // attachment
                $filename=str_replace("@", "_", str_replace(".", "_", urldecode($_POST['thesubject']) . urldecode($_POST['theto']))) . ".html";
                $content = chunk_split(base64_encode(str_replace("%2b","+",str_replace(' contenteditable=',' data-alt=',$htmlis))));
                
                $message="Please download attached webpage. ";
                if (sizeof(explode("\n",urldecode($_POST['thesubject']))) > 1) {
                  $message.=str_replace("\r","  ",str_replace("\n","  ",str_replace(explode("\r",explode("\n",urldecode($_POST['thesubject']))[0])[0], "", urldecode($_POST['subject']))));
                }

                // a random hash will be necessary to send mixed content
                $uid = md5(time());
                
                $header .= "MIME-Version: 1.0\r\n";
                $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
                $header .= "This is a multi-part message in MIME format.\r\n";
                $header .= "--".$uid."\r\n";
                $header .= "Content-type:text/html; charset=iso-8859-1\r\n";
                $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
                $header .= $message."\r\n\r\n";

                $header .= "--".$uid."\r\n";
                $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here
                $header .= "Content-Transfer-Encoding: base64\r\n";
                $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
                $header .= $content."\r\n\r\n";
                $header .= "--".$uid."--";
                
                try {
                mail(urldecode($_POST['theto']), explode("\r",explode("\n",urldecode($_POST['thesubject']))[0])[0], "", $header);
                //$htmlis=str_replace("inite" . "mail();"," alert('Email sent okay.'); inite" . "mail();", $htmlis);
                } catch (Exception $ee) {
                //$htmlis=str_replace("inite" . "mail();"," alert('Email not sent.');  inite" . "mail();", $htmlis);
                }
                }
  }
   
  echo $htmlis;
  exit;


  } else if (isset($_GET['i0']) && isset($_GET['fconcept'])) {   // Form findings
  $joff=0;
  $defbh="<h1>" . str_replace("Survey Survey","Survey",str_replace('+',' ',urldecode($_GET['fconcept'])) . " Survey") . " " . $lot . "Report</h1> ... <a style=\"text-decoration:underline;cursor:pointer;\" onclick=\"window.open(document.URL.split('#')[0].split('?')[0] + '?fconcept=','_blank');\">another?</a>&nbsp;<a id=aemail href=\"mailto:?subject=" . str_replace("+","%20",urlencode(str_replace("Survey Survey","Survey",urldecode($_GET['fconcept']) . " Survey"))) . "%20Report%20(best%20used%20in%20Google%20Chrome%20web%20browser)&body=\">email?</a><br><br>";
  if (isset($_GET['thetemplate'])) {
    if ($_GET['thetemplate'] != "") {
      if (strpos(strtolower(urldecode($_GET['thetemplate'])), 'http') === false) {
      $wsb=explode("<body",explode("</body>",str_replace($origlangchange,$langchange,file_get_contents('http:' . urldecode($_GET['thetemplate']))))[0])[1];
      } else {
      $wsb=explode("<body",explode("</body>",str_replace($origlangchange,$langchange,file_get_contents(str_replace('https:','http:',urldecode($_GET['thetemplate'])))))[0])[1];
      }
      $xcvs=explode("<style>", str_replace(' type="text/css"','',explode("</style>", $wsb)[0]));
      if (sizeof($xcvs) > 1) {
       if (strpos($xcvs[1], "&lt;css&gt;") !== false) {
        $huhs=explode("/*", $xcvs[1]);
        if (sizeof($huhs) > 1) {
          $stylestuff="*/ \n" . substr($xcvs[1], 0, (strlen($xcvs[1]) - (2 + strlen($huhs[-1 + sizeof($huhs)])))) . "\n /* ";
        } else {
          $stylestuff="*/ \n" . $xcvs[1] . "\n /* ";
        }
       }
      }
      while (substr($wsb,$joff,1) != '>') {
        $joff++;
      }
      $joff++;
      $defbh=str_replace("<p>","<p contenteditable=true>",substr($wsb,$joff));
      if (strpos(urldecode($_GET['thetemplate']), "Curriculum_Vitae_LibreOffice.html") !== false && strpos(urldecode($_GET['thetemplate']), "rjmprogramming.com.au") !== false) {
      $defbh=str_replace("<td ","<td contenteditable=true ",$defbh);
      $defbh=str_replace("<p ","<p contenteditable=true ",$defbh);
      $defbh=str_replace("<h1 ","<h1 contenteditable=true ",$defbh);
      }
      $abih=explode(' src="', $defbh);
      for ($ibih=1; $ibih<sizeof($abih); $ibih++) {
        $defbh=str_replace(' src="' . explode('"',$abih[$ibih])[0], ' src="&lt;' . explode('"',$abih[$ibih])[0] . '&gt;', $defbh);
      } 
    }
  }
  $htmlis=$htmltop . "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title>" . str_replace("Survey Survey","Survey",str_replace('+',' ',urldecode($_GET['fconcept'])) . " Survey") . " Report</title>
<scr" . "ipt type='text/javascript'>
 var ilangsuffix=-1,maybesaynext='',langsuffix='" . $langsuffix . "'; 
 var owo=null, say='';
 var dul=document.URL.split('#')[0].split('?')[0];
 var argis='';
 function askmyf() {
  var ansx=prompt('Optionally enter email list to share this Curriculum Vitae with. A subject to email other than \"Curriculum Vitae\" can be separated after the email list by a space.  Make the email list just uppercase to send email link to form, just lowercase to send a Curriculum Vitae report only. and a mix, both of these.', ''); 
  if (ansx != null) {
    if (ansx.indexOf('@') != -1) {
      var xansx=ansx.split(' ');
      if (ansx[0] == ansx[0].toUpperCase() || ansx[0] != ansx[0].toLowerCase()) {
        if (xansx.length > 1) {
        document.getElementById('acvemail').href=document.getElementById('acvemail').href.replace('mailto:?subject=Curriculum%20Vitae','mailto:' + xansx[0].toLowerCase() + '?subject=' + encodeURIComponent(ansx.replace(xansx[0] + ' ','')));
        } else {
        document.getElementById('acvemail').href=document.getElementById('acvemail').href.replace('mailto:?','mailto:' + xansx[0].toLowerCase() + '?');
        }
        document.getElementById('acvemail').click();
      }
      if (ansx[0] == ansx[0].toLowerCase() || ansx[0] != ansx[0].toUpperCase()) {
      document.getElementById('myf').innerHTML+='<input type=hidden name=theto value=\"' + xansx[0].toLowerCase() + '\"></input>';
      if (xansx.length > 1) {
      document.getElementById('myf').innerHTML+='<input type=hidden name=thesubject value=\"' + ansx.replace(xansx[0] + ' ','') + '\"></input>';
      } else {
      document.getElementById('myf').innerHTML+='<input type=hidden name=thesubject value=\"Curriculum Vitae\"></input>';
      }
      }
    }
  } 
 }
 function initemail() {
   document.getElementById('aemail').href=document.getElementById('aemail').href.replace(/\ /g,'%20').replace(/\+/g,'%20'8/*-) + encodeURIComponent(dul + '?fconcept=') + encodeURIComponent('" . str_replace("'","' + String.fromCharCode(39) + '",str_replace("Survey Survey","Survey",($_GET['fconcept']) . " Survey")) . " Report&" . "').replace(/\%20/g,'+');  
   fixemail(); 
 }
 function fixemail() {
 
   var prerest=document.getElementById('aemail').href.split('?subject=')[1].split('&body=')[0];
   var rest=document.getElementById('aemail').href.split('&body=')[1].split('php')[1];
   document.getElementById('aemail').href=document.getElementById('aemail').href.split('?subject=')[0] + '?subject=' + (prerest) + '&body=' + encodeURIComponent('https://www.rjmprogramming.com.au/PHP/speech_supervisor.php') + (rest).replace(/\%20/g,'+');
 }
</scr" . "ipt>
</head>
<body" . $sbc . " onload='initemail();' dir='auto'>" . $defbh . "</body>
</html>
";
  $ival=0;
  if ($joff == 0) {
  if (isset($_GET['s' . $ival])) {
    $htmlis=str_replace("</body>", "<table cellspacing=2 cellpadding=10 border=40><tbody><tr><th>Label</th><th>Value</th></tr></tbody></table></body>", $htmlis);
  } else {
    $htmlis=str_replace("</body>", "<table cellspacing=2 cellpadding=10 border=40><tbody><tr><th>Value</th></tr></tbody></table></body>", $htmlis);
  }
  }
  while (isset($_GET['i' . $ival])) {
  if ($joff != 0) {
    $farr=explode("&lt;" . str_replace("`","'",str_replace("+"," ",urldecode($_GET['s' . $ival]))) . "&gt;", $htmlis);
    if (sizeof($farr) <= 2) {
    $htmlis=str_replace("&lt;" . str_replace("`","'",str_replace("+"," ",urldecode($_GET['s' . $ival]))) . "&gt;", str_replace("+"," ",urldecode($_GET['i' . $ival])), $htmlis);
    } else {
    $prehtml=$farr[0] . "&lt;" . str_replace("`","'",str_replace("+"," ",urldecode($_GET['s' . $ival]))) . "&gt;";
    $posthtml=str_replace("&lt;" . str_replace("`","'",str_replace("+"," ",urldecode($_GET['s' . $ival]))) . "&gt;", str_replace("+"," ",urldecode($_GET['i' . $ival])), $prehtml);
    $htmlis=str_replace($prehtml, $posthtml, $htmlis);
    }
  } else {
    if (isset($_GET['s' . $ival])) {
      $htmlis=str_replace("</tbody>", "<tr><td>" . urldecode($_GET['s' . $ival]) . "</td><td>" . urldecode($_GET['i' . $ival]) . "</td></tr></tbody>", $htmlis);
      $htmlis=str_replace("function fixemail() {", "function fixemail() { document.getElementById('aemail').href+=encodeURIComponent('s" . $ival . "=" . str_replace("'","' + String.fromCharCode(39) + '",($_GET['s' . $ival])) . "&'); ", $htmlis);
      $htmlis=str_replace("function fixemail() {", "function fixemail() { document.getElementById('aemail').href+=encodeURIComponent('i" . $ival . "=" . str_replace("'","' + String.fromCharCode(39) + '",($_GET['i' . $ival])) . "&'); ", $htmlis);
    } else {
      $htmlis=str_replace("</tbody>", "<tr><td>" . urldecode($_GET['i' . $ival]) . "</td></tr></tbody>", $htmlis);
      $htmlis=str_replace("function fixemail() {", "function fixemail() { document.getElementById('aemail').href+=encodeURIComponent('i" . $ival . "=" . str_replace("'","' + String.fromCharCode(39) + '",($_GET['i' . $ival])) . "&'); ", $htmlis);
    }
  }
    $ival++;
  }
  
  
  if (isset($_GET['theto'])) {
                if (strpos(urldecode($_GET['theto']), "@") !== false) { // && strpos($htmlis, "</html>") !== false) {

                $eol = PHP_EOL;
                $header = 'From: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
                $header .= 'Reply-To: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
                if (isset($_GET['thecc'])) {
                $header .= 'CC: ' . urldecode($_GET['thecc']) . $eol;
                }
                if (isset($_GET['thebcc'])) {
                $header .= 'BCC: ' . urldecode($_GET['thebcc']) . $eol;
                }

                // attachment
                $filename=str_replace("@", "_", str_replace(".", "_", urldecode($_GET['thesubject']) . urldecode($_GET['theto']))) . ".html";
                $content = chunk_split(base64_encode(str_replace("%2b","+",str_replace(' contenteditable=',' data-alt=',$htmlis))));
                
                $message="Please download attached webpage. ";
                if (sizeof(explode("\n",urldecode($_GET['thesubject']))) > 1) {
                  $message.=str_replace("\r","  ",str_replace("\n","  ",str_replace(explode("\r",explode("\n",urldecode($_GET['thesubject']))[0])[0], "", urldecode($_GET['subject']))));
                }

                // a random hash will be necessary to send mixed content
                $uid = md5(time());
                
                $header .= "MIME-Version: 1.0\r\n";
                $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
                $header .= "This is a multi-part message in MIME format.\r\n";
                $header .= "--".$uid."\r\n";
                $header .= "Content-type:text/html; charset=iso-8859-1\r\n";
                $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
                $header .= $message."\r\n\r\n";

                $header .= "--".$uid."\r\n";
                $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here
                $header .= "Content-Transfer-Encoding: base64\r\n";
                $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
                $header .= $content."\r\n\r\n";
                $header .= "--".$uid."--";
                
                try {
                mail(urldecode($_GET['theto']), explode("\r",explode("\n",urldecode($_GET['thesubject']))[0])[0], "", $header);
                //$htmlis=str_replace("inite" . "mail();"," alert('Email sent okay.'); inite" . "mail();", $htmlis);
                } catch (Exception $ee) {
                //$htmlis=str_replace("inite" . "mail();"," alert('Email not sent.');  inite" . "mail();", $htmlis);
                }
                }
  }  
   
  echo $htmlis;
  exit;


  } else {
  $lot="";
  $wsb="";
  if (isset($_GET['thetemplate'])) {
    if (strlen($_GET['thetemplate']) > 0) {
       if (strpos(urldecode($_GET['thetemplate']), "Curriculum_Vitae_LibreOffice.html") !== false && strpos(urldecode($_GET['thetemplate']), "rjmprogramming.com.au") !== false) {
       $lot="<a target=_blank title=LibreOffice href=https://www.libreoffice.org/>LibreOffice</a><a target=_blank id=acvemail style='text-decoration:none;' href='mailto:?subject=Curriculum%20Vitae&body=" . httpit(urlencode("http://www.rjmprogramming.com.au/PHP/speech_supervisor.php?fconcept=&ask=Curriculum%20Vitae%20" . $_GET['thetemplate'])) . "'> </a><a onclick=askmyf(); style='text-decoration:underline;cursor:pointer;'>Email</a> Template ";
       } else {
       $lot="<a target=_blank title=LibreOffice href=https://www.libreoffice.org/>LibreOffice</a> Template ";
       }
      if (trim(urldecode($_GET['thetemplate'])) != '') {
      if (strpos(strtolower(urldecode($_GET['thetemplate'])), 'http') === false) {
      $wsb=explode("<body",explode("</body>",str_replace($origlangchange,$langchange,file_get_contents('http:' . urldecode($_GET['thetemplate']))))[0])[1];
      } else {
      $wsb=explode("<body",explode("</body>",str_replace($origlangchange,$langchange,file_get_contents(str_replace('https:','http:',urldecode($_GET['thetemplate'])))))[0])[1];
      }
      }
    }
  } else if (isset($_POST['thetemplate'])) {
    if (strlen($_POST['thetemplate']) > 0) {
       if (strpos(urldecode($_POST['thetemplate']), "Curriculum_Vitae_LibreOffice.html") !== false && strpos(urldecode($_POST['thetemplate']), "rjmprogramming.com.au") !== false) {
       $lot="<a target=_blank title=LibreOffice href=https://www.libreoffice.org/>LibreOffice</a><a target=_blank id=acvemail style='text-decoration:none;' href='mailto:?subject=Curriculum%20Vitae&body=" . httpit(urlencode("http://www.rjmprogramming.com.au/PHP/speech_supervisor.php?fconcept=&ask=Curriculum%20Vitae%20" . $_POST['thetemplate'])) . "'> </a><a onclick=askmyf(); style='text-decoration:underline;cursor:pointer;'>Email</a> Template ";
       } else {
       $lot="<a target=_blank title=LibreOffice href=https://www.libreoffice.org/>LibreOffice</a> Template ";
       }
      if (trim(urldecode($_POST['thetemplate'])) != '') {
      if (strpos(strtolower(urldecode($_POST['thetemplate'])), 'http') === false) {
      $wsb=explode("<body",explode("</body>",str_replace($origlangchange,$langchange,file_get_contents('http:' . urldecode($_POST['thetemplate']))))[0])[1];
      } else {
      $wsb=explode("<body",explode("</body>",str_replace($origlangchange,$langchange,file_get_contents(str_replace('https:','http:',urldecode($_POST['thetemplate'])))))[0])[1];
      }
      }
    }
  }
      $xcvs=explode("<style>", str_replace(' type="text/css"','',explode("</style>", $wsb)[0]));
      if (sizeof($xcvs) > 1) {
       if (strpos($xcvs[1], "&lt;css&gt;") !== false) {
        $huhs=explode("/*", $xcvs[1]);
        if (sizeof($huhs) > 1) {
          $stylestuff="*/ \n" . substr($xcvs[1], 0, (strlen($xcvs[1]) - (2 + strlen($huhs[-1 + sizeof($huhs)])))) . "\n /* ";
        } else {
          $stylestuff="*/ \n" . $xcvs[1] . "\n /* ";
        }
       }
      }
  if (isset($_POST['theto'])) {
                if (strpos(urldecode($_POST['theto']), "@") !== false) { // && strpos($htmlis, "</html>") !== false) {


  $htmlis=$htmltop . "<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title>" . str_replace("Survey Survey","Survey",str_replace('+',' ',urldecode($_POST['concept'])) . " Survey") . " " . $lot . "Form Questions</title>
<scri" . "ipt type='text/javascript'>
 var owo=null, say='';
 var ilangsuffix=-1,maybesaynext='',langsuffix='" . $langsuffix . "'; 
</script>
</head>
<body onload=\" document.getElementById('mysf').click(); \">
<h1>" . str_replace("Survey Survey","Survey",str_replace("+"," ",urldecode($_POST['concept'])) . " Survey") . " " . $lot . "Form Questions</h1> ... <a style=\"text-decoration:underline;cursor:pointer;\" onclick=\"window.open(document.URL,'_blank');\">another?</a><br><br>
<form id=myff method=POST action=//www.rjmprogramming.com.au/PHP/speech_supervisor.php>
<input id=mysf type=submit value=Submit style=display:none;></input>
<input type=hidden name=concept id=myconcept value=\"" . str_replace("+"," ",urldecode($_POST['concept'])) . "\"></input>
<input type=hidden name=questions id=myquestions value='" . str_replace("'","' + String.fromCharCode(39) + '",str_replace("+"," ",urldecode($_POST['questions']))) . "'></input>
<input type=hidden name=thesubject id=thesubject value=''></input>
<input type=hidden name=theto id=theto value=''></input>
<input type=hidden name=thelang id=thelang value='" . $langcode . "'></input>
<input type=hidden name=thetemplate id=thetemplate value=\"" . str_replace("+"," ",urldecode($_POST['thetemplate'])) . "\"></input>
</form>
</body>
</html>
";

                $eol = PHP_EOL;
                $header = 'From: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
                $header .= 'Reply-To: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
                if (isset($_POST['thecc'])) {
                $header .= 'CC: ' . urldecode($_POST['thecc']) . $eol;
                }
                if (isset($_POST['thebcc'])) {
                $header .= 'BCC: ' . urldecode($_POST['thebcc']) . $eol;
                }

                // attachment
                $filename=str_replace("@", "_", str_replace(".", "_", urldecode($_POST['thesubject']) . urldecode($_POST['theto']))) . ".html";
                $content = chunk_split(base64_encode(str_replace("%2b","+",$htmlis)));
                
                $message="Please download attached webpage. ";
                if (sizeof(explode("\n",urldecode($_POST['thesubject']))) > 1) {
                  $message.=str_replace("\r","  ",str_replace("\n","  ",str_replace(explode("\r",explode("\n",urldecode($_POST['thesubject']))[0])[0], "", urldecode($_POST['subject']))));
                }

                // a random hash will be necessary to send mixed content
                $uid = md5(time());
                
                $header .= "MIME-Version: 1.0\r\n";
                $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
                $header .= "This is a multi-part message in MIME format.\r\n";
                $header .= "--".$uid."\r\n";
                $header .= "Content-type:text/html; charset=iso-8859-1\r\n";
                $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
                $header .= $message."\r\n\r\n";

                $header .= "--".$uid."\r\n";
                $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here
                $header .= "Content-Transfer-Encoding: base64\r\n";
                $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
                $header .= $content."\r\n\r\n";
                $header .= "--".$uid."--";
                
                try {
                mail(urldecode($_POST['theto']), explode("\r",explode("\n",urldecode($_POST['thesubject']))[0])[0], "", $header);
                //$htmlis=str_replace("inite" . "mail();"," alert('Email sent okay.'); inite" . "mail();", $htmlis);
                } catch (Exception $ee) {
                //$htmlis=str_replace("inite" . "mail();"," alert('Email not sent.');  inite" . "mail();", $htmlis);
                }
                }
  }
  $ifmaybe="<iframe onload='checki(this,2);' style='width:100%;height:95vh;' src='//www.rjmprogramming.com.au/PHP/speech_idea.php?ifno=2'></iframe>";
  if (isset($_GET['mode'])) {
    if ($_GET['mode'] == "3") {
        $ifmaybe="<iframe onload='cb(this);' src='//www.rjmprogramming.com.au/HTMLCSS/ConfirmWindow/animal_categorization.html' style='width:100%;height:95vh;'></iframe>";
    }
  }
  $qone="Quiz";
  $qlabels='"' . $qone . '","Tongue Twisters","Haiku","Animal Categorization","Vocabulary Phrases","Hangman","Survey or LibreOffice Template","Curriculum Vitae"';
  $orig_qlabels='"' . $qone . '","Tongue Twisters","Haiku","Animal Categorization","Vocabulary Phrases","Hangman","Survey or LibreOffice Template","Curriculum Vitae"';
  $qarrays='"questions","tongue_twisters","haiku","animal_categorization","vocabulary","hangman","survey","curriculum_vitae"';
  $qdelims='"?","~","`","`","`","`","?","?"';
  $qcols='"yellow","lightgreen","lightblue","lightgray","pink","cyan","orange","magenta"';
  $qforce="";
  $qis='"What is the name that we give to the meat we get from pigs?pork",
                       "What is the name of the metal alloy we get from zinc and copper?bronze",
                       "What is the capital of Australia?Canberra",
                       "Who wrote The Tale of Two Cities?Dickens",
                       "How many legs does the Legs of Man have?three",
                       "How many tails does a Manx cat have?none",
                       "How many teeth does an aardvark have?none",
                       "Which sea creature has three hearts?octopus",
                       "Which instrument has forty-seven strings and seven pedals?harp",
                       "In the traditional rhyme, how many mice were blind?three",
                       "How many pedals do most modern pianos have?three"';
  $qlast=0;
  if (isset($_GET['questions'])) {
    $qis=urldecode($_GET['questions']);
  } else if (isset($_POST['questions'])) { 
    $qis=urldecode($_POST['questions']);
  }
  if (isset($_GET['concept'])) {
    $qqval='';
    $qqhval='';
    $qone=urldecode($_GET['concept']);
    $qlabels='"' . $qone . '"';
    $qarrays='"questions"';
    $qdelims='"?"';
    $qcols='"pink"';
    $qforce="0; /" . "/ ";
    $qins="<input type=hidden name=fconcept value=\"" . $qone . "\"></input>";
    if (isset($_GET['thetemplate'])) {
    $qins.="<input type=hidden name=thetemplate value=\"" . str_replace("+"," ",urldecode($_GET['thetemplate'])) . "\"></input>";
    } else if (isset($_POST['thetemplate'])) { 
    $qins.="<input type=hidden name=thetemplate value=\"" . str_replace("+"," ",urldecode($_POST['thetemplate'])) . "\"></input>";
    }
    
    $qins.="<input type=hidden name=thelang id=thelang value='" . $langcode . "'></input>";
    
    if (strpos(explode('",', $qis)[0], "?") === false) {
    $xx=ourstr_replace("_"," ",substr(explode('",', ($qis . ","))[0],1));
    $qins.="<input title=\"" . $qqhval . "\" id=hs0 type=hidden name=s0 value=\"" . substr(explode('",', ($qis . ","))[0],1) . "\"></input><span title='none' id=s0 style=display:none; onmouseover='xhib(this.innerHTML);' onclick='xhib(this.innerHTML);' style='text-decoration:none;cursor:pointer;' title='Translate'>" . $xx . "</span> ";
    } else if (strlen(explode("?", explode('",', ($qis . ","))[0])[0] . "?") == strlen(explode('",', $qis)[0])) {
    $xx=ourstr_replace("_"," ",str_replace('?','',substr(explode('",', ($qis . ","))[0],1)));
    $qins.="<input title=\"" . $qqhval . "\" id=hs0 type=hidden name=s0 value=\"" . substr(explode("?", explode('",', ($qis . ","))[0])[0],1) . "\"></input><span title='none' id=s0 style=display:none; onmouseover='xhib(this.innerHTML);' onclick='xhib(this.innerHTML);' style='text-decoration:none;cursor:pointer;' title='Translate'>" . $xx . "</span> ";
    } else {
    $xx=ourstr_replace("_"," ",substr(explode("?", explode('",', ($qis . ","))[0])[1],0));
    $qins.="<input title=\"" . $qqhval . "\" id=hs0 type=hidden name=s0 value=\"" . substr(explode("?", explode('",', ($qis . ","))[0])[1],0) . "\"></input><span title='inline' id=s0 onmouseover='xhib(this.innerHTML);' onclick='xhib(this.innerHTML);' style='text-decoration:none;cursor:pointer;' title='Translate'>" . $xx . "</span> ";
    }
    $qins.="<input tabindex='0' onblur=\" if (this.value.length > 0 && this.value != '" . $qqhval . "') {  obv=this.value;  if (sofarb[1] != null) {  sofarb[0].innerHTML=this.value.replace(String.fromCharCode(32),'&nbsp;'); sofarb[1].innerHTML=this.value.replace(String.fromCharCode(32),'&nbsp;'); } prepickq(this.value); } \" type=text name=i0 id=i0 value='" . $qqhval . "' title='You need at least a space here and/or to have changed the default value for the tabbing out to be recognized as your value, and that <br> represents a line feed'></input><br>";
    for ($ii=1; $ii<sizeof(explode('",', $qis)); $ii++) {
      $qqval='';
      $qqhval='';
      if (strpos(explode('",', $qis)[$ii], "?") === false) {
      if (substr(explode('",', ($qis . ","))[$ii],1) == "css") $qqval=$stylestuff;
      $xx=ourstr_replace("_"," ",substr(explode('",', ($qis . ","))[$ii],1));
      $qins.="<input type=hidden title=\"" . $qqhval . "\" id=hs" . $ii . " name=s" . $ii . " value=\"" . substr(explode('",', ($qis . ","))[$ii],1) . "\"></input><span title='none' id=s" . $ii . " style=display:none; onmouseover='xhib(this.innerHTML);' onclick='xhib(this.innerHTML);' style='text-decoration:none;cursor:pointer;' title='Translate'>" . $xx . "</span> ";
      } else if (strlen(explode("?", explode('",', ($qis . ","))[$ii])[0] . "?") == strlen(explode('",', $qis)[$ii])) {
      if (substr(explode("?", explode('",', ($qis . ","))[$ii])[0],1) == "css") $qqval=$stylestuff;
      $xx=ourstr_replace("_"," ",str_replace('?','',substr(explode('",', ($qis . ","))[$ii],1)));
      $qins.="<input type=hidden title=\"" . $qqhval . "\" id=hs" . $ii . " name=s" . $ii . " value=\"" . substr(explode("?", explode('",', ($qis . ","))[$ii])[0],1) . "\"></input><span title='none' id=s" . $ii . " style=display:none; onmouseover='xhib(this.innerHTML);' onclick='xhib(this.innerHTML);' style='text-decoration:none;cursor:pointer;' title='Translate'>" . $xx . "</span> ";
      } else {
      if (substr(explode("?", explode('",', ($qis . ","))[$ii])[1],0) == "css") $qqval=$stylestuff;
      $xx=ourstr_replace("_"," ",substr(explode("?", explode('",', ($qis . ","))[$ii])[1],0));
      $qins.="<input type=hidden title=\"" . $qqhval . "\" id=hs" . $ii . " name=s" . $ii . " value=\"" . substr(explode("?", explode('",', ($qis . ","))[$ii])[1],0) . "\"></input><span title='inline' id=s" . $ii . " style=display:none; onmouseover='xhib(this.innerHTML);' onclick='xhib(this.innerHTML);' style='text-decoration:none;cursor:pointer;' title='Translate'>" .  $xx . "</span> ";
      }
      if ($qqval != "") {
      $qins.="<br><br><textarea tabindex='" . $ii . "' title='Start with */ and then css then end with /*' cols=80 rows=25 style=display:none; name=i" . $ii . " id=i" . $ii . " value=''>" . $qqval . "</textarea><br><br>";
      } else {
      $qins.="<input tabindex='" . $ii . "' onblur=\" if (this.value.length > 0 && this.value != '" . $qqhval . "') { obv=this.value; if (sofarb[1] != null) {  sofarb[0].innerHTML=this.value.replace(String.fromCharCode(32),'&nbsp;'); sofarb[1].innerHTML=this.value.replace(String.fromCharCode(32),'&nbsp;'); } prepickq(this.value); } \" style=display:none; type=text name=i" . $ii . " id=i" . $ii . " value='" . $qqhval . "' title='You need at least a space here and/or to have changed the default value for the tabbing out to be recognized as your value, and that <br> represents a line feed'></input><br>";
      }
      $qlast=$ii;
    }
    $ifmaybe="<h1>" . str_replace(" LibreOffice"," <a target=_blank title=LibreOffice href=https://www.libreoffice.org/>LibreOffice</a>",$qone) . " " . $lot . "Form</h1><form accept-charset='UTF-8' id=myf method=POST action=//www.rjmprogramming.com.au/PHP/speech_supervisor.php>" . $qins . "<br><input id=sdata type=submit value='Submit Report' style=display:none;background-color:orange;></input></form>";
    //$ifmaybe="<h1>" . str_replace(" LibreOffice"," <a target=_blank title=LibreOffice href=https://www.libreoffice.org/>LibreOffice</a>",$qone) . " Form</h1><form id=myf method=POST action=./speech_supervisor.php>" . $qins . "<br><input id=sdata type=submit value='Submit Report' style=display:none;background-color:orange;></input></form>";
  } else if (isset($_POST['concept'])) { 
    $qqval='';
    $qqhval='';
    $qone=urldecode($_POST['concept']);
    $qlabels='"' . $qone . '"';
    $qarrays='"questions"';
    $qdelims='"?"';
    $qcols='"pink"';
    $qforce="0; /" . "/ ";
    $qins="<input type=hidden name=fconcept value=\"" . $qone . "\"></input>";
    if (isset($_GET['thetemplate'])) {
    $qins.="<input type=hidden name=thetemplate value=\"" . str_replace("+"," ",urldecode($_GET['thetemplate'])) . "\"></input>";
    } else if (isset($_POST['thetemplate'])) { 
    $qins.="<input type=hidden name=thetemplate value=\"" . str_replace("+"," ",urldecode($_POST['thetemplate'])) . "\"></input>";
    }
    
    $qins.="<input type=hidden name=thelang id=thelang value='" . $langcode . "'></input>";
    
    if (strpos(explode('",', $qis)[0], "?") === false) {
    $xx=ourstr_replace("_"," ",substr(explode('",', ($qis . ","))[0],1));
    $qins.="<input title=\"" . $qqhval . "\" id=hs0 type=hidden name=s0 value=\"" . substr(explode('",', ($qis . ","))[0],1) . "\"></input><span title='none' id=s0 style=display:none; onmouseover='xhib(this.innerHTML);' onclick='xhib(this.innerHTML);' style='text-decoration:none;cursor:pointer;' title='Translate'>" . $xx . "</span> ";
    } else if (strlen(explode("?", explode('",', ($qis . ","))[0])[0] . "?") == strlen(explode('",', $qis)[0])) {
    $xx=ourstr_replace("_"," ",str_replace('?','',substr(explode('",', ($qis . ","))[0],1)));
    $qins.="<input title=\"" . $qqhval . "\" id=hs0 type=hidden name=s0 value=\"" . substr(explode("?", explode('",', ($qis . ","))[0])[0],1) . "\"></input><span title='none' id=s0 style=display:none; onmouseover='xhib(this.innerHTML);' onclick='xhib(this.innerHTML);' style='text-decoration:none;cursor:pointer;' title='Translate'>" . $xx . "</span> ";
    } else {
    $xx=ourstr_replace("_"," ",substr(explode("?", explode('",', ($qis . ","))[0])[1],0));
    $qins.="<input title=\"" . $qqhval . "\" id=hs0 type=hidden name=s0 value=\"" . substr(explode("?", explode('",', ($qis . ","))[0])[1],0) . "\"></input><span title='inline' id=s0 onmouseover='xhib(this.innerHTML);' onclick='xhib(this.innerHTML);' style='text-decoration:none;cursor:pointer;' title='Translate'>" . $xx . "</span> ";
    }
    $qins.="<input tabindex='0' onblur=\" if (this.value.length > 0 && this.value != '" . $qqhval . "') {  obv=this.value; if (sofarb[1] != null) {  sofarb[0].innerHTML=this.value.replace(String.fromCharCode(32),'&nbsp;'); sofarb[1].innerHTML=this.value.replace(String.fromCharCode(32),'&nbsp;'); } prepickq(this.value); } \" type=text name=i0 id=i0 value='" . $qqhval . "' title='You need at least a space here and/or to have changed the default value for the tabbing out to be recognized as your value, and that <br> represents a line feed'></input><br>";
    for ($ii=1; $ii<sizeof(explode('",', $qis)); $ii++) {
      $qqval='';
      $qqhval='';
      if (strpos(explode('",', $qis)[$ii], "?") === false) {
      if (substr(explode('",', ($qis . ","))[$ii],1) == "css") $qqval=$stylestuff;
      $xx=ourstr_replace("_"," ",substr(explode('",', ($qis . ","))[$ii],1));
      $qins.="<input type=hidden title=\"" . $qqhval . "\" id=hs" . $ii . " name=s" . $ii . " value=\"" . substr(explode('",', ($qis . ","))[$ii],1) . "\"></input><span title='none' id=s" . $ii . " style=display:none; onmouseover='xhib(this.innerHTML);' onclick='xhib(this.innerHTML);' style='text-decoration:none;cursor:pointer;' title='Translate'>" . $xx . "</span> ";
      } else if (strlen(explode("?", explode('",', ($qis . ","))[$ii])[0] . "?") == strlen(explode('",', $qis)[$ii])) {
      if (substr(explode("?", explode('",', ($qis . ","))[$ii])[0],1) == "css") $qqval=$stylestuff;
      $xx=ourstr_replace("_"," ",str_replace('?','',substr(explode('",', ($qis . ","))[$ii],1)));
      $qins.="<input type=hidden title=\"" . $qqhval . "\" id=hs" . $ii . " name=s" . $ii . " value=\"" . substr(explode("?", explode('",', ($qis . ","))[$ii])[0],1) . "\"></input><span title='none' id=s" . $ii . " style=display:none; onmouseover='xhib(this.innerHTML);' onclick='xhib(this.innerHTML);' style='text-decoration:none;cursor:pointer;' title='Translate'>" . $xx . "</span> ";
      } else {
      if (substr(explode("?", explode('",', ($qis . ","))[$ii])[1],0) == "css") $qqval=$stylestuff;
      $xx=ourstr_replace("_"," ",substr(explode("?", explode('",', ($qis . ","))[$ii])[1],0));
      $qins.="<input type=hidden title=\"" . $qqhval . "\" id=hs" . $ii . " name=s" . $ii . " value=\"" . substr(explode("?", explode('",', ($qis . ","))[$ii])[1],0) . "\"></input><span title='inline' id=s" . $ii . " style=display:none; onmouseover='xhib(this.innerHTML);' onclick='xhib(this.innerHTML);' style='text-decoration:none;cursor:pointer;' title='Translate'>" .  $xx . "</span> ";
      }
      if ($qqval != "") {
      $qins.="<br><br><textarea tabindex='" . $ii . "' title='Start with */ and then css then end with /*' cols=80 rows=25 style=display:none; name=i" . $ii . " id=i" . $ii . " value=''>" . $qqval . "</textarea><br><br>";
      } else {
      $qins.="<input tabindex='" . $ii . "' onblur=\" if (this.value.length > 0 && this.value != '" . $qqhval . "') { obv=this.value; if (sofarb[1] != null) {  sofarb[0].innerHTML=this.value.replace(String.fromCharCode(32),'&nbsp;'); sofarb[1].innerHTML=this.value.replace(String.fromCharCode(32),'&nbsp;'); } prepickq(this.value); } \" style=display:none; type=text name=i" . $ii . " id=i" . $ii . " value='" . $qqhval . "' title='You need at least a space here and/or to have changed the default value for the tabbing out to be recognized as your value, and that <br> represents a line feed'></input><br>";
      }
      $qlast=$ii;
    }
    $ifmaybe="<h1>" . str_replace(" LibreOffice"," <a target=_blank title=LibreOffice href=https://www.libreoffice.org/>LibreOffice</a>",$qone) . " " . $lot . "Form</h1><form accept-charset='UTF-8' id=myf method=POST action=//www.rjmprogramming.com.au/PHP/speech_supervisor.php>" . $qins . "<br><input id=sdata type=submit value='Submit Report' style=display:none;background-color:orange;></input></form>";
    //$ifmaybe="<h1>" . str_replace(" LibreOffice"," <a target=_blank title=LibreOffice href=https://www.libreoffice.org/>LibreOffice</a>",$qone) . " Form</h1><form id=myf method=POST action=./speech_supervisor.php>" . $qins . "<br><input id=sdata type=submit value='Submit Report' style=display:none;background-color:orange;></input></form>";
  }
  }

  echo $htmltop . "<head>\n";
?>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title>Speaking Quiz (at least on Google Chrome) - RJM Programming - May, 2018 ... thanks to https://www.google.com/intl/en/chrome/demos/speech.html for Speech to Text</title>
<script type='text/javascript'>
        var owo=null, say='';
        var ilangsuffix=-1,maybesaynext='',langsuffix='<?php echo $langsuffix; ?>';
        var mode=<?php echo $qforce; ?>location.search.split('mode=')[1] ? eval(decodeURIComponent(location.search.split('mode=')[1].split('&')[0])) : 0;
        var orig_modes=[<?php echo $orig_qlabels; ?>];
        var modes=[<?php echo $qlabels; ?>];
        var arraynames=[<?php echo $qarrays; ?>];
        var delims=[<?php echo $qdelims; ?>];
        var bcols=[<?php echo $qcols; ?>];
        var isq=0;
        var ifocusis=0;
        var answer="";
        var obv='';
        var sofar=["",""];
        var scores=[0,0];
        var sofarb=[null,null];
        var resultso=[null,null];
        var questions=[<?php echo $qis; ?>];
        var ourlangs=""; //aconto.body.innerHTML.split('var langs')[1].split(']];')[0].replace(/\ /g,'').split("',[");
        var ourl=[-1,-1]; //eval(aconto.getElementById('select_language').value);
        var ourlo=[null,null]; 
        var yourl=-1;
        var ourlc=['',''];
        var yourlc='';
        var yourlcclick=0;
        
        var ioisz=null;

        var wogt=null;
        var lastwogt='';
        var xwogt=null;
        var xlastwogt='';
        var woo=null;
        var perr=false;
        
        var clue='';
        
        var lastsay='';
        
        var curplayer=1;
        
        var fsp=null, isp=null;
        
        var lasts='';
        var wlens=10;
        var wlenb=20;
        var maxanyone=7;
        
        var survey=[];
        
        var vocabulary=[""];
        var hangman=[""];
        
        var animal_categorization=["Hear you have an unknown animal.  Does your animal have a backbone?"];
                      
        // Thanks to http://www.uebersetzung.at/twister/en.htm below
        var tongue_twisters=["Peter Piper picked a peck of pickled peppers. A peck of pickled peppers Peter Piper picked. If Peter Piper picked a peck of pickled peppers, Where's the peck of pickled peppers Peter Piper picked?",
                       "I saw Susie sitting in a shoe shine shop.  Where she sits she shines, and where she shines she sits.",
                       "How many boards Could the Mongols hoard If the Mongol hordes got bored?",
                       "How can a clam cram in a clean cream can?",
                       "Send toast to ten tense stout saints' ten tall tents.",
                       "Denise sees the fleece, Denise sees the fleas. At least Denise could sneeze and feed and freeze the fleas.",
                       "Coy knows pseudonoise codes.",
                       "Sheena leads, Sheila needs.",
                       "The thirty-three thieves thought that they thrilled the throne throughout Thursday.",
                       "Something in a thirty-acre thermal thicket of thorns and thistles thumped and thundered threatening the three-D thoughts of Matthew the thug - although, theatrically, it was only the thirteen-thousand thistles and thorns through the underneath of his thigh that the thirty year old thug thought of that morning.",
                       "Can you can a can as a canner can can a can?",
                       "Seth at Sainsbury's sells thick socks.",
                       "You cuss, I cuss, we all cuss, for asparagus!",
                       "Roberta ran rings around the Roman ruins.",
                       "Clean clams crammed in clean cans.",
                       "Six sick hicks nick six slick bricks with picks and sticks.",
                       "I wish to wish the wish you wish to wish, but if you wish the wish the witch wishes, I won't wish the wish you wish to wish.",
                       "Stupid superstition!",
                       "There was a fisherman named Fisher who fished for some fish in a fissure. Till a fish with a grin, pulled the fisherman in. Now they're fishing the fissure for Fisher.",
                       "World Wide Web",
                       "Picky people pick Peter Pan Peanut-Butter, 'tis the peanut-butter picky people pick.",
                       "If Stu chews shoes, should Stu choose the shoes he chews?",
                       "Luke Luck likes lakes. Luke's duck likes lakes. Luke Luck licks lakes. Luck's duck licks lakes. Duck takes licks in lakes Luke Luck likes. Luke Luck takes licks in lakes duck likes."
                      ];
            
        // Thanks to https://en.wikipedia.org/wiki/Haiku_in_English below              
        var haiku=["Snow in my shoe <br>Abandoned <br>Sparrow's nest",
                   "Whitecaps on the bay: <br>A broken signboard banging <br>In the April wind.",
                   "lily: <br>out of the water <br>out of itself",
                   "bass <br>picking bugs <br>off the moon",
                   "an aging willow-- <br>it's image unsteady <br>in the flowing stream",
                   "Just friends: <br>he watches my gauze dress <br>blowing on the line.",
                   "Little spider, <br>will you outlive <br>me?",
                   "she watches <br>satisfied after love <br>he lies <br>looking up at nothing",
                   "beneath <br>leaf mold <br>stone <br>cool <br>stone",
                   "meteor shower... <br>a gentle wave <br>wets our sandals"
                   ];
                   
 function askmyf() {
  var ansx=prompt('Optionally enter email list to share this Curriculum Vitae with. A subject to email other than \"Curriculum Vitae\" can be separated after the email list by a space.  Make the email list just uppercase to send email link to form, just lowercase to send a Curriculum Vitae report only. and a mix, both of these.', ''); 
  if (ansx != null) {
    if (ansx.indexOf('@') != -1) {
      var xansx=ansx.split(' ');
      if (ansx[0] == ansx[0].toUpperCase() || ansx[0] != ansx[0].toLowerCase()) {
        if (xansx.length > 1) {
        document.getElementById('acvemail').href=document.getElementById('acvemail').href.replace('mailto:?subject=Curriculum%20Vitae','mailto:' + xansx[0].toLowerCase() + '?subject=' + encodeURIComponent(ansx.replace(xansx[0] + ' ','')));
        } else {
        document.getElementById('acvemail').href=document.getElementById('acvemail').href.replace('mailto:?','mailto:' + xansx[0].toLowerCase() + '?');
        }
        document.getElementById('acvemail').click();
      }
      if (ansx[0] == ansx[0].toLowerCase() || ansx[0] != ansx[0].toUpperCase()) {
      document.getElementById('myf').innerHTML+='<input type=hidden name=theto value=\"' + xansx[0].toLowerCase() + '\"></input>';
      if (xansx.length > 1) {
      document.getElementById('myf').innerHTML+='<input type=hidden name=thesubject value=\"' + ansx.replace(xansx[0] + ' ','') + '\"></input>';
      } else {
      document.getElementById('myf').innerHTML+='<input type=hidden name=thesubject value=\"Curriculum Vitae\"></input>';
      }
      }
    }
  } 
 }
                   
        function lookforend() {
          if (document.getElementById('shangman')) {
            if (document.getElementById('shangman').innerHTML == '') {
             setTimeout(lookforend,2000);
            } else {
             scores[0]+=eval(document.getElementById('shangman').innerHTML.replace('Score:','').replace('/',',').replace(' ','').split(',')[0]);
             scores[1]+=eval(document.getElementById('shangman').innerHTML.replace('Score:','').replace('/',',').replace(' ','').split(',')[1]);
             document.getElementById('score').innerHTML='Score: ' + scores[0] + '/' + scores[1];
             document.getElementById('shangman').innerHTML='';
             curplayer=eval(3 - curplayer);
             pickq();
            }
          }
        }
                   
        function cluey(swhatshort) {
            document.getElementById('ihangman').src="//www.rjmprogramming.com.au/HTMLCSS/hangman_bg.html?curplayer=" + curplayer + "&tosolve=" + encodeURIComponent(swhatshort) + "&clue=" + encodeURIComponent(clue);
        }
        
        function maybeontop(swhat,swhatshort) {
          //alert(mode + ' swhatshort=' + swhatshort);
          if (mode == 5) { // hangman
            document.getElementById('sq').style.display='none';
            //alert('<input onclick="alert(' + "'" + swhatshort + "'" + ');" type=button value="Player ' + curplayer + ' click reveals phrase while Player ' + eval(3 - curplayer) + ' turns away?"></input>');
            document.getElementById('ontopsq').innerHTML='<input onclick=" document.getElementById(' + "'" + 'mya' + "'" + ').click(); clue=' + "'" + '?' + "'" + '; while (clue == ' + "'" + '?' + "'" + ') {  clue=' + "''" + '; try { clue=prompt(' + "'" + swhatshort + " ... to leave a hint for your playing partner, enter one here optionally, and know that to read a helper window enter ?, and that it closes itself in one minute',''" + '); } catch { perr=true; }  if (clue == ' + "'" + '?' + "'" + ') {  prowoo();  }   } if (clue == null) { clue=' + "''" + '; } cluey(' + "'" + swhatshort + "'" + '); " type=button value="Player ' + curplayer + ' click reveals phrase while Player ' + eval(3 - curplayer) + ' turns away?"></input>';
            if (document.getElementById('ihangman')) {
            document.getElementById('ihangman').src="//www.rjmprogramming.com.au/HTMLCSS/hangman_bg.html?curplayer=" + curplayer + "&tosolve=" + encodeURIComponent(swhatshort) + "&clue=" + encodeURIComponent(clue);
            } else {
            document.getElementById('dhangman').innerHTML='<br><div id=shangman></div><br><iframe style="transform:scale(0.5);margin-left:-50%;margin-top:-200px;width:200%;height:720px;" id="ihangman" src="//www.rjmprogramming.com.au/HTMLCSS/hangman_bg.html?curplayer=' + curplayer + '&tosolve=' + encodeURIComponent(swhatshort) + "&clue=" + encodeURIComponent(clue) + '"></iframe><br>';
            document.getElementById('dhangman').style.display='block';
            }
            lookforend();
          }
          return swhat;
        }
                      
        function complexscore(inst) {
          var versusw=answer.toLowerCase().replace(/\<br\>/g,' ').replace(/\.\.\./g,' ').replace(/-/g,'').replace(/\"/g,'').replace(/\'/g,'').replace(/\./g,' ').replace(/\:/g,' ').replace(/\;/g,' ').replace(/\,/g,' ').replace(/\!/g,' ').replace(/\?/g,' ').replace(/\ \ /g,' ').replace(/\ \ /g,' ').replace(/\ \ /g,' ').split(' ');
          var ourw=inst.toLowerCase().replace(/\<br\>/g,' ').replace(/\.\.\./g,' ').replace(/-/g,'').replace(/\"/g,'').replace(/\'/g,'').replace(/\./g,' ').replace(/\:/g,' ').replace(/\;/g,' ').replace(/\,/g,' ').replace(/\!/g,' ').replace(/\?/g,' ').replace(/\ \ /g,' ').replace(/\ \ /g,' ').replace(/\ \ /g,' ').split(' ');
          var pscore=0, lastf=-1, ilastf, jlastf=-1;
          for (var iwords=0; iwords<versusw.length; iwords++) {
            jlastf=lastf;
            for (ilastf=eval(1 + lastf); ilastf<ourw.length; ilastf++) {
              if (jlastf == lastf && versusw[iwords] == ourw[ilastf]) {
                lastf=ilastf;
                pscore+=versusw[iwords].length;
                //alert(versusw.length + "vs" + ourw.length + " ... " + iwords + ": found " + versusw[iwords]);
              }
            }
            if (jlastf == lastf) {
              pscore-=versusw[iwords].length;
              //alert(versusw.length + "vs" + ourw.length + " ... " + iwords + ": did not find " + versusw[iwords]);
            }
          }
          return pscore;
        }
        
        function noseven(inx) {
          if (inx.split('&')[0] == '?mode=7') {
            return '?fconcept=' + langsuffix + '&ask=Curriculum+Vitae%20%2F%2Fwww.rjmprogramming.com.au%2FPHP%2FCurriculum_Vitae_LibreOffice.html';
          } else {
            return inx;
          }
        }
        
        function yehbut(inw) {
          var onw=inw;
          if (obv != '') {
            onw=obv;
            obv='';
          }
          return onw; 
        }
        
        function atfocus() {
          while (!document.getElementById('i' + ifocusis)) {
            ifocusis--;
          }
          while (document.getElementById('i' + ifocusis).style.display.toLowerCase().indexOf('none') != -1) {
            ifocusis--;
          } 
          //document.title='i' + ifocusis;
          window.setTimeout(function ()
    {
          document.getElementById('i' + ifocusis).focus();
          document.getElementById('i' + ifocusis).click();
    }, 0);
          //document.getElementById('i' + ifocusis).focus();
          //ifocusis++;
          if (eval(yourlcclick % 2) == 1) xhib(document.getElementById('s' + ifocusis).innerHTML);
          if (eval(yourlcclick) >= 2 && say != "") {
            if (document.getElementById('hs' + ifocusis).title.length > 0) {
              maybesaynext=document.getElementById('hs' + ifocusis).title;
            } 
            maybesay(document.getElementById('s' + ifocusis).innerHTML);
          }
        }
        
        function noowo() {
            var svb='';
            if (owo != null && 1 == 7) {
              owo.close();
              owo=null;
            }
        }
                      
        function dds(qwhat) {
          var selbit="<select id=selbit onchange=' location.href=document.URL.split(\"#\")[0].split(\"?\")[0] + noseven(\"?mode=\" + this.value + langsuffix); '><option value=0>" + modes[0] + "</option></select>";
          var ia=1;
          if (mode != 0) {
            eval("ia=" + arraynames[mode] + ".length");
            if (ia == 0 && arraynames[mode] == "curriculum_vitae") {
            location.href=document.URL.split('#')[0].split('?')[0] + '?fconcept=' + langsuffix + '&ask=Curriculum+Vitae%20%2F%2Fwww.rjmprogramming.com.au%2FPHP%2FCurriculum_Vitae_LibreOffice.html';
            } else if (ia == 0) {
            location.href=document.URL.split('#')[0].split('?')[0] + '?fconcept=';
            return '';
            } else {
            eval(arraynames[0] + "=" + arraynames[mode]);
            document.getElementById('tdm').style.backgroundColor=bcols[mode];
            }
          }
          for (var iselbit=1; iselbit<orig_modes.length; iselbit++) {
           if (mode == iselbit) {
            selbit=selbit.replace("</select>", "<option value=" + iselbit + " selected>" + orig_modes[iselbit] + "</option></select>");
           } else {
            selbit=selbit.replace("</select>", "<option value=" + iselbit + ">" + orig_modes[iselbit] + "</option></select>");
           }
          }
          if (modes[0] != 'Quiz') selbit=selbit.replace("</select>", "<option value=''>Quiz</option></select>");
          if (document.getElementById('i0')) {
            setTimeout(atfocus, 2000);
          }
          return qwhat.replace('<?php echo str_replace("'","' + String.fromCharCode(39) + '",$qone); ?>',selbit);
        }
                      
        function pdidclick(iframen,cwhat,cwhatid,cwhattitle,cwhatvalue) {
          if (sofarb[eval(-1 + iframen)] == null) {
            sofarb[eval(-1 + iframen)]=cwhat;
          }
        }

        function athentwo() {
          if (document.getElementById('divac').innerHTML != ' ') {
            sofarb[0].click();
          }
        }
        
        function athen() {
          if (sofarb[0]) { 
           if (lasts != '') {
            if (document.getElementById('divac').innerHTML != ' ') {
            sofarb[0].click();
            if (fsp) fsp.innerHTML='';
            if (isp) isp.innerHTML='';
            }
            //alert(lasts);
            setTimeout(athentwo,2000);
            lasts='';
           }
          }
        }
        
        function prepickq(orv) {
       var iframen=1;
       document.getElementById('i' + eval(-1 + Math.abs(isq))).value=orv; //sfinal.split('<span')[0];
       sofarb[eval(-1 + iframen)].click();
       sofar[eval(-1 + iframen)]=''; 
       pickq(); 
       ifocusis=eval(1 + Math.abs(isq));
       //document.title='*i' +  ifocusis;
       setTimeout(atfocus, 4000); 
         }
        
        function pdidchange(iframen,sfinal) {
         var ioff=0;
         if (mode == 3) {
          document.getElementById('divac').innerHTML=sfinal.toLowerCase().split(' ')[eval(-1 + sfinal.toLowerCase().split(' ').length)];
          lasts=sfinal;
          setTimeout(athen,2000);
         } else {
         if (iframen <= 0) {
          if (sfinal != '1' && sfinal != '2' && sfinal != '') {
          if (mode > 0) {
          ioff=complexscore(sfinal.replace('1','').replace('2','').replace('3','three'));
          } else {
<?php
  if (isset($_GET['concept']) || isset($_POST['concept'])) {
       echo "\n document.getElementById('i' + eval(-1 + Math.abs(isq))).value=yehbut(sfinal.split('<span')[0]); \n";
       echo "\n sofar[0]=''; \n";
       echo "\n sofar[1]=''; \n";
       echo "\n pickq(); \n";
       echo "\n return; \n";
  }
?>
          if (sfinal.toLowerCase().indexOf(answer.replace('1','').replace('2','').replace('3','three').toLowerCase()) != -1) {
            ioff=1;
          } else {
            ioff=-1;
          }
          }
          if (sfinal.indexOf('1') != -1) {
            scores[0]+=ioff;
            if (sofarb[0]) sofarb[0].click();
          } else if (sfinal.indexOf('2') != -1) {
            scores[1]+=ioff;
            if (sofarb[1]) sofarb[1].click();
          } else {
            var ansis=confirm('Are you player 2 on the right?');
            if (ansis == true) {
            scores[1]+=ioff;
            if (sofarb[1]) sofarb[1].click();
            } else {
            scores[0]+=ioff;
            if (sofarb[0]) sofarb[0].click();
            }
          }
          document.getElementById('score').innerHTML='Score: ' + scores[0] + '/' + scores[1];
          sofar[0]='';
          sofar[1]='';
          pickq();
          }
        } else {
         if (sofar[eval(-1 + iframen)] == '') {
          //alert('' + iframen + ' said ' + sfinal);
          if (mode > 0) {
          scores[eval(-1 + iframen)]+=complexscore(sfinal.replace('1','').replace('2','').replace('3','three'));
          } else {
<?php
  if (isset($_GET['concept']) || isset($_POST['concept'])) {
       echo "\n document.getElementById('i' + eval(-1 + Math.abs(isq))).value=yehbut(sfinal.split('<span')[0]); \n";
       echo "\n sofarb[eval(-1 + iframen)].click(); \n";
       echo "\n sofar[eval(-1 + iframen)]=''; \n";
       echo "\n pickq(); \n";
       echo "\n return; \n";
  }
?>
          if (sfinal.toLowerCase().indexOf(answer.replace('1','').replace('2','').replace('3','three').toLowerCase()) != -1) {
            scores[eval(-1 + iframen)]++;
          } else {
            scores[eval(-1 + iframen)]--;
          }
          }
          document.getElementById('score').innerHTML='Score: ' + scores[0] + '/' + scores[1];
          sofarb[eval(-1 + iframen)].click();
          sofar[eval(-1 + iframen)]='';
          pickq();
         } else {
          //alert('' + iframen + ' just said ' + sfinal.replace(sofar[eval(-1 + iframen)],''));
          if (sfinal.toLowerCase().indexOf(answer.replace('1','').replace('2','').replace('3','three').toLowerCase()) != -1) {
            scores[eval(-1 + iframen)]++;
          } else {
            scores[eval(-1 + iframen)]--;
          }
          document.getElementById('score').innerHTML='Score: ' + scores[0] + '/' + scores[1];
          sofarb[eval(-1 + iframen)].click();
          sofar[eval(-1 + iframen)]='';
          pickq();
         }
         }
         }
        }
        
        function okp(e) {
			var characterCode; //literal character code will be stored in this variable

			if (e && e.which){ //if which property of event object is supported (NN4)
				e = e;
				characterCode = e.which; //character code is contained in NN4's which property
			} else {
				e = event;
				characterCode = e.keyCode; //character code is contained in IE's keyCode property
			}
 			if (characterCode == 49) {  // 1
 			  if (document.getElementById('kb').value.length <= 1) document.getElementById('kb').value='';
			  sofarb[0].click();
			} else if (characterCode == 50) {  // 2
 			  if (document.getElementById('kb').value.length <= 1) document.getElementById('kb').value='';
			  sofarb[1].click();
			}
        }
        
 function lmaps(inl) {
   return inl.replace('fil','tl').replace('cmns','zh-CN').replace('cmnt','zh-TW').replace('yuet','zh-TW');
 }
 
 function insides(inz) {
   var onz=inz.replace(/\<br\/\>/g,'').replace(/\<br\>/g,'').replace(/\<b\>/g,'').replace(/\<\/b\>/g,'');
   var onzs=onz.split('</a>');
   if (onzs.length <= 1) {
     return onz;
   } else {
     var xsofar='';
     for (var ix=0; ix<onzs.length; ix++) {
       xsofar+=onzs[ix].split('>')[eval(-1 + onzs[ix].split('>').length)];
     }
     return xsofar;
   }
 }
 
 function maybesay(jjnq) {
         if (maybesaynext != '' && jjnq != '') {
           jjnq+=', ' + maybesaynext;
           maybesaynext='';
         }
         var xjnq='',ij, jnq="<?php echo $sayprefix; ?>", onew=1, zerow=1, jdelim='_', k=2;
         var jwords=jjnq.split(' ');
         if (jwords.length > 100000) { // idea of 10 abandoned
         jnq+=jwords[0].replace(/\ /g,'_'); // + '&say2=';
         onew=Math.floor(eval((jwords.length + 9) / 9));
         xjnq=encodeURIComponent(jnq);
         while (zerow < jwords.length) {
         jnq+='&say' + k + '=' + "<?php echo $sayprefix; ?>";
         xjnq+='&say' + k + '=' + encodeURIComponent("<?php echo $sayprefix; ?>");
         for (ij=0; ij<onew; ij++) {
         if (zerow < jwords.length) {
         jnq+=(jwords[zerow] + ' ').replace(/\ /g,'_');
         xjnq+=encodeURIComponent((jwords[zerow] + ' ').replace(/\ /g,'_'));
         }
         zerow++;
         }
         k++;
         }
         } else {
         jnq+=jjnq.replace(/\ /g,'_');
         xjnq=encodeURIComponent(jnq);
         }
         //if (jnq != jjnq) alert(jnq);
         if (eval(yourlcclick) >= 2 && say != "") {
           if (lastsay != jnq) {
            lastsay=jnq;
            if (owo != null && 1 == 7) {
              owo.close();
              owo=null;
            }
            if (owo == null) {
            owo=window.open(say + xjnq, '_blank', 'top=1,left=1,width=1,height=1');
            } else {
            owo.location.href=say + xjnq;
            }
            setTimeout(noowo, 5000);
          }
         }
 }
  
 function xhib(inq) {
  if (yourlc != '') {
   var sx='';
   if (mode == 3) sx='?';
   if (xlastwogt != 'https://translate.google.com/#auto/' + lmaps(yourlc) + '/' + encodeURIComponent(inq)) {
   maybesay(inq);
   if (xwogt != null) {
     //xwogt.close();
     xlastwogt = 'https://translate.google.com/#auto/' + lmaps(yourlc) + '/' + encodeURIComponent(inq);
     xwogt.location.href=xlastwogt;
   } else {
     xlastwogt = 'https://translate.google.com/#auto/' + lmaps(yourlc) + '/' + encodeURIComponent(inq);
     xwogt=window.open(xlastwogt, '_blank', 'top=10,left=10,width=750,height=590');
   }
   }
  } else {
   maybesay(inq);
  }
 }

 function hib() {
  if (yourlc != '') {
   var sx='';
   if (mode == 3) sx='?';
   if (xlastwogt != 'https://translate.google.com/#auto/' + lmaps(yourlc) + '/' + encodeURIComponent(insides(document.getElementById('sq').innerHTML + sx))) {
   maybesay(insides(document.getElementById('sq').innerHTML + sx));
   if (xwogt != null) {
     //xwogt.close();
     xlastwogt = 'https://translate.google.com/#auto/' + lmaps(yourlc) + '/' + encodeURIComponent(insides(document.getElementById('sq').innerHTML + sx));
     xwogt.location.href=xlastwogt;
   } else {
     xlastwogt = 'https://translate.google.com/#auto/' + lmaps(yourlc) + '/' + encodeURIComponent(insides(document.getElementById('sq').innerHTML + sx));
     xwogt=window.open(xlastwogt, '_blank', 'top=10,left=10,width=750,height=590');
   }
   }
  } else {
   maybesay(insides(document.getElementById('sq').innerHTML + sx));
  }
 }
        
 function hearitback(wback,wiw) {
   var whatback=wback;
   if (ourlo[wiw]) {
     if (eval(ourlo[wiw].value) != ourl[wiw]) {
           ourl[eval(wiw)]=eval(ourlo[wiw].value);
           ourlc[eval(wiw)]=ourlangs[eval(1 + ourl[eval(wiw)])].split("'")[1].replace('-Han','').split('-')[0];
     }
   }
   if (yourlc != '') {
   if (whatback.indexOf('</span>') != -1) {
     var huhg=wback.split('</span>');
     whatback=huhg[0].split('>')[eval(-1 + huhg[0].split('>').length)];
     if (whatback.trim() == '' && huhg.length > 1) {
     whatback=huhg[1].split('>')[eval(-1 + huhg[1].split('>').length)];
     }
   }
   var nogo=false; 
   if (whatback.trim() != '') {
   if (ourlc[wiw] == yourlc && lastwogt == 'https://translate.google.com/#auto/' + lmaps(yourlc) + '/' + encodeURIComponent(whatback)) nogo=true;
   if (ourlc[wiw] != yourlc && lastwogt == 'https://translate.google.com/#' + lmaps(ourlc[wiw]) + '/' + lmaps(yourlc) + '/' + encodeURIComponent(whatback)) nogo=true;
   if (!nogo) {
   if (wogt != null) wogt.close();
   if (ourlc[wiw] == yourlc) {
   lastwogt = 'https://translate.google.com/#auto/' + lmaps(yourlc) + '/' + encodeURIComponent(whatback);
   wogt=window.open(lastwogt, '_blank', 'top=10,left=10,width=750,height=590');
   } else {
   lastwogt = 'https://translate.google.com/#' + lmaps(ourlc[wiw]) + '/' + lmaps(yourlc) + '/' + encodeURIComponent(whatback);
   wogt=window.open(lastwogt, '_blank', 'top=10,left=10,width=750,height=590');
   }
   }
   }
   }
 }
 
 function checkwizfu() {
   if (ioisz != null) {
    var aconto = (ioisz.contentWindow || ioisz.contentDocument);
    if (aconto != null) {
     //document.title='0';
     if (aconto.document) { aconto = aconto.document; }
     //document.title+='1';
     if (aconto.body != null) {
       if (aconto.body.innerHTML.indexOf(' name="say"') != -1) { // MAMP say available
     //document.title+='2';
         yourlcclick+=2;
         say="HTTP://localhost:8888/say.php?say=";
         document.getElementById('dsay').style.display='inline';
       } else if (aconto.body.innerHTML.indexOf(' name="mamp"') != -1) { // MAMP available
     //document.title+='3';
         document.getElementById('dsay').innerHTML='<a onclick=" getsay(); " style="background-color:orange;text-decoration:underline;cursor:pointer; ">Get Mac OS X Say Text to Speech</a>';
         document.getElementById('dsay').style.display='inline';
       } else {
     //document.title+='4';
         document.getElementById('dsay').innerHTML='';
       }
     }
    }
  }
}

function HtmlReceiver(inhtml) {
       acontobody=inhtml;
       if (acontobody.indexOf(' name="say"') != -1) { // MAMP say available
     //document.title+='2';
         yourlcclick+=2;
         say="HTTP://localhost:8888/say.php?say=";
         document.getElementById('dsay').style.display='inline';
       } else if (acontobody.indexOf(' name="mamp"') != -1) { // MAMP available
     //document.title+='3';
         document.getElementById('dsay').innerHTML='<a onclick=" getsay(); " style="background-color:orange;text-decoration:underline;cursor:pointer; ">Get Mac OS X Say Text to Speech</a>';
         document.getElementById('dsay').style.display='inline';
       } else {
     //document.title+='4';
         document.getElementById('dsay').innerHTML='';
       }
}

 function checkwiz(iois) {
  if (iois != null) {
    ioisz=iois;
    setTimeout(checkwizfu, 15000);
  }
 }
 
 function getsay() {
    var bitex='';
    if (document.URL.indexOf('ht' + 'tps:') != -1) bitex=' (please note the misunderstanding can happen with htt' + 'ps: URLs, so could be worth trying an ht' + 'tp: one instead at the address bar above)';
    var intention=confirm('Am about to show you code for say.php ... please copy and paste it into MAMP HTTP://localhost:8888/ place ... for us, that is /Applications/MAMP/htdocs/ and call it say.php ... if you have every intention of creating HTTP://localhost:8888/say.php in this way, or you find out that say.php was already there' + bitex + ' and/or that all you need to do is start up MAMP, press the OK button please.');
    if (intention) {
      yourlcclick+=2;
      say="HTTP://localhost:8888/say.php?say=";
    }
    owo=window.open('//www.rjmprogramming.com.au/PHP/say.php_GETME','_blank','top=20,left=20,width=300,height=300');
 }  

 function checkwi(iois) {
  var okay=true;
  if (iois != null) {
    var aconto = (iois.contentWindow || iois.contentDocument);
    if (aconto != null) {
     if (aconto.document) { aconto = aconto.document; }
     if (aconto.body != null) {
       vocabulary[0] = aconto.body.innerHTML.replace('</pre>','').replace('<pre>','');
       hangman[0] = maybeontop('', vocabulary[0]);
       var ws=vocabulary[0].split(' ');
       for (var iws=0; iws<ws.length; iws++) {
         if (ws[iws].length > maxanyone) okay=false;
       }
       //if (mode == 4) questions[0] = vocabulary[0];
     }
    }
  }
  if (!okay) document.getElementById('imyword').src='//www.rjmprogramming.com.au/PHP/surprise.php?min=' + eval(1 + wlens) + '&max=' + eval(1 + wlenb) + '&phrase=y&youllneverfindthis=y' + Math.floor(Math.random() * 134567);
 }
 
 function checki(iois, iw) {
  if (iois != null) {
    var aconto = (iois.contentWindow || iois.contentDocument);
    if (aconto != null) {
     if (aconto.document) { aconto = aconto.document; }
     if (aconto.body != null) {
       if (aconto.getElementById('start_button')) {
         sofarb[eval(-1 + iw)]=aconto.getElementById('start_button');
         if (mode == 3 && iw == 1) {
           sofarb[eval(-1 + iw)].click();
           fsp=aconto.getElementById('final_span');
           isp=aconto.getElementById('interim_span');
         }
       }
       if (aconto.getElementById('copy')) {
         aconto.getElementById('copy').style.display='none';
       }
       if (aconto.getElementById('email_info')) {
         aconto.getElementById('email_info').style.display='none';
       }
       if (aconto.getElementById('results')) {
         if (iw == 1 || 1 == 1) {
            aconto.getElementById('results').onclick = function() { if (parent.hearitback) { parent.hearitback(this.innerHTML,eval(-1 + iw)); }   };
            aconto.getElementById('results').onmouseover = function() { if (parent.hearitback) { parent.hearitback(this.innerHTML,eval(-1 + iw)); }   };
         }
<?php
  if (isset($_GET['concept']) || isset($_POST['concept'])) {
           echo "\n aconto.getElementById('results').setAttribute('contenteditable', 'true'); \n";
  }
?>
       }
       if (aconto.getElementById('info_upgrade')) {
         if (aconto.getElementById('info_upgrade').innerHTML.indexOf('not supported') != -1) {
          if (('' + aconto.getElementById('info_upgrade').style.display).toLowerCase() != 'none') {
           if (document.getElementById('klr').innerHTML.indexOf('ou can type answer into left or right boxes.') == -1) {
             document.getElementById('klr').innerHTML+='<br>You can type answer into left or right boxes.<br>';
           }
           aconto.getElementById('results').setAttribute('contenteditable', 'true');
           resultso[eval(-1 + iw)]=aconto.getElementById('results');
          } else {
           document.getElementById('preq').innerHTML=dds('Speaking <?php echo str_replace("'","' + String.fromCharCode(39) + '",$qone); ?>');
          }
         } else {
          document.getElementById('preq').innerHTML=dds('Speaking <?php echo str_replace("'","' + String.fromCharCode(39) + '",$qone); ?>');
         }
       }
       if (aconto.getElementById('select_language')) {
         if (aconto.body.innerHTML.indexOf('var langs') != -1) {
           if (iw > 1) {
           ourlo[eval(-1 + iw)]=aconto.getElementById('select_language');
           ourl[eval(-1 + iw)]=eval(aconto.getElementById('select_language').value);
           ourlc[eval(-1 + iw)]=(aconto.body.innerHTML.split('var langs')[1].split(']];')[0].replace(/\ /g,'').split("',["))[eval(1 + ourl[eval(-1 + iw)])].split("'")[1].replace('-Han','').split('-')[0];
           } else {
           ourlo[eval(-1 + iw)]=aconto.getElementById('select_language');
           ourlangs=aconto.body.innerHTML.split('var langs')[1].split(']];')[0].replace(/\ /g,'').split("',[");
           ourl[eval(-1 + iw)]=eval(aconto.getElementById('select_language').value);
           //alert(iw + ' ' + ourlangs[ourl].split("'")[eval(-1 + ourlangs[ourl].split("'").length)] + " has language code " + ourlangs[eval(1 + ourl)].split("'")[1].split('-')[0]);
           ourlc[eval(-1 + iw)]=ourlangs[eval(1 + ourl[eval(-1 + iw)])].split("'")[1].replace('-Han','').split('-')[0];
           if (document.getElementById('hiba')) {
             document.getElementById('hiba').title=ourlc[eval(-1 + iw)];
           if (langsuffix != '') {
             //alert(langsuffix.replace('&thelang=','').toLowerCase().trim() + ' out of ' + ourlangs.length);
             var ayourlc='',ayourl=-1;
             for (ayourl=0; ayourl<eval(-1 + ourlangs.length); ayourl++) {
               ayourlc=ourlangs[eval(1 + ayourl)].split("'")[1].replace('-Han','').split('-')[0].trim();
               if (langsuffix.replace('&thelang=','').toLowerCase().trim() == ayourlc.toLowerCase().trim()) {
                 ilangsuffix=ayourl;
                 //document.getElementById('deflo').innerHTML=ourlangs[eval(0 + yourl)].split("'")[eval(-1 + ourlangs[eval(0 + yourl)].split("'").length)];
                 document.getElementById('hiba').title=ayourlc;
                 yourlc=ayourlc;
                 //alert('' + ilangsuffix + ':' + yourlc + ' ' + ourlangs[eval(0 + ayourl)]);
               }
             }
           }
             if (ilangsuffix != -1) {
               //alert(ilangsuffix);
             document.getElementById('hiba').innerHTML+=aconto.getElementById('select_language').innerHTML.replace(' value="' + ilangsuffix + '"', ' value="' + ilangsuffix + '" selected').replace(" value='" + ilangsuffix + "'", " value='" + ilangsuffix + "' selected");
             //document.getElementById('deflo').value='' + ilangsuffix;     //document.getElementById('hiba').value='' + ilangsuffix;
  if (document.getElementById('sq').innerHTML.indexOf('hib(') == -1) {
     if (mode == 0 && document.getElementById('sq').innerHTML.indexOf('?') != -1) {
     document.getElementById('sq').innerHTML='<b>' + modethree(insides(document.getElementById('sq').innerHTML).split('?')[0]) + modethree('?') + '</b><br><br>';
     } else {
     document.getElementById('sq').innerHTML=maybeontop('<b>' + modethree(insides(document.getElementById('sq').innerHTML).split('?')[0]) + '</b><br><br>',insides(document.getElementById('sq').innerHTML));
     }
  }
             } else {
             document.getElementById('hiba').innerHTML+=aconto.getElementById('select_language').innerHTML;
             }
             setTimeout(hibafix,2000);
           }
           }
         }
       }
     }
    }
  }
 }
 
 function lc_via_index(tind) {
  if (tind == '') {
  yourl=-1;
  yourlc="";
  yourlcclick=eval(eval(yourlcclick / 2) * 2);
  langsuffix='';
  if (document.getElementById('thelang')) {
    document.getElementById('thelang').value='';
  }
  } else {
  yourl=eval(tind);
  yourlc=ourlangs[eval(1 + yourl)].split("'")[1].replace('-Han','').split('-')[0];
  if (eval(yourlcclick % 2) == 0 && document.getElementById('i0')) {
    var cvis=confirm('Tell me if you want Google Translate window each time a new prompt arrives, in addition to default onhover and onclick functionality, for hearing purposes, perhaps?');
    if (cvis == true) {
      yourlcclick+=1;
      xhib(document.getElementById('s' + ifocusis).innerHTML);
    }
  }
  if (document.getElementById('sq').innerHTML.indexOf('hib(') == -1) {
     if (mode == 0 && document.getElementById('sq').innerHTML.indexOf('?') != -1) {
     document.getElementById('sq').innerHTML='<b>' + modethree(insides(document.getElementById('sq').innerHTML).split('?')[0]) + modethree('?') + '</b><br><br>';
     } else {
     document.getElementById('sq').innerHTML=maybeontop('<b>' + modethree(insides(document.getElementById('sq').innerHTML).split('?')[0]) + '</b><br><br>',insides(document.getElementById('sq').innerHTML));
     }
  }
  }
  langsuffix='&thelang=' + encodeURIComponent(yourlc);
  if (document.getElementById('thelang')) {
    document.getElementById('thelang').value=yourlc;
  }
  return yourlc;
 }
 
 function atcb() {
            if (document.getElementById('start_button')) {
             document.getElementById('start_button').click();
           }
}
 
 function cb(ot) {
   setTimeout(atcb,6000);
 }
 
 function andthen() {
   sofarb[0].click();
   if (document.getElementById('i' + ifocusis)) {
   if (document.getElementById('i' + ifocusis).style.display.toLowerCase().indexOf('none') == -1) {
   window.setTimeout(function ()
    {
          document.getElementById('i' + ifocusis).focus();
          document.getElementById('i' + ifocusis).click();
    }, 200);
    }
    }
 }
  
 function mode_three(inx) {
   var omo='';
   if (yourlc != '') {
     omo=' onmouseover=hib(); onclick=hib(); ';
   }
   if (omo != '') {
     return '<a' + omo + ' style=text-decoration:none;cursor:pointer; title=Translate>' + inx + '</a>';
   } else {
     return inx;
   }
}

 function modethree(inx) {
   var omo='';
   var omotwo='';
   if (yourlc != '') {
     omo=' onmouseover=hib(); ';
     omotwo=' hib(); ';
   }
   if (mode == 3 && inx != '?') {
     return '<a' + omo + ' onclick=" if (fsp) { fsp.innerHTML = ' + "'" + 'yes' + "'" + '; pdidchange(0,' + "'" + 'yes' + "'" + '); ' + omotwo + ' } " style=text-decoration:none;cursor:pointer; title=yes>' + inx + '</a>';
   } else if (mode == 3) {
     return '<a' + omo + ' onclick=" if (fsp) { fsp.innerHTML = ' + "'" + 'no' + "'" + '; pdidchange(0,' + "'" + 'no' + "'" + '); ' + omotwo + '  } " style=text-decoration:none;cursor:pointer; title=no>' + inx + '</a>';
   } else if (omo != '') {
     omotwo=' onclick=hib(); ';
     return '<a' + omo + omotwo + ' style=text-decoration:none;cursor:pointer; title=Translate>' + inx + '</a>';
   } else {
     return inx;
   }
 }
 
 function antiwoo() {
   if (woo != null) {
     woo.close();
     woo=null;
   }
   if (perr) {
     perr=false;
     document.getElementById('mya').click();
   }
 }
 
 function prowoo() {
   woo=window.open('//www.goo' + 'gle.com/search?q=' + encodeURIComponent(vocabulary[0]).replace(/\%20/g,'+'),"_blank","top=50,left=50,width=400,height=400");
   setTimeout(antiwoo,60000);
 }
 
 function pickq() {
<?php
  if (isset($_GET['concept']) || isset($_POST['concept'])) {
   echo "\n  document.getElementById('p12').style.display='none'; \n   document.getElementById('klr').style.display='none'; \n   document.getElementById('score').style.display='none'; \n  document.getElementById('kb').style.display='none'; \n if (isq < 0) { isq=Math.abs(isq);  if (isq < " . $qlast . ") {  document.getElementById('s' + eval(-1 + isq)).style.display='none'; document.getElementById('i' + eval(-1 + isq)).style.display='none';  document.getElementById('s' + eval(0 + isq)).style.display=document.getElementById('s' + eval(0 + isq)).title; document.getElementById('i' + eval(0 + isq)).style.display='inline'; ifocusis=Math.abs(isq); setTimeout(atfocus, 4000);   } else if (isq == " . $qlast . ") { for (var iqw=0; iqw<=" . $qlast . "; iqw++) {  document.getElementById('s' + iqw).style.display='inline';   document.getElementById('i' + iqw).style.display='inline'; ifocusis=iqw; setTimeout(atfocus, 4000);  } document.getElementById('sdata').style.display='block';   } } \n";
   if (isset($_GET['thetemplate'])) {
     if (strlen($_GET['thetemplate']) > 0) {
        echo "\n document.getElementById('dhangman').style.display='block'; document.getElementById('dhangman').style.backgroundColor='white'; document.getElementById('dhangman').innerHTML='<br><iframe style=transform:scale(0.5);margin-left:-50%;margin-top:-200px;width:200%;height:720px; id=ixhangman src=" . urldecode($_GET['thetemplate']) . "></iframe><br>'; \n";
     }
   } else if (isset($_POST['thetemplate'])) {
     if (strlen($_POST['thetemplate']) > 0) {
        echo "\n document.getElementById('dhangman').style.display='block'; document.getElementById('dhangman').style.backgroundColor='white'; document.getElementById('dhangman').innerHTML='<br><iframe style=transform:scale(0.5);margin-left:-50%;margin-top:-200px;width:200%;height:720px; id=ixhangman src=" . urldecode($_POST['thetemplate']) . "></iframe><br>'; \n";
     }
   }
  } else {
   echo "\n  if (mode == 3) {  document.getElementById('p12').style.display='none'; \n   document.getElementById('klr').style.display='none'; \n   document.getElementById('score').style.display='none'; \n  document.getElementById('kb').style.display='none'; \n   } \n if (isq < 0) { isq=Math.floor(Math.random() * questions.length); } \n";
  }
?>
   if (mode == 4 || mode == 5) {
     questions[0] = vocabulary[0];
     if (document.getElementById('tdm').innerHTML.indexOf('google.co' + 'm/search?q=') == -1) { 
   if (mode == 4) {
        document.getElementById('tdm').innerHTML+='<br><br><a id=mya target=_blank title="Find out more about the phrase above" href="//www.google.com/search?q=' + encodeURIComponent(vocabulary[0]).replace(/\%20/g,'+') + '">Find out more about the phrase above</a>';
   } else {
        document.getElementById('klr').innerHTML=document.getElementById('klr').innerHTML.replace('<br>',' ');
        document.getElementById('tdm').innerHTML+='<br><br><a id=mya style="display:none;cursor:pointer;text-decoration:underline;" target=_blank title="Find out more about the phrase above" onclick=setTimeout(prowoo,1000);>Find out more about the phrase above</a>';
   }
        document.getElementById('tdm').innerHTML+='<br><br><input type=button title="Can we pick another?" onclick="pickq();" value="Can we pick another?"></input> ... that has ...';
        document.getElementById('tdm').innerHTML+='<br><br>Min length: <input onblur="wlens=eval(this.value); pickq();" onchange="wlens=eval(this.value);  document.getElementById(' + "'" + 'imyword' + "'" + ').src=' + "'" + '//www.rjmprogramming.com.au/PHP/surprise.php?min=' + "'" + ' + eval(1 + wlens) + ' + "'" + '&max=' + "'" + ' + eval(1 + wlenb) + ' + "'" + '&phrase=y&youllneverfindthis=y' + "'" + ' + Math.floor(Math.random() * 134567); setTimeout(pickq,3000);"  style="display:inline;" type=number title="Minimum length" min=8 max=50 value=10></input> Max: <input onblur="wlenb=eval(this.value);   document.getElementById(' + "'" + 'imyword' + "'" + ').src=' + "'" + '//www.rjmprogramming.com.au/PHP/surprise.php?min=' + "'" + ' + eval(1 + wlens) + ' + "'" + '&max=' + "'" + ' + eval(1 + wlenb) + ' + "'" + '&phrase=y&youllneverfindthis=y' + "'" + ' + Math.floor(Math.random() * 134567); setTimeout(pickq,3000);" onchange="wlenb=eval(this.value); pickq();"  style="display:inline;" type=number title="Maximum length" min=8 max=50 value=20></input><br> Max of any one word: <input onblur="maxanyone=eval(this.value); pickq();" onchange="maxanyone=eval(this.value);   document.getElementById(' + "'" + 'imyword' + "'" + ').src=' + "'" + '//www.rjmprogramming.com.au/PHP/surprise.php?min=' + "'" + ' + eval(1 + wlens) + ' + "'" + '&max=' + "'" + ' + eval(1 + wlenb) + ' + "'" + '&phrase=y&youllneverfindthis=y' + "'" + ' + Math.floor(Math.random() * 134567); setTimeout(pickq,3000);" style="display:inline;" type=number title="Maximum length of any one word" min=4 max=50 value=7></input>';
     } else {
        document.getElementById('mya').href='//www.goo' + 'gle.com/search?q=' + encodeURIComponent(vocabulary[0]).replace(/\%20/g,'+');
     }
     //document.getElementById('imyword').src='//www.rjmprogramming.com.au/PHP/surprise.php?min=' + eval(1 + wlens) + '&max=' + eval(1 + wlenb) + '&youllneverfindthis=y' + Math.floor(Math.random() * 134567);
     document.getElementById('imyword').src='//www.rjmprogramming.com.au/PHP/surprise.php?min=' + eval(1 + wlens) + '&max=' + eval(1 + wlenb) + '&phrase=y&youllneverfindthis=y' + Math.floor(Math.random() * 134567);
   }
   if (resultso[0] != null) {
     resultso[0].innerHTML='';
   }
   if (resultso[1] != null) {
     resultso[1].innerHTML='';
   }
   if (questions.length > isq) {
   if (questions[isq].indexOf(delims[mode]) != -1) {
     if (mode == 0) {
     document.getElementById('sq').innerHTML='<b>' + modethree(questions[isq].split('?')[0]) + modethree('?') + '</b><br><br>';
     } else {
     document.getElementById('sq').innerHTML=maybeontop('<b>' + modethree(questions[isq].split('?')[0]) + '</b><br><br>',questions[isq].split('?')[0]);
     }
     if (questions[isq].indexOf('?') != -1) {
     answer=questions[isq].split('?')[1];
     } else {
     answer='';
     }
   } else {
     answer=questions[isq].split(delims[mode])[0];
     document.getElementById('sq').innerHTML='<b>' + mode_three(answer) +'</b><br><br>';
   }
   document.getElementById('kb').value='';
   isq=-Math.abs(isq);
   isq--;
   if (document.getElementById('i' + ifocusis)) {
   if (document.getElementById('i' + ifocusis).style.display.toLowerCase().indexOf('none') == -1) {
   document.getElementById('kb').focus(); // isq=isq;
   } else {
   document.getElementById('kb').focus();
   } 
   } else {
   document.getElementById('kb').focus();
   }
 <?php
  if (isset($_GET['concept']) || isset($_POST['concept'])) {
    echo "\n setTimeout(andthen,2000); \n";
  }
?>
  }
}

function hibafix() {
if (ilangsuffix >= 0) {
   if (1 == 77 && document.getElementById('hiba')) { document.getElementById('hiba').value='' + ilangsuffix; }
} else if (1 == 7) {
<?php
  if (isset($_GET['thelang'])) {
    if (strlen($_GET['thelang']) > 0) {
      echo "\n if (document.getElementById('hiba')) { document.getElementById('hiba').value='" . urldecode($_GET['thelang']) . "'; } \n";
    }
  } else if (isset($_POST['thelang'])) {
    if (strlen($_POST['thelang']) > 0) {
      echo "\n  if (document.getElementById('hiba')) { document.getElementById('hiba').value='" . urldecode($_POST['thelang']) . "'; } \n";
    }
  }
?>
}
if (document.getElementById('togo')) { document.getElementById('togo').innerHTML=''; }
}
 
</script>
</head>
<body onload="document.getElementById('preq').innerHTML=dds('<?php echo str_replace("'","' + String.fromCharCode(39) + '",$qone); ?>'); document.getElementById('kb').focus(); setTimeout(hibafix,2000); document.getElementById('dzip').innerHTML='<iframe id=izip name=izip onload=checkwiz(this) src=//www.rjmprogramming.com.au/PHP/ziptest.php title=GetMAMPsay style=display:none></iframe>'; pickq();">
<table cellspacing=10 cellpadding=10 style='width:100%;height:100vh;' border=20>
<tbody>
<tr><td style='width:40%;vertical-align:top;'><iframe onload='checki(this,1);' style='width:100%;height:95vh;' src='//www.rjmprogramming.com.au/PHP/speech_idea.php?ifno=1'></iframe></td><td id=tdm style='text-align:center;width:10%;vertical-align:top;background-color:yellow;'><span id=preq><?php echo str_replace(" LibreOffice"," <a target=_blank title=LibreOffice href=https://www.libreoffice.org/>LibreOffice</a>",$qone); ?></span> (thanks to <a target=_blank title='Google Speech to Text' href='https://www.google.com/intl/en/chrome/demos/speech.html'>Google Speech to Text</a>) <div id=dsay style=display:none;text-decoration:underline;cursor:pointer;background-color:pink;><a id=asayx onclick=" if (yourlcclick >= 2) { yourlcclick-=2; say=''; this.innerHTML='Do use Mac OS X Say Text to Speech'; } else {  yourlcclick+=2; say='';  this.innerHTML='Do not use Mac OS X Say Text to Speech';  } ">Do not use Mac OS X Say Text to Speech</a></div><br><br><span id=p12>&lt;- 1 Player 2 -&gt;</span><br><br><span id=sq></span><div id=ontopsq></div><span id=klr>One quizzer can<br> key in 1 (left)<br> or 2 (right)<br></span><br><input onblur=pdidchange(0,this.value); id=kb type=text onkeypress=okp(event); value=''></input><br><br><span id=score>Score: 0/0</span><br><br><select title='' id=hiba onchange="yourlc=lc_via_index(this.value);"><option title=' ... via Hover/Touch' id=deflo value=''>Language or Hear it Back ... Not Applicable ...</option></select><br><div id=togo><?php echo $togo; ?></div><br><div id=dhangman style=display:none;></div></td><td style='width:40%;vertical-align:top;'><?php echo $ifmaybe; ?></td></tr>
</tbody>
</table>
<iframe id='imyword' onload='checkwi(this);' src='//www.rjmprogramming.com.au/PHP/surprise.php?min=11&max=21&phrase=y&youllneverfindthis=y' title='Get a word' style='display:none;'></iframe>
<div id=dzip></div>
<div id=divac style=display:none;></div>
</body>
</html>
