var ie = document.all;
var nn6 = document.getElementById && !document.all;
var mouseX, mouseY,xPosition,yPosition;

function getMousePos(e)
{
	if (!e)
	{
		var e = window.event || window.Event;
	}

	if('undefined'!=typeof e.pageX)
	{
		mouseX = e.pageX;
		mouseY = e.pageY;	
	}
	else
	{
		/* 
			This wouldnt work with DOCTYPE STRICT ... Microsoft :/
			mouseX = e.clientX + document.body.scrollLeft;
		*/
		mouseX = e.clientX;
		mouseY = e.clientY + document.documentElement.scrollTop;
	}	
}

document.onmousemove = getMousePos;	

function displayBanner(divId)
{			
	var theDiv = document.getElementById(divId);
	
	theDiv.style.position = "absolute";
	theDiv.style.display = "block";
	
	var c = document.getElementById('Container');
	var offSetX = theDiv.clientWidth/2;
	var offSetY = theDiv.clientHeight + 200;
	xPosition = (mouseX - offSetX) - c.offsetLeft ;
	yPosition = mouseY - offSetY;		
		
	if (xPosition <= 0)
		xPosition=0;
	
	theDiv.style.left = xPosition + "px";
	theDiv.style.top = yPosition + "px";
}	

function hideBanner(divId)
{	
	document.getElementById(divId).style.display = "none";
}

var displayedIDs = new Array();

function showMenu(menuID)
{		
	var theMenu = document.getElementById(menuID);

	var alreadyInMenu = false;
	for(i=0;i<displayedIDs.length;i++)
	{						
		currentId = displayedIDs[i];
		if (currentId == menuID)
		{
			alreadyInMenu = true;
		}
	}		
	if(!alreadyInMenu)
	{
		displayedIDs.push(menuID);
	}
	
	fadeInMenu(menuID);		
}

function fadeInMenu(menuID) 
{
	var removedFromMenu = true;
	for(i=0;i<displayedIDs.length;i++)
	{						
		currentId = displayedIDs[i];
		if (currentId == menuID)
		{
			removedFromMenu = false;
		}
	}		
	if(!removedFromMenu)
	{
		var theMenu = document.getElementById(menuID);				
		var newOpacity = parseFloat(theMenu.style.opacity) + 0.1;		
		
		theMenu.style.opacity = newOpacity;	
		theMenu.style.filter = 'alpha(opacity=' + newOpacity * 100 + ')';			
		
		if(newOpacity < 1)
		{
			setTimeout('fadeInMenu("' + menuID + '")', 20);
		}
	}
}

function hideMenu(menuID)
{		
	for(i=0;i<displayedIDs.length;i++)
	{		
		if(displayedIDs[i] == menuID)
		{								
			displayedIDs.splice(i,1);			
		}
	}

	setTimeout('fadeOutMenu("' + menuID + '")',80);
}

function fadeOutMenu(menuID) 
{
	var backInMenu = false;
	for(i=0;i<displayedIDs.length;i++)
	{						
		currentId = displayedIDs[i];
		if (currentId == menuID)
		{
			backInMenu = true;
		}
	}		
	if(!backInMenu)
	{
		var theMenu = document.getElementById(menuID);				
		var newOpacity = parseFloat(theMenu.style.opacity) - 0.1;	
		
		theMenu.style.opacity = newOpacity;	
		theMenu.style.filter = 'alpha(opacity=' + newOpacity * 100 + ')';			
		
		if(newOpacity > 0.4)
		{
			setTimeout('fadeOutMenu("' + menuID + '")',20);
		}
	}
}

