function keywords(key)
{
  var arr = new Array();
  var x;
  arr = key.split(/\,/g);
  key = "";
  for (x in arr)
    {
      if (arr[x].length > 0)
        {
          var y = arr[x].replace(/^\s*/g,"");
          y = y.replace(/\s*$/g,"");
          key += '<a href="/cgi/search.cgi?words='+y+'">'+y+'</a>&#160;,&#160;';
        }
    }    
  key = key.replace(/\,(&\#160;)$/gim,"");
  document.writeln(key);
}    

function try_quiz(try_text,head)
{
 var url = location.href;
 url = url.replace(/^(.*)\..*$/g,"$1");
 url += ".tdf?0";
 head = head.replace(/(^\s*)|(\s*$)/,"");
 var try_quiz = "<div style=\"text-align:center;\"><a href=\""+url+"\">"+try_text+" "+head+"</a></div>";
 document.writeln(try_quiz);
}

function edit_cust_link(edit,cust)
{
 var url = location.href;
 var query_string = url;

 url = url.replace(/^([^\?]*).*$/,"$1");
 url = url.replace(/^.*cgi\/online\/serve.cgi\//,"");
 query_string = query_string.replace(/^[^\?]*\?(.*?)$/,"$1");

 var quiz = url.replace(/^(.*)\..*?$/,"$1");

 document.getElementById('edit_cust').innerHTML = '<a href="/cgi/editor/sat.cgi?'+quiz+'">'+edit+'</a>&#160;<a href="/cgi/editor/sat.cgi?'+url+'&amp;&amp;'+query_string+'">'+cust+'</a>';
}

function test_paper_link(xsl_file)
{
 var html = ""; 
 var url = location.href;
 url = url.replace(/^([^\?]*\?).*$/g,"$1");

 if (xsl_file == 'question_hide')
   {
     html = "<a href=\""+url+xsl_file+"\" style=\"color:navy;font-family:couriernew;font-size:80%;\">View Questions &#38; Answers</a>";
   }
 else if (xsl_file == 'question_only')
   {
     html = "<a href=\""+url+xsl_file+"\" style=\"color:navy;font-family:couriernew;font-size:80%;\">View Questions only</a>";
   }
 else if (xsl_file == 'answer_only')
   {
     html = "<a href=\""+url+xsl_file+"\" style=\"color:navy;font-family:couriernew;font-size:80%;\">View Answers only</a>";
   }

 document.write(html);
}

function html_edit()
{
  var file = location.href;
  file = file.replace(/(.*)\?.*/g,"$1");
  file = file.replace(/.*cgi/g,"");
  file = file.replace(/\.html/g,"");
  document.getElementById("FilePathSE").value = file;
  document.getElementById("SpotEdit").value = "DONE";
  document.getElementById("submit").click();
}

