
/*
********************************************************************
* REsize Script to ensure Menus align properly on REsize
*******************************************************************/
window.onresize= doRefresh;

function doRefresh() {
  document.location = document.location;
}

/*
********************************************************************
* Drop Down Menu JavaScript Functions
********************************************************************
File Name: /Scripts/app_MenuJSFunctions.js
Author: Kevin Berquist - VisionOne, Inc.
Completion Date: 
Date of Last Revision: 1/15/2001
Last Revisor: Robert Schultz
Function: render and position drop down menu containers and options
OS: N/A
Requires: Internet Explorer / Netscape 4.0 or higher browser.
********************************************************************
*/

/*
********************************************************************
* Function: N/A
* Objective: Global Variables to determine browser type, menu 
			 container margins and padding,  drop down mouse 
			 event control, drop down menu HTML. 
* Input: N/A
* Output: N/A
********************************************************************
*/

var g_blnIe;
var g_blnDom;
var g_intYOffset;
var g_intYPadding;
var g_ClientWidth;
var g_intXOffset;
var g_CurrentParent;
var g_objCurrentLayer;
var g_blnInLayer;
var g_strMenuSeperator;
var g_strMenuHTML;
var g_intWinOffset;
var g_SubMenuPanelClass;
var g_parentHighlightClass;
var g_parentNoHighlightClass;
var g_currentSectionClass;

function setGlobals(){
	g_blnIe = (document.all) ? true:false;
	g_blnDom = (document.getElementById) ? true:false;
	g_ClientWidth = (g_blnIe) ? document.body.clientWidth:window.innerWidth;
	g_intXOffset = 0//((g_ClientWidth - 736)/2);
	g_intYOffset = 0;
	g_intYPadding = 5;
	g_objCurrentLayer = null;
	g_blnInLayer = false;
	g_strMenuSeperator = "|";
	g_strMenuHTML = "";
	g_intWinOffset = 0;
	g_SubMenuPanelClass = "SubMenuPanel";
	g_parentHighlightClass = "MenuNavigation";
	g_parentNoHighlightClass = "MenuNavigation";
	g_currentSectionClass = "MenuNavigation";
	g_DonationsURL = "";
}

/*
********************************************************************
* Function: _menuOver
* Objective: performs menu drop down process
* Input: sLayerName - HTML container name
	x - The X coordinate on the screen
	y - The Y coordinate on the screen
* Output: N/A
********************************************************************
*/
function _menuOver(sLayerName,x,y){
	g_blnInLayer = true;
	var objLayer = (g_blnDom) ? document.getElementById(sLayerName):document.layers[sLayerName];
	positionLayer(objLayer,x,y);
	showLayer(objLayer);
	g_objCurrentLayer = objLayer;
}

/*
********************************************************************
* Function: buildMenu
* Objective: Writes out the full HTML for the menu after parsing all the
	functions.
* Input: N/A
* Output: N/A
********************************************************************
*/
function buildMenu(){
	document.write(g_strMenuHTML);
}

/*
********************************************************************
* Function: closeContainer
* Objective: write the appropriate closingHTML container tag based 
			 on user user platform
* Input: N/A
* Output: N/A
********************************************************************
*/
function closeContainer(){
	
	if(g_blnIe || g_blnDom)
		g_strMenuHTML += '</div>\n';
	else
		g_strMenuHTML += '</layer>\n';
	
}

/*
********************************************************************
* Function: getElemX
* Objective: returns the x position of the argument element
			 using get real left
* Input: objElem - HTML Container Object
* Output: integer
********************************************************************
*/
function getElemX(objElem){
	var intX = (g_blnIe || g_blnDom) ? getRealLeft(objElem):objElem.x;	
	return intX;
}

/*
********************************************************************
* Function: getElemY
* Objective: returns the y position of the argument element
			 using get real top
* Input: objElem - HTML Container Object
* Output: integer
********************************************************************
*/
function getElemY(objElem){
	var intY = (g_blnIe || g_blnDom) ? getRealTop(objElem):objElem.y;	
	intY += (g_blnIe || g_blnDom) ? objElem.offsetHeight:g_intYOffset;
	return intY + g_intYPadding;
}

/*
********************************************************************
* Function: getRealLeft
* Objective: finds the left edge of the element argument
* Input: objEl - HTML Container Object
* Output: integer
********************************************************************
*/
function getRealLeft(objEl) {
    intXPos = objEl.offsetLeft;
    objTempEl = objEl.offsetParent;
    while (objTempEl != null) {
        intXPos += objTempEl.offsetLeft;
        objTempEl = objTempEl.offsetParent;
    }
    return intXPos;
}

/*
********************************************************************
* Function: getRealTop
* Objective: finds the top edge of the element argument
* Input: objEl - HTML Container Object
* Output: integer
********************************************************************
*/
function getRealTop(objEl) {
    intYPos = objEl.offsetTop;
    objTempEl = objEl.offsetParent;
    while (objTempEl != null) {
        intYPos += objTempEl.offsetTop;
        objTempEl = objTempEl.offsetParent;
    }
    return intYPos;
}

/*
********************************************************************
* Function: startHide
* Objective: begins to hide the current layer by setting a countdown 
			hidelayer
* Input: N/A
* Output: N/A
********************************************************************
*/
function startHide(){
	setTimeout("hideLayer(g_objCurrentLayer)",300);
}

/*
********************************************************************
* Function: hideLayer
* Objective: hides the current layer 
* Input: objElem - HTML Container Object
* Output: N/A
********************************************************************
*/
function hideLayer(objElem){
	if(!g_blnInLayer && objElem != null){
		if(g_blnDom){
			objElem.style.display='none';
			dehighlightParent();
		}	
		else{
		objElem.visibility='hide';
		
		}
	}
}

/*
********************************************************************
* Function: layerOut
* Objective: sets global var g_blnInLayer = false called when mouse
		     leaves a current HTML container
* Input: N/A
* Output: N/A
********************************************************************
*/
function layerOut(){
	g_blnInLayer = false;
	startHide();
}

/*
********************************************************************
* Function: layerOver
* Objective: sets global var g_blnInLayer = true
* Input: N/A
* Output: N/A
********************************************************************
*/
function layerOver(){
	highlightParent();
	g_blnInLayer = true;
}

/*
********************************************************************
* Function: menuOut
* Objective: sets global var g_blnInLayer = false called when mouse
			 leaves a the menu bar
* Input: N/A
* Output: N/A
********************************************************************
*/
function menuOut(){
	g_blnInLayer = false;
	if(!g_blnInLayer)startHide();
}

/*
********************************************************************
* Function: menuOver
* Objective: begins the menu drop down process
* Input: objElem - HTML container object
	strLayerName - HTML container object name
* Output: N/A
********************************************************************
*/
function menuOver(objElem,strLayerName){
	dehighlightParent();
	g_CurrentParent = objElem; 
	highlightParent();
	if(g_objCurrentLayer != null && g_objCurrentLayer.id != strLayerName) hideLayer(g_objCurrentLayer);
	_menuOver(strLayerName,getElemX(objElem),getElemY(objElem));
}

/*
********************************************************************
* Function: Highlight
* Objective: Highlights the current parent item
* Input: objElem - HTML container object
* Output: N/A
********************************************************************
*/

function highlightParent(){
	if(g_CurrentParent && g_CurrentParent.className != g_currentSectionClass){
		g_CurrentParent.className = g_parentHighlightClass; 
	}
}

/*
********************************************************************
* Function: deHighlightparent
* Objective: deHighlights the current parent item
* Input: objElem - HTML container object
* Output: N/A
********************************************************************
*/
function dehighlightParent(){
	if(g_CurrentParent && g_CurrentParent.className != g_currentSectionClass){
		g_CurrentParent.className = g_parentNoHighlightClass;
	}
}

/*
********************************************************************
* Function: menuOverXY
* Objective: begins the menu drop down process using supplied x and y
* Input: objElem - HTML container object
	strLayerName - HTML container object name
* Output: N/A
********************************************************************
*/
function menuOverXY(objElem,strLayerName,x,y){
	if(g_objCurrentLayer != null) hideLayer(g_objCurrentLayer);
	_menuOver(strLayerName,x,y);
}





/*
********************************************************************
* Function: openContainerWithId
* Objective: write the appropriate opening HTML container tag based 
			 on user user platform
* Input: intId - The ElementID for the container
* Output: N/A
********************************************************************
*/
function openContainerWithId(intId){
	if(g_blnIe || g_blnDom)
		g_strMenuHTML += '<div class="'+g_SubMenuPanelClass+'" id="' +intId+'" style="position:absolute;display:none;" onmouseover="javascript:layerOver();" onmouseout="javascript:layerOut();">\n';
	else
		g_strMenuHTML += '<layer class="'+g_SubMenuPanelClass+'" id="'+intId+'" visibility="hide" onmouseover="javascript:layerOver();" onmouseout="javascript:layerOut();">\n';
	
}

/*
********************************************************************
* Function: positionLayer
* Objective: positions a HTML container object using x,y coordinates
* Input: objElem - HTML Container Object
	intX - the X coordinate on the screen
	intY - the Y coordinate on the screen
* Output: N/A
********************************************************************
*/
function positionLayer(objElem,intX,intY){
	var intLyrWdth = (g_blnIe || g_blnDom) ? objElem.offsetWidth:objElem.clip.width;
	var intScrnWdth = (g_blnIe) ? document.body.clientWidth:window.innerWidth;
	var intOffset = (((intLyrWdth + g_intWinOffset) + intX) > intScrnWdth) ? ((intX+intLyrWdth+g_intWinOffset) - intScrnWdth):0;
	if(g_blnDom){
		objElem.style.left=intX - intOffset + g_intXOffset;
		objElem.style.top=intY;
	}else{
		objElem.left=intX - intOffset;
		objElem.top=intY;
	}

}

/*
********************************************************************
* Function: showLayer
* Objective: shows a HTML container object
* Input: objElem - HTML Container Object
* Output: N/A
********************************************************************
*/
function showLayer(objElem){
	if(g_blnDom)objElem.style.display='block';
	else objElem.visibility='show';
}


/*
********************************************************************
* Function: writeMenu
* Objective: write the menu drop down options in an HTML Table
* Input: strOps - The array holding all the link values
* Output: N/A
********************************************************************
*/
function writeMenu(strOps){
	for(var i = 0; i<strOps.length; i++){
		var strMenuOp = strOps[i].split(g_strMenuSeperator)
		g_strMenuHTML += '<a href="'+strMenuOp[1]+'">'+strMenuOp[0]+'</a>\n';
		
	}
}

/*
********************************************************************
* Function: createHTML
* Objective: write the HTML menu code
* Input: 
* Output: 
********************************************************************
*/

function createHTML(strObj,aryObj){
	openContainerWithId(strObj);
		writeMenu(eval(aryObj));
	closeContainer();	
}


