var loc = new Array();
var myAs = new Array();
var aSett = new Array();
var text = new Array();
var first=0;
var first2=0;
var otherfirst=0;
var winn;
var win;
var anchor2 = new Array();
var num = 0;
var sectionNumber = new Array();
var maindoc;
var impElement = new Array();
var aSet;
var sectionTitle = new Array();
var win2;

function listanchors(t) 
{
  if(first2==0)
  {
    winn = window.open("", "", 
                             "scrollbars=yes,resizable=yes," +
                             "width=225,height=150");
							 
	maindoc = t.document;
	
	
	v = winn.document;
	v.write('<html><head><title></title></head><body onunload="opener.first2=0; opener.win2.close()"><span id="placeholder">Table of Contents</span></body></html>');

    var toc = v.createElement("div");
    toc.style.backgroundColor = "white";
    toc.style.fontFamily = "sans-serif";
	
	var anchor = v.createElement("a"); 
	toc.appendChild(anchor);                   
	
    anchor.appendChild(v.createTextNode("List of the Page's Links"));
	
	var table = v.createElement("table");
    toc.appendChild(table);
	
	tbody = v.createElement("tbody");
    table.appendChild(tbody);


    
    for(var i = 0; i < maindoc.anchors.length; i++) 
	{

        var a = maindoc.anchors[i];
	
		loc[i] = a.href;
		
		
		
		
        text[i] = null;
        if (a.text) text[i] = a.text;                          // Netscape 4
        else if (a.innerText) text[i] = a.innerText;           // IE 4+
        if ((text[i] == null) || (text[i] == '')) text[i] = a.name;  // Default
		
		var row = v.createElement("tr");
				    
		var col1 = v.createElement("td");
		
		myAs[i] = v.createElement("a");
	    	myAs[i].setAttribute("name",loc[i]);
        	myAs[i].setAttribute("href","");
			
		myAs[i].setAttribute("innerText",text[i]);		

		col1.setAttribute("align", "left");
		col1.appendChild(myAs[i]);

		row.appendChild(col1);
		   		
		tbody.appendChild(row);

		
		
		
    }
	replace = v.getElementById("placeholder");
    replace.parentNode.replaceChild(toc, replace);
  }
  	first2=1;
	aSett = v.getElementsByTagName("a")
		
	for(w=1;w<aSett.length;w++)
	{
		
	  	aSett[w].onclick = function(){win2 = window.open("", "newwin", 
                             "scrollbars=yes,resizable=yes," +
                             "width=650,height=500"); win2.location=this.name; return false;}
		
  	}

    v.close();   // Never forget to close the document!
}



function makewin(t)
{

  if(first==0)
  {

	var link = new Array();
	maindoc = t.document;
	
   	win = window.open("", "", "width=700,height=100,resizable=yes,scrollbars=yes");
	d = win.document;
	d.write('<html><head><title></title></head><body onunload="opener.first=0;"><span id="placeholder">Table of Contents</span></body></html>');
	d = win.document;
	var toc = d.createElement("div");


    toc.style.backgroundColor = "white";
    toc.style.fontFamily = "sans-serif";

    var anchor = d.createElement("a"); 
    toc.appendChild(anchor);                   

    anchor.appendChild(d.createTextNode("Table Of Contents"));

    var table = d.createElement("table");
    toc.appendChild(table);

    var tbody = d.createElement("tbody");
    table.appendChild(tbody);

    var sectionNumbers = [0,0,0,0,0,0];


    addSections(this.document.body, tbody, sectionNumbers);


    replace = d.getElementById("placeholder");
    replace.parentNode.replaceChild(toc, replace);


    function addSections(n, toc, sectionNumbers) 
	{
        
        
        for(var m = n.firstChild; m != null; m = m.nextSibling) 
		{


            if ((m.nodeType == 1) &&  (m.tagName.length == 2) && (m.tagName.charAt(0) == "H")) 
			{
		
                var level = parseInt(m.tagName.charAt(1));
                
             		if (!isNaN(level) && (level >= 1) && (level <= 6)) 
					{
		    
		        	sectionNumbers[level-1]++;
		    
		      		for(var i = level; i < 6; i++) sectionNumbers[i] = 0;

		    		sectionNumber[num] = "";
		    		for(var i = 0; i < level; i++) 
						{
						sectionNumber[num] += sectionNumbers[i];
						if (i < level-1) sectionNumber[num] += ".";
		   		 		}
					
				
				impElement[num] = m;
				impElement[num].setAttribute("id",("SECT"+sectionNumber[num]));
					
				sectionTitle[num] = getTextContent(impElement[num]);
		
				if(otherfirst==0)
				{
				impElement[num].insertBefore(this.document.createTextNode(sectionNumber[num]+": "),m.firstChild);
		   		}
		    	var row = d.createElement("tr");
		    
		   		var col1 = d.createElement("td");
		   		var col2 = d.createElement("td");

		   		col1.setAttribute("align", "left");
				var theone = d.createTextNode(sectionNumber[num])
		   		 	col1.appendChild(theone);

					
					link[num] = d.createElement("a");

		    		link[num].appendChild(d.createTextNode(sectionTitle[num]));
					

		    		link[num].setAttribute("name","SECT"+sectionNumber[num]);
		    		link[num].setAttribute("href","");
		  		  	col2.appendChild(link[num]);
					
					
		  		row.appendChild(col1);
		   		row.appendChild(col2);
		   		toc.appendChild(row);
					 
					
				num +=1;
			   }
 
            		}
	    		else 
			{ 
			addSections(m, toc, sectionNumbers);
	    		}
		   			   
        }
    }


    function getTextContent(n) 
    {   
        var s = '';
        var children = n.childNodes;
        for(var i = 0; i < children.length; i++) 
		{	
            var child = children[i];
            if (child.nodeType == 3) s += child.data;
            else s += getTextContent(child);
        }
        return s;
    }
		

  }
  first=1;
  otherfirst=1;
  
    
  	aSet = d.getElementsByTagName("a")
	
	for(w=1;w<aSet.length;w++)
	{
	
  	aSet[w].onclick=function(){(maindoc.getElementById(this.name)).scrollIntoView(true); return false;}
	
  	}
	d.close();
}
function closeThem()
{
	if(win) win.close();
	
   	if(winn) winn.close();

	if(win2) win2.close();
	
	
}
