//copyright John A Brown 2005


function showHelp(myID)
{
	var myFrame = window.top.document.getElementById("Left");
	myFrame.src = "help-ancestors.html";

        myFrame = window.top.document.getElementById("Center");
	myFrame.src = "help-individual.php";

        myFrame = window.top.document.getElementById("Right");
	myFrame.src = "help-decendents.html";
}



function getElement(e)
{
    var targ
    if (!e) var e = window.event
    if (e.target) targ = e.target
    else if (e.srcElement) targ = e.srcElement
    if (targ.nodeType == 3) // defeat Safari bug
        targ = targ.parentNode
    return targ;
}

function toggleA(e)
{
    var x=getElement(e).parentNode.childNodes;
    for (var i=0;i<x.length;i++)
    { 
        switch(x[i].tagName)
        {
            case 'DIV':
            {
                if (x[i].style.display == 'block') x[i].style.display = 'none';
                else x[i].style.display = 'block';
            }
            break
            case 'IMG':
            {
                if (x[i].src.match("minus") != null) x[i].src="plus.gif";
                else if (x[i].src.match("plus") != null) x[i].src="minus.gif";
            }
            break
       }
   }
}


function toggleD(e)
{
    var MyElement = getElement(e);
    var MySiblingNodes = MyElement.parentNode.childNodes;
    var i=-1;
    var foundIt = false;

    // find MyNode in the list MySiblingNodes
    while ((!foundIt) && (i <= MySiblingNodes.length))
    {
        i++; 
        if (MySiblingNodes[i] == MyElement) foundIt = true;
    }

    //toggle this IMG element and then find the following DIV element
    if (foundIt)
    {
        if (MySiblingNodes[i].src.match("minus") != null)
            MySiblingNodes[i].src="plus.gif";
        else if (MySiblingNodes[i].src.match("plus") != null)
            MySiblingNodes[i].src="minus.gif";
    
        // find the next DIV element in the list MySiblingNodes
        foundIt = false;
        while ((!foundIt) && (i <= MySiblingNodes.length))
        { 
            i++;
            if (MySiblingNodes[i].tagName == 'DIV') foundIt = true;
        }

        //toggle this DIV element
        if (foundIt)
        {
            if (MySiblingNodes[i].style.display == 'block') MySiblingNodes[i].style.display = 'none';
            else MySiblingNodes[i].style.display = 'block';
        }
    }
}


//********************************************
//old functions


function toggleDiv(id)
{
    var myDiv = document.getElementById(id+"-div");
    if (myDiv.style.display == 'block')
        myDiv.style.display='none';
    else
        myDiv.style.display='block';
 }


function toggleIcon(id)
{
    var myIcon = document.getElementById(id+"-icon");
    if (myIcon.src == openIcon.src)
        myIcon.src=closedIcon.src;
    else
        myIcon.src=openIcon.src;
 }



function toggleBranch(id)
{
    toggleIcon(id);
    toggleDiv(id);
 }


function toggleFork($fatherId, $motherId, $individualId)
{
    if ($individualId != "")
        toggleIcon($individualId);

    if ($fatherId != "")
        toggleDiv($fatherId);

    if ($motherId != "")
        toggleDiv($motherId);
}


