	
	function Concelho_ShowAnimation(){
		$('concelho_onprocess').innerHTML = "<table width=\"100%\"><tbody><tr><td height=\"23\" align=\"center\"><img src=\"images/wait16trans.gif\" width=\"16\" height=\"16\"/></td></tr></tbody></table>";
		$('concelho_onprocess').style.display = 'block';
		$('concelho_onprocess').style.visibility = 'visible';
		$('concelho_onactive').style.display = 'none';
		$('concelho_onactive').style.visibility = 'hidden';
	}
	function Concelho_HideAnimation(){
		$('concelho_onprocess').style.display = 'none';
		$('concelho_onprocess').style.visibility = 'hidden';
		$('concelho_onactive').style.display = 'block';
		$('concelho_onactive').style.visibility = 'visible';
	}
	
	function Concelho_ShowResponse(transport){
		// get combo target 
		var selectBoxTarget = $('concelho');
		
		// Process response
		if (transport.status == 200){
			// Get response Xml
			var xmlResponse = transport.responseXML;
			// read Xml nodes
			var parentNode = xmlResponse.getElementsByTagName("parent_category")[0];
			var docRoot = xmlResponse.getElementsByTagName("categories")[0];

			// Map coodinates
			if(parentNode != null){
				var parentID = parentNode.attributes[0].value;
				var parentName = parentNode.attributes[1].value;
				var parentLat = parentNode.attributes[2].value;
				var parentLng = parentNode.attributes[3].value;
				var parentZoom = parentNode.attributes[4].value;
				
				// if map exists in current page
				if($('map')){
					// Set point
					SetMapPoint(parentLat, parentLng, parentZoom);
				}
			}

			// Empty SelectBox
			removeAllOptions(selectBoxTarget);
			removeAllOptions($('location'));
			
			if(docRoot != null){
				// Add Default SelectBox Options
				addOption(selectBoxTarget, '0', '-- Todos --');
				addOption($('location'), '0', '-- Depende do Concelho --');
				// Fill SelectBox with a new 
				for(var i=0;i<docRoot.childNodes.length;i++){//percorrendo os filhos do nó
					if(docRoot.childNodes[i].nodeType == 1){//ignorar espaços em branco
						addOption(selectBoxTarget, docRoot.childNodes[i].attributes[0].value, docRoot.childNodes[i].attributes[1].value);
					}
				}
			}else{
				// Add Default SelectBox Options
				addOption(selectBoxTarget, '0', '-- Depende do Distrito --');
				addOption($('location'), '0', '-- Depende do Concelho --');
			}
			// Hide animation
			Concelho_HideAnimation();
		} else {
			// Hide animation
			Concelho_HideAnimation();
		}
	}
	
	function RequestConcelho(){
		// Show animation
		Concelho_ShowAnimation();
		// Set ajax call
		var url = wServiceRequesterURL;
		var pars = 'COMMAND=REQUEST_CATEGORY&TARGET=CONCELHO&DISTRITOVALUE='+$('distrito').value+'&CONCELHOVALUE=&LOCATIONVALUE=';
		
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'GET', 
				parameters: pars, 
				onComplete: Concelho_ShowResponse
			});
	}