var rootElement;
var currentCenterElement;
function initTreeGlobals(){
if(isNonInteractive()){
suspectVersion=true;
return;
}
if(window.location.search)return;
rootElement=universalGetElementById('root');
forceRerenderElement=universalGetElementById('forceRerender');
if((! rootElement)||(! forceRerenderElement)){
oops('could not get rootElement('+idE(rootElement)+')and/or forceRerenderElement('+idE(forceRerenderElement)+'),going to set "suspectVersion"');
suspectVersion=true;
}
currentCenterElement=rootElement;
foregroundThisElement(currentCenterElement);
}
function centerOnThisElement(event,thisElement){
if(suspectVersion)return false;
if(! stopBubbleUp(event))return false;
if(currentCenterElement)unForegroundThisElement(currentCenterElement);
var oldYPos=findYPos(thisElement);
var oldScroll=new Array(2);
oldScroll=getCurrentScroll();
var desiredDisplayValue;
if(currentCenterElement){
unForegroundThisElement(currentCenterElement);
desiredDisplayValue='block';
hideShowAncestors(currentCenterElement,true,desiredDisplayValue);
hideShowSiblings(currentCenterElement,true,desiredDisplayValue);
}
currentCenterElement=thisElement;
foregroundThisElement(currentCenterElement);
desiredDisplayValue='none';
hideShowAncestors(currentCenterElement,true,desiredDisplayValue);
hideShowSiblings(currentCenterElement,true,desiredDisplayValue);
forceRerender();
var newYPos=findYPos(thisElement);
var newYScroll;
if(oldScroll&&oldScroll[1])newYScroll=oldScroll[1] - oldYPos+newYPos;
if(newYScroll&&(newYScroll!=oldScroll[1])){
setCurrentScroll(oldScroll[0],newYScroll);
}
return false;
}
function foregroundThisElement(element)
{
element.style.fontWeight='bolder';
element.style.backgroundColor='#ffb';
}
function unForegroundThisElement(element)
{
element.style.removeProperty('font-weight');
element.style.removeProperty('background-color');
}
function hideShowAncestors(activeElement,inverseFlag,desiredDisplayValue){
if(suspectVersion)return;
if((activeElement==rootElement)||(! activeElement.parentNode))return;
if(! activeElement)softOops('hideShowAncestors('+idE(activeElement)+','+inverseFlag+','+desiredDisplayValue+')invoked(bad activeElement)');
if((typeof inverseFlag)!='boolean')softOops('hideShowAncestors('+idE(activeElement)+','+inverseFlag+','+desiredDisplayValue+')invoked(inverse flag not boolean)');
if((typeof desiredDisplayValue)!='string')softOops('hideShowAncestors('+idE(activeElement)+','+inverseFlag+','+desiredDisplayValue+')invoked(desiredDisplayValue not string)');
var ancestorNode=activeElement.parentNode;
while(ancestorNode){
if((ancestorNode.nodeType==1)&&(ancestorNode.tagName=='DIV')){
if(inverseFlag){
hideShowSiblings(ancestorNode,false,desiredDisplayValue);
}else{
ancestorNode.style.display=desiredDisplayValue;
}
if(ancestorNode==rootElement)break;
}
ancestorNode=ancestorNode.parentNode;
}
}
function hideShowSiblings(activeElement,childrenFlag,desiredDisplayValue){
if(suspectVersion)return;
if(! activeElement)softOops('hideShowSiblings('+activeElement+','+inverseFlag+','+desiredDisplayValue+')invoked(bad activeElement)');
if((typeof childrenFlag)!='boolean')softOops('hideShowSiblings('+activeElement+','+inverseFlag+','+desiredDisplayValue+')invoked(children flag not boolean)');
if((typeof desiredDisplayValue)!='string')softOops('hideShowSiblings('+activeElement+','+inverseFlag+','+desiredDisplayValue+')invoked(desiredDisplayValue not string)');
if(activeElement==rootElement)return;
var siblingNodes=activeElement.parentNode.childNodes;
var siblingNode;
for(var i=0;i<siblingNodes.length;++i){
siblingNode=siblingNodes[i];
if((siblingNode.nodeType!=1)||(siblingNode.tagName!='DIV'))continue;
if(siblingNode==activeElement)continue;
if(childrenFlag){
hideShowChildren(siblingNode,false,desiredDisplayValue);
}else{
siblingNode.style.display=desiredDisplayValue;
}
}
}
function hideShowChildren(activeElement,descendantsFlag,desiredDisplayValue){
if(suspectVersion)return;
if(! activeElement)oops('hideShowChildren('+activeElement+','+inverseFlag+','+desiredDisplayValue+')invoked(bad activeElement)');
if((typeof descendantsFlag)!='boolean')oops('hideShowChildren('+activeElement+','+inverseFlag+','+desiredDisplayValue+')invoked(descendants flag not boolean)');
if((typeof desiredDisplayValue)!='string')oops('hideShowChildren('+idE(activeElement)+','+inverseFlag+','+desiredDisplayValue+')invoked(desiredDisplayValue not string)');
if(! activeElement.childNodes)return;
var childNodes=activeElement.childNodes;
var childNode;
for(var i=0;i< childNodes.length;++i){
childNode=childNodes[i];
if((childNode.nodeType!=1)||(childNode.tagName!='DIV'))continue;
childNode.style.display=desiredDisplayValue;
if(descendantsFlag){
hideShowChildren(childNode,true,desiredDisplayValue);
}
}
}
initTreeGlobals();

