
// ================================================================================== //
// function to show/hide the stillhouse popup menus
function toggle_menu(ID,toggle){
	// popup div ID = the ID passed to this function
	// with "menu_" pre-pended to it.
	
	// only if a target was sent.... other wise hide all by class only 
	if (ID) {
		var obj = document.getElementById('menu_'+ID);
	
		// current visibility
		var curr_visibility = obj.style.visibility;
		
	if ( curr_visibility == 'visible' && toggle == undefined) { return;}
	}
	
	
	// hide all divs by class    requires styley.js
	setStyleByClass('DIV','nav_menu','visibility','hidden');
	
	// dispay the target div, if this was a show and an ID was specified.
	if (curr_visibility != 'visible' && ID) { init_nav_container_div(); obj.style.visibility = 'visible';  }
}
// ================================================================================== //


// ================================================================================== //
// fix to event bubbling that keeps the menu persistant
// when the mouse hovers over a links in the popup div
function isMouseLeaveOrEnter(e, handler)
			{		
				var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement;
				while (reltg && reltg != handler) reltg = reltg.parentNode;
				return (reltg != handler);
			}
// ================================================================================== //


// ================================================================================== //			
// function to return the x,y locaiton of a passed object
// this function doesn't work with IE 7. go figure.

	function GetObjLocation_notused(obj) {
	var x = (document.layers) ? obj.x : obj.offsetLeft;
	var y = (document.layers) ? obj.y : obj.offsetTop;
	//document.getElementById('xy').innerHTML = 'obj: ' + obj.id + ', x: ' + x +', y: '+y;
	return ([x,y]);
}

// I did find this function that works in IE 7
function GetObjLocation(obj){
	var posX = obj.offsetLeft;var posY = obj.offsetTop;
	while(obj.offsetParent){
		posX+=obj.offsetParent.offsetLeft;
		posY+=obj.offsetParent.offsetTop;
		if(obj==document.getElementsByTagName('body')[0]){break}
	else{obj=obj.offsetParent;}
	}

	//alert('obj: ' + obj.id + ', x: ' + posX +', y: '+posY);
	return ([posX,posY]);
}

// ================================================================================== //



// ================================================================================== //
// function to place the absolute position of the menu container popup.
	function init_nav_container_div() {
		// this fuction assumes the div ID of the nav
		// container is popup_menu_container
		
		// capture the object this is the popup container
		var container_obj = document.getElementById('popup_menu_container');
		
		// capture the object of the anchor menu bar
		var anchor_obj = document.getElementById('Image1');
		
		// get the x,y location of the UL
		var aryXY = GetObjLocation(anchor_obj);
		
		// set the xy of the container
		container_obj.style.left = aryXY[0]+'px';
		container_obj.style.top  = aryXY[1]+'px';
	}

