	var tmr2;	

	function GetFrameMap()	{
		var oFrame = parent["2der"];
		return oFrame; }

	function Reporte() {
		var szWhere = '';
		var szGSE = '';

			if (document.datos.tvblancoynegro.checked) {
				if (szWhere == '') {
					szWhere = "CNT_HGR_TV_BLANCO_NEGRO > 0 "; }
				else {
					szWhere = szWhere + "AND CNT_HGR_TV_BLANCO_NEGRO > 0 "; } }

			if (document.datos.tvcolor.checked) {				
				if (szWhere == '') {
					szWhere = "CNT_HGR_TV_COLOR > 0 "; }
				else {
					szWhere = szWhere + "AND CNT_HGR_TV_COLOR > 0 "; } }

			if (document.datos.vcr.checked) {
				if (szWhere == '') {
					szWhere = "CNT_HGR_VCR > 0 "; }
				else {
					szWhere = szWhere + "AND CNT_HGR_VCR > 0 "; } }
					
			if (document.datos.conexiontvcable.checked) {
				if (szWhere == '') {
					szWhere = "CNT_HGR_CONEXION_TV_CABLE > 0 ";	}
				else {
					szWhere = szWhere + "AND CNT_HGR_CONEXION_TV_CABLE > 0 "; } }

			if (document.datos.minicomponente.checked) {
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_MINICOMPONENTE > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_MINICOMPONENTE > 0 ";
				}
			}
			if (document.datos.lavadora.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_LAVADORA > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_LAVADORA > 0 ";
				}
			}
			if (document.datos.secadora.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_SECADORA > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_SECADORA > 0 ";
				}
			}
			if (document.datos.refrigerador.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_REFRIGERADOR > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_REFRIGERADOR > 0 ";
				}
			}
			if (document.datos.congelador.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_CONGELADOR > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_CONGELADOR > 0 ";
				}
			}

			if (document.datos.horno.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_HORNO > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_HORNO > 0 ";
				}
			}
			if (document.datos.lavavajillas.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_LAVAVAGILLAS > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_LAVAVAGILLAS > 0 ";
				}
			}
			if (document.datos.calefont.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_CALEFONT > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_CALEFONT > 0 ";
				}
			}
			if (document.datos.fono_celular.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_FONO_CELULAR > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_FONO_CELULAR > 0 ";
				}
			}
			if (document.datos.fono_red_fija.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_FONO_RED_FIJA > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_FONO_RED_FIJA > 0 ";
				}
			}
			if (document.datos.computador.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_PC > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_PC > 0 ";
				}
			}
			if (document.datos.conexion_internet.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_CONEXION_INTERNET > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_CONEXION_INTERNET > 0 ";
				}
			}
			if (document.datos.bicicleta.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_BICICLETA > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_BICICLETA > 0 ";
				}
			}
			if (document.datos.moto.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_MOTO > 0 ";
				}

				else
				{
					szWhere = szWhere + "AND CNT_HGR_MOTO > 0 ";
				}
			}
			if (document.datos.furgon.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_FURGON > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_FURGON > 0 ";
				}
			}
			if (document.datos.automovil.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_AUTOMOVIL > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_AUTOMOVIL > 0 ";
				}
			}
			if (document.datos.camioneta.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_CAMIONETA > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_CAMIONETA > 0 ";
				}
			}
			if (document.datos.lancha.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_LANCHA > 0 ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_LANCHA > 0 ";
				}
			}


			if (document.datos.abc1.checked)
			{
/*				if (szWhere == '')
				{
					szWhere = "cnt_hgr_gse = 'ABC1' ";
				}
				else
				{
					szWhere = szWhere + "AND cnt_hgr_gse = 'ABC1' ";
				}*/
				
				if (szGSE == '')
				{
					szGSE = "(cnt_hgr_gse = 'ABC1' ";
				}
				else
				{
					szGSE = szGSE + "OR cnt_hgr_gse = 'ABC1' ";
				}
			}
			
			

			if (document.datos.c2.checked)
			{
/*				if (szWhere == '')
				{
					szWhere = "cnt_hgr_gse = 'C2' ";
				}
				else
				{
					szWhere = szWhere + "AND cnt_hgr_gse = 'C2' ";
				}*/
				if (szGSE == '')
				{
					szGSE = "(cnt_hgr_gse = 'C2' ";
				}
				else
				{
					szGSE = szGSE + "OR cnt_hgr_gse = 'C2' ";
				}				
			}

			if (document.datos.c3.checked)
			{
/*				if (szWhere == '')
				{
					szWhere = "cnt_hgr_gse = 'C3' ";
				}
				else
				{
					szWhere = szWhere + "AND cnt_hgr_gse = 'C3' ";
				}*/
				
				if (szGSE == '')
				{
					szGSE = "(cnt_hgr_gse = 'C3' ";
				}
				else
				{
					szGSE = szGSE + "OR cnt_hgr_gse = 'C3' ";
				}
				
			}

			if (document.datos.d.checked)
			{
/*				if (szWhere == '')
				{
					szWhere = "cnt_hgr_gse = 'D' ";
				}
				else
				{
					szWhere = szWhere + "AND cnt_hgr_gse = 'D' ";
				}*/
				
				if (szGSE == '')
				{
					szGSE = "(cnt_hgr_gse = 'D' ";
				}
				else
				{
					szGSE = szGSE + "OR cnt_hgr_gse = 'D' ";
				}
				
			}

			if (document.datos.e.checked)
			{
/*				if (szWhere == '')
				{
					szWhere = "cnt_hgr_gse = 'E' ";
				}
				else
				{
					szWhere = szWhere + "AND cnt_hgr_gse = 'E' ";
				}*/
				
				if (szGSE == '')
				{
					szGSE = "(cnt_hgr_gse = 'E' ";
				}
				else
				{
					szGSE = szGSE + "OR cnt_hgr_gse = 'E' ";
				}
				
			}
			
			
			if (szWhere == '')
			{
				szWhere = szGSE + ")";
			}
			else
			{
				szWhere = szWehere + "AND " + szGSE + ")";
			}


			if (document.datos.ambos.checked)
			{
				var lpMenor = document.datos.MENOR.value;
				var lpMayor = document.datos.MAYOR.value;

				if (szWhere == '')
				{
					szWhere = "Sexo = 3 and total > 0 and edad between " + lpMenor + " and " + lpMayor;
				}
				else
				{
					szWhere = szWhere + "AND Sexo = 3 and total > 0 and edad between " + lpMenor + " and " + lpMayor;
				}
			}

			if (document.datos.hombres.checked)
			{
				var lpMenor = document.datos.MENOR.value;
				var lpMayor = document.datos.MAYOR.value;

				if (szWhere == '')
				{
					szWhere = "Sexo = 1 and total > 0 and edad between " + lpMenor + " and " + lpMayor;
				}
				else
				{
					szWhere = szWhere + "AND Sexo = 1 and total > 0 and edad between " + lpMenor + " and " + lpMayor;
				}
			}

			if (document.datos.mujeres.checked)
			{
				var lpMenor = document.datos.MENOR.value;
				var lpMayor = document.datos.MAYOR.value;

				if (szWhere == '')
				{
					szWhere = "Sexo = 2 and total > 0 and edad between " + lpMenor + " and " + lpMayor;
				}
				else
				{
					szWhere = szWhere + "AND Sexo = 2 and total > 0 and edad between " + lpMenor + " and " + lpMayor;
				}
			}



		var szUrl = 'reporte/reporte_direccion.asp?Where=' + szWhere;
		var oWinSave = window.open(szUrl, 'reporte','height=500, width=700, scrollbars=yes');
		oWinSave.focus();
	}

	function Prender()
	{
		var szWhere = '';
		var szLabel = 'Resultado Consulta';
		var szName = '';
		var szGSE = '';
		var m = GetFrameMap().GetMap();

		var maplayer = m.getMapLayer("manzana_censal_app");
		clearTimeout(tmr2);
		if (m == null || m.isBusy() || maplayer == null )
			tmr2 = setTimeout ("Prender()",100);
		else
		{ if (document.datos.tvblancoynegro.checked) {
				if (szWhere == '') {
					szWhere = "CNT_HGR_TV_BLANCO_NEGRO > 0 ";
					szName = "'TOTAL Hogar Tv Blanco y Negro : ' || CNT_HGR_TV_BLANCO_NEGRO "; 
				} else {
					szWhere = szWhere + "AND CNT_HGR_TV_BLANCO_NEGRO > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Tv Blanco y Negro : ' || CNT_HGR_TV_BLANCO_NEGRO ";
				}

				//var szName = "'Total Mujeres : ' || CNT_HGR_MUJER ";
				//var szLabel = "Mujeres"
			}
			if (document.datos.tvcolor.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_TV_COLOR > 0 ";
					szName = "'TOTAL Hogar Tv Color : ' || CNT_HGR_TV_COLOR ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_TV_COLOR > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Tv Color : ' || CNT_HGR_TV_COLOR ";
				}
			}
			if (document.datos.vcr.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_VCR > 0 ";
					szName = "'TOTAL Hogar Videograbador : ' || CNT_HGR_VCR ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_VCR > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Videograbador  : ' || CNT_HGR_VCR ";
				}
			}
			if (document.datos.conexiontvcable.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_CONEXION_TV_CABLE > 0 ";
					szName = "'TOTAL Hogar Conexion Tv Cable: ' || CNT_HGR_CONEXION_TV_CABLE ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_CONEXION_TV_CABLE > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Conexion Tv Cable : ' || CNT_HGR_CONEXION_TV_CABLE ";
				}
			}
			if (document.datos.minicomponente.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_MINICOMPONENTE > 0 ";
					szName = "'TOTAL Hogar Minicomponente : ' || CNT_HGR_MINICOMPONENTE ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_MINICOMPONENTE > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Minicomponente : ' || CNT_HGR_MINICOMPONENTE ";
				}
			}
			if (document.datos.lavadora.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_LAVADORA > 0 ";
					szName = "'TOTAL Hogar Lavadora : ' || CNT_HGR_LAVADORA ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_LAVADORA > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Lavadora : ' || CNT_HGR_LAVADORA ";
				}
			}
			if (document.datos.secadora.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_SECADORA > 0 ";
					szName = "'TOTAL Hogar Secadora : ' || CNT_HGR_SECADORA ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_SECADORA > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Secadora : ' || CNT_HGR_SECADORA ";
				}
			}
			if (document.datos.refrigerador.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_REFRIGERADOR > 0 ";
					szName = "'TOTAL Hogar Refrigerador : ' || CNT_HGR_REFRIGERADOR ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_REFRIGERADOR > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Refrigerador : ' || CNT_HGR_REFRIGERADOR ";
				}
			}
			if (document.datos.congelador.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_CONGELADOR > 0 ";
					szName = "'TOTAL Hogar Congelador : ' || CNT_HGR_CONGELADOR ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_CONGELADOR > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Congelador : ' || CNT_HGR_CONGELADOR ";
				}
			}

			if (document.datos.horno.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_HORNO > 0 ";
					szName = "'TOTAL Hogar Horno : ' || CNT_HGR_HORNO ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_HORNO > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Horno : ' || CNT_HGR_HORNO ";
				}
			}
			if (document.datos.lavavajillas.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_LAVAVAGILLAS > 0 ";
					szName = "'TOTAL Hogar Lava vajillas: ' || CNT_HGR_LAVAVAGILLAS ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_LAVAVAGILLAS > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Lava vajillas : ' || CNT_HGR_LAVAVAGILLAS ";
				}
			}
			if (document.datos.calefont.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_CALEFONT > 0 ";
					szName = "'TOTAL Hogar Calefont : ' || CNT_HGR_CALEFONT ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_CALEFONT > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Calefont : ' || CNT_HGR_CALEFONT ";
				}
			}
			if (document.datos.fono_celular.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_FONO_CELULAR > 0 ";
					szName 	= "'TOTAL Hogar Celular : ' || CNT_HGR_FONO_CELULAR ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_FONO_CELULAR > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Celular : ' || CNT_HGR_FONO_CELULAR ";
				}
			}
			if (document.datos.fono_red_fija.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_FONO_RED_FIJA > 0 ";
					szName = "'TOTAL Hogar Fono Red Fija: ' || CNT_HGR_FONO_RED_FIJA ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_FONO_RED_FIJA > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Fono Red Fija : ' || CNT_HGR_FONO_RED_FIJA ";
				}
			}
			
			if (document.datos.computador.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_PC > 0 ";
					szName = "'TOTAL Hogar Computadores : ' || CNT_HGR_PC ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_PC > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Computadores : ' || CNT_HGR_PC ";
				}
			}
			
			if (document.datos.conexion_internet.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_CONEXION_INTERNET > 0 ";
					szName = "'TOTAL Hogar Conexion Internet: ' || CNT_HGR_CONEXION_INTERNET ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_CONEXION_INTERNET > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Conexion Internet : ' || CNT_HGR_CONEXION_INTERNET ";
				}
			}
			
			if (document.datos.bicicleta.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_BICICLETA > 0 ";
					szName = "'TOTAL Hogar Bicicleta : ' || CNT_HGR_BICICLETA ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_BICICLETA > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Bicicleta : ' || CNT_HGR_BICICLETA ";
				}
			}
			if (document.datos.moto.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_MOTO > 0 ";
					szName = "'TOTAL Hogar Moto : ' || CNT_HGR_MOTO ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_MOTO > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Moto : ' || CNT_HGR_MOTO ";
				}
			}
			if (document.datos.furgon.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_FURGON > 0 ";
					szName = "'TOTAL Hogar Furgon: ' || CNT_HGR_FURGON ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_FURGON > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Furgon : ' || CNT_HGR_FURGON ";
				}
			}
			if (document.datos.automovil.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_AUTOMOVIL > 0 ";
					szName = "'TOTAL Hogar Automovil : ' || CNT_HGR_AUTOMOVIL ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_AUTOMOVIL > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Automovil : ' || CNT_HGR_AUTOMOVIL ";
				}
			}
			if (document.datos.camioneta.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_CAMIONETA > 0 ";
					szName = "'TOTAL Hogar Camioneta: ' || CNT_HGR_CAMIONETA ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_CAMIONETA > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Camioneta : ' || CNT_HGR_CAMIONETA ";
				}
			}
			
			if (document.datos.lancha.checked)
			{
				if (szWhere == '')
				{
					szWhere = "CNT_HGR_LANCHA > 0 ";
					szName = "'TOTAL Hogar Lancha : ' || CNT_HGR_LANCHA ";
				}
				else
				{
					szWhere = szWhere + "AND CNT_HGR_LANCHA > 0 ";
					szName = szName + "|| '\nTOTAL Hogar Lancha : ' || CNT_HGR_LANCHA ";
				}
			}
		}

			if (document.datos.ambos.checked)
			{
				
				var lpRangoEdad = document.datos.RANGOEDAD.value;

				if (szWhere == '')
				{
					szWhere = "cnt_hgr_total>0 ";
				}
				else
				{
					szWhere = szWhere + "AND cnt_hgr_total>0 ";
					szName = szName + "|| '\n' || ";
				}
				
				
				if (lpRangoEdad == '0')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_0_5_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(0 y 5): ' || cnt_hgr_edad_0_5_t";
				}
				if (lpRangoEdad == '6')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_6_10_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(6 y 10): ' || cnt_hgr_edad_6_10_t";
				}
				if (lpRangoEdad == '11')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_11_15_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(11 y 15): ' || cnt_hgr_edad_11_15_t";
				}
				if (lpRangoEdad == '16')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_16_20_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(16 y 20): ' || cnt_hgr_edad_16_20_t";
				}
				if (lpRangoEdad == '21')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_21_25_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(21 y 25): ' || cnt_hgr_edad_21_25_t";
				}
				if (lpRangoEdad == '26')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_26_30_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(26 y 30): ' || cnt_hgr_edad_26_30_t";
				}
				if (lpRangoEdad == '31')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_31_35_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(31 y 35): ' || cnt_hgr_edad_31_35_t";
				}
				if (lpRangoEdad == '36')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_36_40_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(36 y 40): ' || cnt_hgr_edad_36_40_t";
				}
				if (lpRangoEdad == '41')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_41_45_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(41 y 45): ' || cnt_hgr_edad_41_45_t";
				}
				if (lpRangoEdad == '46')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_46_50_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(46 y 50): ' || cnt_hgr_edad_46_50_t";
				}
				if (lpRangoEdad == '51')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_51_55_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(51 y 55): ' || cnt_hgr_edad_51_55_t";
				}
				if (lpRangoEdad == '56')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_56_60_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(56 y 60): ' || cnt_hgr_edad_56_60_t";
				}
				if (lpRangoEdad == '61')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_61_65_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(61 y 65): ' || cnt_hgr_edad_61_65_t";
				}
				if (lpRangoEdad == '66')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_66_70_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(66 y 70): ' || cnt_hgr_edad_66_70_t";
				}
				if (lpRangoEdad == '71')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_71_75_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(71 y 75): ' || cnt_hgr_edad_71_75_t";
				}
				if (lpRangoEdad == '76')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_76_80_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(76 y 80): ' || cnt_hgr_edad_76_80_t";
				}
				if (lpRangoEdad == '81')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_81_85_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(81 y 85): ' || cnt_hgr_edad_81_85_t";
				}
				if (lpRangoEdad == '86')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_86_90_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos entre(86 y 90): ' || cnt_hgr_edad_86_90_t";
				}
				if (lpRangoEdad == '91')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_mayor_90_t>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Ambos mayores de 90: ' || cnt_hgr_edad_mayor_90_t";
				}
				
/*				var lpMenor = document.datos.MENOR.value;
				var lpMayor = document.datos.MAYOR.value;

				if (szWhere == '')
				{
					szWhere = "Sexo = 3 and total > 0 and edad between " + lpMenor + " and " + lpMayor;
					szName = "'TOTAL Ambos  Entre("+ lpMenor +"-"+ lpMayor +") : ' || total ";
				}
				else
				{
					szWhere = szWhere + "AND Sexo = 3 and total > 0 and edad between " + lpMenor + " and " + lpMayor;
					szName = szName + "|| '\nTOTAL Ambos  Entre("+ lpMenor +"-"+ lpMayor +") : ' || total ";
				}*/
			}
			
			if (document.datos.hombres.checked)
			{
				var lpRangoEdad = document.datos.RANGOEDAD.value;

				if (szWhere == '')
				{
					szWhere = "cnt_hgr_hombre>0 ";
				}
				else
				{
					szWhere = szWhere + "AND cnt_hgr_hombre>0 ";
					szName = szName + "|| '\n' || ";
				}
				
				
				if (lpRangoEdad == '0')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_0_5_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(0 y 5): ' || cnt_hgr_edad_0_5_h";
				}
				if (lpRangoEdad == '6')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_6_10_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(6 y 10): ' || cnt_hgr_edad_6_10_h";
				}
				if (lpRangoEdad == '11')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_11_15_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(11 y 15): ' || cnt_hgr_edad_11_15_h";
				}
				if (lpRangoEdad == '16')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_16_20_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(16 y 20): ' || cnt_hgr_edad_16_20_h";
				}
				if (lpRangoEdad == '21')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_21_25_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(21 y 25): ' || cnt_hgr_edad_21_25_h";
				}
				if (lpRangoEdad == '26')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_26_30_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(26 y 30): ' || cnt_hgr_edad_26_30_h";
				}
				if (lpRangoEdad == '31')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_31_35_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(31 y 35): ' || cnt_hgr_edad_31_35_h";
				}
				if (lpRangoEdad == '36')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_36_40_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(36 y 40): ' || cnt_hgr_edad_36_40_h";
				}
				if (lpRangoEdad == '41')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_41_45_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(41 y 45): ' || cnt_hgr_edad_41_45_h";
				}
				if (lpRangoEdad == '46')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_46_50_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(46 y 50): ' || cnt_hgr_edad_46_50_h";
				}
				if (lpRangoEdad == '51')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_51_55_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(51 y 55): ' || cnt_hgr_edad_51_55_h";
				}
				if (lpRangoEdad == '56')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_56_60_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(56 y 60): ' || cnt_hgr_edad_56_60_h";
				}
				if (lpRangoEdad == '61')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_61_65_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(61 y 65): ' || cnt_hgr_edad_61_65_h";
				}
				if (lpRangoEdad == '66')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_66_70_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(66 y 70): ' || cnt_hgr_edad_66_70_h";
				}
				if (lpRangoEdad == '71')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_71_75_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(71 y 75): ' || cnt_hgr_edad_71_75_h";
				}
				if (lpRangoEdad == '76')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_76_80_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(76 y 80): ' || cnt_hgr_edad_76_80_h";
				}
				if (lpRangoEdad == '81')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_81_85_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(81 y 85): ' || cnt_hgr_edad_81_85_h";
				}
				if (lpRangoEdad == '86')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_86_90_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombre entre(86 y 90): ' || cnt_hgr_edad_86_90_h";
				}
				if (lpRangoEdad == '91')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_mayor_90_h>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Hombres mayores de 90: ' || cnt_hgr_edad_mayor_90_h";
				}
					
			}


			if (document.datos.mujeres.checked)
			{
				
				var lpRangoEdad = document.datos.RANGOEDAD.value;

				if (szWhere == '')
				{
					szWhere = "cnt_hgr_mujer>0 ";
				}
				else
				{
					szWhere = szWhere + "AND cnt_hgr_mujer>0 ";
					szName = szName + "|| '\n' || ";
				}
				
				
				if (lpRangoEdad == '0')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_0_5_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(0 y 5): ' || cnt_hgr_edad_0_5_m";
				}
				if (lpRangoEdad == '6')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_6_10_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(6 y 10): ' || cnt_hgr_edad_6_10_m";
				}
				if (lpRangoEdad == '11')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_11_15_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(11 y 15): ' || cnt_hgr_edad_11_15_m";
				}
				if (lpRangoEdad == '16')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_16_20_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(16 y 20): ' || cnt_hgr_edad_16_20_m";
				}
				if (lpRangoEdad == '21')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_21_25_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(21 y 25): ' || cnt_hgr_edad_21_25_m";
				}
				if (lpRangoEdad == '26')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_26_30_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(26 y 30): ' || cnt_hgr_edad_26_30_m";
				}
				if (lpRangoEdad == '31')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_31_35_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(31 y 35): ' || cnt_hgr_edad_31_35_m";
				}
				if (lpRangoEdad == '36')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_36_40_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(36 y 40): ' || cnt_hgr_edad_36_40_m";
				}
				if (lpRangoEdad == '41')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_41_45_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(41 y 45): ' || cnt_hgr_edad_41_45_m";
				}
				if (lpRangoEdad == '46')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_46_50_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(46 y 50): ' || cnt_hgr_edad_46_50_m";
				}
				if (lpRangoEdad == '51')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_51_55_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(51 y 55): ' || cnt_hgr_edad_51_55_m";
				}
				if (lpRangoEdad == '56')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_56_60_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(56 y 60): ' || cnt_hgr_edad_56_60_m";
				}
				if (lpRangoEdad == '61')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_61_65_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(61 y 65): ' || cnt_hgr_edad_61_65_m";
				}
				if (lpRangoEdad == '66')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_66_70_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(66 y 70): ' || cnt_hgr_edad_66_70_m";
				}
				if (lpRangoEdad == '71')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_71_75_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(71 y 75): ' || cnt_hgr_edad_71_75_m";
				}
				if (lpRangoEdad == '76')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_76_80_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(76 y 80): ' || cnt_hgr_edad_76_80_m";
				}
				if (lpRangoEdad == '81')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_81_85_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(81 y 85): ' || cnt_hgr_edad_81_85_m";
				}
				if (lpRangoEdad == '86')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_86_90_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujer entre(86 y 90): ' || cnt_hgr_edad_86_90_m";
				}
				if (lpRangoEdad == '91')
				{
					szWhere = szWhere + "AND cnt_hgr_edad_mayor_90_m>0 ";
					szName = szName + "ID_MANZANA || ' - ' || 'TOTAL Mujeres mayores de 90: ' || cnt_hgr_edad_mayor_90_m";
				}
				
/*				var lpMenor = document.datos.MENOR.value;
				var lpMayor = document.datos.MAYOR.value;

				if (szWhere == '')
				{
					szWhere = "Sexo = 2 and total > 0 and edad between " + lpMenor + " and " + lpMayor;
				}
				else
				{
					szWhere = szWhere + "AND Sexo = 2 and total > 0 and edad between " + lpMenor + " and " + lpMayor;
				}*/
			}



			if (document.datos.abc1.checked)
			{
/*				if (szWhere == '')
				{
					szWhere = "cnt_hgr_gse = 'ABC1' ";
					szName = "'TOTAL Hogar ABC1 : ' || cnt_hgr_gse_abc1 ";
				}
				else
				{
					szWhere = szWhere + "AND cnt_hgr_gse = 'ABC1' ";
					szName = szName + "|| '\nTOTAL Hogar ABC1 : ' || cnt_hgr_gse_abc1 ";
				}*/
				
				if (szGSE == '')
				{
					szGSE = "(cnt_hgr_gse = 'ABC1' ";
				}
				else
				{
					szGSE = szGSE + "OR cnt_hgr_gse = 'ABC1' ";
				}
				if (szName == '')
				{
					szName = "'TOTAL Hogar ABC1 : ' || cnt_hgr_gse_abc1 ";
				}
				else
				{
					szName = szName + "|| '\nTOTAL Hogar ABC1 : ' || cnt_hgr_gse_abc1 ";
				}
				
			}

			if (document.datos.c2.checked)
			{
/*				if (szWhere == '')
				{
					szWhere = "cnt_hgr_gse = 'C2' ";
					szName = "'TOTAL Hogar C2 : ' || cnt_hgr_gse_c2 ";
				}
				else
				{
					szWhere = szWhere + "AND cnt_hgr_gse = 'C2' ";
					szName = szName + "|| '\nTOTAL Hogar C2 : ' || cnt_hgr_gse_c2 ";
				}*/
				
				if (szGSE == '')
				{
					szGSE = "(cnt_hgr_gse = 'C2' ";
				}
				else
				{
					szGSE = szGSE + "OR cnt_hgr_gse = 'C2' ";
				}
				if (szName == '')
				{
					szName = "'TOTAL Hogar C2 : ' || cnt_hgr_gse_c2 ";
				}
				else
				{
					szName = szName + "|| '\nTOTAL Hogar C2 : ' || cnt_hgr_gse_c2 ";
				}
				
			}

			if (document.datos.c3.checked)
			{
/*				if (szWhere == '')
				{
					szWhere = "cnt_hgr_gse = 'C3' ";
					szName = "'TOTAL Hogar C3 : ' || cnt_hgr_gse_c3 ";
				}
				else
				{
					szWhere = szWhere + "AND cnt_hgr_gse = 'C3' ";
					szName = szName + " || '\nTOTAL Hogar C3 : ' || cnt_hgr_gse_c3 ";
				}*/
				
				if (szGSE == '')
				{
					szGSE = "(cnt_hgr_gse = 'C3' ";
				}
				else
				{
					szGSE = szGSE + "OR cnt_hgr_gse = 'C3' ";
				}				
				if (szName == '')
				{
					szName = "'TOTAL Hogar C3 : ' || cnt_hgr_gse_c3 ";
				}
				else
				{
					szName = szName + "|| '\nTOTAL Hogar C3 : ' || cnt_hgr_gse_c3 ";
				}				
			}

			if (document.datos.d.checked)
			{
/*				if (szWhere == '')
				{
					szWhere = "cnt_hgr_gse = 'D' ";
					szName = "'TOTAL Hogar D : ' || cnt_hgr_gse_d ";
				}
				else
				{
					szWhere = szWhere + "AND cnt_hgr_gse = 'D' ";
					szName = szName + "|| '\nTOTAL Hogar D : ' || cnt_hgr_gse_d ";
				}*/
				
				if (szGSE == '')
				{
					szGSE = "(cnt_hgr_gse = 'D' ";
				}
				else
				{
					szGSE = szGSE + "OR cnt_hgr_gse = 'D' ";
				}				
				if (szName == '')
				{
					szName = "'TOTAL Hogar D : ' || cnt_hgr_gse_d ";
				}
				else
				{
					szName = szName + "|| '\nTOTAL Hogar D : ' || cnt_hgr_gse_d ";
				}
				
				
			}

			if (document.datos.e.checked)
			{
/*				if (szWhere == '')
				{
					szWhere = "cnt_hgr_gse = 'E' ";
					szName = "'TOTAL Hogar E : ' || cnt_hgr_gse_e ";
				}
				else
				{
					szWhere = szWhere + "AND cnt_hgr_gse = 'E' ";
					szName = szName + "|| '\nTOTAL Hogar E : ' || cnt_hgr_gse_e ";
				}*/
				
				if (szGSE == '')
				{
					szGSE = "(cnt_hgr_gse = 'E' ";					
				}
				else
				{
					szGSE = szGSE + "OR cnt_hgr_gse = 'E' ";					
				}								
				if (szName == '')
				{
					szName = "'TOTAL Hogar E : ' || cnt_hgr_gse_e ";
				}
				else
				{
					szName = szName + "|| '\nTOTAL Hogar E : ' || cnt_hgr_gse_e ";
				}
			}

			if (szGSE != '')
			{
				if (szWhere == '')
				{
					szWhere = szGSE + ")";
				}
				else
				{
					szWhere = szWhere + "AND " + szGSE + ")";
				}
			}


		if (szWhere == '')
		{
			szWhere = "id_manzana is null";
		}

		if (szWhere != '')
		{
			//alert(szName);
			//alert(szWhere);
			Capa_punto(maplayer, "ODBC_MARTE_ORC", szLabel, "Mapchile.DIRECCION", "ID_DIRECCION", "Numeric", szName, szWhere);
			m.refresh();
		}
	}		



	function PrenderNiveles()
	{
		var szWhere = '';
		var szLabel = 'Resultado Consulta';
		var szName = '';
		var m = GetFrameMap().GetMap();

		clearTimeout(tmr2);
		if (m == null || m.isBusy() )
			tmr2 = setTimeout ("PrenderNiveles()",100);
		else
		{

			if (document.datosNiveles.Grupo_SE.checked)
			{
				var maplayer = m.getMapLayer("Manzana_Grupo_SocioEconomico");
				maplayer.setVisibility(true);
			}
			else
			{
				var maplayer = m.getMapLayer("Manzana_Grupo_SocioEconomico");
				maplayer.setVisibility(false);
			}

			/*if (document.datosNiveles.Total_Celular.checked)
			{
				var maplayer = m.getMapLayer("Manzana_Total_Celular");
				maplayer.setVisibility(true);
			}
			else
			{
				var maplayer = m.getMapLayer("Manzana_Total_Celular");
				maplayer.setVisibility(false);
			}*/


			/*if (document.datosNiveles.Tematica_Comunal.checked)
			{
				var maplayer = m.getMapLayer("Tematica_comunal_penetracion_internet");
				maplayer.setVisibility(true);
			}
			else
			{
				var maplayer = m.getMapLayer("Tematica_comunal_penetracion_internet");
				maplayer.setVisibility(false);
			}*/

			if (document.datosNiveles.Grilla_Gse.checked)
			{
				var maplayer = m.getMapLayer("Grilla_Gse");
				maplayer.setVisibility(true);
			}
			else
			{
				var maplayer = m.getMapLayer("Grilla_Gse");
				maplayer.setVisibility(false);
			}


			/*if (document.datosNiveles.Grilla_Pc.checked)
			{
				var maplayer = m.getMapLayer("Grilla_Cnt_Pc");
				maplayer.setVisibility(true);
			}
			else
			{
				var maplayer = m.getMapLayer("Grilla_Cnt_Pc");
				maplayer.setVisibility(false);
			}*/


		}

		m.refresh();
	}		




	function Capa_punto(Nivel,Odbc,Label,Tabla,Key,Type,Name,Where)
	{
				var layersetup= Nivel.getLayerSetup();				
				var bdsetup= layersetup.getDatabaseSetup();
				//bdsetup.setDataSource(Odbc);
				//bdsetup.setTable(Tabla);
				//bdsetup.setKeyColumn(Key);
				//bdsetup.setKeyColumnType(Type);
				bdsetup.setNameColumn(Name);
				bdsetup.setWhereClause(Where);
				Nivel.setLegendLabel(Label)	
				Nivel.setShowInLegend(true);
				Nivel.setVisibility(true);
	}

