

var openingit = 'yes';
function picopen(n)
{
	pic = ('pic' + n);
	document.getElementById(pic).src = "../gifs/wwwg-opened.gif";
}
function picclose(n)
{
	pic = ('pic' + n);
	document.getElementById(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+=1 )
	{
		whichchoice = ('choice' + i);
		submenu = document.getElementById(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);
			if( document.all )
			{
				oldloc = document.getElementById(whichchoice).style.pixelTop;
			}
			else
			{
				oldloc = document.getElementById(whichchoice).style.top;
			}
			intloc = parseInt(oldloc, 10);
			newloc = intloc+distance;
			document.getElementById(whichchoice).style.top = newloc;
		}
	}
	else
	{
		// ---- TRY TO CLOSE LEVEL-3 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);
					if( document.all )
					{
						oldloc = document.getElementById(whichchoicej).style.pixelTop;
					}
					else
					{
						oldloc = document.getElementById(whichchoicej).style.top;
					}
					intloc = parseInt(oldloc, 10);
					newloc = intloc-levelthreeheight;
					document.getElementById(whichchoicej).style.top = newloc;
				}
			}
		}


		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);
					if( document.all )
					{
						oldloc = document.getElementById(whichchoicej).style.pixelTop;
					}
					else
					{
						oldloc = document.getElementById(whichchoicej).style.top;
					}
					intloc = parseInt(oldloc, 10);
					newloc = intloc-levelthreeheight;
					document.getElementById(whichchoicej).style.top = newloc;
				}
			}
		}


		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);
					if( document.all )
					{
						oldloc = document.getElementById(whichchoicej).style.pixelTop;
					}
					else
					{
						oldloc = document.getElementById(whichchoicej).style.top;
					}
					intloc = parseInt(oldloc, 10);
					newloc = intloc-levelthreeheight;
					document.getElementById(whichchoicej).style.top = newloc;
				}
			}
		}





		// ---- OK, CLOSE THE MAIN ITEM ----

		picclose(id);
		for( var i=firstitemtomove; i<=nummenus; i++ )
		{
			whichchoice = ('choice' + i);
			oldloc = document.getElementById(whichchoice).style.top;
			intloc = parseInt(oldloc, 10);
			newloc = intloc-distance;
			document.getElementById(whichchoice).style.top = newloc;
		}
	}
}

