


var openingit = 'yes';
function picopen(n)
{
	pic = ('pic' + n);
	document.all(pic).src = "../gifs/wwwg-opened.gif";
}
function picclose(n)
{
	pic = ('pic' + n);
	document.all(pic).src = "../gifs/wwwg-closed.gif";
}





function toggle(id,firstitemtomove,distance,thirdida,thirdheighta,thirdidb,thirdheightb,thirdidc,thirdheightc,nummenus)
{

	// ---- FIRST MAKE THINGS VISIBLE/HIDDEN ----

	for( var i=(id+1); i<firstitemtomove; i+=2 )
	{
		whichchoice = ('choice' + i);
		submenu = document.all(whichchoice).style;
		if( submenu.visibility == 'visible' )
		{
			submenu.visibility = 'hidden';
			openingit = 'no';
		}
		else
		{
			submenu.visibility = 'visible';
			openingit = 'yes';
		}
	}

	// ---- THEN MOVE OTHER THINGS DOWN/UP ----

	if( openingit == 'yes' )
	{
		picopen(id);
		for( var i=firstitemtomove; i<=nummenus; i++ )
		{
			whichchoice = ('choice' + i);
			document.all(whichchoice).style.pixelTop += distance;
		}
	}
	else
	{


		// ---- TRY TO CLOSE THIRD-LEVEL ITEMS ----

		if( thirdidc > 0 )
		{
			whichchoice = ('choice' + thirdidc);
			var levelthreeheight = thirdheightc;
			submenu = document.all(whichchoice).style;
			if( submenu.visibility == 'visible' )
			{
				parentid = (thirdidc-1);
				picclose(parentid);
				submenu.visibility = 'hidden';
				for( j=(thirdidc+1); j<=nummenus; j++ )
				{
					whichchoicej = ('choice' + j);
					document.all(whichchoicej).style.pixelTop -= levelthreeheight;
				}
			}
		}

		if( thirdidb > 0 )
		{
			whichchoice = ('choice' + thirdidb);
			var levelthreeheight = thirdheightb;
			submenu = document.all(whichchoice).style;
			if( submenu.visibility == 'visible' )
			{
				parentid = (thirdidb-1);
				picclose(parentid);
				submenu.visibility = 'hidden';
				for( j=(thirdidb+1); j<=nummenus; j++ )
				{
					whichchoicej = ('choice' + j);
					document.all(whichchoicej).style.pixelTop -= levelthreeheight;
				}
			}
		}

		if( thirdida > 0 )
		{
			whichchoice = ('choice' + thirdida);
			var levelthreeheight = thirdheighta;
			submenu = document.all(whichchoice).style;
			if( submenu.visibility == 'visible' )
			{
				parentid = (thirdida-1);
				picclose(parentid);
				submenu.visibility = 'hidden';
				for( j=(thirdida+1); j<=nummenus; j++ )
				{
					whichchoicej = ('choice' + j);
					document.all(whichchoicej).style.pixelTop -= levelthreeheight;
				}
			}
		}





		// ---- OK, CLOSE THE MAIN ITEM ----

		picclose(id);
		for( var i=firstitemtomove; i<=nummenus; i++ )
		{
			whichchoice = ('choice' + i);
		 	document.all(whichchoice).style.pixelTop -= distance;
		}
	}
}



