var prefix;
var MenuID;
var MenuDef;
var MenuSingle=0;
var AllDone=0;

lrMenu=new Array();

if (navigator.userAgent.indexOf('MSIE')>0) 
	{
	isIE = 1;
	isV4=0;
	prefix="document.all[\'";
	suffix="\']";
	}
else
	{
	isIE = 0;
	if (parseInt(navigator.appVersion)>4)
		{
		isV4=0;
		prefix="document.getElementById('";
		suffix="')";
		}
	else
		{
		isV4=1;
		prefix="document.layers[\'";
		suffix="\']";
		}
	}

function PositionLayers()
	{	
	if (isIE==1)
		{
		//leftpos=(document.body.clientWidth-760)/2;
		//if ((leftpos % 2)==0)
		//	{leftpos--;}
		//if (leftpos<=0) {leftpos=0};
		leftpos=35;
		pos=lrMenu[0].layer.style.pixelTop;
		for (looper=0;looper<lrMenu.length;looper++)
			{
			lrMenu[looper].layer.style.pixelTop=pos;
			lrMenu[looper].layer.style.pixelLeft=leftpos;
			pos=pos+parseInt(lrMenu[looper].layer.style.height);
			}
		}
	else if (isV4==0)
		{
		leftpos=35;
		pos=parseInt(lrMenu[0].layer.style.top);
		for (looper=0;looper<lrMenu.length;looper++)
			{
			lrMenu[looper].layer.style.top=pos;
			lrMenu[looper].layer.style.left=leftpos;
			pos=pos+parseInt(lrMenu[looper].layer.style.height);
			}
		}
	else
		{
		//leftpos=(window.innerWidth-772)/2;
		//pos=lrMenu[0].layer.style.pixelTop;
		//if ((leftpos % 2)==0)
		//	{leftpos--;}
		//if (leftpos<=0) {leftpos=0};
		leftpos=35;
		pos=lrMenu[0].layer.top;
		for (looper=0;looper<lrMenu.length;looper++)
			{
			lrMenu[looper].layer.top=pos;
			lrMenu[looper].layer.left=leftpos;
			pos=pos+parseInt(lrMenu[looper].layer.clip.height);
			}
		}
	}

function SwapLayer()
	{
	args = SwapLayer.arguments;
	//theLayer = eval(prefix + args[0] + suffix);
	id=args[0];	
	if ((id<MenuDef) && (MenuSingle==1))
		{
		for (looper=0;looper<MenuDef;looper++)
			{
			if (id!=looper)
				{
				if ((isIE==1) || (isV4==0))
					{ lrMenu[looper].layer.style.height=lrMenu[looper].MinHeight+'px'; }
				else
					{ lrMenu[looper].layer.clip.height=lrMenu[looper].MinHeight; }
				}
			}
		}

	PositionLayers();

	if ((isIE==1) || (isV4==0))
		{
		if (parseInt(lrMenu[id].layer.style.height)==lrMenu[id].MinHeight) 
			{ newh=lrMenu[id].MaxHeight; }
		else 
			{ newh=lrMenu[id].MinHeight; }
		lrMenu[id].layer.style.height=newh + 'px';
		}
	else
		{
		if (parseInt(lrMenu[id].layer.clip.height)==lrMenu[id].MinHeight) 
			{ newh=lrMenu[id].MaxHeight; }
		else 
			{ newh=lrMenu[id].MinHeight; }
		lrMenu[id].layer.height=newh;
		lrMenu[id].layer.clip.height=newh;
		}
	PositionLayers();
	}
	
function InitMenu()
	{
	if ((isIE==1) || (isV4==0))
		{
		/*
		theLayer='div0';
		Lyr=eval(prefix + theLayer + suffix);
		lrMenu[0]=new MenuEntry(theLayer,20,Lyr.offsetHeight);
		*/
		for (looper=0;looper<3;looper++)
			{
			theLayer='div'+looper;
			Lyr=eval(prefix + theLayer + suffix);
			if (Lyr) { lrMenu[looper]=new MenuEntry(theLayer,18,Lyr.offsetHeight); } else {return};
			}
		}
	else 
		{ // Netscape 4
		theLayer='div0';
		Lyr=eval(prefix + theLayer + suffix);
		lrMenu[0]=new MenuEntry(theLayer,20,80);
	
		theLayer='div1';
		Lyr=eval(prefix + theLayer + suffix);
		lrMenu[1]=new MenuEntry(theLayer,20,80);
	
		theLayer='div2';
		Lyr=eval(prefix + theLayer + suffix);
		lrMenu[2]=new MenuEntry(theLayer,20,80);
		}

	MenuDef=lrMenu.length;
	args = InitMenu.arguments;
	for (looper=0;looper<lrMenu.length;looper++)
		{
		if ((isIE==1) || (isV4==0))
			{lrMenu[looper].layer.style.height=lrMenu[looper].MinHeight+'px';}
		else
			{lrMenu[looper].layer.clip.height=lrMenu[looper].MinHeight;}
		}

	for (looper=0;looper<=args.length-1;looper++)
		{
		id=args[looper];
		if ((isIE==1) || (isV4==0))
			{lrMenu[id].layer.style.height=lrMenu[id].MaxHeight+'px';}
		else
			{lrMenu[id].layer.clip.height=lrMenu[id].MaxHeight;}
		}
		
	PositionLayers();
	
	for (looper=0;looper<lrMenu.length;looper++)
		{
		if ((isIE==1) || (isV4==0))
			{lrMenu[looper].layer.style.visibility='visible';}
		else
			{lrMenu[looper].layer.visibility='show';}
		}

	}

function AddMenu(extraname,minh,maxh)
	{
	if (extraname!="")
		{
		cnt=lrMenu.length;
		theLayer=extraname;		
		lrMenu[cnt]=new MenuEntry(theLayer,minh,maxh);
		if ((isIE==1) || (isV4==0))
			{lrMenu[cnt].layer.style.height=lrMenu[cnt].MaxHeight+'px';}
		else
			{lrMenu[cnt].layer.clip.height=lrMenu[cnt].MaxHeight;}

		PositionLayers();
		if ((isIE==1) || (isV4==0))
			{lrMenu[cnt].layer.style.visibility='visible';}
		else
			{lrMenu[cnt].layer.visibility='show';}
		}
	}
		
function MenuEntry(Layer,MinHeight,MaxHeight)
{
	this.name=Layer;
	this.layer=eval(prefix + Layer + suffix);
	this.MinHeight=MinHeight;
	this.MaxHeight=MaxHeight;	
}
