/*
********************************************************************
* PopUp Window Function
********************************************************************
*/
function pop(url,w,h){
	var strWh = (h && w) ? ",toolbar=0,width="+w+",height="+w : ",toolbar=1";
	
	window.open(url,'',"scrollbars=yes,resizable=yes"+strWh);
}


/*
********************************************************************
* Drop Down Menu JavaScript Functions
********************************************************************
File Name: /Scripts/menus.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 = (document.all) ? true:false;
var g_blnDom = (document.getElementById) ? true:false;
var g_intYOffset = 18;
var g_intYPadding = 3;
var g_intXOffset = 0;
var g_objCurrentLayer = null;
var g_blnInLayer = false;
var g_strMenuSeperator = "|";
var g_strMenuHTML = "";
var g_intWinOffset = 20;

/*
********************************************************************
* 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];
	showLayer(objLayer);
	positionLayer(objLayer,x,y);
	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: 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';
		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(){
	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;
	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,x,y){
	var posX = (x) ? x:getElemX(objElem);
	var posY = (y) ? y:getElemY(objElem);
	
	if(g_objCurrentLayer != null) hideLayer(g_objCurrentLayer);
	_menuOver(strLayerName,posX,posY);
}

/*
********************************************************************
* 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 id="' +intId+'" style="position:absolute;display:none;" onmouseover="javascript:layerOver();" onmouseout="javascript:layerOut();">\n';
	else
		g_strMenuHTML += '<layer 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;
		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: 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)",200);
}

/*
********************************************************************
* 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){
	g_strMenuHTML += '<table cellpadding=0 cellspacing=0 border=0 bgcolor="#000000" class="drop"><tr><td>\n';
	g_strMenuHTML += '<table cellpadding=3 border=0 cellspacing=0>\n';
	for(var i = 0; i<strOps.length; i++){
		var strMenuOp = strOps[i].split(g_strMenuSeperator)
		g_strMenuHTML += '<tr bgcolor="#000000"><td nowrap>\n';
		g_strMenuHTML += '<a href="'+strMenuOp[1]+'" class="nav">'+strMenuOp[0]+'</a>\n';
		g_strMenuHTML += '</td></tr>\n';
	}
	g_strMenuHTML += "</table>\n";
	g_strMenuHTML += '</td></tr></table>\n';
}

/*
********************************************************************
* Function: createHTML
* Objective: write the HTML menu code
* Input: 
* Output: 
********************************************************************
*/

function createHTML(strObj,aryObj){
	openContainerWithId(strObj);
		writeMenu(eval(aryObj));
	closeContainer();	
}



