//define app
app = navigator.userAgent.toLowerCase();
		
//ns4
ns4 = document.layers;
		
//reload on document resize
window.onresize = function()  { window.location.reload(); };

//layer positioning
function getTableLeft(itemWidth)
{
	var winWidth = getPageWidth();
	if (winWidth > itemWidth) tableleft = (winWidth - itemWidth)/2;
	else tableleft = 0;
	return tableleft;
}
function getTableTop(itemHeight)
{
	var winHeight = getPageHeight();
	if (winHeight > itemHeight) tabletop = (winHeight - itemHeight)/2;
	else tabletop = 0;
	return tabletop;
}
function getPageWidth()
{
	if (app.indexOf("netscape6") != -1) return window.innerWidth;
	else if (document.layers) return window.innerWidth;
	else return window.innerWidth? window.innerWidth : Math.max(document.body.clientWidth, document.documentElement.clientWidth)
}
function getPageHeight()
{
	if (app.indexOf("netscape6") != -1) return window.innerHeight;
	else if (document.layers) return window.innerHeight;
	else return window.innerHeight? window.innerHeight : Math.max(document.body.clientHeight, document.documentElement.clientHeight); 
}			
		
function positionLayer(layerName, layerLeft, layerTop)
{
	var d
	//position menu dependant on location of table
	if (document.getElementById) //Netscape 6 and W3C DOM
		{
		d = document.getElementById(layerName).style; // + "px";
		}
	else if (document.layers)
		{
		d = eval("document." + layerName);
		}                                                 
	else //assume msie or msie compatible
		{
		d = document.all(layerName).style;
		};
	d.top = document.layers ? layerTop : layerTop + "px"; //if ns4 do not use 'px'
	d.left = document.layers ? layerLeft : layerLeft + "px";
	MM_showHideLayers(layerName, '', 'show');
}
			
function setOpacity(id, arg) //arg = 0 to 100
{
	if (document.getElementById)
		{
		var object = document.getElementById(id).style; 
		object.opacity = (arg / 100); 
		object.MozOpacity = (arg / 100); 
		object.KhtmlOpacity = (arg / 100); 
		object.filter = "alpha(opacity=" + arg + ")"; 
		}
}
function fadein(id, opacStart, opacEnd, millisec)
{
	//speed for each frame 
	var speed = Math.round(millisec / 100); 
	var timer = 0; 
	//determine the direction for the blending, if start and end are the same nothing happens 
	if(opacStart > opacEnd) 
		{ 
		for(i = opacStart; i >= opacEnd; i--) 
			{ 
			setTimeout("setOpacity('" + id + "'," + i + ")",(timer * speed)); 
			timer++; 
			} 
		} 
	else if(opacStart < opacEnd) 
		{ 
		for(i = opacStart; i <= opacEnd; i++) 
			{ 
			setTimeout("setOpacity('" + id + "'," + i + ")",(timer * speed)); 
			timer++; 
			} 
		} 
} 
function show_it(id, opac)
{

	setOpacity(id, 0);
	make_visible(id);
	setOpacity(id, opac);

}
function make_visible(id)
{
	document.getElementById(id).style.visibility='visible';
}
function make_invisible(id)
{
	document.getElementById(id).style.visibility='hidden';
}
