//--------------------------------------------------
// 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=11;
	
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","resto","K",false,true);
themeButtons[8]=new themeButton("themeButton9","lazer","I",false,true);
themeButtons[9]=new themeButton("themeButton10","turismo","J",false,true);
themeButtons[10]=new themeButton("themeButton11","wifi","W",false,true);
themeButtons[11]=new themeButton("themeButton12","ciclovia","V",false,true);

function themeButton_onmouseover(button,theme)						
{

	button.style.border = "solid lightgrey 1px";
	
	//imgButton.src = "images/page/tema_"+theme+"_c.jpg";
}
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.style.border = "solid #DF8200 1px";
			} else {
				button.style.border = "solid white 1px";
			}
															
			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);

			if (theme == "ciclovia" && buttonTmp.mySelected)
			{
			    showPanel(document.getElementById('tab2'),'panel2');
			}
						
			return false;
		}
	}
}

function themeButtonViewHideAll_onmouseover(button, action)
{
	button.style.border = "solid lightgrey 1px";
	//button.src = "images/page/tema_" + action + "_c.jpg";
}
function themeButtonViewHideAll_onmouseout(button, action)
{
	button.style.border = "solid white 1px";
}
function themeButtonViewHideAll_onclick(visible)
{
	if (gMC.IsBusy)
	{
	   return false;
	}


	var button;
	
	var layersList = "";
			
	for (i=0; i < themeButtons.length; i++)
	{
		var button = themeButtons[i];
		
		if (button!= null)
		{
			var imgButton = document.getElementById(button.myButtonId);
			
			if (imgButton != null)
			{
				if (visible)
				{				
					imgButton.style.border = "solid #DF8200 1px";
				} else {
					imgButton.style.border = "solid white 1px";
				}		
				
				layersList += " " + button.myLayerName;
			}
			
			button.mySelected = visible;
		}			
	}
	
	SetLayersListVisibility(layersList, visible);
	
	return false;
}

/*---------------------------------------------------------------*/
var themeButtonsGroup=new Array();
themeButtonsGroup.length=2;

themeButtonsGroup[0]=new themeButton("themeButtonG1","cartografia",true,true);
themeButtonsGroup[1]=new themeButton("themeButtonG2","ortofotos",false,false);
themeButtonsGroup[2]=new themeButton("themeButtonG3","percurso",false,false);

function themeButtonGroup_onmouseover(button, group)
{
	button.style.border = "solid lightgrey 1px";
	//imgButton.src="images/page/tema_" + group + "_c.jpg";
}
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.style.border = "solid MidnightBlue 1px";
			} else {
				button.style.border = "solid white 1px";
			}
															
			return false;
		}
	}		
	
	return false;
}
function themeButtonGroup_onclick(imgButton, group)
{
	if (gMC.IsBusy)
	{
	   return false;
	}


	var button;
			
	for (i=0; i < themeButtonsGroup.length; i++)
	{
		button = themeButtonsGroup[i];
			
		if(button.myLayerName == group)
		{			
			button.mySelected = !button.mySelected;
						
			SetLayerVisibility(group, button.mySelected);
						
			return false;
		}
	}
}
function getVisibleLayerGroups()
{
	var button;
	
	var layersList = "";
			
	for (i=0; i < themeButtonsGroup.length; i++)
	{
		var button = themeButtonsGroup[i];
		
		if (button!= null && button.mySelected == true)
		{
		    layersList += " " + button.myLayerName;
		}			
	}
    
	layersList = trim(layersList);
	
	return layersList;

}