/***************************************************************
* Start Code for menu functionality
****************************************************************/
sfHover = function() {
	var sfNavs = document.getElementById("nav");

	if (null != sfNavs)
	{
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		if(null != sfEls)
		{
			for (var i=0; i<sfEls.length; i++) 
			{
				sfEls[i].onmouseover=function()
				{
					this.className+=" sfhover";
				}
				sfEls[i].onmouseout=function() 
				{
					this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
				}
			}
		}
	}
}
if (window.addEventListener)
{
	window.addEventListener("load", sfHover, false);
}
else if (window.attachEvent) 
{
	window.attachEvent("onload", sfHover);
}



/***************************************************************
* Start Code for image shrinking 
****************************************************************/
var gaImageW = new Array();
var gaImageH = new Array();
var gaShrink = new Array();
var gaImage = new Array();
var gcTimeout =10;

function shrinkimage(strOperation, nCurrentBox)
{

// Only allow the event if scrolling isn't happening
if (gbAllowOtherScript)
{
    if(bAllowScript)
    { 
	if (nCurrentBox > 0)
	{
	
		// Check the speed
		if (event != null)
		{
			if (event.srcElement.tagName == "TABLE")
			{
				gcTimeout = 5;
			}
			else
			{
				gcTimeout = 5;
			}
		}
		
		// Check which element invoked this, or is it a recursive call?
		if(strOperation == "shrink")
		{
			if (event.srcElement.name != "") gaImage[nCurrentBox] = document.getElementById("navbox" + nCurrentBox);
			if (gaImage[nCurrentBox] != null)
			{

				gaShrink[nCurrentBox] = true;
				if (gaImageW[nCurrentBox] == undefined) gaImageW[nCurrentBox] = gaImage[nCurrentBox].width;
				if (gaImageH[nCurrentBox] == undefined) gaImageH[nCurrentBox] = gaImage[nCurrentBox].height;
		
				// Switch the text in the box
				if (document.getElementById("navboxtext" + nCurrentBox).getAttribute("toggleHTML") != "" && document.getElementById("navboxtext" + nCurrentBox).getAttribute("toggleHTML") != undefined)
				{
					document.getElementById("navboxtext" + nCurrentBox).innerHTML = document.getElementById("navboxtext" + nCurrentBox).getAttribute("toggleHTML");
				}
			}
		}
	
		if (strOperation == "unshrink")
		{
			gaShrink[nCurrentBox] = false;
			//if (event.srcElement.name != "") gaImage[nCurrentBox] = document.getElementById("navbox" + nCurrentBox);
		}

		if (gaImage[nCurrentBox] != null)
		{
			var nImageW = gaImage[nCurrentBox].width;
			var nImageH = gaImage[nCurrentBox].height;

			if (gaShrink[nCurrentBox])
			{
			
				//window.status = "SHRINK: " + nImageW + " x " + nImageH;
				if (nImageW > 4)
				{
					gaImage[nCurrentBox].style.width = nImageW - 3;
					eval("setTimeout(\'shrinkimage(\"continue\"," + nCurrentBox + ")\', gcTimeout)");
				}
				else
				{
					gaImage[nCurrentBox].style.width = 0;
				}
			}
			else
			{
				//window.status = "UNSHRINK: " + nImageW + " x " + nImageH;
				if (nImageW < gaImageW[nCurrentBox] - 4)
				{
					gaImage[nCurrentBox].style.width = nImageW + 4;
					eval("setTimeout(\'shrinkimage(\"continue\"," + nCurrentBox + ")\', gcTimeout)");
				}	
				else
				{
					gaImage[nCurrentBox].style.width = gaImageW[nCurrentBox];
				}	
			}
		}				
	}
    }
    else
    {
	// Switch the text in the box
	if (document.getElementById("navboxtext" + nCurrentBox).getAttribute("toggleHTML") != "" && document.getElementById("navboxtext" + nCurrentBox).getAttribute("toggleHTML") != undefined)
	{
		document.getElementById("navboxtext" + nCurrentBox).innerHTML = document.getElementById("navboxtext" + nCurrentBox).getAttribute("toggleHTML");
	}
	
	
	if (strOperation == "shrink")
	{
		var thisbox = document.getElementById("navbox" + nCurrentBox);
		gaImageW[nCurrentBox] = thisbox.width;
		gaImageH[nCurrentBox] = thisbox.height;
		thisbox.style.width = 0;
		thisbox.style.height = gaImageH[nCurrentBox];
	}

	if (strOperation == "unshrink")
	{
		var thisbox = document.getElementById("navbox" + nCurrentBox);
		thisbox.style.width = gaImageW[nCurrentBox];
		thisbox.style.height = gaImageH[nCurrentBox];
	}
	
    }
}
else
{
	// Another scrolling event is happening so revert back to default settings

	if (bAllowScript && gaImage[nCurrentBox] != null)
	{
		gaImage[nCurrentBox].style.width = gaImageW[nCurrentBox];
		gaImage[nCurrentBox].style.height = gaImageH[nCurrentBox];
	}		
	else
	{
		var thisbox = document.getElementById("navbox" + nCurrentBox);
		thisbox.style.width = gaImageW[nCurrentBox];
		thisbox.style.height = gaImageH[nCurrentBox];
	}	
}
}

// Attach this event to each navbox
sfShrink = function() {

	var sfNavbox = document.getElementById("navboxcont");	
	if (null != sfNavbox)
	{

		// Add the hover effects to the navigation boxes
		var sfTABLEs = document.getElementById("navboxcont").getElementsByTagName("TABLE");
		if(null != sfTABLEs)
		{
			for (var i=0; i<sfTABLEs.length; i++) 
			{
				if (sfTABLEs[i].className == "navbox")
				{
						var strFunc = "sfTABLEs[i].onmouseover=function(){shrinkimage('shrink'," + sfTABLEs[i].getAttribute("name").substring(6)*1 + ");this.className = 'navboxhover';}";
						eval(strFunc);
						strFunc = "sfTABLEs[i].onmouseout=function(){shrinkimage('unshrink'," + sfTABLEs[i].getAttribute("name").substring(6)*1 + ");this.className = 'navbox';}";
						eval(strFunc);
				}
			}
		}
		
			// Add the shrink/unshrink events to the navigation boxes
			var sfTDs = document.getElementById("navboxcont").getElementsByTagName("TD");
			if(null != sfTDs)
			{
				for (var i=0; i<sfTDs.length; i++) 
				{
					if (sfTDs[i].className == "navbox")
					{
						var strFunc = "sfTDs[i].onmouseover=function(){shrinkimage('shrink'," + sfTDs[i].getAttribute("name").substring(6)*1 + ");}";
						strFunc = "sfTDs[i].onmouseout=function(){shrinkimage('unshrink'," + sfTDs[i].getAttribute("name").substring(6)*1 + ");}";
					}
				}
			}
	}
}

if (window.addEventListener)
{
	window.addEventListener("load", sfShrink, false);
}
else if (window.attachEvent) 
{
	window.attachEvent("onload", sfShrink);
}
