////////////////////////////////////////////////////////////////////////////////////////////////////
//   Guardar o estado dos modulos                                                                 //
////////////////////////////////////////////////////////////////////////////////////////////////////

function Click(id)
{
	div = document.getElementById(id);
		
	if (div.className == "divNacional")
	{
		div.className = "divNacionalOff";
	}
	else
	{
		div.className = "divNacional";
	}
}

function noClick(id)
{
	div = document.getElementById(id);
    cookie = GetUserCookie(id).split(",");
    
    
    if (cookie == "")
	{
		div.className = "divModule";
		SetCookie(id,'On');
	}
	else
	{
		if (cookie == "Off")
			{
				div.className = "divModuleOff";
				SetCookie(id,'Off');
			}
			else
			{
				div.className = "divModule";
				SetCookie(id,'On');
			}
	}
}

function onClick(id)
{
	div = document.getElementById(id);
    cookie = GetUserCookie(id).split(",");

	if (cookie == "Off")
		{
			div.className = "divModule";
			SetCookie(id,'On');
		}
		else
		{
			div.className = "divModuleOff";
			SetCookie(id,'Off');
		}
}
  



function SetCookie(id,Type)
{
	date = new Date();
    date.setTime(date.getTime() + (1000 * 60 * 60 * 24 * 30)); 
    document.cookie = id + "=" + Type + "; expires=" + date.toGMTString();  
}


function GetUserCookie(id)
{
    colCookie = document.cookie.split("; ");
    
    for (a=0; a < colCookie.length; a++)
    {
        colCrumb = colCookie[a].split("=");                    
        if(colCrumb[0] == id)
            return unescape(colCrumb[1]);
    }
    return "";
}

/*function mostrar(tr,tabela) {
	var TBody = tr.parentNode
	var Open
	var FirstTime = true
	var Index = -1


	for (i=1;i<TBody.childNodes.length;i++) {
		if (TBody.childNodes(i).id==tabela) {
			if (FirstTime) {
				Index = i-1 
				FirstTime = false
			}
			if (TBody.childNodes(i).style.display == "none") {
				TBody.childNodes(i).style.display = "";
				Open = true
				//alert(TBody.childNodes(i).tagName)
			} else {
				TBody.childNodes(i).style.display = "none";
				Open = false
			}
		}
	}

	if (Open) {
		for (i=1;i<TBody.childNodes.length;i++) 
			if ((TBody.childNodes(i).id!=tabela) && (TBody.childNodes(i).id!='')) 
				TBody.childNodes(i).style.display = "none";
	}

	for (i=1;i<TBody.childNodes.length;i++) {
		if (TBody.childNodes(i).id=='') {
			var Text = '<img src="images/btn_seta_down_small.gif" width="17" height="8">'	
			if ((Index==i) && (Open)) Text = '<img src="images/btn_seta_up_small.gif" width="17" height="8">'
			
			//TBody.childNodes(i).childNodes(TBody.childNodes(i).childNodes.length-1).innerHTML = Text							
			TBody.childNodes(i).childNodes(TBody.childNodes(i).firstChild.length).innerHTML = Text
		}
	}
}*/

function mostrar(tr,tabela) 
{
	var TBody = tr.parentNode;
	var Text;
	//Verifica o tipo de brower
	var is_netscape = (navigator.userAgent.indexOf('Firefox') >= 0) ? 1 : 0;
	
	if (is_netscape)
	{
		for (i=1;i<TBody.childNodes.length;i++) 
		{
			if (TBody.childNodes[i].id == tabela) 
			{
				if ( TBody.childNodes[i].nodeType != 3) 
				{
					if (TBody.childNodes[i].style.display == "none") 
					{
						TBody.childNodes[i].style.display = "";
						Text = '<img src="images/btn_seta_up_small.gif" width="17" height="8">'
					} 
					else 
					{
						TBody.childNodes[i].style.display = "none";
						Text = '<img src="images/btn_seta_down_small.gif" width="17" height="8">'
					}
					if (TBody.childNodes[i-2].id=='') 
					{
						//TBody.childNodes[i-2].childNodes(TBody.childNodes[i].firstChild.length).innerHTML = Text
						TBody.childNodes[i-2].childNodes[1].innerHTML = Text
					}
				}
				else
				{
					//TBody.removeChild(TBody.childNodes[i]);
					TBody.childNodes[i].nodeValue="";
				}
			}
		  }
		}
		else
		{
		   for (i=1;i<TBody.childNodes.length;i++) 
		   {
				if (TBody.childNodes(i).id==tabela) 
				{
					if (TBody.childNodes(i).style.display == "none") 
					{
						TBody.childNodes(i).style.display = "";
						Text = '<img src="images/btn_seta_up_small.gif" width="17" height="8">'
					} 
					else 
					{
						TBody.childNodes(i).style.display = "none";
						Text = '<img src="images/btn_seta_down_small.gif" width="17" height="8">'
					}
					if (TBody.childNodes(i-1).id=='') 
					{
						TBody.childNodes(i-1).childNodes(TBody.childNodes(i).firstChild.length).innerHTML = Text
					}
				}
			 }
		}
}

function MostrarTodos (tr)
{
	var TBody = tr.parentNode;
	var Text;
	var TROpcaoMostrar;
	var TROpcaoFechar;
	//Verifica o tipo de brower
	var is_netscape = (navigator.userAgent.indexOf('Firefox') >= 0) ? 1 : 0;
	
	if(is_netscape)
	{
		for (i=1;i<TBody.childNodes.length;i++) 
		{
			if (TBody.childNodes[i].id!='')
			{
				if ( TBody.childNodes[i].nodeType != 3) 
				{
						TBody.childNodes[i].style.display = "block";
						Text = '<img src="images/btn_seta_up_small.gif" width="17" height="8">';
						
						if (TBody.childNodes[i-2].id=='') 
						{
							//TBody.childNodes[i-2].childNodes(TBody.childNodes[i].firstChild.length).innerHTML = Text
							TBody.childNodes[i-2].childNodes[1].innerHTML = Text
						}
					}
					else
					{
						//TBody.removeChild(TBody.childNodes[i]);
						TBody.childNodes[i].nodeValue="";
					}
			 }
		  }
		}
		else
		{
			for (i=1;i<TBody.childNodes.length;i++) 
			{
				if (TBody.childNodes(i).id!='')
				{
					TBody.childNodes(i).style.display = "block";
					Text = '<img src="images/btn_seta_up_small.gif" width="17" height="8">';
					
					if (TBody.childNodes(i-1).id=='') 
					{
						TBody.childNodes(i-1).childNodes(TBody.childNodes(i).firstChild.length).innerHTML = Text
					}
				}
			}
		}
	
	TROpcaoMostrar = document.getElementById('MostrarTodos');
	TROpcaoFechar = document.getElementById('FecharTodos');
	
	if(TROpcaoMostrar != null)
	{
		TROpcaoMostrar.className = "Off"
	}
	if(TROpcaoFechar != null)
	{
		TROpcaoFechar.className = "trWhite"
	}
}
function FecharTodos (tr)
{
	var TBody = tr.parentNode;
	var Text;
	var TROpcaoMostrar;
	var TROpcaoFechar;
	//Verifica o tipo de brower
	var is_netscape = (navigator.userAgent.indexOf('Firefox') >= 0) ? 1 : 0;
	
	if(is_netscape)
	{
		for (i=1;i<TBody.childNodes.length;i++) 
		{
			if (TBody.childNodes[i].id!='')
			{
				if ( TBody.childNodes[i].nodeType != 3) 
				{
					TBody.childNodes[i].style.display = "none";
					Text = '<img src="images/btn_seta_down_small.gif" width="17" height="8">';
			
					if (TBody.childNodes[i-2].id=='') 
					{
						//TBody.childNodes[i-2].childNodes(TBody.childNodes[i].firstChild.length).innerHTML = Text
						TBody.childNodes[i-2].childNodes[1].innerHTML = Text
					}
				}
				 else
				{
					//TBody.removeChild(TBody.childNodes[i]);
					TBody.childNodes[i].nodeValue="";
				}
			}
		 }
		}
		else
		{
			for (i=1;i<TBody.childNodes.length;i++) 
			{
				if (TBody.childNodes(i).id!='')
				{
					TBody.childNodes(i).style.display = "none";
					Text = '<img src="images/btn_seta_down_small.gif" width="17" height="8">';
					
					if (TBody.childNodes(i-1).id=='') 
					{
						TBody.childNodes(i-1).childNodes(TBody.childNodes(i).firstChild.length).innerHTML = Text
					}
				}
			}
		}
	
	
	TROpcaoMostrar = document.getElementById('MostrarTodos');
	TROpcaoFechar = document.getElementById('FecharTodos');
	
	if(TROpcaoMostrar != null)
	{
		TROpcaoMostrar.className = "trWhite"
	}
	if(TROpcaoFechar != null)
	{
		TROpcaoFechar.className = "Off"
	}
}