// 05/09/08
// The idea here is to show NEW on index page when document in L/ should be viewed i.e. there is a new CURRENT document
//    index.html points to current version wanting to be viewed. CURRENT == Ln .   older versions exist
// 6) hardcode version="yymmdd" in doc.  .js defines KEY and newest VERSION
//             Only set cookie if version of this doc is .GT. old cookie
//    if .js says newest is 03; user after       viewing 03, sees no new ones! (TRUE)
//                              user goes back and views 02, sees no new ones! (TRUE)
// 05/12/08 revise viewing to only set cookie if existing cookie <= version

//invoked just before calling isItNew or viewing
// isItNew might be in the index.html and viewing in the detail.html
function isItNew() {           // if key value < version say "its new"
  var firstChar, lastChar;
  var cookieS = document.cookie;    // make it a string 

  firstChar  = cookieS.indexOf(key); 
  if(firstChar > -1 ) {                  // key not found ~= new
    firstChar += key.length + 1;
    lastChar=cookieS.indexOf(";", firstChar); if(lastChar == -1) lastChar=cookieS.length; 
                                                    // no ending ; so must be last n=v pair
    if ( cookieS.substring(firstChar, lastChar) >= version ) return false; 
                     }
    document.write(
     ' <img src=pics/newspin.gif alt="NEW" title="NEW" > ');
  showMsg(20);       
  return  true;
}  	

function viewing(){ if ( version == '' )return;  // oops, no version defined.
  var expDate = (new Date((new Date()).getTime() + 4368*3600000)).toGMTString(); 
  var firstChar, lastChar;
  var cookieS = document.cookie;    // make it a string 
  firstChar  = cookieS.indexOf(key); 
  if(firstChar > -1 ) {                  // key not found ~= new
    firstChar += key.length + 1;
    lastChar=cookieS.indexOf(";", firstChar); if(lastChar == -1) lastChar=cookieS.length; 
                                                    // no ending ; so must be last n=v pair
    if ( cookieS.substring(firstChar, lastChar) >= version  ) return; // the one he saw before is newer
                       }
  document.cookie = key+"="+version+";path=/;expires="+expDate  ;
  return ;
} 
function showMsg( step )  /* ng for netscape */
{ if( step-- ==0 )	return true;// without setting timeout
  window.status = (step % 2) ?   "                New " : "-<=#=>- New  -<=#=>-";  
	window.setTimeout( "showMsg(" + step + ")" ,800   ); // come back to me 
	return true;
}

// 03/01/08
// 1) Having VERSION in  letters.js 
//    index, current, Ln and Ln-1 include .js    Viewing ANY implies ALL were viewed : not true
//                                               This means that navagation did not from  /index maybe letters/index
//                                               Maybe  search engine
//                                               If you're smart enough to use letters/index well...
// 2) Ln contains 080301, Ln-1 contains 080201  .js contains 080301  viewing 03 then 02 shows new NG
// 3) actually these are 2 uniq unrelated documents and should have uniq keys ?? how many to check in index ?? NG
// 4) use LETTER and LETTEROLDER stores 2 keys,             viewing any OLDER implies all, 
//                                               change LETTER.js to notnew.js when adding a new letter
//  best:
// 5) index, current and Ln include .js          replace  letters.js from Ln-1 document when Ln is new with  notnew.js 
//                                              hardcode KEY=LETTERS;VERSION=""; (naw!)
//                Ln-1, L-2 ... include notnew.js VERSION=''; 
//                                               Have viewing() not write cookie i.e. CURRENT not viewed
//                                               viewing CURRENT implies ALL were viewed (well the old ones aren't new!)
