// This file contains intellectual property and artistic creations 
// by Dennis Sandow and is copyright 2000-2009 by the author. 
// For use only on websites maintained by Dennis Sandow, or with
// specific permission.  Do not remove this notice.
var MesagePtr=21, PrintableSidebars='', MPN=Wingding('mouse12',1);
if (isPrint) MPN='<img src='+pixPath+'mouse12.gif border=0>';
var cur=new Date();
nowCXD = cur.getFullYear() *10000 + (cur.getMonth() +1) *100 + cur.getDate() ;
var SidebarStatusLine = new Array();
if(typeof UsingSidebarCal_NoOptions == udf ) var UsingSidebarCal_NoOptions=0;

function stripPtag(arg){
  if( typeof arg == udf ) return;
  return arg.replace(/<p>$/g,'').replace(/<p>$/g,'').replace(/<p>$/g,'') ;
};

function LoadSidebarBlock(localList,thisHref,BoxTitleOpt,thisTitle, thisCaptionA,thisCaptionB,StatusBarMsg,isScroll){
  HotSpot="<a href="+thisHref+" onmouseover='xnd();window.status=\"\"; return true;' class=NoUL>&nbsp;</a>"
  if ( BoxTitleOpt ) { Hot2='';} else {Hot2=HotSpot;};
// alert(thisTitle+' '+ cur.getFullYear()+' '+ cur.getMonth()+' '+cur.getDate()+' '+nowCXD) ;
  localArray=new Array(); localArray=localList.split('|'); 
  spEvStr = ''; recurEvStr = ''; SkinnyBlankLine=''; PrintableTemp='';prevDMD='';

  for (x=0; x < ( localArray.length - 2 ); x += 6 ){
    regLink=''; room=''; genre=''; roomNote='';
    if( UsingSidebarCal_NoOptions ){
      Tokens=new Array(); Tokens = localArray[x+3].split(' ');
      for ( xt=0; xt<Tokens.length; xt++ ){
        if (Tokens[xt].indexOf('ROOM') >= 0)room = Tokens[xt].split(':')[1];
        if (Tokens[xt].indexOf('GENRE') >=0)genre = parseInt(Tokens[xt].split(':')[1]); 
      };
    };
    if ( ( thisTitle.split('!')[0] == 'LIBRARY NOTICES' || UsingSidebarCal_NoOptions ) && 
         localArray[x+3].indexOf('REGISTER') >= 0 ) {
      dotDay = localArray[x];
      dotTime = localArray[x+1];
      titl = localArray[x+4]; 
      regLink = '&nbsp; <a href="javascript:RegisterEmail2(\''+localArray[x+3]+'\',\''+titl+' '+dotDay+' '+dotTime+'\')" onMouseout="window.status=window.defaultStatus; return true;" onMouseover="window.status=\'Send Email\'; return true;" class="v10generic"><b>Register</b></a>';
    };
    if (room == 'T') roomNote = '<center><i>In the Training Room</i></center>'
    if (room == 'C') roomNote = '<center><i>In the Conference Room</i></center>'
    if (room == 'M') roomNote = '<center><i>In the Community Room</i></center>'

    Mesage[++MesagePtr]=
      stripPtag( localArray[x+5] )+'</i></b>'+regLink+roomNote+'</font>';
// if(regLink) alert(MesagePtr+' '+Mesage[MesagePtr])
    if ( localArray[x+1] == "No Meeting Header" ) localArray[x+1]='';
    if( localArray[x+2] ) {
      killCXD = parseInt(localArray[x+2]) ;
// alert (thisTitle+' '+x+' '+ nowCXD +' '+killCXD);
      if ( killCXD > 20000000 && killCXD < nowCXD ) continue ;
    };

    if (! thisCaptionA ) {
        Captn[MesagePtr]=localArray[x+4].replace(/^\*/,'');
    } else if(localArray[x].indexOf('Since') == 0){
        Captn[MesagePtr]=thisCaptionA + ' '+localArray[x]+' '+localArray[x+1];
    } else {
// CaptnIntros is Alt Header line for GV4 "Campaign Event|Community Event".
// Switch if first char of Title is '*'
// Similarly for Library Calendar-in-Sidebar.  Switch on var genre
        CaptnIntros=(thisCaptionA+'|||||||').split('|'); CaptnIntrosX=0;
        if( localArray[x+4].substr(0,1)=='*' && CaptnIntros[1] ) CaptnIntrosX=1;
        if (genre && CaptnIntros[genre]) CaptnIntrosX=genre;
        Captn[MesagePtr]=CaptnIntros[CaptnIntrosX]+' '+thisCaptionB+ ' '+localArray[x]+' '+localArray[x+1];
    };
    if ( UsingSidebarCal_NoOptions && prevDMD == localArray[x]){
      DateTag=SkinnyBlankLine; 
      SidebarStatusLine[MesagePtr]=localArray[x+4].replace(/^\*/,'');
    } else if (thisCaptionA){
      DateTag=localArray[x]+'<br>'; 
      SidebarStatusLine[MesagePtr]=localArray[x+4].replace(/^\*/,'');
    } else { 
      DateTag=SkinnyBlankLine; SidebarStatusLine[MesagePtr]='Posted on '+localArray[x] ;
    };
    prevDMD=localArray[x];
    tStr = '<tr><td class=v8>'+DateTag+'<center><nobr>'+
      '<a href="javascript:void(0)" '+
        'onmouseover="return ShowSidebarItem('+ MesagePtr+');" '+
        'onMouseOut="xnd()" class=h'+((localArray[x+3].indexOf('VERDI') >= 0)?'g':'')+'>'+MPN+'&nbsp;'+Solid(localArray[x+4].replace(/^\*/,''))+
      '&nbsp;'+MPN+'</a>'+Hot2+'</nobr></center></td></tr>' ;
    if (localArray[x].substr(0,3) != '<b>' ) spEvStr+=tStr; else recurEvStr+=tStr;
    SkinnyBlankLine='<span class=v4>&nbsp;</span><br>'; Hot2='';
    PrintableTemp += '<tr><td class=v8 align=left><center>'
    if (thisCaptionA) PrintableTemp += Captn[MesagePtr]+'&nbsp;&nbsp;&nbsp; '
    PrintableTemp += '<span class=v10><b>'+localArray[x+4].replace(/^\*/,'')+
      '</b></span></center><hr width=50%>'+stripPtag( localArray[x+5] )+
      '</td></tr>\n';
  };

// "No Events" message fits in parent sidebar cell. No nested tables.
  if ( ! spEvStr && ! recurEvStr ){
    if ( BoxTitleOpt ) { 
      document.write('<span class=v8><CENTER>'+
      '<nobr><font color=red>There are NO</font></nobr>'+
      '<br><nobr><b>'+thisTitle.split('!')[0]+'</b>'+HotSpot+
      '</nobr></CENTER></span>') ; 
    };
    return;
  };

  document.write('<table width=100% border=0 cellpadding=0 cellspacing=0>');

  if ( BoxTitleOpt ) { 
    document.write('<tr><td class=v8 align=center>');
    if (BoxTitleOpt == 2 ) { 
      document.write('<a href="'+thisHref+'"'+
        ' onmouseover="window.status=\''+StatusBarMsg+'\'; return true;"'+
        ' onMouseout="window.status=window.defaultStatus; return true;"' +
        '><b>'+Solid(thisTitle.split('!')[0])+'</b></a>');
      CAMB='Click above or mouseover below'; 
      if (isPrint) CAMB='Click above to print the Notices'; 
      document.write('<br><span class=v6>'+CAMB+'</span>'); 
    } else {
      subTitle=((thisTitle+'!').split('!')[1])?(thisTitle+'!').split('!')[1]+'<br>':''
      document.write('<nobr><b>'+Solid(thisTitle.split('!')[0])+'</b>'+HotSpot+'<br>'+subTitle+'<span class="v4">&nbsp;</span></nobr>');
    };
    document.write('</td></tr>'); 
  }; // end header block 

  if ( spEvStr ) {
    if (isScroll && (ie5A || ns6A) ) {
      document.write(''+
        '</table><hr width=65%>' + // close header table
        '<div style="overflow:auto; height:'+(typeof isLHT != udf?350:210)+'px;">' +
          '<table width=100% border=0 cellpadding=0 cellspacing=0>' + 
            spEvStr +
          '</table>' +
        '</div>'
      );
    } else document.write(spEvStr+'</table>') ;
  };
  if (recurEvStr) {
    if ( spEvStr ) document.write ( '<hr width=65%>' );
    document.write ( '<table width=100% border=0 cellpadding=0 cellspacing=0>'+ recurEvStr +'</table>' );
  };

  if (PrintableTemp) PrintableSidebars += ''+
    '<table width=90% border=1 cellpadding=5 cellspacing=0>'+
    '<tr bgcolor=#ffc0c0><td align=left class=v10>'+
    'The <b>'+thisTitle.replace(/<.*/,'').split('!')[0]+'</b> pop-ups can not be printed directly.&nbsp; '+
    'For convenience, the contents are repeated here.</td></tr>\n'+PrintableTemp+'\n</table><br>' ;

  return ;
};

function ShowSidebarItem(mc) {
  if ( isPrint ) { window.status='The text of this notice is displayed at the bottom of this page.'; return true;};
  if ( Mesage[mc].indexOf('href=') > 0 ){ return ShowSidebarItemStk(mc); };
  if( typeof SidebarRight == udf ) OLLR='L'; else OLLR = 'R';
  HintPop(mc,SidebarStatusLine[mc],'400,'+OLLR);
  return true;
};
function ShowSidebarItemStk(mc) {
  if( typeof SidebarRight == udf ) OLLR='L'; else OLLR = 'R';
  HintStick(mc,SidebarStatusLine[mc],'400,'+OLLR);
  return true;
};

function PrintableNotices(){
  if ( isPrint && PrintableSidebars ) document.write(PrintableSidebars);
  return;
};

function RegisterEmail2(lineItem4Tokens,rawTitleArg){
  NewUrl=NxPg('mailer.htm');
  NewWd(NewUrl,'mailerRegister');
  Tokens=new Array(); Tokens = lineItem4Tokens.split(' ');
  for ( x=0; x<Tokens.length; x++ ){
    if ( Tokens[x].indexOf('REGISTER') >= 0 ) {
      retrievedSendTo = Tokens[x].split(':')[1]; break;
    };
  };
  WPop.SendTo = retrievedSendTo;
  WPop.SendPagename = '';
  WPop.SendRedNote = '';
  WPop.noHtml = 'KILLHTML';
  WPop.deMinimus = 'KILLEXTRAS';
  cleanTitle=rawTitleArg.replace(/<b>/g,'' ).replace(/<\/b>/g,'');
  switch(retrievedSendTo){
    case 'friends@longhilllibrary.org': 
    case 'director@longhilllibrary.org':
    case 'adult@longhilllibrary.org':
    case 'teen@longhilllibrary.org':
         WPop.SendSubj = 'Please Register me for '+cleanTitle;
         WPop.Body = "Number attending:&nbsp;\n\nPhone:&nbsp;" ;
         break; 
    case 'children@longhilllibrary.org':
         WPop.SendSubj = 'Please Register my child for '+cleanTitle;
         WPop.Body = "Child's Name:&nbsp;\n\nPhone:&nbsp;" ;
         break; 
    case 'recreation@longhillnj.info':
         WPop.SendSubj = 'Please Register me for '+cleanTitle;
         WPop.Body = "\n\nPhone:&nbsp;\n\nAre you willing to be an organizer (captain, scheduler, etc.):&nbsp;"
         WPop.SendFootNote = "Please mail your check to<br>Recreation Department<br>Long Hill Township<br>915 Valley Road<br>Gillette, NJ 07932<br><br>and write the event name on the check." ;
//         WPop.noSQ = 'nosquelch';
         break; 
    default: 
         WPop.SendTo = 'webmaster@dennissandow.com';
         WPop.SendSubj = 'Unknown for '+cleanTitle;
         WPop.Body = "Something is wrong. Please describe what you were trying to do, and submit this message to the Webmaster so he can fix it. {"+rAddr+")\n\nComments:&nbsp;" ;
         break; 
  };
};

