//-------------------------------------------------------//
// Author:Rodolfo Machon
// Company:WebSoft, SA de CV 
// Nombre del archivo: expediente_comm.js
// Created: 2016-03-26
// Updates: 2016-03-26
// Copyright - All Rights Reserved
//-------------------------------------------------------//
//-------------------------------------------------------//
var xmlHttp1;
var xmlHttpStream1;
var isIE      = document.all?true:false;
var isNS      = document.layers?true:false;
//-------------------------------------------------------//
window.onload = function(){
    setTimeout("loadParameters()",1000);
}
//-------------------------------------------------------//
//LEVEL 1
function loadParameters() {
    lan		  = parent.list.document.linkl.lan.value;
    appid	  = parent.list.document.linkl.appid.value;
    clase     = parent.list.document.linkl.clase.value;
    component = parent.list.document.linkl.appid.value;
}
function OpenNuc(){
    PutId();
    var expediente=document.linkf.i8_expediente_id.value;
    var tipo_expediente=document.linkf.i2_tipo_expediente_id.value;
    var i8_nuc_id=document.linkf.i8_nuc_id.value;
    var i8_nis_id=document.linkf.i8_nis_id.value;
    if(i8_nuc_id!="" || i8_nis_id!=""){Go();return;};
    if(expediente=="" && i8_nuc_id=="" && i8_nis_id=="" ){alert("Falta ID");return;}
    var URL     = "/cgi-bin/"+appid+"/pl/relacionar_expediente_nuc.pl?appid="+appid+"&lan="+lan+"&i8_expediente_id="+expediente+"&tipo="+tipo_expediente;
    xmlHttp1	= GetXmlHttpObject(stateChangedOpenNuc);
    xmlHttp1.open("GET",URL,true) ;
    xmlHttp1.send(null);
}
//-------------------------------------------------------//
//LEVEL 2
function onlyDigits(e,decReq) {
    var key = (isIE) ? window.event.keyCode : e.which;
    var obj = (isIE) ? event.srcElement : e.target;
    var isNum = (key > 47 && key < 58) ? true:false;
    var dotOK = (key==46 && decReq=='decOK' && (obj.value.indexOf(".")<0 || obj.value.length==0)) ? true:false;
    window.event.keyCode = (!isNum && !dotOK && isIE) ? 0:key;
    e.which = (!isNum && !dotOK && isNS) ? 0:key;
    return (isNum || dotOK);
}
function buscar(){
    win ="window.open('/cgi-bin/"+appid+"/pl/nuc_buscar.pl"+"?lan="+lan+"&appid="+appid+"','','left=250,top=100,width=700,height=130')";
    eval(win);
}
function buscar1(){
    win ="window.open('/cgi-bin/"+appid+"/pl/buscar_expedientes_sinnuc.pl"+"?lan="+lan+"&appid="+appid+"','','left=250,top=100,width=700,height=130')";
    eval(win);
}
function OpenSearch(){
    var tipo_expediente=parent.form.document.linkf.i2_tipo_expediente_id.value;
    if(tipo_expediente==1){parent.list.GetBack('srch','contribuyentes','i8_contribuyente_id','LTMD|contribuyente_inmuebles|i8_inmueble_id|parent.opener.parent.opener.parent.form.document.linkf|200|100||i8_inmueble_id||',300,100,'','i8_contribuyente_id',1)}
    else{parent.list.GetBack('srch','contribuyentes','i8_contribuyente_id','LTMD|contribuyente_empresas|i8_empresa_id|parent.opener.parent.opener.parent.form.document.linkf|200|100||i8_empresa_id||',300,100,'','i8_contribuyente_id',1)}
}
function Go() {
    var len   = document.linkf.pago.length;
    for (var a=0;a<len;a++) {
            //alert(a+"<>"+document.linkf.pago[a].value)
            if (document.linkf.pago[a].checked) {
                value = document.linkf.pago[a].value
            }
    }
    id_field = value;
    parent.list.document.linkl.id_field.value = id_field;
    id       = eval("document.linkf."+id_field+".value");
    if(id==""){
        alert("Favor Ingrese el ID de busqueda");
        return;
    }
    var frame = "this.location.href='commf.pl?lan="+lan+"&appid="+appid+"&clase="+clase+"&id_field="+id_field+"&id="+id+"'";
    eval(frame);
    //alert(frame);
    parent.list.GetOptions();
}
function VerPartidaOriginal(winame,comm){
	var commands	= comm.split(",");
	var id_field	= parent.list.document.linkl.id_field.value;
	var id		= "N_"+document.linkf.y4_libro.value+"_"+document.linkf.c4_nacimiento_libro_id.value+"_01_"+document.linkf.c4_folio_final_id.value;
	var frame	= "parent.report.location.href='"+commands[0]+".pl?lan="+lan+"&appid="+appid+"&clase="+commands[1]+"&id="+id+"'";
	eval(frame);
}
function LoadFrame(){
	alert(i8_nuc_id);
    if(document.linkf.i8_nuc_id.value!=""){
        parent.list.OpenFrameNABS('VerRegistro','nuc_repts,nuc')    
    }
}
function AbrirFrame(){
    if(document.linkf.i8_nuc_id.value!=""){
        parent.list.OpenFrameNABS('VerRegistro','nuc_repts,nuc')    
    }
}
function PutId(){
    var expediente;
    var tipo_expediente=document.linkf.i2_tipo_expediente_id.value;
    //if(tipo_expediente==1){expediente=document.linkf.i8_inmueble_id.value;document.linkf.pago[1].checked=true;}
    //else{expediente=document.linkf.i8_empresa_id.value;document.linkf.pago[2].checked=true;}
    if(tipo_expediente==1){expediente=document.linkf.i8_inmueble_id.value;}
    else{expediente=document.linkf.i8_empresa_id.value;}	
    document.linkf.i8_expediente_id.value=expediente;
	//alert(tipo_expediente+">>"+expediente);
    Go();
}
function ChangeType(){
    var tipo_expediente=document.linkf.i2_tipo_expediente_id.value;
    if(tipo_expediente==1) {
        document.getElementById('inmueble').style.display="";
        document.getElementById('empresa').style.display="none";
    }else {
        document.getElementById('empresa').style.display="";
        document.getElementById('inmueble').style.display="none";
    }
}
function stateChangedOpenNuc(){
    if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete"){ 
    xmlHttpStream1=xmlHttp1.responseText;
    //alert(xmlHttpStream1);
	if (xmlHttpStream1=="true") {
            Go();
            AbrirFrame();
        }
    }
}
function GetExpediente(){
    var generador = document.form.v64_tipo_generador.value.toLowerCase();
    if(generador!=""){
	var command = "GetBack('LTMD','contribuyente_"+generador+"s','i8_"+generador+"_id|i8_expediente_id,txt_ubicacion|txt_expediente_direccion,txt_propietarios|txt_expediente_propietarios','parent.opener.form',100,100,'i8_contribuyente_id','i8_expediente_id')";
	eval(command);
    }else{alert("Seleccione el Generador")}
}
function GetContribuyente(){
	var command = "GetBack('SRCH','contribuyentes','i8_contribuyente_id,v128_contribuyente|v128_nuc','parent.opener.form',300,100,'','v128_contribuyente')";
	eval(command);
}
function change(id,h){
    var new_hght= 0;
    var ids	= id.split(',');
    var owidth  = 650;
    var oheight = 650;
    var hght	= parent.document.body.clientHeight;
    var wdth	= parent.document.body.clientWidth;    
    for(var i=0;i<ids.length;i++){
      identity = document.getElementById(ids[i]);
      if(identity.style.display=="none"){
          identity.style.display = "";
          new_hght= hght+h;
          eval("parent.window.resizeTo(650,"+new_hght+")");
      }else{
          identity.style.display="none";
          new_hght= hght-h+72;
          eval("parent.window.resizeTo(650,"+new_hght+")");
      }
    }
}
//----------------------------------------------------------//
//Auxiliars