n = (document.layers) ? 1:0
ie = (document.all) ? 1:0

var tabclicked;		// array number of tab clicked on
var lasttabclicked;	// array number of tab last clicked on
var aremoving = 0;	// tells if tabs are in active animation
var opentab = 0;	// tells if tabs are presently open (T/F)
var arraylen = 4;	// array length (+ Blank & SliderLayer)
var animdelay = 10;	// set the anim delay, use 10 if too slow
var ymoveamt = 5;	// give the amount to move the items

var tabs = new Array("RollTab1","RollTab2","RollTab3","Blank") // array of Div names (unopen tabs + Blank & SliderLayer)
var tabs2 = new Array("NoRollTab1","NoRollTab2","NoRollTab3") // array of Div names (open tabs)
var tablinks = new Array(0,116,0,0) // space for links (equation is -> line-height(in px) * numoflinks)
var tabtops = new Array(29,63,80,165) // array of corresponding top values


function checkclick(num)
{
	if ((aremoving == 0) && (num != tabclicked))
		{aremoving = 1; lasttabclicked=tabclicked; tabclicked=num; objslide();}  // sets tabs to active
}

function objshow(showobj)
{
	if (n) {document.layers[showobj].visibility = "show"}
	if (ie) {document.all[showobj].style.visibility = "visible"}
}

function objhide(hideobj)
{
	if (n) {document.layers[hideobj].visibility = "hide"}
	if (ie) {document.all[hideobj].style.visibility = "hidden"}
}

function objslide()
{
	if (n)
	{
		if (opentab == 1)
		{
			mfactor = tablinks[lasttabclicked] + 4  // mfactor = distance of move (+ xtra space)
			if (lasttabclicked == 0)
				{movetab = 0}
			else
				{movetab = lasttabclicked + 1}  // movetab = array number of tab under lasttabclicked
			moveobj = tabs[movetab]  // moveobj = Div name of movetab
			document.layers[moveobj].ypos = parseInt(document.layers[moveobj].top)  // sets ypos
			if (document.layers[moveobj].ypos > (tabtops[movetab] - mfactor) && tablinks[lasttabclicked] != 0)
			{  // checks if destination is reached
				for(movetab; movetab < arraylen; movetab++)
				{  // loops though tabs (& blank)
					moveobj = tabs[movetab] // moveobj = Div name of movetab (repeated for 1st tab)
					document.layers[moveobj].ypos = parseInt(document.layers[moveobj].top) // sets ypos (repeated for 1st tab)
					document.layers[moveobj].ypos -= ymoveamt  // sets up move (ymoveamt pixels)
					document.layers[moveobj].top = document.layers[moveobj].ypos
				} // does move
				setTimeout("objslide()",animdelay)
			}
			else
			{
				for(movetab; movetab < arraylen; movetab++)
				{  // loops through affected tabs (& blank)
					moveobj = tabs[movetab]  // moveobj = Div name of movetab (repeated for 1st tab)
					tabtops[movetab] = parseInt(document.layers[moveobj].top)
				}  // sets new top value in array
				opentab = 0  // tabs are now presently closed
				objshow(tabs[lasttabclicked]);objhide(tabs2[lasttabclicked])
				// switches open tab to closed
				objslide()
			}
		}
		else
		{
			if (tabclicked != -1)
			{
				objshow(tabs2[tabclicked]);objhide(tabs[tabclicked])  // switches clicked tab to open
				objslide2()
			}
			else
			{
				if (tabclicked == 0)
					{objslide2()}
				else
					{aremoving = 0}
			}
		}
	}

	if (ie)
	{
		if (opentab == 1)
		{
			mfactor = tablinks[lasttabclicked] + 4  // mfactor = distance of move (+ xtra space)
			if (lasttabclicked == 0)
				{movetab = 0}
			else
				{movetab = lasttabclicked + 1}  // movetab = array number of tab under lasttabclicked
			moveobj = tabs[movetab]  // moveobj = Div name of movetab
			document.all[moveobj].style.ypos = parseInt(document.all[moveobj].style.top)  // sets ypos
			if (document.all[moveobj].style.ypos > (tabtops[movetab] - mfactor) && tablinks[lasttabclicked] != 0)
			{  // checks if destination is reached
				for(movetab; movetab < arraylen; movetab++)
				{  // loops though tabs (& blank)
					moveobj = tabs[movetab] // moveobj = Div name of movetab (repeated for 1st tab)
					document.all[moveobj].style.ypos = parseInt(document.all[moveobj].style.top) // sets ypos (repeated for 1st tab)
					document.all[moveobj].style.ypos -= ymoveamt  // sets up move (ymoveamt pixels)
					document.all[moveobj].style.top = document.all[moveobj].style.ypos
				} // does move
				setTimeout("objslide()",animdelay)
			}
			else
			{
				for(movetab; movetab < arraylen; movetab++)
				{  // loops through affected tabs (& blank)
					moveobj = tabs[movetab]  // moveobj = Div name of movetab (repeated for 1st tab)
					tabtops[movetab] = parseInt(document.all[moveobj].style.top)
  				}  // sets new top value in array
				opentab = 0  // tabs are now presently closed
				objshow(tabs[lasttabclicked]);objhide(tabs2[lasttabclicked])
				// switches open tab to closed
				objslide()
			}
		}
		else
		{
			if (tabclicked != -1)
			{
				objshow(tabs2[tabclicked]);objhide(tabs[tabclicked])  // switches clicked tab to open
				objslide2()
			}
			else
			{
				if (tabclicked == 0)
					{objslide2()}
				else
					{aremoving = 0}
			}
		}
	}
}

function objslide2()
{
	if (n)
	{
		mfactor = tablinks[tabclicked] + 4 // mfactor = distance of move (+ xtra space)
		if (tabclicked == 0)
			{movetab = 0}
		else
			{movetab = tabclicked + 1}  // movetab = array number of tab under tabclicked
		moveobj = tabs[movetab]  // moveobj = Div name of movetab
		document.layers[moveobj].ypos = parseInt(document.layers[moveobj].top)  // sets ypos

		if (document.layers[moveobj].ypos < (tabtops[movetab] + mfactor) && tablinks[tabclicked] != 0)
		{  // checks if destination is reached
			for(movetab; movetab < arraylen; movetab++)
			{  // loops though tabs (& blank)
				moveobj = tabs[movetab] // moveobj = Div name of movetab (repeated for 1st tab)
				document.layers[moveobj].ypos = parseInt(document.layers[moveobj].top) // sets ypos (repeated for 1st tab)
				document.layers[moveobj].ypos += ymoveamt  // sets up move (ymoveamt pixels)
				document.layers[moveobj].top = document.layers[moveobj].ypos
			} // does move
			setTimeout("objslide2()",animdelay)
		}
		else
		{
			for(movetab; movetab < arraylen; movetab++)
			{  // loops through affected tabs (& blank)
				moveobj = tabs[movetab]  // moveobj = Div name of movetab (repeated for 1st tab)
				tabtops[movetab] = parseInt(document.layers[moveobj].top)
			}  // sets new top value in array
			opentab = 1; aremoving = 0;
		}  // tabs are now presently open & inactive

	}

	if (ie)
	{
		mfactor = tablinks[tabclicked] + 4 // mfactor = distance of move (+ xtra space)
		if (tabclicked == 0)
			{movetab = 0}
		else
			{movetab = tabclicked + 1}  // movetab = array number of tab under tabclicked
		moveobj = tabs[movetab]  // moveobj = Div name of movetab
		document.all[moveobj].style.ypos = parseInt(document.all[moveobj].style.top)  // sets ypos

		if (document.all[moveobj].style.ypos < (tabtops[movetab] + mfactor) && tablinks[tabclicked] != 0)
		{  // checks if destination is reached
			for(movetab; movetab < arraylen; movetab++)
			{  // loops though tabs (& blank)
				moveobj = tabs[movetab] // moveobj = Div name of movetab (repeated for 1st tab)
				document.all[moveobj].style.ypos = parseInt(document.all[moveobj].style.top) // sets ypos (repeated for 1st tab)
				document.all[moveobj].style.ypos += ymoveamt  // sets up move (ymoveamt pixels)
				document.all[moveobj].style.top = document.all[moveobj].style.ypos
			} // does move
			setTimeout("objslide2()",animdelay)
		}
		else
		{
			for(movetab; movetab < arraylen; movetab++)
			{  // loops through affected tabs (& blank)
				moveobj = tabs[movetab]  // moveobj = Div name of movetab (repeated for 1st tab)
				tabtops[movetab] = parseInt(document.all[moveobj].style.top)
			}  // sets new top value in array
			opentab = 1; aremoving = 0;
		}  // tabs are now presently open & inactive

	}
}
