/*
													
	Navigation menu effects script					
													
   V. Singleton (ModeZero.net)						
													
*/

// yuk, global timer used to reset menu back to default (avoids flicker)
var gSubNavTimerId = null;

// mouse into an A														
// highlight that one and lowlight the rest								
function nfx_NavIn(ActionObj)
{	
	if (gSubNavTimerId != null)
	{
		clearTimeout(gSubNavTimerId);
		gSubNavTimerId= null;
	}
	// reset to "base" state before changing again	
	NavResetTimer( ActionObj.getAttribute('MenuGroup') )

	// first find the name of the Menu group for this item
  if (document.getElementById) 
  {
  	var sMenuGroup = ActionObj.getAttribute('MenuGroup')
  	
  	// find all others in this menu group and set to their dull class
		var rLinks = document.getElementsByTagName('a');		
		
		if (!ActionObj.oldClass) ActionObj.oldClass = ActionObj.className;
		ActionObj.className = ActionObj.getAttribute('OnClass');

		// go through each looking for matching group
		var sGrp 
		for (var i = 0; i < rLinks.length; i++) 
		{
			sGrp = rLinks[i].getAttribute('MenuGroup');
			if (sGrp && sGrp == sMenuGroup && rLinks[i].href != ActionObj.href)
			{
				if (!rLinks[i].oldClass) rLinks[i].oldClass = rLinks[i].className ? rLinks[i].className : 'undef';
				
				rLinks[i].className = rLinks[i].getAttribute('DullClass');
			}
		}  	
  }
}

// mouse out of an A, reset the menu shortly if no further mouse overs sent	
//
function nfx_NavOut(ActionObj)
{
	gSubNavTimerId = setTimeout("NavResetTimer('" + ActionObj.getAttribute('MenuGroup') + "')", 100);	
//	NavResetTimer(ActionObj.getAttribute('MenuGroup'))
}

//
// MZFX function to fade an image to given opacity level
//
var MZFadeTo = 
{
	Final: function( oImg, nFadeStep, nFinalOpacity )
	{
		// if not started, or fading the other way, then start our one	
		if (!oImg.FadeStep || oImg.FadeStep != nFadeStep)
		{	
			// if dont know, assume not opaque	
			if (!oImg.CurrentOpacity)
			{
				if (oImg.style.display == "none")
				{
					oImg.CurrentOpacity = 0;
					oImg.style.display = "block";
				}
				else
				{			
					oImg.CurrentOpacity = 100;
				}
			}
			
			oImg.FadeStep			= nFadeStep;		
			oImg.FadeFinalOpacity	= nFinalOpacity;
												
			MZFadeTo.callbackFadeStep(oImg);
		}		
	},

	callbackFadeStep: function (oImg)
	{		
		if ((oImg.FadeStep < 0 && oImg.CurrentOpacity > oImg.FadeFinalOpacity) ||
		    (oImg.FadeStep > 0 && oImg.CurrentOpacity < oImg.FadeFinalOpacity) )
		{
			oImg.CurrentOpacity += 	oImg.FadeStep
		
			oImg.style.filter="alpha(opacity="+oImg.CurrentOpacity+")"	// for IE		
			oImg.style.opacity = oImg.CurrentOpacity/100;				// for others	
								
			setTimeout( function() { MZFadeTo.callbackFadeStep(oImg) }, 10 )
		}
		else
		{
			if (oImg.FadeFinalOpacity == 0)
			{
				oImg.style.display="none";
			}
		}
	}
}
// ------------------------------ INTERNAL ROUTINES ------------------------------	

// reset the group to its default class values								
function NavResetTimer(sGroupName)
{
	// revert all to default
		var rLinks = document.getElementsByTagName('a');		
			
		// go through each looking for matching group
		for (var i = 0; i < rLinks.length; i++) 
		{
			sGrp = rLinks[i].getAttribute('MenuGroup');
			if (sGrp && sGrp == sGroupName)
			{
				if (rLinks[i].oldClass)
				{
					rLinks[i].className = rLinks[i].oldClass;
				}
			}
		}  	
		gSubNavTimerId = null;
}

