<!--

// Functions to support hover windows.

// Function that find the top and left of an
// oject on the page.  Returns an array of
// left, top.
function findPos(obj) {

	var curleft = curtop = 0;

	// We need to traverse up the tree
	// to get the total offsets.
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
		
	return [curleft,curtop];
}

// Function to just return the top offset.
function findTop(obj) {
	return findPos(obj)[1];
}

// Function to return just the left offset.
function findLeft(obj) {
	return findPos(obj)[0];
}

// Determine how much the visitor had scrolled
function findScrolledPos() {
	var scrolledX, scrolledY;

	// 	Due to different browser naming of certain key global variables, 
	// we need to do three different tests to determine their values
	if (self.pageYOffset) {
		scrolledX = self.pageXOffset;
		scrolledY = self.pageYOffset;
	} 
	else if (document.documentElement && document.documentElement.scrollTop) {
		scrolledX = document.documentElement.scrollLeft;
		scrolledY = document.documentElement.scrollTop;
	} 
	else if (document.body) {
		scrolledX = document.body.scrollLeft;
		scrolledY = document.body.scrollTop;
	}

	return [scrolledX,scrolledY];
}

// Determine the coordinates of the top center of the page.
function getTopCenterPos() {
	var centerX, centerY;
	
	// 	Due to different browser naming of certain key global variables, 
	// we need to do three different tests to determine their values
	if (self.innerHeight) {
  		centerX = self.innerWidth;
  		centerY = self.innerHeight;
	} 
	else if (document.documentElement && document.documentElement.clientHeight) {
		centerX = document.documentElement.clientWidth;
		centerY = document.documentElement.clientHeight;
	} 
	else if (document.body) {
		centerX = document.body.clientWidth;
		centerY = document.body.clientHeight;
	}
	
	return [centerX, centerY]
}

// Determine the coordinates of the center of the page
function getCenterPos() {
	var centerX, centerY;
	var scrollPos = findScrolledPos();
	
	// 	Due to different browser naming of certain key global variables, 
	// we need to do three different tests to determine their values
	if (self.innerHeight) {
  		centerX = self.innerWidth;
  		centerY = self.innerHeight;
	} 
	else if (document.documentElement && document.documentElement.clientHeight) {
		centerX = document.documentElement.clientWidth;
		centerY = document.documentElement.clientHeight;
	} 
	else if (document.body) {
		centerX = document.body.clientWidth;
		centerY = document.body.clientHeight;
	}
	
	
	var leftOffset = scrollPos[0] + (centerX - 300) / 2;
	var topOffset = scrollPos[1] + (centerY - 250) / 2;

	return [leftOffset, topOffset]
}

// Pass in the name of div tag and hover window will cover the element.  The hover
// will have the same top,left as element.	
function fireHoverOverElement(hoverName, elementName) {
  document.getElementById(hoverName).style.top =  findTop(document.getElementById(elementName)) + "px";
  document.getElementById(hoverName).style.left = findLeft(document.getElementById(elementName)) + "px";
  document.getElementById(hoverName).style.display = "block";
}

// This will determine the center of the window and attempt to 
// center the hover.
function centerHover(hoverName) {
	var centerPos = getCenterPos();
	
	document.getElementById(hoverName).style.top = centerPos[1] + "px";
	document.getElementById(hoverName).style.left = centerPos[0] + "px";
	document.getElementById(hoverName).style.display = "block";
}

// This will determine the top center of the window and attempt to 
// center the hover at the top of the page.
function topCenterHover(hoverName) {
	var centerPos = getTopCenterPos();
	var scrollPos = findScrolledPos();
	var hoverWidth = new String(document.getElementById(hoverName).style.width);
	hoverWidth = hoverWidth.substr(0, hoverWidth.length - 2);
	
	var leftOffset = scrollPos[0] + (centerPos[0] - hoverWidth) / 2;
	var topOffset = scrollPos[1]; 

	
	document.getElementById(hoverName).style.top = topOffset + "px";
	document.getElementById(hoverName).style.left = leftOffset + "px";
	document.getElementById(hoverName).style.display = "block";
	
}

// This will determine the top center of the window and attempt to 
// center the hover at the top of the page.
function centerBelowHover(hoverName, offsetTop, offsetLeft) {
	var centerPos = getTopCenterPos();
	var scrollPos = findScrolledPos();
	var hoverWidth = new String(document.getElementById(hoverName).style.width);
	hoverWidth = hoverWidth.substr(0, hoverWidth.length - 2);
	
	var leftOffset = scrollPos[0] + ((centerPos[0] - hoverWidth) / 2) + offsetLeft;
	var topOffset = scrollPos[1] +  offsetTop;

	
	document.getElementById(hoverName).style.top = topOffset + "px";
	document.getElementById(hoverName).style.left = leftOffset + "px";
	document.getElementById(hoverName).style.display = "block";
	document.getElementById(hoverName).style.zIndex = "1000";
}

// This will determine the top center of the window and attempt to 
// center the hover at the top of the page.
function centerBelowHoverNoZ(hoverName, offsetTop, offsetLeft) {
	var centerPos = getTopCenterPos();
	var scrollPos = findScrolledPos();
	var hoverWidth = new String(document.getElementById(hoverName).style.width);
	hoverWidth = hoverWidth.substr(0, hoverWidth.length - 2);
	
	var leftOffset = scrollPos[0] + ((centerPos[0] - hoverWidth) / 2) + offsetLeft;
	var topOffset = scrollPos[1] +  offsetTop;

	
	document.getElementById(hoverName).style.top = topOffset + "px";
	document.getElementById(hoverName).style.left = leftOffset + "px";
	document.getElementById(hoverName).style.display = "block";
}

// This will determine the top center of the window and attempt to 
// center the hover at the top of the page.
function centerBelowHoverZ(hoverName, offsetTop, offsetLeft, zindex) {
	var centerPos = getTopCenterPos();
	var scrollPos = findScrolledPos();
	var hoverWidth = new String(document.getElementById(hoverName).style.width);
	hoverWidth = hoverWidth.substr(0, hoverWidth.length - 2);
	
	var leftOffset = scrollPos[0] + ((centerPos[0] - hoverWidth) / 2) + offsetLeft;
	var topOffset = scrollPos[1] +  offsetTop;

	
	document.getElementById(hoverName).style.top = topOffset + "px";
	document.getElementById(hoverName).style.left = leftOffset + "px";
	document.getElementById(hoverName).style.display = "block";
	document.getElementById(hoverName).style.zIndex = zindex;
}


// This will determine the left center of the window and attempt to 
// place the hover at the top left of the page.
function leftCenterHover(hoverName) {
	var centerPos = getTopCenterPos();
	var scrollPos = findScrolledPos();
	var hoverWidth = new String(document.getElementById(hoverName).style.width);
	hoverWidth = hoverWidth.substr(0, hoverWidth.length - 2);
	
	var leftOffset = 0;
	var topOffset = scrollPos[1]; 
	
	document.getElementById(hoverName).style.top = topOffset + "px";
	document.getElementById(hoverName).style.left = leftOffset + "px";
	document.getElementById(hoverName).style.display = "block";
	
}


// Pass in the hover window element name and the hover will disappear.
function closeHoverOverElement(hoverName) {
	document.getElementById(hoverName).style.display = 'none'
}

function fireHoverToRightElement(hoverName, elementName, addPixels) {
	var leftPx;
	
	leftPx = findLeft(document.getElementById(elementName)) + addPixels;
	
 	document.getElementById(hoverName).style.top =  findTop(document.getElementById(elementName)) + "px";
  	document.getElementById(hoverName).style.left = leftPx + "px";
  	document.getElementById(hoverName).style.display = "block";
}


function fireHoverBelowElement(hoverName, elementName, bottomPad, leftPad) {
	var topPx;
	var leftPx;
	
	leftPx = findLeft(document.getElementById(elementName));
	topPx = findTop(document.getElementById(elementName));
	
 	document.getElementById(hoverName).style.top =   topPx + bottomPad + "px";
  	document.getElementById(hoverName).style.left = leftPx + leftPad + "px";
  	document.getElementById(hoverName).style.display = "block";
}


// This method will show the element named by the parameter
// flag = true = show
// flag = false = hide
function dispElement(name, flag) {
	var visible;
	var hidden;
	var element;
	
	// Check the type of browser
    if (document.layers) {
    	visible = 'show';
    	hidden = 'hide';
    } 
	else {
    	if (document.all) {
    		visible = 'visible';
    		hidden = 'hidden';
    	} 
		else {
    		if (document.getElementById) {
    			visible = 'visible';
    		  	hidden = 'hidden';
    		}
    	}
    }
	
    // Get the element depending on the browser.
   	if (document.getElementById){
   		element = document.getElementById(name).style;
   	}
   	else {
   		if (document.all) {
   	    	element = document.all(name).style;
     		}
   		else {
   			if (document.layers) {
   				element = document.layers[name];
   			}
   		}
   	}

    // Set as requested.
    if (flag == true) {
    	element.visibility = visible;
	}
    else {
		element.visibility = hidden;
    }
}

// Shortcut method
function showElement(name) {
	dispElement(name, true);
}

// Shortcut method
function hideElement(name) {
	dispElement(name, false);
}

// This method will move an element to a position defined as top.  
// Note that the element must a style of style='position: absolute;'
function moveElement(name, top) {
 	document.getElementById(name).style.top =  top + "px";
}

// This method will move an element to be position below the
// element named by the element parameter.
// Note that the element must a style of style='position: absolute;'
function moveBelowElement(element, moveElement, pad) {
	document.getElementById(moveElement).style.top = findTop(document.getElementById(element)) + getElementHeight(element) + pad + "px";	
}

function getElementHeight(elementName) {
	return document.getElementById(elementName).offsetHeight ;
}

//-->
