//--------------------------------------------------
// Botões para activar e desactivar temas
//--------------------------------------------------
function themeButton(buttonId ,layerName, layerCode, selected, query)
{
	this.myButtonId=buttonId;
	this.myLayerName=layerName;
	this.myLayerCode=layerCode;
	this.mySelected=selected;
	this.myQuery=query;
}
	
var themeButtons=new Array();
themeButtons.length=10;
	
themeButtons[0]=new themeButton("themeButton1","transportes","A",false,true);
themeButtons[1]=new themeButton("themeButton2","servicos","B",false,true);
themeButtons[2]=new themeButton("themeButton3","saude","C",false,true);
themeButtons[3]=new themeButton("themeButton4","equipamentos","D",false,true);
themeButtons[4]=new themeButton("themeButton5","educacao","E",false,true);	
themeButtons[5]=new themeButton("themeButton6","desporto","F",false,true);	
themeButtons[6]=new themeButton("themeButton7","historia","G",false,true);
themeButtons[7]=new themeButton("themeButton8","cultura","K",false,true);
themeButtons[8]=new themeButton("themeButton9","lazer","I",false,true);
themeButtons[9]=new themeButton("themeButton10","turismo","J",false,true);


function themeButton_onmouseover(button,theme)						
{
	button.src = "images/page/tema_"+theme+"_c.png";
}

function themeButton_onmouseout(button,theme)						
{			

	var buttonTmp;
	
	for (i=0; i < themeButtons.length; i++)
	{
		buttonTmp = themeButtons[i];
			
		if(buttonTmp.myLayerName == theme)
		{									
			if (buttonTmp.mySelected)
			{
				button.src="images/page/tema_"+theme+"_l.png";
			} else {
				button.src="images/page/tema_"+theme+"_a.png";
			}
															
			return false;
		}
	}			
}
function themeButton_onclick(button, theme)
{		
	
	if (gMC.IsBusy)
	{
	   return false;
	}

	var buttonTmp;
			
	for (i=0; i < themeButtons.length; i++)
	{
		buttonTmp = themeButtons[i];
			
		if(buttonTmp.myLayerName == theme)
		{			
			buttonTmp.mySelected = !buttonTmp.mySelected;			
						
			SetLayerVisibility(theme, buttonTmp.mySelected);
						
			return false;
		}
	}
}

function themeButtonViewHideAll_onmouseover(button, action)
{
	button.src = "images/page/tema_" + action + "_c.png";
}
function themeButtonViewHideAll_onmouseout(button, action)
{
	button.src = "images/page/tema_" + action + "_a.png";
}
function themeButtonViewHideAll_onclick(visible)
{
	if (gMC.IsBusy)
	{
	   return false;
	}

	var buttonTmp;
	
	var layersList = "";
			
	for (i=0; i < themeButtons.length; i++)
	{
		buttonTmp = themeButtons[i];
		
		if (buttonTmp!= null)
		{
			var imgButton = document.getElementById(buttonTmp.myButtonId);
			
			if (imgButton != null)
			{
				if (visible)
				{				
					imgButton.src="images/page/tema_"+buttonTmp.myLayerName+"_l.png";
				} else {
					imgButton.src="images/page/tema_"+buttonTmp.myLayerName+"_a.png";
				}		
					
				
				layersList += " " + buttonTmp.myLayerName;
			}
			
			buttonTmp.mySelected = visible;
		}			
	}
	
	SetLayersListVisibility(layersList, visible);
	
	return false;
}

/*---------------------------------------------------------------*/
var themeButtonsGroup=new Array();
themeButtonsGroup.length=2;

themeButtonsGroup[0]=new themeButton("themeButtonG1","cartografia","CARTO",true,true);
themeButtonsGroup[1]=new themeButton("themeButtonG2","ortofotos","ORTO",false,true);

function themeButtonGroup_onmouseover(button, group)
{
	button.src="images/page/tema_" + group + "_c.png";
}
function themeButtonGroup_onmouseout(button, group)
{
	var buttonTmp;
	
	for (i=0; i < themeButtonsGroup.length; i++)
	{
		buttonTmp = themeButtonsGroup[i];
			
		if(buttonTmp.myLayerName == group)
		{									
			if (buttonTmp.mySelected)
			{
				button.src = "images/page/tema_"+group+"_l.png";
			} else {
				button.src= "images/page/tema_"+group+"_a.png";
			}
															
			return false;
		}
	}		
	
	return false;
}
function themeButtonGroup_onclick(button, group)
{
	if (gMC.IsBusy)
	{
	   return false;
	}

	var buttonTmp;
			
	for (i=0; i < themeButtonsGroup.length; i++)
	{
		buttonTmp = themeButtonsGroup[i];
			
		if(buttonTmp!= null && buttonTmp.myLayerName == group)
		{			
			buttonTmp.mySelected = !buttonTmp.mySelected;
						
			SetLayerVisibility(group, buttonTmp.mySelected);
						
			return false;
		}
	}
}
function getVisibleLayerGroups()
{
	var buttonTmp;
	
	var layersList = "";
			
	for (i=0; i < themeButtonsGroup.length; i++)
	{
		buttonTmp = themeButtonsGroup[i];
		
		if (buttonTmp!= null && buttonTmp.mySelected == true)
		{
		    layersList += " " + buttonTmp.myLayerName;
		}			
	}
    
	layersList = trim(layersList);
	
	return layersList;
}
