window.onload = function(){
	if(document.getElementById('mnArmor'))
	{
		var td = document.getElementById('mnArmor').getElementsByTagName('td');
		for(i=0;i<td.length;i++)
		{
			if(td[i].width == '123')
			{
			   _arrowClick(td[i],'');
			}
		}						 
	}
}


///
///   © 2007, Bweb Brasil Ltda
///
///   Author: Fabio Tezedor
///   Modify: Eduardo Faber # 31/05/2007
///
///   recursively searches the table's cells that contains the arrow image from the DIV.
///   returns a null value if the mentioned image doesn't exists.
///
function getArrowReference( container )
{
	//alert( container.nodeType + " | " + container.nodeName + " | " + container.id );
	try
	{
		var ptr = null;
		if ( container.nodeName == "TD" )
		{
			var img = container.getElementsByTagName("img")[0];
			if ( typeof( img ) == "object" )
			{
			   if (img.src.indexOf("trans.gif") > 0)
				   return container;
			}
		}
		else
		{
			if ( container.childNodes.length > 0 )
			{
				for ( var i=0;i<container.childNodes.length;i++ )
				{
					ptr = getArrowReference( container.childNodes[i] );
					if ( ptr != null ) return ptr;
				}
			}
		}
		return ptr;
	}
	catch ( ex )
	{
		throw ex;
	}
}
///
///  creates or replace the cookie value and/or expire date
///
function createCookie(name,value,days)
{
	var expires = "";
	if(days)
	{
		var date = new Date();
		date.setTime( date.getTime() + (days*86400000) );
		expires = date.toGMTString();
	}
	document.cookie = name+"="+value+"; "+expires+"; path=/";
}
///
///  lookup for a cookie and returns its value
///
function getCookie(name)
{
	var aCookies = document.cookie.split(";");
	for ( var i=0;i<aCookies.length;i++ )
	{
		if ( aCookies[i].indexOf(name+"=") >= 0 )
		{
			var p1 = aCookies[i].indexOf(name+"=") + name.length + 1;
			//var p2 = aCookies[i].indexOf(";",p1);
			//if ( p2 == -1 ) p2 = aCookies[i]
			return aCookies[i].substring(p1);
		}
	}
}
///
///  deletes a cookie
///
function deleteCookie(name)
{
	createCookie(name,"",-1);
}
///
///  returns true if the navigator is the Internet Explorer
///
function isIE()
{
	return ( window.navigator.appName.indexOf("Internet Explorer") >= 0 );
}
///
///  shows the dinamic page identfied by the "x" parameter
///
function openContent(x)
{
	try
	{
		window.location.href = "/site/general/content.aspx?pg="+x;
		//window.location.href = "menu.htm";
	}
	catch(ex)
	{
		alert(ex.message);
	}
}
///
///  just a shell function to the _click() function
///
function _arrowClick(e, i)
{
	try
	{
		_click(e, i);
	}
	catch(ex)
	{
		window.alert("O erro abaixo ocorreu durante a tentiva de expandir o menu\r\n\r\n" + ex.message);
	}
}
///
///  open the submenus relateds to the clicked arrow
///
function _click(e, i)
{
   //alert( typeof(e) + "-" + e )
	try
	{
		var img = (i == null) ? e.getElementsByTagName("img")[0] : document.getElementById(i) ;
		if (img != null)
		{
			if ( img.src.indexOf("trans.gif") > 0 )
				img.src = "/images/trans.gif"
			else
				img.src = "/images/trans.gif"
		}
		var pe = e.parentNode.parentNode.parentNode.parentNode; //.parentNode.parentNode.parentNode.parentNode;
		var dvs = pe.childNodes;
		//alert(dvs.length);
		for ( var i=0;i<dvs.length;i++ )
		{
			if( dvs[i].nodeName == "DIV" )
			{
				dvs[i].className = (dvs[i].className=="mnItemClose"?"mnItemOpen":"mnItemClose");
			}
		}
	}
	catch (ex)
	{
		throw ex;
	}
}
///
///  calls the url identified by "u" parameter and
///  sets the active menu item identified by "e" parameter
///
function _open(e,u,t)
{
	try
	{
		// set or delete the cookie based on the clicked menu item
		
		if ( e == null )
		{
			deleteCookie( "mi" )
		}
		else
		{
			var n = e.parentNode.childNodes;
			
		   //var nNodes = (n[n.length-(isIE()?1:2)]).parentNode;
		   n = (n[n.length-(isIE()?1:2)]).parentNode;
		   
		   //for (var i = 0; i < 4; i++ ) n = n.parentNode;
		   for (var i = 0; i < 3; i++ ) n = n.parentNode;
			
			createCookie( "mi", n.id )
			//createCookie( "mi",(n[n.length-(isIE()?1:2)]).parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.id )
		}
		
		// verify if the menu item link is a simple url link or a encoded link
		if ( u.indexOf("eval$") == 0 )
		{
			u = u.replace("eval$","");
			u = u.replace("[","'").replace("]","'");
			eval(u);
		}
		else
		{
			window.open(u,t);
			//window.open("menu.htm","_self");

		}
	}
	catch(ex)
	{
		window.alert(ex.message);
	}
}