// This file contains intellectual property and artistic creations 
// by Dennis Sandow and is copyright 2000-2010 by the author. 
// For use only on websites maintained by Dennis Sandow, or with
// specific permission.  Do not remove this notice.

var udf='undefined';

// ==============
// This.js is only installed in main templates, if ANY of the yMenu, Recent or Comments features is needed.  Install after ddms.js and biskits.js, but before misc.js.
// ==============
// In control.txt, set "USE.BULLETS#TRUE" to manufacture bullet handling into the pages.
// Mfgr installs call to bullets(key)
// NB: Mfgr ALWAYS inserts |[Y[YY]][W[WW]]| into tclist.js if mfgr detects New (%53|%54) or 'Comment('.  Presence of |YW| in tclist.js ignored by html page unless further tests are met.
// ==============
// New (yellow) bullets
// Allowed in page to the extent that Y or Yy are set in var useRecent here.
// uppercase=target page (rotating). lowercase=under target page (static).

var useRecent='Yy' ;

// In all templates, <body> starts with call to setSizes() in misc.js.
// SetSizes() TESTS FOR, then calls menuSupportSetup() which is here.  
// If any of the three flags are on, then menuSupportSetup() calls mPgListParse()
// If user cookie kkKillNewInMenu is not set, then scan tclist.js for 'Y' and date-last-updated and scan kkHist cookie list for date-last-viewed.  Prepare array yMenuAr[8char] = '[Y][yyy]' to include self and children. Skip all NOMENU.
// On loading of page, each menu entry calls bullets().
// If kkKillNewInMenu cookie is set, then suppress recent logic.
// Write Y or y dot with link to page and mouseover to hintPop().
// Mouseover is suppressed if yMenu is active on this menu line.
// ==============

// Comment (white) bullets
// Allowed if UseComments == 1 appears in ddms.js (set from siteopts.htm and news.cgi)  (Nice thought - never developed.)
// local override (install in non-main.mas pages that do not read menusupport.js)

// --31
if (typeof UseComments == udf ) UseComments=1;

// Individual pages may suppress Comments by setting var KillComments=1 in --31
// if KillComments, then UseComments is unset in readme.js

// In all templates, <body> starts with call to setSizes() in misc.js.
// SetSizes() TESTS FOR, then calls menuSupportSetup() which is here.  
// If any of the three flags are on, then menuSupportSetup() calls mPgListParse()
// Prepare array yMenuAr[8char] = '[W][www]' to include self and children. Skip all NOMENU.
// On loading of page, each menu entry calls bullets().
// If ! UseComments then suppress.
// Write W or w dot with link to page and mouseover to hintPop().
// Mouseover is suppressed if yMenu is active on this menu line.

// ==============

// In control.txt, set "USE.POPMENU#TRUE" to manufacture popout menu handling into the pages.
// Mfgr installs onmouseover call to yMenu(key)

var gotListParse=0;
function menuSupportSetup(){
  if ( typeof isKookie != udf && isKookie &&
     typeof MenuItems != udf && MenuItems && 
     ( 
       ( typeof useRecent != udf && useRecent ) ||
       ( typeof UseComments != udf && UseComments ) ||
       ( typeof UseYMenu != udf && UseYMenu ) 
     ) 
  ) gotListParse = mPgListParse();
};

function mPgListParse(){
  if ( typeof TcntList == udf || ! TcntList ) return 0;
  if ( typeof kkKillNewInMenu != udf && kkKillNewInMenu && typeof kkKillYMenu != udf && kkKillYMenu ) return 0;
  TcLisArray=TcntList.split('|'); ord=0; Qurrent = new Array();
  for (x=0; x < ( TcLisArray.length - 1 ); x += 9 ){
    Depth= parseInt(TcLisArray[x]); 
    notOnParentMenu= TcLisArray[x+1];
    fileName8Char=TcLisArray[x+4]; 
    if( fileName8Char == 'index' ) fileName8Char='home';
    Qurrent[Depth] = fileName8Char ;

    if ( typeof kkKillNewInMenu != udf && ! kkKillNewInMenu ){
      masDate=TcLisArray[x+6];
      newOrCmmtsInMe=TcLisArray[x+7]; 

// for every page in the TcntList, if the "viewed page date" cookie is newer than the "page updated" cookie, then suppress the Y flag from the TcntList (if it existed)
      for (kkx in kkHist) {
        if( fileName8Char == kkHist[kkx].split('~')[0] ) {
          if ( (masDate - 732) <= parseInt( kkHist[kkx].split('~')[1] ) ) {
            newOrCmmtsInMe = newOrCmmtsInMe.replace(/Y/g,'');
          };
          break;
        };
      };
// for every page in the TcntList, examine this page and all its menu superiors.
      for ( yDeep=1; yDeep<=Depth; yDeep++) {
// If this page, note the page updated date and record the ADJUSTED new Y flag for use by bullets()
        if (yDeep == Depth) {
          upDatesAr[fileName8Char] = masDate ;
          blltsAr[fileName8Char] = newOrCmmtsInMe ;
        } else if ( notOnParentMenu != 'N' ) {
// if examining a superior page (and this page is in the superior menu), look for page update dates of other subs and remember the latest of (other subs or this sub); and append the ADJUSTED AND LOWERCASED new YW flag for use by bullets()
          updMe = ( upDatesAr[Qurrent[yDeep]]+'|' ).split('|')[0];
          updSubs = ( upDatesAr[Qurrent[yDeep]]+'|' ).split('|')[1];
          if (updSubs) updSubs = parseInt(updSubs);
          upDatesAr[Qurrent[yDeep]] = updMe+'|'+Math.max(updSubs,masDate);
          blltsAr[Qurrent[yDeep]] = blltsAr[Qurrent[yDeep]]+newOrCmmtsInMe.toLowerCase() ;
        };
      };
    }; // end NewInMenu

    if ( typeof kkKillYMenu != udf && ! kkKillYMenu ){
      yMenuAr[fileName8Char]=''; ListWord=TcLisArray[x+5]; ListStatusString=TcLisArray[x+8];
      for (yx=x+9; yx < ( TcLisArray.length - 1 ); yx += 9 ){
        Depth2 = parseInt(TcLisArray[yx]); if ( Depth2 <= Depth  ) break;
        fileName2=TcLisArray[yx+4]; 
        if ( fileName2 == iAm ) { yMenuAr[fileName8Char]='' ; break; };
        if ( TcLisArray[yx+1] == 'N' ) continue; // exclude NoMenu
        if ( ! kkNestYMenu && Depth2 > Depth+1 ) continue;
        ListWord2=TcLisArray[yx+5];
        ListStatusString2=TcLisArray[yx+8];
        yMenuAr[fileName8Char]+='<tr><td class=v8>&nbsp;&nbsp;&nbsp;'+
          (Depth2 > Depth+1?'&nbsp;&nbsp;':'')+
          '<a href="'+constructHref(fileName2)+'" class="noUL" '+
            'onmouseover="window.status=\''+ListStatusString2+'\'; return true" '+
            'onmouseout="window.status=window.defaultStatus; return true;">'+
          ListWord2.replace(/ /g,'&nbsp;')+'</a></td></tr>';
      };

      if (yMenuAr[fileName8Char]) yMenuAr[fileName8Char] = '<table width=100% border=0 cellpadding=0 cellspacing=0><tr><td class=v8><a href="'+constructHref(fileName8Char)+'" class="noUL" onmouseover="window.status=\''+ListStatusString+'\'; return true" onmouseout="window.status=window.defaultStatus; return true;"><b>'+ListWord+'</b></a></td></tr>'+yMenuAr[fileName8Char]+'</table>';
    }; // end yMenu
  }; // end TcntList loop
  return 1;
};

alct=0;
function constructHref(hKey){
//  if ( alct < 10 )   alert ( hKey); 
  for (zx=4; zx < ( TcLisArray.length - 1 ); zx += 9 ){
//  if ( alct < 10 && zx < 40 ) alert ( zx +' '+hKey+' '+TcLisArray[zx])
    if ( TcLisArray[zx] != hKey ) continue;
    hKey = (isWeb?WorkDir:'')+hKey+'.htm'; 
    if ( TcLisArray[zx-1] == 2 ) return 'javascript:NewWd(\''+hKey+'\')';
    return hKey;
    break;
  };
//  if ( alct < 10 )  { alert ( 'constructHref failed for '+ hKey); alct++; }; 
  return '';
};

function bullets(arg){
  if ( ! arg || ! gotListParse || typeof useRecent == udf || ! useRecent ) return;
  useB=useRecent; mPgKey=arg; bLink=constructHref(arg) ;HP=1;

  if ( typeof blltsAr != udf && typeof blltsAr[mPgKey] != udf ) {
    dotBL = blltsAr[mPgKey]; 
  } else dotBL = '';
  if ( typeof kkKillNewInMenu != udf && kkKillNewInMenu ) dotBL = dotBL.replace(/[Yy]/g,'');
  if ( typeof yMenuAr != udf && typeof yMenuAr[arg] != udf && yMenuAr[arg] ) HP=0;
  if ( dotBL ) {
    if ( useB.indexOf("Y") >=0 && dotBL.indexOf('Y') >= 0 && HP ) {
      document.write('<a href="'+bLink+'" onmouseout="xnd()" onMouseover="return HintPop(\'YellowDot\',\'Yellow Dot\')" class=noUL><img src="'+pixPath+'boxyela.gif" width=16 border=0><a>');
    } else if ( useB.indexOf("y") >=0 && dotBL.indexOf('y') >= 0 && HP) {
      document.write('<a href="'+bLink+'" onmouseout="xnd()" onMouseover="return HintPop(\'yellowDot\',\'Yellow Dot\')" class=noUL><img src="'+pixPath+'boxyel.gif" width=16 border=0><a>');
    } else if ( useB.indexOf("Y") >=0 && dotBL.indexOf('Y') >= 0  ) {
      document.write('<a href="'+bLink+'" onmouseout="window.status=window.defaultStatus; return true;" onMouseover="window.status=Mesage[\'YellowDot\']; return true;" class=noUL><img src="'+pixPath+'boxyela.gif" width=16 border=0><a>');
    } else if ( useB.indexOf("y") >=0 && dotBL.indexOf('y') >= 0 ) {
      document.write('<a href="'+bLink+'" onmouseout="window.status=window.defaultStatus; return true;" onMouseover="window.status=Mesage[\'yellowDot\']; return true;" class=noUL><img src="'+pixPath+'boxyel.gif" width=16 border=0><a>');
    };
  };
  if ( typeof UseComments == udf || ! UseComments ) return;
  if ( dotBL.indexOf('W') >= 0 && HP ) {
    document.write('<a href="'+bLink+'" onmouseout="xnd()" onMouseover="return HintPop(\'GreyDot\',\'Grey Dot\')" class=noUL><img src="'+pixPath+'boxwhia.gif" width=16 border=0><a>');
  } else if ( dotBL.indexOf('w') >= 0 && HP ) {
    document.write('<a href="'+bLink+'" onmouseout="xnd()" onMouseover="return HintPop(\'greyDot\',\'Grey Dot\')" class=noUL><img src="'+pixPath+'boxwhi.gif" width=16 border=0><a>');
  } else if ( dotBL.indexOf('W') >= 0 ) {
    document.write('<a href="'+bLink+'" onmouseout="window.status=window.defaultStatus; return true;" onMouseover="window.status=Mesage[\'GreyDot\']; return true;" class=noUL><img src="'+pixPath+'boxwhia.gif" width=16 border=0><a>');
  } else if ( dotBL.indexOf('w') >= 0 ) {
    document.write('<a href="'+bLink+'" onmouseout="window.status=window.defaultStatus; return true;" onMouseover="window.status=Mesage[\'greyDot\']; return true;" class=noUL><img src="'+pixPath+'boxwhi.gif" width=16 border=0><a>');
  };
};

if ( typeof Mesage == udf ) { var Mesage=new Array(), Captn=new Array(); };
Mesage['YellowDot'] = 'The yellow dot means that this page contains something new.';
Mesage['yellowDot'] = 'The yellow dot means that a page in this section contains something new.';
Mesage['GreyDot'] = 'The grey dot means that this page includes personal comments or analysis by the Webmaster.';
Mesage['greyDot'] = 'The grey dot means that a page in this section includes personal comments or analysis by the Webmaster.';

// UseYMenu is declared in template/main and patch rev L357
function yMenu(arg, ymWord){
  if ( typeof kkKillYMenu != udf && kkKillYMenu ) UseYMenu = 0;
  if ( ! arg || typeof UseYMenu == udf || ! UseYMenu || arg == iAm ) {
    xnd(); window.status=ymWord; return true;
  };
  if ( typeof yMenuAr != udf && typeof yMenuAr[arg] != udf && yMenuAr[arg] ) {
    overlib(yMenuAr[arg],STATUS,ymWord,FIXX,150,STICKY,TIMEOUT,10000, TEXTSIZE,2,VAUTO,SNAPY,15,WIDTH,250);
    return true;
  } 
  xnd(); window.status=ymWord; 
  return true;
};
