
var menuinterval;

function findPosY(obj)
{
	var elcurtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			elcurtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		elcurtop += obj.y;
	return elcurtop;
}

function checkPos()
{
if(navigator.appName == "Microsoft Internet Explorer")
{
menuinterval = setInterval("getMenuLocation()",50);
}
else
{
menuinterval = setInterval("getMenuLocation()",100);
}
}

function stopInterval()
{
clearInterval(menuinterval);
menuinterval = null;
}

function getMenuLocation()
{
var i = 1;
var yPos,curTop,top;
yPos = findPosY(document.getElementById('menudiv'));
var width = screen.width;
//var bodywidth = document.getElementById("bodydiv").style.width;
var position;
if(width == 1024){position=(width - 1024) / 2;}
if(width > 1024){position=(width - 1024) / 2;} //have to test on other screen (change 1024)

if(navigator.appName == "Microsoft Internet Explorer")
{
curTop = document.documentElement.scrollTop;//location of the top of the screen after scrolling in IE 
}
else
{
curTop = window.pageYOffset;//location of the top of the screen after scrolling
}

top = 90 - curTop;

if(top > 0)
{
document.getElementById("menudiv").style.position='relative';
document.getElementById("menudiv").style.left=0;
document.getElementById("menudiv").style.top=0;
}

if(curTop > 90)
{
document.getElementById("menudiv").style.position='fixed';
document.getElementById("menudiv").style.left=position + "px"; 
}
}


function setOpacity(newOpacity,menu_num)
{
	if(menu_num == 1)
	{
	document.getElementById('articles_submenu1').style.opacity = newOpacity;
	document.getElementById('articles_submenu1').style.filter ='alpha(opacity=' + newOpacity + ')';
	}
	if(menu_num == 2)
	{
	document.getElementById('articles_subsubmenu1').style.opacity = newOpacity;
	//document.getElementById('articles_subsubmenu1').style.filter ='alpha(opacity=' + newOpacity + ')';
	}
	if(menu_num == 3)
	{
	document.getElementById('articles_subsubmenu2').style.opacity = newOpacity;
	//document.getElementById('articles_subsubmenu2').style.filter ='alpha(opacity=' + newOpacity + ')';
	}
	if(menu_num == 4)
	{
	document.getElementById('articles_subsubmenu3').style.opacity = newOpacity;
	//document.getElementById('articles_subsubmenu3').style.filter ='alpha(opacity=' + newOpacity + ')';
	}
}


function fadeIn(menu_num)
{
var opac,opacIE;

if(navigator.appName == "Microsoft Internet Explorer")
{
for(opacIE = 0; opacIE <= 100; opacIE += 1)
{
setTimeout("setOpacity(" + opacIE + "," + menu_num + ");",10 * opacIE);
}

}
else
{
for(opac = 0.0; opac <= 1.0; opac += 0.1)
{
setTimeout("setOpacity(" + opac + "," + menu_num + ");",400 * opac);

}
}
}

function fadeOut(menu_num)
{
var opac,opacIE;

for(opac = 1.0; opac >= 0.0; opac -= 0.01)
{
setTimeout("setOpacity(" + opac + "," + menu_num + ");",opac / 400);
}
}
