// =============================================================
//
// Copyright (c) 2000-2003 GE Smallworld. All Rights Reserved.
//
// =============================================================

//var hcfRoot;

//hcfRoot = this.top;


function propietarios() {

 //  crea una query para obtener los propietarios y registrso tributarios de IBI de la parcela seleccionada
   
   	aService="propietario";

	var aStylesheet='content_propietarios.xsl';
	
	aService = unescape(aService);
	aStylesheet = unescape(aStylesheet);

	//var cteParcela = "swrefVgeometryVdatasetZgisVcollectionZparcelaVfieldZrotuloVlocalZTrueVkeysZ"
	var st = hcfRoot.GLOBAL_CONTEXT.state;
	var xmldoc= new ActiveXObject("Microsoft.XMLDOM"); 
	xmldoc.async="false"; 
	xmldoc.validateOnParse = true; 
	xmldoc.loadXML(st);
	doc=xmldoc.documentElement;



	 var xmlNodo = xmldoc.selectSingleNode("//collection[@name='select_list']/records");
	 
	var urn_parcela=''
	for (var i=0;xmlNodo.childNodes.length;i++) {
		var n=xmlNodo.childNodes[i];
		if (n== null) {
			break;
			}
		var obj1=n.getAttribute('object');
		if (obj1.indexOf('swrefVgeometryVdatasetZgisVcollectionZparcelaVfieldZcontornoVlocalZTrueVkeys') != -1)
	 	{
			urn_parcela = obj1;
			break;
		}
  	}
	if (urn_parcela!=''){
   		// setup the request
			var aRequest = '<request>' +
   						'<name>' + aService + '</name>' +
						'<comando> procesar </comando>' +
						'<parcela>'+urn_parcela+'</parcela>' +
						'<swldy_generate_map>true</swldy_generate_map>' +
						'<swldy_feature_count>200</swldy_feature_count>' +
   						'<format>xml</format>' +
   						'<query></query>' +
   						'<swldy_write_dd>true</swldy_write_dd>' +
						'<swldy_select_mode>replace_select</swldy_select_mode>' +
						'<swldy_write_relationships>false</swldy_write_relationships>'+
						'</request>';
		hcfRoot.executeRequest(hcfRoot.hcf_content, aRequest, aStylesheet,"Propietarios");

		BarraProgresoCapa = hcfRoot.xbGetElementById('progressIndicator', hcfRoot.hcf_content);
		
   		if (BarraProgresoCapa)
   		{
			BarraProgresoCapaStyle = new hcfRoot.xbStyle(BarraProgresoCapa);
			BarraProgresoCapaStyle.setVisibility('hidden');
		}
	}
	else
  		alert('No se ha seleccionado la parcela');
	
}


function fichaIbi(num_exp,urn_parcela) {
   //	----------------------------------------------------------------------
//	Loads the plot panel with a plot info request. The plot panel is setup
//	to execute a request on hcf_content for a default plot preview. This is
//	done because it is impossible to show a plot preview without first calling
//	plot info to get the plot template information.
//	Parameters:
//		None
//	---------------------------------------------------------------------- 

//hcfRoot.registerContentListener('plot', hcfRoot.updateMapContent, 'map');

	hcfRoot.num_exp = num_exp;
	sParameters = '<function_parameters><root><items>' +
			 '<num_exp>' +num_exp+ '</num_exp>'+
			'<urn_parcela>'+urn_parcela + '</urn_parcela>'+
			'</items></root></function_parameters>';


	//set up plot request
	var aRequest =  '<request>'+
					'<name>plot</name>'+
					'<swldy_command>info</swldy_command>'+
					'<format>xml</format>'+
					sParameters + 
					'</request>';
	

		
	//set up ace request
	aRequest = aRequest +  
				'<request>'+
					'<name>ace</name>'+
					'<command>aces</command>'+
					'<format>xml</format>'+
				'</request>';
	//selecciona parcela
		aRequest = aRequest +  
				'<request>'+
					'<name>feature_info</name>'+
					'<swldy_command>select</swldy_command>'+
					'<swldy_generate_map>true</swldy_generate_map>'+
					'<swldy_objects>'+urn_parcela+'</swldy_objects>'+
					'<format>xml</format>'+
				'</request>';
	
	//set up map request
	//aRequest = aRequest +  
	//			'<request>'+
	//					'<name>map</name>'+
	//					'<format>xml</format>'+
	//			'</request>';
			

	var aStylesheet = 'panel_plot_wizard_ibi2.xsl';	
	//var aStylesheet = 'panel_plot_wizard.xsl';				
	//now execute request
	hcfRoot.executeRequest(hcfRoot.hcf_panel, aRequest, aStylesheet);
	//writePanelTitle(hcfRoot.PLOT_PREVIEW_TITLE);
// last tell the world that the content has been loaded
  // hcfRoot.onContentLoaded('map');
hcfRoot.focus();


}

function actualizaMapa()
{
aRequest = 	'<request>'+
		'<name>map</name>'+
		'<format>xml</format>'+
		'</request>';
hcfRoot.executeRequest(hcfRoot.hcf_content, aRequest, 'content_map.xsl');
}


