
function getHTTPObject() 
{
	var requester;

	try 
	{ 
		requester = new XMLHttpRequest(); 
	} 
	catch (error) 
	{ 
		try 
		{ 
			requester = new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch (error) 
		{ 
			requester = false; 
		}
	}
	
	return requester;
}

function collapse(root)
{
	var nextSibling = getNextSibling(root);

	while (nextSibling != null)
	{
		if (nextSibling.className == "location")
			return;

		if (nextSibling.className == root.className)
			return;

		nextSibling.style.display = "none";
		nextSibling = getNextSibling(nextSibling);
	}				
}

function getNextSibling(startBrother)
{
    endBrother = startBrother.nextSibling;
    
    while (endBrother != null && endBrother.nodeType != 1)
    {
        endBrother = endBrother.nextSibling;
    }
    
    return endBrother;
}

function getCollectionIMGNode(root)
{
   var node = root;

   while (1)
   {
       node = node.firstChild;
       while (node != null && node.nodeName == "#text" || (node.nodeName == "IMG" && node.src.search("plus") == -1  && node.src.search("minus") == -1 ))
           node = node.nextSibling;
       
       if (node == null)
           break;
       
       if ((node.nodeName == "IMG") && ((node.src.search("plus") != -1 ) || (node.src.search("minus") != -1 )))
           break;
   }   
   
   return node;
}

function expand(root)
{
	var nextSibling = getNextSibling(root); 
	var pieceDisplay = "";

	while (nextSibling != null)
	{
		if (nextSibling.className == root.className)
			return;

		switch (nextSibling.className)
		{
		case "collection":
			nextSibling.style.display = "";
			var img = getCollectionIMGNode(nextSibling);
			if (img != null)
			{
				if (img.src.search("plus") == -1)
					pieceDisplay = "";
				else
					pieceDisplay = "none";								
			}
			break;
		case "piece":
			nextSibling.style.display = pieceDisplay;
			break;
		}

		nextSibling = getNextSibling(nextSibling); //nextSibling.nextSibling;
	}				
}

function doToggle(e, plus, minus, plusAlt, minusAlt)
{	
	var img;
    var element;
    
    if (e.srcElement)
        element = e.srcElement;
    else
        element = e.target;
    
	if (element.className == "group")
	{
		switch (element.nodeName)
		{
		case "A":
			img = element.firstChild;
			break;
		case "IMG":
			img = element;
			break;
		default:
			return;
		}
	}
	else
		return;

	var root = img.parentNode.parentNode.parentNode.parentNode;
	var display;
						
	if (img.src.search("plus") == -1)
	{
		img.src = plus;
		img.alt = plusAlt;
		collapse(root);
	}
	else
	{
		img.src = minus;
		img.alt = minusAlt;
		expand(root);
	}
}

var ss_INTERVAL;

function scrollToAnchor(anchor)
{
	var destinationLink = document.getElementById(anchor)
	var desty = destinationLink.offsetTop; 
	var cypos = ss_getCurrentYPos();
	var thisNode = destinationLink; 
	while (thisNode.offsetParent && (thisNode.offsetParent != document.body)) 
	{ 
		thisNode = thisNode.offsetParent; 
		desty += thisNode.offsetTop; 
	} 

	// If we're below where we want to go, that's OK, return
    if (cypos > desty)
		return; 

	// Stop any current scrolling 
	clearInterval(ss_INTERVAL); 

	var ss_stepsize = parseInt((desty-cypos)/20); 
	ss_INTERVAL = setInterval('ss_scrollWindow(' + ss_stepsize + ',' + desty + ',"' + anchor + '")', 1); 
  
	// And stop the actual click happening 
	if (window.event) 
	{ 
		window.event.cancelBubble = true; 
		window.event.returnValue = false; 
	}
 
	//if (e && e.preventDefault && e.stopPropagation) 
	//{ 
	//	e.preventDefault(); 
	//	e.stopPropagation(); 
	//} 
}

function ss_scrollWindow(scramount, dest, anchor) 
{ 
	wascypos = ss_getCurrentYPos(); 
	isAbove = (wascypos < dest); 
	window.scrollTo(0, wascypos + scramount); 
	iscypos = ss_getCurrentYPos(); 
	isAboveNow = (iscypos < dest); 
	if ((isAbove != isAboveNow) || (wascypos == iscypos)) 
	{ 
		// if we've just scrolled past the destination, or 
		// we haven't moved from the last scroll (i.e., we're at the 
		// bottom of the page) then scroll exactly to the link 
		window.scrollTo(0, dest); 
		// cancel the repeating timer 
		clearInterval(ss_INTERVAL); 
		// and jump to the link directly so the URL's right 
		location.hash = anchor; 
	} 
} 

function ss_getCurrentYPos() 
{ 
	if (document.body && document.body.scrollTop) 
		return document.body.scrollTop; 
	if (document.documentElement && document.documentElement.scrollTop) 
		return document.documentElement.scrollTop; 
	if (window.pageYOffset) 
		return window.pageYOffset; 
	return 0; 
} 




