// JavaScript Document

sfHover = function() {
	document.level=-1;
	document.myHeight=22;
	document.toHeight=22;
	var root = document.getElementById("pt_nav");
	var sfEls = root.getElementsByTagName("LI");
	var newClassName = ""
	for (var i=0; i<sfEls.length; i++) {
		
		var level=0;
		var node=sfEls[i].parentNode;
		while (node.tagName=="UL"){
			if (node.id=="pt_nav"){newClassName = "level"+level};
			level++;
			node=node.parentNode.parentNode;
			}
		
		sfEls[i].className=newClassName;
		
		sfEls[i].onmouseover=function() {
			if (window.attachEvent){
				this.className+=" sfhover";
				}
			setActive(this);
		}
		sfEls[i].onmouseout=function() {
			if (window.attachEvent){
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			
				}
			setInactive(this);
		}
	}
}
/*if (window.attachEvent) window.attachEvent("onload", sfHover);*/


function checkClassName(myObj){
	
	}

function setActive(myObj){
	var myLevel= parseInt(myObj.className.substr(5,1));
	var currentLevel=document.level;
	if (myLevel>currentLevel){
		currentLevel=myLevel;
		document.level=currentLevel;
		calcHeight(myObj);
		}
	}
	
function setInactive(myObj){
	var myLevel= parseInt(myObj.className.substr(5,1));
	var currentLevel=document.level;
	if (myLevel==currentLevel){
		currentLevel=myLevel-1;
		document.level=currentLevel;
		calcHeight(myObj);
		}
	/*var infoBox=document.getElementById("info");
	infoBox.innerHTML += myObj.className;*/
	}


function calcHeight(myObj){
	var node=myObj.parentNode;
	var currentLevel=document.level;
	var nodes= new Array();
	
	var hasChild=myObj.getElementsByTagName("ul")[0];
	if (hasChild && currentLevel!=-1){
		currentLevel++;
		node=hasChild;
		}
	
	while (node.tagName=="UL" && node.id!="pt_nav"){
			nodes.push(node);
			node=node.parentNode.parentNode;
			}
	nodes.reverse();
	var currentTop=0;
	var maxHeight=0;
	var newHeight;
	for (var i=0;i<nodes.length;i++){
		currentTop+=nodes[i].offsetTop;
		newHeight=currentTop+nodes[i].offsetHeight;
		if (newHeight>maxHeight){
			maxHeight=newHeight;
			}
		}
		
	maxHeight+=22;
	
	if (maxHeight<22){
		maxHeight=22
		}
	document.toHeight=maxHeight;
	animate();
	
}

function animate(){
	clearInterval(document.interval);
	document.interval=setInterval(setHeight,15);
	}
	
function setHeight(){
	var height=document.toHeight;
	/*var infoBox=document.getElementById("info");
	infoBox.innerHTML += height;*/
	document.myHeight-=(document.myHeight-height)/2;
	var container = document.getElementById("pt_nav");
	container.style.height=document.myHeight+"px";
	/*container.style.width="500px";*/
	}
