// =============================================================
//
// Copyright (c) 2000-2003 GE Smallworld. All Rights Reserved.
//
// =============================================================

var hcfRoot;

hcfRoot = this.top;

function changeLocalizaciones(localizaciones)
{
	hcfRoot.header.frmoculto.localizaciones.value = localizaciones;
}

function doFindCoordinate()
{
	//specify stylesheet
	var aStylesheet = 'content_map.xsl';

	//get form
	aForm = hcfRoot.getForm(window, '', 'FindCoordinateForm');

	if (aForm.x.value == '' || aForm.y.value == '') {
		alert(hcfRoot.COORDINATE_FORM_ERROR_MESSAGE);
		return;
	}

	if (isNaN(aForm.x.value) || isNaN(aForm.y.value)) {
		alert(hcfRoot.COORDINATE_FORM_ERROR_MESSAGE);
		return;
	}

	var	swldy_centre = hcfRoot.encodexml(aForm.x.value) + ',' + hcfRoot.encodexml(aForm.y.value);

	var aRequest = 	'<request>' +
						'<name>navigation</name>' +
						'<format>xml</format>' +
						'<command>center</command>' +
						'<swldy_coord_centre>'+swldy_centre+'</swldy_coord_centre>' +
					'</request>';

	//register x, y and parameters
	hcfRoot.registerParam('swldy_centre', swldy_centre);
	if (aForm.swldy_scale) {
		if (aForm.swldy_scale.value != '') {
			if (isNaN(aForm.swldy_scale.value)) {
				alert(hcfRoot.COORDINATE_FORM_ERROR_MESSAGE);
				return;
			}
			else hcfRoot.registerParam('swldy_scale', aForm.swldy_scale.value);
		}
	}
	
	//execute request
	hcfRoot.executeRequest(hcfRoot.hcf_content, aRequest, aStylesheet);
}


function MostrarLocalizacion() {

 //  a través de una lista de direcciones (codigo de vial, codigo ubicación, ref_catastral o coordenada)
// situa y reslata en el mapa
   
   	aService="localizar";

	var aStylesheet='content_map.xsl';
	//var localizaciones ="1,1848, , , , ,LIC,1024/04/2,3, , ,4932018TG3443B, , ,PAR,1024/04/2,3, , ,4932021TG3443B, , ,PAR,1024/04/2,4, , , ,234934168,143261136,LIC,1024/04/2";   
	//var localizaciones =  "2, 2950, 99999999, , , , ITE, 608/2002,";
	var localizaciones = hcfRoot.header.frmoculto.localizaciones.value;

	aService = unescape(aService);
	aStylesheet = unescape(aStylesheet);
	localizaciones = unescape(localizaciones);
	
   	// Remove listeners for active panel here
   	hcfRoot.unregisterContentListener(hcfRoot.hcf_panel);
    	hcfRoot.registerContentListener('map', hcfRoot.updateFeatureSummary, hcfRoot.hcf_panel);

   	
	//obtenemos los valores de la consulta del formulario consulta
		
	// setup the request
		var aRequest = '<request>' +
   						'<name>' + aService + '</name>' +
						'<comando> localizar </comando>' +
						'<localizaciones>'+localizaciones+'</localizaciones>' +
						'<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);

	BarraProgresoCapa = hcfRoot.xbGetElementById('progressIndicator', hcfRoot.hcf_content);
		
   	if (BarraProgresoCapa)
   	{
		BarraProgresoCapaStyle = new hcfRoot.xbStyle(BarraProgresoCapa);
		BarraProgresoCapaStyle.setVisibility('hidden');
	}
}

function LimpiarLocalizacion() {

 //  vacia la tabla de localizaciones.

   
   aService="localizar";
   aService = unescape(aService);

	
   // Remove listeners for active panel here
   hcfRoot.unregisterContentListener(hcfRoot.hcf_panel);
   
   // Register a panel listener for Feature Info
//   hcfRoot.registerContentListener('map', hcfRoot.updateQuerySummary, hcfRoot.hcf_panel);

   // specify a stylesheet
   var aStylesheet = 'content_map.xsl';

  // setup the request
	var aRequest = '<request>' +
   						'<name>' + aService + '</name>' +
						'<comando> limpiar </comando>' +
						'<queryname>'+window.name +'</queryname>'+

						'<swldy_generate_map>true</swldy_generate_map>' +
   						'<format>xml</format>' +
   						'<query></query>' +
   						'</request>';
	
   // var aStylesheet = 'content_localizaciones.xsl';
 
	
  //execute request
	hcfRoot.executeRequest(hcfRoot.hcf_content, aRequest, aStylesheet);
	hcfRoot.focus();
}

function RepresentaLocalizacion()
{
	// A través de una lista de direcciones (codigo de vial, codigo ubicación, ref_catastral o coordenada)
	// situa y resalta en el mapa
  
 	var aStylesheet = 'content_localizaciones.xsl';
   var aService="localizar";
	
	var datetime = new Date();
	var queryname = '';
	queryname += datetime.getDate().toString() + '_';
	queryname += (datetime.getMonth()+1).toString() + '_';
	queryname += datetime.getYear().toString() + '_';
	queryname += datetime.getHours().toString() + '_';
	queryname += datetime.getMinutes().toString() + '_';
	queryname += datetime.getSeconds().toString();
	
	//var localizaciones ="2, 2950, 60132, , , , ITE, 1,1,1848, , , , ,LIC,2,1,850, , , , ,LIC,3,1,1114, , , , ,LIC,4,1,1265, , , , ,LIC,5,1,1497, , , , ,LIC,6,3, , ,4932018TG3443B, , ,PAR,7,4, , , ,234934168,143261136,LIC,8,1,1848, , , , ,LIC,1024/04/2,3, , ,4932018TG3443B, , ,PAR,1024/04/2,3, , ,4932021TG3443B, , ,PAR,1024/04/2,4, , , ,234934168,143261136,LIC,1024/04/2"   
	var localizaciones = hcfRoot.header.frmoculto.localizaciones.value;
	
	aService = unescape(aService);
	aStylesheet = unescape(aStylesheet);
	queryname = unescape(queryname);

	
   // Remove listeners for active panel here
   //hcfRoot.unregisterContentListener(hcfRoot.hcf_panel);
   
   // Register a panel listener for Feature Info
   //hcfRoot.registerContentListener('map', hcfRoot.updateFeatureSummary, hcfRoot.hcf_panel);
		
	// setup the request
	var aRequest = '<request>' +
   					'<name>' + aService + '</name>' +
						'<comando> representar </comando>' +
						'<localizaciones>'+localizaciones+'</localizaciones>' +
						'<swldy_generate_map>true</swldy_generate_map>' +
   						'<format>xml</format>' +
						'<query></query>' +
   						'<swldy_write_dd>true</swldy_write_dd>' +
						'<swldy_feature_count>200</swldy_feature_count>' +
						'<swldy_write_relationships>false</swldy_write_relationships>'+
						'<swldy_select_mode>replace_select</swldy_select_mode>' +
						'<queryname>'+queryname+'</queryname>'+
						'</request>';

	//execute request
	hcfRoot.executeRequest(hcfRoot.hcf_content, aRequest, aStylesheet,queryname);
   	
	BarraProgresoCapa = hcfRoot.xbGetElementById('progressIndicator', hcfRoot.hcf_content);
		
   if (BarraProgresoCapa)
   {
		BarraProgresoCapaStyle = new hcfRoot.xbStyle(BarraProgresoCapa);
		BarraProgresoCapaStyle.setVisibility('hidden');
	}
	
}


