﻿ 
function fcn_cambia_img(objimg,sRuta,sNombre)
{    
 window.document.images[objimg].src = sRuta + sNombre;
}

function puSub_LocalizarCiudad(){
	var cboCiudad = document.getElementById("cboCiudad");
    if(cboCiudad.value != "0"){
		thelyr="Limite Ciudades"
		sResp = cboCiudad.value; 
        codDpto = sResp.substring(0, sResp.indexOf("*"));
		obj_id = sResp.substring(sResp.indexOf("*")+1, sResp.length);
		ZoomAllFeature(thelyr + '|OBJECTID', obj_id);
    }
}

function fnc_MostrarNivel(){
    var codDpto="00";
    var codProv="00";
    var codDist="00";
    var obj_id="0";
    var thelyr=""
    var i_nivel_actual=0;
    
	//DEPARTAMENTO
    var cboDepartamento = document.getElementById("cboDepartamento");
    if(cboDepartamento.value != "0"){
		i_nivel_actual = 1;
		thelyr="Departamentos"
		sResp = cboDepartamento.value; 
        codDpto = sResp.substring(0, sResp.indexOf("*"));
		obj_id = sResp.substring(sResp.indexOf("*")+1, sResp.length);
    }
	
	//PROVINCIA
    var cboProvincia = document.getElementById("cboProvincia");
	if(cboProvincia.value != "0"){
		i_nivel_actual = 2;
		thelyr="Provincias"
		sResp = cboProvincia.value; 
        codProv = sResp.substring(0, sResp.indexOf("*"));
		obj_id = sResp.substring(sResp.indexOf("*")+1, sResp.length);
    }
	
	//DISTRITO
    var cboDistrito = document.getElementById("cboDistrito");
	if(cboDistrito.value != "0"){
		i_nivel_actual = 3;
		thelyr="Distritos"
		sResp = cboDistrito.value; 
        codDist = sResp.substring(0, sResp.indexOf("*"));
		obj_id = sResp.substring(sResp.indexOf("*")+1, sResp.length);
    }

	//CIUDAD
    var cboLocalidad = document.getElementById("cboLocalidad");
	if(cboLocalidad.value != "0"){
		i_nivel_actual = 4;
		thelyr="Manzanas"
		sResp = cboLocalidad.value; 
        codDist = sResp.substring(0, sResp.indexOf("*"));
		//obj_id = sResp.substring(sResp.indexOf("*")+1, sResp.length);
		obj_id=cboLocalidad.value;
		
    }
    	
	var sResp = "";
	sResp = "Nivel: " + i_nivel_actual;
	sResp += "\n ObjectID: " + obj_id;
	sResp += "\n Departamento: " + codDpto; 
	sResp += "\n Provincia: " + codProv; 
	sResp += "\n Distrito: " + codDist;
	//alert(sResp);    
    ZoomAllFeature(thelyr + '|OBJECTID', obj_id);
 }  
 
function fnc_MostrarAgentes(){
    var sTpSql=1;
    var sCodCiu="00";
    var sCodGeo="00";
    var sTipAge="00";
      
    var cboDistxCiudad = document.getElementById("agedist_cboDistxCiudad");
    var cboTipoAgente = document.getElementById("agedist_cboTipoAgente");
    
    if(cboDistxCiudad.value != "0" && cboTipoAgente.value != "0") {
      sResp=cboDistxCiudad.value
      sCodCiu = sResp.substring(0, sResp.indexOf("*"));
	  sCodGeo = sResp.substring(sResp.indexOf("*")+1, sResp.length);
      sTipAge = cboTipoAgente.value
      
     var sUrl = "App_Rpt/Rpt_Agente.aspx?tpSql="+sTpSql+"&ciu="+ sCodCiu+"&dis="+ sCodGeo +"&act=" + sTipAge;
     winAgent=window.open(sUrl,"verdatos","location=0,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=1,width=850px,height=650px,left=150px,top=150px");
     winAgent.focus();
     hideFloatingPanel('agedist') ;
     
    }else{ 
     var sMsg="Sistema Geografico OSIGIS - OSINERGMIN";
         sMsg+="\n\n Error: Usted debe Seleccionar Distrito y Agente";
     alert(sMsg);
    }

 }
 
function fnc_AgexRazSocial(){
    var sTpSql=2;
    var sCodRaz="";
      
    var txtRazon = document.getElementById("FP_AgexRazSoc_txtRazon");
    if(txtRazon.value.length!=0) {
      sCodRaz=txtRazon.value.toUpperCase(); 
     var sUrl = "App_Rpt/Rpt_Agente.aspx?tpSql="+sTpSql+"&raz="+ sCodRaz;
     winAgent=window.open(sUrl,"verdatos","location=0,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=1,width=700px,height=500px,left=150px,top=150px");
     winAgent.focus();
     hideFloatingPanel('FP_AgexRazSoc') ;
     
    }else{ 
     var sMsg="Sistema Geografico OSIGIS - OSINERGMIN";
         sMsg+="\n\n Error: Usted debe Ingresar la Razón Social";
     alert(sMsg);
    }

 }
 
 function fnc_AgexOsinergmin(){
    var sTpSql=3;
    var sCodOsi="";
      
    var txtOsinergmin = document.getElementById("FP_AgexCodOsi_txtOsinergmin");
    
    if(txtOsinergmin.value.length!=0) {
      sCodOsi=txtOsinergmin.value.toUpperCase(); 
     var sUrl = "App_Rpt/Rpt_Agente.aspx?tpSql="+sTpSql+"&osi="+ sCodOsi;
     winAgent=window.open(sUrl,"verdatos","location=0,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=1,width=700px,height=500px,left=150px,top=150px");
     winAgent.focus();
     hideFloatingPanel('FP_AgexCodOsi') ;
     
    }else{ 
     var sMsg="Sistema Geografico OSIGIS - OSINERGMIN";
         sMsg+="\n\n Error: Usted debe Ingresar un Código Osinergmin";
     alert(sMsg);
    }

 }
  
 function fnc_MostrarEstablecimiento(){
    var sCodCiu="00";
    var sCodGeo="00";
    var sTipAge="00";
      
    var cboDistxCiudad = document.getElementById("estdist_cboDistxCiudad2");
    var cboTipoEstable = document.getElementById("estdist_cboTipoEstablec");
    
    if(cboDistxCiudad.value != "0" && cboTipoEstable.value != "0") {
      sResp=cboDistxCiudad.value
      sCodCiu = sResp.substring(0, sResp.indexOf("*"));
	  sCodGeo = sResp.substring(sResp.indexOf("*")+1, sResp.length);
      sTipEst = cboTipoEstable.value
      
     var sUrl = "App_Rpt/EstPubRes.aspx?ciu="+ sCodCiu+"&dis="+ sCodGeo +"&act=" + sTipEst;
     winAgent=window.open(sUrl,"verdatos","location=0,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=1,width=850px,height=650px,left=150px,top=150px");
     winAgent.focus();
     hideFloatingPanel('estdist') ;
     
    }else{ 
     var sMsg="Sistema Geografico OSIGIS - OSINERGMIN";
         sMsg+="\n\n Error: Usted debe Seleccionar Distrito y Establecimiento";
     alert(sMsg);
    }

 }
 
  function fnc_MostrarMateriales(){
    var sCodCiu="00";
    var sCodGeo="00";
    var sTipNiv="00";
      
    var cboDistxCiudad = document.getElementById("FP_Materiales_cboMatDistxCiudad");
    var cboTipoNivel = document.getElementById("FP_Materiales_cboMatNivel");
    
    if(cboDistxCiudad.value != "0" && cboTipoNivel.value != "0") {
      sResp=cboDistxCiudad.value
      sCodCiu = sResp.substring(0, sResp.indexOf("*"));
	  sCodGeo = sResp.substring(sResp.indexOf("*")+1, sResp.length);
      sTipNiv = cboTipoNivel.value
      
     var sUrl = "App_Rpt/Rpt_Material.aspx?ciu="+ sCodCiu+"&dis="+ sCodGeo +"&niv=" + sTipNiv;
     winAgent=window.open(sUrl,"verdatos","location=0,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=1,width=850px,height=650px,left=150px,top=150px");
     winAgent.focus();
     hideFloatingPanel('FP_Materiales') ;
     
    }else{ 
     var sMsg="Sistema Geografico OSIGIS - OSINERGMIN";
         sMsg+="\n\n Error: Usted debe Seleccionar Distrito y Nivel de Peligro";
     alert(sMsg);
    }

 }
 
   function fnc_MostrarVias(){
    var sTpSql=1;
    var sCodCiu="00";
    var sCodGeo="00";
    var sNomVia="00";
      
    var cboDistxCiudad = document.getElementById("FP_Vias_cboViaDistxCiudad");
    var txtNomVia = document.getElementById("FP_Vias_txtViaNomVia");

    if(cboDistxCiudad.value != "0" && txtNomVia.value.length!=0) {
      sResp=cboDistxCiudad.value
      sCodCiu = sResp.substring(0, sResp.indexOf("*"));
      sCodGeo = sResp.substring(sResp.indexOf("*")+1, sResp.length);
      sNomVia = txtNomVia.value.toUpperCase();
      
     var sUrl = "App_Rpt/Rpt_Vias.aspx?tpSql="+ sTpSql + "&ciu="+ sCodCiu+"&dis="+ sCodGeo +"&via=" + sNomVia;
     winAgent=window.open(sUrl,"verdatos","location=0,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=1,width=850px,height=650px,left=150px,top=150px");
     winAgent.focus();
     hideFloatingPanel('FP_Vias') ;
     
    }else{ 
     var sMsg="Sistema Geografico OSIGIS - OSINERGMIN";
         sMsg+="\n\n Error: Usted debe Seleccionar Distrito e Ingresar una Vía";
     alert(sMsg);
    }

 }
 
 function fnc_MostrarInformales(){
    var sCodCiu="00";
    var sCodGeo="00";
    var sTipAge="00";
      
    var cboDistxCiudad = document.getElementById("FP_Informales_cboInfDistxCiudad");
    var cboTipoInformal = document.getElementById("FP_Informales_cboInfActividad");
    
    if(cboDistxCiudad.value != "0" && cboTipoInformal.value != "0") {
      sResp=cboDistxCiudad.value
      sCodCiu = sResp.substring(0, sResp.indexOf("*"));
	  sCodGeo = sResp.substring(sResp.indexOf("*")+1, sResp.length);
      sTipEst = cboTipoInformal.value
      
     var sUrl = "App_Rpt/Rpt_Informal.aspx?ciu="+ sCodCiu+"&dis="+ sCodGeo +"&act=" + sTipEst;
     winAgent=window.open(sUrl,"verdatos","location=0,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=1,width=700px,height=500px,left=150px,top=150px");
     winAgent.focus();
     hideFloatingPanel('FP_Informales') ;
     
    }else{ 
     var sMsg="Sistema Geografico OSIGIS - OSINERGMIN";
         sMsg+="\n\n Error: Usted debe Seleccionar Distrito y Actividad";
     alert(sMsg);
    }

 }
 
 function fnc_MostrarSolicitudes(){
    var sCodCiu="00";
    var sCodGeo="00";
    var sTipAge="00";
      
    var cboDistxCiudad = document.getElementById("FP_Solicitudes_cboSolDistxCiudad");
    var cboTipoInformal = document.getElementById("FP_Solicitudes_cboSolActividad");
    
    if(cboDistxCiudad.value != "0" && cboTipoInformal.value != "0") {
      sResp=cboDistxCiudad.value
      sCodCiu = sResp.substring(0, sResp.indexOf("*"));
	  sCodGeo = sResp.substring(sResp.indexOf("*")+1, sResp.length);
      sTipEst = cboTipoInformal.value
      
     var sUrl = "App_Rpt/Rpt_Solicitud.aspx?ciu="+ sCodCiu+"&dis="+ sCodGeo +"&act=" + sTipEst;
     winAgent=window.open(sUrl,"verdatos","location=0,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=1,width=700px,height=500px,left=150px,top=150px");
     winAgent.focus();
     hideFloatingPanel('FP_Solicitudes') ;
     
    }else{ 
     var sMsg="Sistema Geografico OSIGIS - OSINERGMIN";
         sMsg+="\n\n Error: Usted debe Seleccionar Distrito y Actividad";
     alert(sMsg);
    }

 }
 
 function fnc_MostrarNomVias(){
    var sTpSql=2;
    var sCodGeo="0";
    var sTipVia="0";
    var cboDistxCiudad = document.getElementById("cbociudad");
    var cboTipoVia = document.getElementById("FP_CVias_cboCViaTipo");
    var txtNomVia = document.getElementById("FP_CVias_txtCViaNomVia");
    
    if(cboDistxCiudad.value != "0"){
      sResp=cboDistxCiudad.value
      sCodCiu = sResp.substring(0, sResp.indexOf("*"));
      sTipVia=cboTipoVia.value + '.';
      if (cboTipoVia.value== "0"){
       var sMsg1="Sistema Geografico OSIGIS - OSINERGMIN";
           sMsg1+="\n\n Error: Usted debe Seleccionar un Tipo";
       alert(sMsg1);
       return;
      }
      sNomVia = txtNomVia.value.toUpperCase();
          
      var sUrl = "App_Rpt/Rpt_Vias.aspx?tpSql="+sTpSql + "&ciu="+ sCodCiu+"&tip=" + sTipVia +"&via=" + sNomVia;
      winAgent=window.open(sUrl,"verdatos","location=0,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=1,width=850px,height=650px,left=150px,top=150px");
      winAgent.focus();
      hideFloatingPanel('FP_CVias') ;
     
    }else{ 
     var sMsg="Sistema Geografico OSIGIS - OSINERGMIN";
         sMsg+="\n\n Error: Usted debe Seleccionar una Ciudad";
     alert(sMsg);
    }
 }
 
 function fnc_ClearPrintText(){
    var cboDistxCiudad = document.getElementById("FP_CVias_cboCViaDistxCiudad");
    var cboTipoVia = document.getElementById("FP_CVias_cboCViaTipo");
 }
 function fnc_Registro(){
   var txtUser = document.getElementById("FP_RegDenuncia_txtUser");
   var txtPwd = document.getElementById("FP_RegDenuncia_txtPwd");
   var message = "Registro|"+ txtUser.value + "|" + txtPwd.value;
   var context = 'Map1';
   WebForm_DoCallback('__Page',message,procesRegistro,context,processMyError,false);
 }
 
 function procesRegistro(returnmessage,context){
   var sResp = new Array();
   sResp = returnmessage.split("|");
   if (sResp[0] != "0"){
     alert(sResp[1]); 
    return;
   }
   fnc_Denuncias(sResp[1]);
   return;
 }
 
 function fnc_Denuncias(strUrl){
    var txtUser = document.getElementById("FP_RegDenuncia_txtUser");
    var txtPwd = document.getElementById("FP_RegDenuncia_txtPwd");
    txtUser.value="";
    txtPwd.value="";
    hideFloatingPanel('FP_RegDenuncia') ;
    if(strUrl.length!=0) {
     winDenun=window.open(strUrl,"Denuncias","location=0,menubar=0,resizable=1,scrollbars=1,titlebar=0,toolbar=0,status=1,width=700px,height=500px,left=150px,top=150px");
     winDenun.focus();
    }else{ 
     var sMsg="Sistema Geografico OSIGIS - OSINERGMIN";
         sMsg+="\n\n Error: No se encuentra la Ruta Especificada";
     alert(sMsg);
    }

 }
