document.writeln('<style type="text/css">');
document.writeln('<!--');
document.writeln('a.alt:link { text-decoration: none; color: #0005BC }');
document.writeln('a.alt:visited { text-decoration: none; color: #668 }');
document.writeln('a.alt:active { text-decoration: underline; color: #F00 }');
document.writeln('a.alt:hover { text-decoration: underline; color: #0005BC }');
document.writeln('-->');
document.writeln('</style>');
// inital display values
var nStart=1;    // news items to display from
var nEnd=6;      // news items to display to (the different of the two being the number of items being displayed)

var nFull=false; // full news item list flag 

if (location.search != "") {
  q = location.search.slice(1);
  switch (eval(q)) {
    case 20 : nEnd=eval(q); nFull=true; break;
    default : if ((eval(q)>4) && (eval(q)<20)) { nEnd=eval(q); }
              else {
                window.alert("Sorry, invalid query!");
                window.location.href="news.htm";
              };
              break;
  }
}

if (article[0]) {
  document.write('<h6>' + (nEnd-nStart) + ' most recent headlines</h6>')
  document.write('<p>')
    for (i=nStart; i<nEnd; i++) {
      document.writeln(
        '<a target="_blank" href="'
      + article[i].url 
      + '">'
      + article[i].headline_text 
      + '</a>'
      + '<br>'
      + '<small>'
      + '<a class="alt" target="_blank" href="'
      + article[i].document_url 
      + '">'
      + article[i].source 
      + '</a> &nbsp; ' 
      + article[i].harvest_time
      + '</small>'
      + '<br>'
      + '<br>'
      );
    }
  document.write('</p>')

  if (!nFull) {
    var l = window.location.href;
    var s = l.split('?');
    delete s[1];
    document.write('<hr align="left" width="200"><p><a href="' + s[0] + '?20">Display all headlines</a></p>');
  };
} else {
    document.write('<p>Sorry, there was an error retrieving the news articles, please <a href="' + window.location.href + '">try again</a> in a few minutes.</p>')
  }
