/* Drop Down Menu Configurations */
var dropDownDelay = 300;
var timeOn = null;
var menuActive = 0;
var selectedNavObj = null;
var selectedNav = null;
// MENU MOUSE OVER 
function menuOver() {
	clearTimeout(timeOn);
	menuActive = 1;
}
// MENU MOUSE OUT 
function menuOut(event) {
	if (menuActive == 1) {
		menuActive = 0 ;	
	 	timeOn = setTimeout("hideAllMenus()", dropDownDelay);
	}
}

function showMenu(menuID, eventObj) {
	hideAllMenus();
	if (menuID != selectedNav) {
		selectedNavObj = $('a#link_' + menuID).parent();
		selectedNavObj.addClass("selected");
	}
	$('div#menu_' + menuID).show().fadeIn(300);
	
	var link = document.getElementById("link_" + menuID);
	var xPos = is_firefox ? findPosX(link) + 2 : (is_ie ? findPosX(link) - 10 : findPosX(link));
	var yPos = (is_firefox || is_ie) ? findPosY(link) + 27 : findPosY(link) + 26;
	$('div#menu_' + menuID).css("left",xPos);
	$('div#menu_' + menuID).css("top",yPos);
	
	eventObj.cancelBubble = true;
	return true;
}

function hideAllMenus() {
	$('div.menu').hide();
	if (selectedNavObj != null && typeof(selectedNavObj) == "object") selectedNavObj.removeClass("selected");
}

function cancelBubble(e)
{
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}

// -----------------------
// hacks and workarounds *
// ------------------------

// initialize hacks whenever the page loads
window.onload = initializeHacks;

// setup an event handler to hide popups for generic clicks on the document
function initializeHacks() {
    // this ugly little hack resizes a blank div to make sure you can click
    // anywhere in the window for Mac MSIE 5
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)) {
	window.onresize = explorerMacResizeFix;
    }

    // this next function creates a placeholder object for older browsers
    createFakeEventObj();
}

function createFakeEventObj() {
    // create a fake event object for older browsers to avoid errors in function call
    // when we need to pass the event object to functions
    if (!window.event) {
	window.event = false;
    }
} // createFakeEventObj

function explorerMacResizeFix () {
    location.reload(false);
}

function findPosX(obj)
{
var curleft = 0;
if(obj.offsetParent)
	while(1) 
	{
	  curleft += obj.offsetLeft;
	  if(!obj.offsetParent)
		break;
	  obj = obj.offsetParent;
	}
else if(obj.x)
	curleft += obj.x;
return curleft;
}

function findPosY(obj)
{
var curtop = 0;
if(obj.offsetParent)
	while(1)
	{
	  curtop += obj.offsetTop;
	  if(!obj.offsetParent)
		break;
	  obj = obj.offsetParent;
	}
else if(obj.y)
	curtop += obj.y;
return curtop;
}