// JavaScript Document for pNav childNav Menu
<!--

var subNavActive = false;

function subNav(){
	subNavActive = true;	
}

function navchildNav_findPosX(obj) 
{
  var curleft = 0;
  if (obj.offsetParent) 
  {
    while (obj.offsetParent) 
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function navchildNav_findPosY(obj) 
{
    var curtop = 0;
    if (obj.offsetParent) 
    {
        while (obj.offsetParent) 
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

function navchildNav_show(childNav, parentId, posX, posY, pnavID, theItem)
{
    navCHildNav_hideAll("subnav");
	it = document.getElementById("subnav");
	subObj = document.getElementById(childNav);
    navParent_active(theItem);
	
    if ((it.style.top == '' || it.style.top == 0) 
        && (it.style.left == '' || it.style.left == 0))
    {
        // need to fixate default size (MSIE problem)
        it.style.width = it.offsetWidth + 'px';
        it.style.height = it.offsetHeight + 'px';
        
        obj = document.getElementById(parentId); 
    
        // if tooltip is too wide, shift left to be within parent 
        if (posX + it.offsetWidth > obj.offsetWidth) posX = obj.offsetWidth - it.offsetWidth;
        if (posX < 0 ) posX = 0; 
        
        x = navchildNav_findPosX(obj) + posX;
        y = navchildNav_findPosY(obj) + posY;
        
        it.style.top = y + 'px';
        it.style.left = x + 'px';
    }
    
    it.style.visibility = 'visible'; 
	subObj.className = '';

	subNavActive = true;
}

it = this.document.getElementById("subnav");
if(it) {
	if ((it.style.top == '' || it.style.top == 0) 
		&& (it.style.left == '' || it.style.left == 0))
	{
			
			it.style.width = it.offsetWidth + 'px';
			it.style.height = it.offsetHeight + 'px';
			if (posX + it.offsetWidth > img.offsetWidth) posX = img.offsetWidth - it.offsetWidth;
			if (posX < 0 ) posX = 0; 
			x = navchildNav_findPosX(img) + posX;
			y = navchildNav_findPosY(img) + posY;
			
			it.style.top = y + 'px';
			it.style.left = x + 'px';
			it.style.visibility = 'visible'; 
	}
}


function navchildNav_hide(id, pnavID)
{
	InitializeTimer(1);
	subNavActive = false;
}

function navParent_active(theItem){
	navParent = document.getElementById("parent");
	for(x=0; x < navParent.childNodes.length; x++){
		if(navParent.childNodes[x].hasChildNodes()){
			if(navParent.childNodes[x].firstChild.name == theItem && navParent.childNodes[x].firstChild.className != 'active'){
				navParent.childNodes[x].firstChild.className = 'over';
			} else {
				if(navParent.childNodes[x].firstChild.className != 'active'){
					navParent.childNodes[x].firstChild.className = '';
				}
			}
		}
		
	}
}

function navCHildNav_hideAll(id)
{
	//Lets make sure to hide all sub nav items before we display
	it = this.document.getElementById(id);
	for(x=0; x < it.childNodes.length; x++){
		if(it.childNodes[x].nodeName == "DIV"){
			it.childNodes[x].className = 'subNavObj';
		}
	}
}

var secs
var timerID = null
var timerRunning = false
var delay = 500

function InitializeTimer(time)
{
    // Set the length of the timer, in seconds
    secs = time
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0 & !subNavActive)
    {
        StopTheClock()
        // What to do when time is reached function call or direct response 
		// We are hidding the subnav layer and removing the parent menu className
        it = document.getElementById("subnav"); 
	    it.style.visibility = 'hidden'; 
		navParent_active('none');
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}




/* ############################################################# */
/* 						Attorney Stats 							 */
/* ############################################################# */
var statsVis = false;

function stats_show(parentId)
{
	if(!statsVis){
		//node = 3 + nodeOffset;
		
		if(IEn){
			obj = document.getElementById(parentId);
			it = obj.lastChild;
			obj1 = obj.firstChild;
			if(obj1.hasChildNodes()){
				obj2 = obj1.firstChild;
				//alert("has child nodes" + obj2.nodeName);	
			}
				//alert(it.parentNode.firstChild.nodeName + " \n" + it.lastChild.nodeName);
		} else {
			obj = document.getElementById(parentId);
			it = obj.childNodes[3];
			obj1 = obj.childNodes[1];
			if(obj1.hasChildNodes()){
				obj2 = obj1.childNodes[0];
			}
		}

	vs = document.getElementById("attorneyPreview"); 
		x = navchildNav_findPosX(obj1);
       	y = navchildNav_findPosY(obj1);	
		py = navchildNav_findPosY(vs);
		newYpadding = y - py - obj.offsetHeight ;
		if(newYpadding < 0){
			newYpadding = 0;	
		}

		
	old = document.getElementById('activeAtt');
	if(old) {
		old.id = '';
	}
	newValue = "<div style='margin-top:"+newYpadding+"px !important;'>" + it.innerHTML + "</div>";
	obj2.id = 'activeAtt';
	vs.innerHTML = newValue;
	statsVis = true;
	}
}

function stats_hide(obj){
	statsVis = false;
}

var IEn = document.all?true:false
if (IEn) { // grab the x-y pos.s if browser is IE
	nodeOffset = -1;
} else {  // grab the x-y pos.s if browser is NS
	nodeOffset = 0;
}  

var secsAtt
var timerIDatt = null
var timerRunningAtt = false
var delayAtt = 250

function InitializeTimerAtt(time)
{
    // Set the length of the timer, in seconds
    secsAtt = time
    StopTheClockAtt()
    StartTheTimerAtt()
}

function StopTheClockAtt()
{
    if(timerRunningAtt)
        clearTimeout(timerIDatt)
    timerRunningAtt = false
}

function StartTheTimerAtt()
{
    if (secsAtt==0 & !statsVis)
    {
        StopTheClockAtt()
        // What to do when time is reached function call or direct response 
		// We are hidding the subnav layer and removing the parent menu className
        it = document.getElementById("attorneyPreview"); 
		it.innerHTML = '';
    }
    else
    {
        self.status = secsAtt
        secsAtt = secsAtt - 1
        timerRunningAtt = true
        timerIDatt = self.setTimeout("StartTheTimerAtt()", delayAtt)
    }
}


/* ############################################################################# */
// 					OLD NOT USED

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// Deprecated code captureEvents()
// If NS -- that is, !IE -- then set up for mouse capture
//if (!IE) document.captureEvents(Event.MOUSEMOVE)

function doLoad()
{
	if (document.addEventListener){
	  document.addEventListener('mousemove', getMouseXY, false); 
	} else if (el.attachEvent){
	  document.attachEvent('mousemove', getMouseXY);
	}
}

/* NEW EVENT LISTENER */



// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  
  //document.getElementById('loading').innerHTML = tempX + "<br />" + tempY;
  return true
}

//-->
