  var showall=true;
  function showrows(src)
  { 
   showall=!showall;
   if (showall) 
   {
     state="";
     txt="Hide";
   }
   else
   {
     state = "none";
     txt="Show"
   }
   rules=document.styleSheets[0].rules||document.styleSheets[0].cssRules;
   rules[0].style.display=state;
   src.innerHTML=txt+src.innerHTML.slice(src.innerHTML.indexOf(' '));
  }
  
String.prototype.trim = function()
{
  // Use a regular expression to remove leading and trailing spaces
  var spacerex=/(^\s+)|(\s+$)/g;
  return this.replace(spacerex, "");
}
// add all these parameters!!!
  function showme(framen, frameid)
  { // check which params actually need to be passed
    var nw=window.open('bexplorepframegrams.php?num=' + framen + '&startwith=1&minvarcount=10&maxvarcount=&showpos=ON&minvarfreq=10&showtable=ON&maxvarfreq=&mintotal=100&maxtotal=&startwithframe=1&showmax=100&order=desc&renum=3&matchword1=&matchword2=&matchword3=&matchword4=&matchword5=&matchword6=&poscodes1=&matchpos1=&poscodes2=&matchpos2=&poscodes3=&matchpos3=&poscodes4=&matchpos4=&poscodes5=&matchpos5=&poscodes6=&matchpos6=&pframeid='+frameid);
    nw.focus();
  }
  function toggleExp(src)
  {
     var state=(src.innerHTML=="Hide");
     src.innerHTML=(state)?"Show":"Hide";
     document.getElementById("explanation").style.display=(state)?"none":"";
  }
function getCite(gram,freq)
{
  // need to re-fuse / de_underscore
  var q = "&quot;";
  var codes="";  
  var searchtext= q + gram.replace(String.fromCharCode(160)," ") + q;
  //alert(searchtext);
  var pat ="<p style='font-size:120%;font-weight:bold;'>Please be patient...<br>your search can take up to several minutes depending on complexity and server load.";
  var wn = window.open("", "", "scrollbars=1,dependent=1,location=0,menubar=1,resizable=1,toolbar=0,directories=0");
  while (!wn) { }
  var doc=wn.document;
  doc.open();
  doc.write("<html><head><title>" + searchtext + " - Random citations from BNC World Edition</title></head>");
  doc.write("<body style='background-color:#ECECEC;color:#000080;font-family:tahoma, verdana, arial, helvetica'><p style='font-size:xx-small;' align='center'><a href='index.html'>&quot;Phrases in English&quot; Home</a><span style='margin-left:1em;margin-right:1em;'>|</span><a href='javascript:window.close();' title='Close this window'>Close</a></p>");
  doc.write("<p style='font-size:120%;font-weight:bold;'>Fetching up to 50 examples of " + searchtext + " from the <i>BNC World Edition.</i><br>" + pat + "</p>");
  // Double quotes for values as they may contain apostrophes
  // doc.write('<form name="frmgetcite" action="' + targetpage + '" method="post"><input type="hidden" name="ofs" value="0"><input type="hidden" name="num" value="' + num + '"><input type="hidden" name="freq" value="' + freq + '"><input type="hidden" name="pos" value="' + pos + '"><input type="hidden" name="find" value="' + gram + '"><input type="hidden" name="codes" value=""></BODY></HTML>');
  doc.write('<form id="frmgetcite" action="getcite.php" method="post"><input type="hidden" name="ofs" value="0"><input type="hidden" name="num" value=""><input type="hidden" name="freq" value="' + freq + '"><input type="hidden" name="pos" value=""><input type="hidden" name="find" value="' + gram + '"><input type="hidden" name="codes" value=""></form></body></html>');
  doc.close();
  doc.getElementById("frmgetcite").submit();
}

