function BuildPedigreeLines(aPeople)
{
	for (i = 0; i < iPeopleLength; ++i)
	{
		sName = aPeople[i].id;
		aIDs = sName.split('_');
		iFather = aIDs[3];
		iMother = aIDs[5];
		oChild = document.getElementById(sName);
		bFoundFather = false;
		bFoundMother = false;
		if (iPeopleLength > (iFather - 1))
		{
			bFoundFather = true;
			oFather = document.getElementById(aPeople[iFather - 1].id);
		}
		if (iPeopleLength > (iMother - 1))
		{
			bFoundMother = true;
			oMother = document.getElementById(aPeople[iMother - 1].id);
		}

		if (bFoundFather && bFoundMother)
		{
			iStartX = findRightEdge(oChild);
			iStartY = findMiddleY(oChild);
			iWayPoint1X = iStartX + 20;
			iWayPoint1Y = iStartY;
			iWayPoint2X = iWayPoint1X;
			iWayPoint2Y = findMiddleY(oFather);
			document.write('<div class="pedigree_line" style="left: ' + iStartX + 'px; top: ' + iStartY + 'px; width: 20px; height: 1px;"></div>');
			document.write('<div class="pedigree_line" style="left: ' + iWayPoint1X + 'px; top: ' + iWayPoint2Y + 'px; width: 1px; height: ' + (iWayPoint1Y - iWayPoint2Y) + 'px;"></div>');
			document.write('<div class="pedigree_line" style="left: ' + iWayPoint2X + 'px; top: ' + iWayPoint2Y + 'px; width: 20px; height: 1px;"></div>');
			iWayPoint2X = iWayPoint1X;
			iWayPoint2Y = findMiddleY(oMother);
			document.write('<div class="pedigree_line" style="left: ' + iWayPoint1X + 'px; top: ' + iWayPoint1Y + 'px; width: 1px; height: ' + (iWayPoint2Y - iWayPoint1Y) + 'px;"></div>');
			document.write('<div class="pedigree_line" style="left: ' + iWayPoint2X + 'px; top: ' + iWayPoint2Y + 'px; width: 20px; height: 1px;"></div>');
		}
	}
}

function ShowPosition(oEle)
{
	alert(findRightEdge(oEle));
	alert(findLeftEdge(oEle));
	alert(findTopEdge(oEle));
	alert(findBottomEdge(oEle));
	alert(findMiddleY(oEle));
}

function findRightEdge(oEle)
{
	var RightEdge = 0;
	RightEdge = findPosX(oEle);
	RightEdge += oEle.offsetWidth + iXOffset;
	return RightEdge;
}

function findLeftEdge(oEle)
{
	var LeftEdge = 0;
	LeftEdge = findPosX(oEle);
	return LeftEdge;
}

function findTopEdge(oEle)
{
	var TopEdge = 0;
	TopEdge = findPosY(oEle);
	return TopEdge;
}

function findBottomEdge(oEle)
{
	var BottomEdge = 0;
	BottomEdge = findPosY(oEle);
	BottomEdge += oEle.offsetHeight;
	return BottomEdge;
}

function findMiddleY(oEle)
{
	var MiddleY = 0;
	MiddleY = findPosY(oEle);
	MiddleY += (oEle.offsetHeight / 2) + iYOffset;
	return MiddleY;
}

function findPosX(obj)
{
	var curleft = 0;
	if(obj.offsetParent)
	{
		while(1)
		{
			curleft += obj.offsetLeft;
			if (!obj.offsetParent)
			{
				break;
			}
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
	{
		curleft += obj.x;
	}
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while(1)
		{
			curtop += obj.offsetTop;
			if(!obj.offsetParent)
			{
				break;
			}
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
	{
		curtop += obj.y;
	}
	return curtop;
}

function getElementsByClassName(searchClass, node, tag)
{
	var classElements=[];
	node = node || document;
	var pattern = new RegExp('(^|\\s)' + searchClass + '(\\s|$)');
	var els = (!tag &&  node.all) || node.getElementsByTagName(tag|| '*');
	var elsLen = els.length;
	for (var i=0, j=0; i<els.length; ++i)
	{
		if (pattern.test(els[i].className))
		{
			classElements[j] = els[i];
			++j;
		}
	}
	return classElements;
}
function showPopup( slot, tall, high ){
// hide any other currently visible popups
  for ( var i = 1; i < iPeopleLength; ++i ) {
    if ( i != slot ) { 
		cancelTimer(i); 
		hidePopup(i);
	}
  }
  
// show current
    var ref = document.all ? document.all["popup_" + slot] : document.getElementById ? document.getElementById("popup_" + slot) : null;
  
  if ( ref ) {ref = ref.style;}
  
  if ( ref.visibility != "show" && ref.visibility != "visible" ) {
    ref.top = ( tall + high ) < 0 ? 0 : ( tall + high + 1 );
    ref.zIndex = 8;
    ref.visibility = "visible";
  }
}

function setTimer(slot) {
	eval( "timer" + slot + "=setTimeout(\"hidePopup(" + slot + ")\",500);");
}

function cancelTimer(slot) {
	eval( "clearTimeout(timer" + slot + ");" ); 
	eval( "timer" + slot + "=false;" );
}

function hidePopup(slot) {
  var ref = document.all ? document.all["popup" + slot] : document.getElementById ? document.getElementById("popup_" + slot) : null ;
  if (ref) { ref.style.visibility = "hidden"; }
  eval("timer" + slot + "=false;");
}
