function showRef(whereTo)
        {
				 thisSUP = window.event.srcElement;
				// alert(thisSUP.innerText + '  '+thisSUP.title);
			
							 
				 openRefs();
				 showWindow.document.all(whereTo).scrollIntoView(true);
				 }
				 
function showStatus()
         {
				 thisSUP = window.event.srcElement; 
				 window.status = thisSUP.title;
				  }				 
				 
 var  buildHtml = '<STYLE type=text/css>TD { vertical-align:text-top;} .jump{color:blue;text-decoration:underline; cursor:hand}</style>';
     buildHtml+='<table  border="0" summary="Table of References for the first five chapters of the Pilgrim Church">'; 

 var  cites = document.all.tags("SUP");

 for (i =0; i<cites.length; i++)
      {
			 num = 1 + i;
	     num = num.toString();
       numRef = cites[i].innerText + ' '+ num +'.<span class="hideMe">ref_'+num+'VJZx</span>';			 
			 buildHtml+= '<tr><td onclick="opener.focus();opener.jumpToLink(\'ref_'+num +'\');window.close()" class="jump">'+num +'.&nbsp;&nbsp;</td><td><a id="ref_'+num +'"></a>'+ cites[i].title+'</td></tr>';
			 

			 sup = cites[i];
				sup.innerHTML =numRef; 
			 sup.id= document.uniqueID;		 
	    sup.setAttribute('onclick','showRef("ref_'+num +'")');
			 sup.setAttribute('onmouseover','showStatus()');			 
			 
			  }
        buildHtml+= '</table>';

 var  showWindow = null;

function openRefs()
  {
	  if (showWindow != null)
				      {
							showWindow.close(); // get around "unspecified error"
							 }
	 showWindow = window.open("about:blank","showWindow");
	 showWindow.document.title='List of References for the Pilgrim Church';
	 showWindow.document.body.innerHTML = '<h2>References</h2>'+ buildHtml;
	 } 	


var	buildExplain;
		 
function openExplanations()
	  {
		
		buildExplain = '';
  var buildAplhaJumps ='';
	var currentLetter ='';
	//alert('Hi');
rootNode = document.all.glossaryList[0].documentElement;
 //	rootNode = document.all.glossaryList.documentElement;
// rootNode =glossaryList.documentElement;
 
//alert(rootNode.xml)	;            //    .documentElement

records = rootNode.selectNodes("record");

				//alert(records.length);
				
 var titles = new Array();				
				
				for (i=0; i< records.length; i++)
			       	{
	                titles.push( records[i].selectSingleNode('Title').text);
	                   }
            titles = titles.sort();
		
						for (i=0; i< titles.length; i++)
				    { 
						      letter = titles[i].substr(0,1).toUpperCase();
									
				     if (currentLetter != letter)
						     {
								  currentLetter = letter;
								   buildAplhaJumps += '<a href=\"#_'+letter+' \">'+letter+'</a> ';
									 information = '<a name=\"_'+letter+'\">panZXCVBNM</a>';
									 }else
									  {information='';}
		//	
							idString = document.uniqueID;
									 
		     information +='<DIV><P opened="hidden" onmouseover="this.style.color=\'blue\';" onmouseout="this.style.color=\'black\'" title=" Click to Open " STYLE="font-weight:bold; text-align:center; cursor:hand" onclick="opener.showHide(this, '+idString+')"	>'+ titles[i] + '</P>';
					
		  	  	thisTerm = rootNode.selectSingleNode('record[Title=\"'+titles[i]+'\"]');
					
				        shortD  = thisTerm.selectNodes("ShortTitle").item(0).text;			
 	             explainX = thisTerm.selectNodes("Explanation").item(0).text;
   	            picture = thisTerm.selectNodes("Image").item(0).text;
              ExpandedX = thisTerm.selectNodes("expanded").item(0).text;
							
							information += '<dd id='+idString+' style="display:none">' 

              	if (shortD != '')
	                    		{information +=  shortD ;} 
	
              	if (explainX != '')
		                     	{information += '<p>'+ explainX +'</p>';}
			
	              if (picture != '')
	                     		{information += '<img src="images/'+picture+'" alt="'+shortD+'" align="right" />';}		
				
	              if (ExpandedX != '')
		                    	{information += '<p>'+ ExpandedX +'</p>';}
			
				  information += '<HR>';
					information += '</DD></DIV>' ;
					
					buildExplain += information;
					
					}
					
					re = /panZXCVBNM/g;      
			
			   buildExplain = buildExplain.replace(re, buildAplhaJumps.bold());
			
		 explainWindow = window.open("blank.htm","explainWindow");
	
      //explainWindow.alert(explainWindow.document.body.innerHTML);
		 }
		 
function daughterReady(daughter)
  {
	 daughter.document.title='Glossary of Explanations for the Pilgrim Church';		
 	 daughter.document.body.innerHTML = '<h2>Explanations</h2>'+  buildExplain;
   daughter.document.body.attachEvent("onbeforeprint", parent.daughterOnbeforeprint);
	 daughter.focus();
	 }		 

function daughterOnbeforeprint()
{
    alert('hi');

   // walk through all the elements in the document with CLASS= "clsCollapsed"
   // and set it to "expanded" just for printing.
   var coll = explainWindow.document.all.tags("DD");
   if (coll!=null)
   {
      for (i=0; i<coll.length; i++) 
	   {  
           coll[i].style.disl=play = "block";		  
		 }
		
   }
}
	 
	var openedExplain = null;	 

function showHide(where, what)
      {
			
	/*dds = where.document.all.tags("dd");
	 for (i=0; i<dds.length; i++)
	       {
				    dds[i].style.display="none"; 
					 }	  		
		*/			 
		
		if (openedExplain != null)
		      {
					 openedExplain.style.display="none";
					 
					 }
					 
			if (where.opened=="hidden")
			       {
						 where.title="\n Click to Close \n";
						 what.style.display="block";
						 where.opened="showing"
						 where.scrollIntoView(true);
						 openedExplain = what;
						 }
					       else
								 {
								 where.title="\n Click to Open \n";
								 what.style.display="none";
								 where.opened="hidden";
								 
								 }
			}

		 
function handleMenu()
 { // temp for proofing process, will be replaced with print stuff
       window.open('mailto:paul_norman_3@compuserve.com?Subject=Pilgrim Church, Version: 2005 03 18 - '+document.all.pageNumber.innerText+'&Body=Please Mark Changes Required Clearly:%0d%0a%0d%0a'+event.srcElement.innerText);

			 window.event.cancelBubble = true;
			 return false;
	}
	
	document.all.display.attachEvent('oncontextmenu', handleMenu);
document.all.display.title ='  To Send This Page for Correction By Email\n\n    Right Click The Required Paragraph ONLY ONCE\n\n  . . . . . .  AND WAIT PLEASE\n\n ';		 

/*
 <xml id=glossaryList Xondatasetcomplete="setUpExplain()" src="xml/PC-explain.xml"></xml>
 
 

 
 var glossaryList = new ActiveXObject("Msxml2.DOMDocument");
glossaryList.async = false;
glossaryList.resolveExternals = false;
//glossaryList.validateOnParse = false;

// Load an XML file into the DOM instance.
glossaryList.load("./xml/PC-explain.xml");
*/



function daughterOnafterprint()
{
   // walk through all the elements in the doc with CLASS="clsExpanded"
   // and set it back to "clsCollapsed" if expanded just for printing purposes.
   var coll = document.all.tags("DIV");
   if (coll!=null)
   {
      for (i=0; i<coll.length; i++) 
	     if ((coll[i].className == "clsExpanded") &&
		     (coll[i].bExpandedForPrinting))
		 {  
           coll[i].className = "clsCollapsed";
		   coll[i].bExpandedForPrinting = false;
		 }
   }
}

