//-------------------------------------------------------//
// Author:Rodolfo Machon
// Company:WebSoft, SA de CV 
// Nombre del archivo: inmueble_bsws.js
// Created: 2015-11-01
// Updates: 2015-11-01
// Copyright - All Rights Reserved
//-------------------------------------------------------//
//-------------------------------------------------------//
var weekdays 	= new Array("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado");
var months 		= new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
var today 		= new Date();
var weekday 	= today.getDay();
var monthday 	= today.getDate();
var month 		= today.getMonth();
var year 		= today.getFullYear();
var weekday		= weekdays[weekday];
var month 		= months[month];
var dateString	= (String(weekday))+" "+(String(monthday))+" de "+(String(month))+", "+(String(year));
var Prop		= document.form.propietarios.value;
var isIE 		= document.all?true:false;
var isNS 		= document.layers?true:false;
var exp_id		= document.form.i8_expediente_id.value;	
var appid		= document.data.appid.value;
var lan			= document.data.lan.value;
var xmlHttp11;
var xmlHttpStream11;
var xmlHttp12;
var xmlHttpStream12;
var xmlHttp13;
var xmlHttpStream13;
//-------------------------------------------------------//
window.onload = function(){
	var w = document.form.width.value;
	var h = document.form.height.value;
	if (document.form.dt_vencimiento.value==="") {
		document.form.fecha_emision.value 		= dateString;
		document.form.fecha_vencimiento.value	= dateString;	
		document.form.dt_vencimiento.value 		= GetFechaHoy();
    }else{
		CambiarVencimiento();
	}

	window.resizeTo(w,h);
	getUserCajaDepartamento();
	comprobar_estado();
	getUserFunctions();
	getUserViews();
	capturar_ultimo_balance();
	getFinanciamientoActivo();
};
//-------------------------------------------------------//
// LEVEL 1
function getUserCajaDepartamento(){
    var URL     = "../pl/user.caja.departamento.get.pl";
    xmlHttp11	= GetXmlHttpObject(getUserCajaDepartamentoSC);
    xmlHttp11.open("GET",URL,true) ;
    xmlHttp11.send(null);
}
function getUserCajaDepartamentoSC(){
    if (xmlHttp11.readyState==4 || xmlHttp11.readyState=="complete"){ 
        xmlHttpStream11=xmlHttp11.responseText;
		if (xmlHttpStream11!=="false" && xmlHttpStream11!==""){
			var datos=xmlHttpStream11.split("|");
			document.form.i8_user_id.value				= datos[0];
			document.form.i8_emisor_id.value			= datos[0];
			document.form.v128_user.value				= datos[1]+" "+datos[2];
			document.form.i2_tipo_departamento_id.value	= datos[3];
			document.form.v64_tipo_departamento.value	= datos[4];
			document.form.i2_cajero_id.value			= datos[5];
		}else{
			document.form.i2_cajero_id.value			= 1;			
		}
    }
}
function getUserFunctions(){
	var cid		= "bsws";
	var clase	= "empresa";
	var oid		= "3006";
    var URL     = "../pl/get_user_option_functions.pl?clase="+clase+"&cid="+cid+"&oid="+oid;
    xmlHttp12	= GetXmlHttpObject(getUserFunctionsSC);
    xmlHttp12.open("GET",URL,true) ;
    xmlHttp12.send(null);
}
function getUserFunctionsSC(){
    if (xmlHttp12.readyState==4 || xmlHttp12.readyState=="complete"){ 
        xmlHttpStream12=xmlHttp12.responseText;
        if (xmlHttpStream12!=="false" && xmlHttpStream12!==""){
			var ol 		= document.getElementById("functions_ol");
			var funs_a	= xmlHttpStream12.split("~~");
			for(var i=0;i<funs_a.length-1;i++ ) {
				var li		= document.createElement("li");
				var mems_a	= funs_a[i].split("[]");
				li.innerHTML= "<a href='#' id='"+mems_a[0]+"' onClick='"+mems_a[1]+"'>"+mems_a[2]+"</a>";
				ol.appendChild(li);
			}			
        }
    }
}
function getUserViews(){
	var cid		= "bsws";
	var clase	= "empresa";
	var oid		= "3006";
    var URL     = "../pl/get_user_option_views.pl?clase="+clase+"&cid="+cid+"&oid="+oid;
    xmlHttp13	= GetXmlHttpObject(getUserViewsSC);
    xmlHttp13.open("GET",URL,true) ;
    xmlHttp13.send(null);
}
function getUserViewsSC(){
    if (xmlHttp13.readyState==4 || xmlHttp13.readyState=="complete"){ 
        xmlHttpStream13=xmlHttp13.responseText;
		//alert(xmlHttpStream13);
        if (xmlHttpStream13!=="false" && xmlHttpStream13!==""){
			var ol 		= document.getElementById("views_ol");
			var vis_a	= xmlHttpStream13.split("~~");
			for(var i=0;i<vis_a.length-1;i++ ) {
				var li		= document.createElement("li");
				var mems_a	= vis_a[i].split("[]");
				var abridor = mems_a[13].replace("()","");
				li.innerHTML= "<a href='#' id='"+mems_a[0]+"' onClick="+abridor+"('"+mems_a[0]+"','"+mems_a[2]+"','"+mems_a[3]+"','"+mems_a[4]+"','"+mems_a[6]+"','"+mems_a[7]+"','"+mems_a[8]+"','"+mems_a[9]+"','"+mems_a[10]+"','"+mems_a[11]+"','"+mems_a[12]+"')>"+mems_a[1]+"</a>";
				ol.appendChild(li);
			}			
        }
    }
}
function comprobar_estado(){
    if(document.form.c16_estado.value!="ACEPTADO"){
       if(document.form.c16_estado.value!="REUNIDO"){
			alert("El estado del inmueble es: "+document.form.c16_estado.value+",\npor lo tanto no podra ser mostrada la informacion del estado de cuenta.\nEl estado se modifico por ultima vez: "+document.form.ts_update.value);
			document.form.pago_parcial.disabled="true"; //deshabilitando boton para facturar
			document.form.go.disabled="true"; //deshabilitando boton para generar estado de cuenta
			document.form.paga.disabled="true"; //deshabilitando checkbox de corte
			return;
        }
    }
    GetPageParams();  
}
//--------------------------------------------------------//
// LEVEL 2
function activarOpciones() {
	if (document.all.opciones_div.style.display=='inline') {
		document.all.opciones_div.style.display	= 'none';
    }else{
		document.all.opciones_div.style.display	= 'inline';		
	}
}
function openView(wid,cmp,cls,fol,tb,sb,mb,rz,lo,st,typ){
    var winame 		= cmp+"_"+wid;
	var id_field	= document.form.id_field.value;
	var id			= eval("document.form."+id_field+".value");
    if (!OpenWindows[winame] || OpenWindows[winame].closed){
		var win ="window.open('/cgi-bin/"+appid+"/"+fol+"/"+cmp+"."+typ+"?lan="+lan+"&appid="+appid+"&clase="+cls+"&id="+id+"','"+cmp+"_"+wid+"','left=20,top=20,width=20,height=20,scrollbars="+sb+",toolbar="+tb+",menubar="+mb+",resizable="+rz+",location="+lo+",status="+st+"')";
		OpenWindows[winame]=eval(win);
    }else{OpenWindows[winame].focus()}
}
// LEVEL 3
function openBalanceResumen(wid,cmp,cls,fol,tb,sb,mb,rz,lo,st,typ) {
	var resform = document.createElement("form");
	var AbonoPers 	= "";
	var Rows   	= GridData.split("~~");	
	if(Rows<1){alert(document.form.empty_grid.value);return}
	for(var k=1;k<Rows.length;k++ ) {
		if(eval("document.form.chk_"+k+".checked")){
			var RowsValues	= Rows[k-1].split("&&");
			for(var l=0;l<RowsValues.length-1;l++ ) {
				var TariffGridFIE= 0;
				var TariffGridINT= 0;
				var TariffGridMUL= 0;
				var TariffValues = RowsValues[l].split("|");
				var TariffGridPER= eval("document.form.PER_"+k+".value");
				var TariffGridDIM= eval("document.form.DIM_"+k+".value");
				var TariffGridVAL= eval("document.form.TAR_"+TariffValues[2].substr(0,8)+"_"+k+".value");
				var TarData = RowsValues[l].split("|");				
				if(TariffGridVAL>0){
					var Trib  = GetTributo(TariffValues[2].substr(0,8));
					if(document.form.ACC_FIESTAS_chk){if(document.form.ACC_FIESTAS_chk.checked){if(TarData[4]>0){TariffGridFIE = Math.round(TariffGridVAL*GridParams['FIE']*DDigits[i2_digitos])/DDigits[i2_digitos];}}}
					if(document.form.ACC_INTERESES_chk){if(document.form.ACC_INTERESES_chk.checked){if(TarData[5]>0){TariffGridINT = Math.round(TariffGridDIM*TariffGridVAL*(GridParams['INT']/365)*DDigits[i2_digitos])/DDigits[i2_digitos];}}}
					if(document.form.ACC_MULTAS_chk){
						if(document.form.ACC_MULTAS_chk.checked){
							if(TarData[6]>0){
								if(TariffGridDIM>=1 && TariffGridDIM<90){TariffGridMUL = TariffGridVAL*GridParams['M89']}
								if(TariffGridDIM>=90){TariffGridMUL = TariffGridVAL*GridParams['M90']}
								if(TariffGridDIM<1){TariffGridMUL = 0}
								TariffGridMUL = Math.round(TariffGridMUL*DDigits[i2_digitos])/DDigits[i2_digitos];
							}
						}
					}
					AbonoPers += TariffGridPER+"|"+TariffGridDIM+"|"+Trib+"|"+TariffValues[2]+"|"+TariffGridVAL+"|"+TariffGridFIE.toFixed(i2_digitos)+"|"+TariffGridINT.toFixed(i2_digitos)+"|"+TariffGridMUL.toFixed(i2_digitos)+"~~";
				}
			}
		}
	}
	
	document.resform.Abonos.value 			= AbonoPers;
	document.resform.dt_emision.value		= document.form.dt_emision.value;
	document.resform.dt_vencimiento.value	= document.form.dt_vencimiento.value;
	document.resform.fecha_emision.value	= document.form.fecha_emision.value;
	document.resform.fecha_vencimiento.value= document.form.fecha_vencimiento.value;	
	document.resform.action					= "/cgi-bin/"+appid+"/"+fol+"/"+cmp+"."+typ
	
	document.resform.submit();
}
function openForm(wid,cmp,cls,fol,tb,sb,mb,rz,lo,st,typ) {
	var form = document.createElement("form");
	form.setAttribute("method", "post");
	form.setAttribute("action", "action.pl");
	form.setAttribute("target", "formresult");
	
    var hiddenField = document.createElement("input");
	hiddenField.setAttribute("name", "search");
	hiddenField.setAttribute("value","product1,product2" );
	hiddenField.setAttribute("type", "hidden");
	form.appendChild(hiddenField);
	document.body.appendChild(form);
	form.submit();
}
//--------------------------------------------------------//
// New Functions
function putMandamientoSave(){
	var TipoAbono 	= "T";
	var NewAddress  = "";
	var NewPropies  = "";	
	var MIV		= "";
	var DIVI	= "";	
	var MIF 	= BillingXML.getElementsByTagName("master_insert_fields")[0].childNodes[0].nodeValue.split(",");
	var DIF		= BillingXML.getElementsByTagName("detail_insert_fields")[0].childNodes[0].nodeValue.split(",");
	var TXS 	= BillingXML.getElementsByTagName("txt_structure")[0].childNodes[0].nodeValue.split(",");
	var Rows	= GridData.split("~~");	
	if(Rows<1){alert(document.form.empty_grid.value);return;}
	
	var NewProp	= Prop.replace(/<TR class=my_style1>/g,'');
	var Propietarios= NewProp.split('</TR>');
	for(var aa=0;aa<Propietarios.length-1;aa++ ) {
		Propietarios[aa]= Propietarios[aa].replace(/<TD>/g,'');
		var PMembers	= Propietarios[aa].split('</TD>');
		NewPropies     +=PMembers[1]+",";
	}

	var AAddress = document.form.txt_expediente_direccion.value.split(",");
	for(var a=0;a<AAddress.length;a++){if(AAddress[a]!==""){NewAddress+=AAddress[a]+",";}}

	document.form.txt_expediente_propietarios.value = NewPropies.substr(0,NewPropies.length-1);
	document.form.txt_expediente_direccion.value	= NewAddress.substr(0,NewAddress.length-1);
	document.form.dt_emision.value 		    		= GetFechaHoy();
	document.form.txt_concepto.value 		    	= document.getElementById('concepto').innerHTML;

	document.form.d82_pago.value=document.form.us_total.value;
	
	for(var f=0;f<MIF.length;f++ ) {
		//alert(MIF[f]);
		if(eval("document.form."+MIF[f])){
			MIV += eval("document.form."+MIF[f]+".value")+"|";
		}else{
			MIV += "|";
		}
	}
	//alert(MIV);
	document.data.miv.value = MIV;

	var OTarifa  = new Object();
	var ATarifas = Tarifas.split("|");
	for (var pp=0;pp<ATarifas.length;pp++ ) {
		var ATarifaMembers = ATarifas[pp].split(",");
		OTarifa[ATarifaMembers[0]] = ATarifaMembers[1];
	}
	
	var OTributo  = new Object();
	var ATributos = Tributos.split("|");
	for (var p=0;p<ATributos.length;p++ ) {
		var ATributoMembers = ATributos[p].split(",");
		OTributo[ATributoMembers[0]] = ATributoMembers[1];
	}

	var OAccesorios	= new Object();
	var AAccesorios	= Accesorios.split("|");
	for (var q=0;q<AAccesorios.length;q++ ) {
		var AAccesorioMembers = AAccesorios[q].split(",");
		OAccesorios[AAccesorioMembers[0]] = AAccesorioMembers[1];
	}

	var TxtPER	= new Object();
	for(var k=1;k<Rows.length;k++ ) {
		if(eval("document.form.chk_"+k+".checked")){
			var RowsValues	= Rows[k-1].split("&&");
			for(var l=0;l<RowsValues.length-1;l++ ) {
				var TariffGridFIE= 0;
				var TariffGridINT= 0;
				var TariffGridMUL= 0;
				var TariffValues = RowsValues[l].split("|");
				//alert(TariffValues);
				var TariffGridPER= eval("document.form.PER_"+k+".value");
				var TariffGridDIM= eval("document.form.DIM_"+k+".value");
				var TariffGridVAL= eval("document.form.TAR_"+TariffValues[2].substr(0,8)+"_"+k+".value");
				var INDX = TariffValues[2]+"_"+TariffGridVAL;
				if(TariffGridVAL>0){
					if(document.form.ACC_FIESTAS_chk){if(document.form.ACC_FIESTAS_chk.checked){TariffGridFIE = Math.round(TariffGridVAL*GridParams['FIE']*DDigits[i2_digitos])/DDigits[i2_digitos];}}
					if(document.form.ACC_INTERESES_chk){if(document.form.ACC_INTERESES_chk.checked){TariffGridINT = Math.round(TariffGridDIM*TariffGridVAL*(GridParams['INT']/365)*DDigits[i2_digitos])/DDigits[i2_digitos];}}
					if(document.form.ACC_MULTAS_chk){if(document.form.ACC_MULTAS_chk.checked){					
						if(TariffGridDIM>=1 && TariffGridDIM<90){TariffGridMUL = TariffGridVAL*(GridParams['M89'])}
						if(TariffGridDIM>=90){TariffGridMUL = TariffGridVAL*(GridParams['M90'])}
						if(TariffGridDIM<1){TariffGridMUL = 0}
						TariffGridMUL = Math.round(TariffGridMUL*DDigits[i2_digitos])/DDigits[i2_digitos];
					}}

					if(OTarifa[TariffValues[2]]-TariffValues[3]==0){
						if(OTarifa[TariffValues[2]]-TariffGridVAL==0){TipoAbono="T"}else{TipoAbono="P"}
					}else{TipoAbono="C"}
					TxtPER[INDX] += TariffGridPER+","+TariffGridDIM+","+TariffValues[2]+","+TariffGridVAL+","+TariffGridFIE.toFixed(i2_digitos)+","+TariffGridINT.toFixed(i2_digitos)+","+TariffGridMUL.toFixed(i2_digitos)+","+TipoAbono+"~";
				}
			}
		}
	}
	var NewTariffPER = "";
	var NewTariffDIM = "";
	var NewTariffTAR = "";
	var NewTariffVAL = "";
	var NewTariffFIE = 0;
	var NewTariffINT = 0;
	var NewTariffMUL = 0;	
	for (var u in TxtPER){
		var NewTxtPER = TxtPER[u].replace(/undefined/g,"");
		//alert(NewTxtPER);
		var Qty = NewTxtPER.split("~");
		var Cant =Qty.length-1;
		for(var v=0;v<Qty.length-1;v++ ) {
			var NewQty   = Qty[v].split(",");
			NewTariffPER = NewQty[0];
			NewTariffDIM = NewQty[1];
			NewTariffTAR = NewQty[2];
			NewTariffVAL = NewQty[3];
		}
		var	NewTariffCUE = OTarifa[NewTariffTAR];
		DIVI += NewTariffTAR+"|"+NewTariffCUE+"|"+OTributo[NewTariffTAR.substr(0,8)]+"|"+Cant+"|"+NewTariffVAL+"|"+NewTxtPER.substr(0,NewTxtPER.length-1)+"~~";
	}
	//alert(DIVI);
	for (var w in OAccesorios){
		if(w.substr(5,3)=="FIE"){
			NewTariffFIE = eval("document.form.STA_FIE.value")*1
			if(document.form.ACC_FIESTAS_chk.checked){
				if((NewTariffFIE*1)>0){DIVI += w+"|"+"12114"+"|"+OAccesorios[w]+"|1|"+NewTariffFIE.toFixed(i2_digitos)+"|~~";}
			}
		}
		if(w.substr(5,3)=="INT"){
			NewTariffINT = eval("document.form.STA_INT.value")*1			
			if(document.form.ACC_INTERESES_chk.checked){
				if((NewTariffINT*1)>0){DIVI += w+"|"+"15302"+"|"+OAccesorios[w]+"|1|"+NewTariffINT.toFixed(i2_digitos)+"|~~";}
			}
		}
		if(w.substr(5,3)=="MUL"){
			NewTariffMUL = eval("document.form.STA_MUL.value")*1			
			if(document.form.ACC_MULTAS_chk.checked){
				if((NewTariffMUL*1)>0){DIVI += w+"|"+"15301"+"|"+OAccesorios[w]+"|1|"+NewTariffMUL.toFixed(i2_digitos)+"|~~";}
			}
		}
	}	
	document.data.div.value = DIVI;
	document.data.submit();	
}
function putExpedienteAbonos() {
	var AbonoPers 	= "";
	var Rows   	= GridData.split("~~");	
	if(Rows<1){alert(document.form.empty_grid.value);return}
	for(var k=1;k<Rows.length;k++ ) {
		if(eval("document.form.chk_"+k+".checked")){
			var RowsValues	= Rows[k-1].split("&&");
			for(var l=0;l<RowsValues.length-1;l++ ) {
				var TariffGridFIE= 0;
				var TariffGridINT= 0;
				var TariffGridMUL= 0;
				var TariffValues = RowsValues[l].split("|");
				var TariffGridPER= eval("document.form.PER_"+k+".value");
				var TariffGridDIM= eval("document.form.DIM_"+k+".value");
				var TariffGridVAL= eval("document.form.TAR_"+TariffValues[2].substr(0,8)+"_"+k+".value");
				var TarData = RowsValues[l].split("|");				
				if(TariffGridVAL>0){
					var Trib  = GetTributo(TariffValues[2].substr(0,8));
					if(document.form.ACC_FIESTAS_chk){if(document.form.ACC_FIESTAS_chk.checked){if(TarData[4]>0){TariffGridFIE = Math.round(TariffGridVAL*GridParams['FIE']*DDigits[i2_digitos])/DDigits[i2_digitos];}}}
					if(document.form.ACC_INTERESES_chk){if(document.form.ACC_INTERESES_chk.checked){if(TarData[5]>0){TariffGridINT = Math.round(TariffGridDIM*TariffGridVAL*(GridParams['INT']/365)*DDigits[i2_digitos])/DDigits[i2_digitos];}}}
					if(document.form.ACC_MULTAS_chk){
						if(document.form.ACC_MULTAS_chk.checked){
							if(TarData[6]>0){
								if(TariffGridDIM>=1 && TariffGridDIM<90){TariffGridMUL = TariffGridVAL*GridParams['M89']}
								if(TariffGridDIM>=90){TariffGridMUL = TariffGridVAL*GridParams['M90']}
								if(TariffGridDIM<1){TariffGridMUL = 0}
								TariffGridMUL = Math.round(TariffGridMUL*DDigits[i2_digitos])/DDigits[i2_digitos];
							}
						}
					}
					AbonoPers += TariffGridPER+"|"+TariffGridDIM+"|"+Trib+"|"+TariffValues[2]+"|"+TariffGridVAL+"|"+TariffGridFIE.toFixed(i2_digitos)+"|"+TariffGridINT.toFixed(i2_digitos)+"|"+TariffGridMUL.toFixed(i2_digitos)+"~~";
				}
			}
		}
	}
	document.abonar.Abonos.value = AbonoPers;
	document.abonar.submit();
}
function createTarget(t){
	window.open("", t, "width=1000,height=700,scrollbars=yes,toolbar=no,menu=no,statusbar=no,location=no");
	return true;
}
//-------------------------------------------------------//
// AUXILIAR
if (window.ActiveXObject){
	var Propietarios = new ActiveXObject("Microsoft.XMLDOM");
	Propietarios.async=false;
	Propietarios.loadXML(Prop);
}else if (document.implementation && document.implementation.createDocument){
	var Propietarias = document.implementation.createDocument("","",null);
	Propietarios= document.implementation.createDocument("","",null);
	//Propietarios.loadXML(Prop);
}else{
	alert('Your browser cannot handle this script');
}
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 CambiarVencimiento(){
	var value	= document.form.dt_vencimiento.value;
	var Members 	= value.split("-");
	var NewDate	= new Date(Members[0],Members[1]-1,Members[2]);
	var NewString	= (String(weekdays[NewDate.getDay()]))+" "+(String(NewDate.getDate()))+" DE "+(String(months[NewDate.getMonth()]))+", "+(String(NewDate.getFullYear()));
	document.form.fecha_vencimiento.value = NewString.toUpperCase();
}
function CleanFechas(chk){
	if(chk==true){

	}else{
		document.form.dt_futuro.value="";
		document.form.dt_corte.value="";
		document.form.dt_corte1.value="";		
	}
}
///---------------------------------------
function capturar_ultimo_balance(){
	var id = document.form.i8_empresa_id.value;
    var URL     = "../pl/empresa_capturar_ultimo_balance.pl?id="+id;
    xmlHttp2	= GetXmlHttpObject(stateChangedBalance);
    xmlHttp2.open("GET",URL,true) ;
    xmlHttp2.send(null);
}
function stateChangedBalance(){
    if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete"){ 
        xmlHttpStream2=xmlHttp2.responseText;
        if (xmlHttpStream2!="false" && xmlHttpStream2!=""){
            document.form.v128_balance.value=xmlHttpStream2;
        }
    } 
}
function ShowTarifa(objRef){
	var chk_name	= objRef.name;
	var chk_indx	= objRef.name.split("_");
	var Rows	= GridData.split("~~");
	var RowData 	= Rows[chk_indx[2]-1].split("&&");
	var colTarifa	= "";
	for(var a=0;a<RowData.length-1;a++ ) {
		var ColsData = RowData[a].split("|");
		if(ColsData[2].substr(0,8)==chk_indx[1]){
			colTarifa = ColsData[2];
		}
	}
	return colTarifa;
}
function OpenRow(objRef,col){
    alert("Deben Existir los Inicios de Cobro!!!! \n Presione Enter para continuar..");
	var chk_name	= objRef.name;
        var valor       =objRef.value;
        var d82_exceso=0;
        if(valor<0){d82_exceso=valor;}
//	alert("Valor:"+valor);
	var chk_indx	= objRef.name.split("_");
	var Rows	= GridData.split("~~");
        //alert(Rows);
        var i8_periodo=eval("document.form.PER_"+chk_indx[2]+".value");
//        alert(i8_periodo);
	var c8_tributo_id=chk_indx[1];
        //alert(c8_tributo_id);
	//var RowColsData	= GetRowColsData(Rows[chk_indx[1]-1]).split("^^");
        ///
        var d82_tarifa=eval("document.form.TAR_"+chk_indx[1]+"_"+chk_indx[2]+".value");
//        alert("Valor tasa:"+d82_tarifa);
	
        //var OTarifa  = new Object();
	var ATarifas = Tarifas.split("~~");
        //alert(Tarifas);
        var tars=Tarifas.split("~~");
	//alert(tars[0]);
        for (var pp=0;pp<ATarifas.length;pp++ ) {
		var ATarifaMembers = ATarifas[pp].split("|");
		if(c8_tributo_id==ATarifaMembers[0].substr(0,8))
                {
                        var d82_tarifa=ATarifaMembers[1];
                        //alert("La tarifa es:"+d82_tarifa);
                }
                
	}
        //var val_tarifa=OTarifa[""]
	c16_tarifa_id = ShowTarifa(objRef);        
        var tables;
	if (!tables || tables.closed){
                if(col=="tributo")
                {
                        //tables =     window.open("../pl/procesar_abonos_indebidos.pl?lan=es&appid=NuevoCuscatlan&i8_empresa_id={i8_empresa_id}&c8_tributo_id="+c8_tributo_id+"&d82_tarifa="+d82_tarifa+"&i8_periodo="+i8_periodo+"&d82_exceso="+d82_exceso+"&Tarifas="+Tarifas+"&cell_value="+valor,"Abonos","top=50,left=50 width=600,height=180,resizable=no,status=no,scrollbars=no");
                        tables =     window.open("../pl/procesar_abonos_indebidos.pl?lan=es&appid=NuevoCuscatlan&i8_empresa_id={i8_empresa_id}&c8_tributo_id="+c8_tributo_id+"&d82_tarifa="+d82_tarifa+"&i8_periodo="+i8_periodo+"&d82_exceso="+d82_exceso+"&c16_tarifa_id="+c16_tarifa_id,"Abonos","top=50,left=50 width=600,height=180,resizable=no,status=no,scrollbars=no");                        
                }
                if(col=="total")
                {
                        var total=d82_tarifa;
                        //tables =     window.open("../pl/procesar_abonos_indebidos.pl?lan=es&appid=NuevoCuscatlan&i8_inmueble_id={i8_inmueble_id}&c8_tributo_id="+c8_tributo_id+"&d82_tarifa="+d82_tarifa+"&total="+total,"Abonos","top=50,left=50 width=600,height=180,resizable=no,status=no,scrollbars=no");
                        tables =     window.open("../pl/procesar_abonos_indebidos.pl?lan=es&appid=NuevoCuscatlan&i8_empresa_id={i8_empresa_id}&c8_tributo_id="+c8_tributo_id+"&d82_tarifa="+d82_tarifa+"&total="+total+"&c16_tarifa_id="+c16_tarifa_id,"Abonos","top=50,left=50 width=600,height=180,resizable=no,status=no,scrollbars=no");
                }
                
	}else{tables.focus()}

	//document.getElementById('Grid').deleteTFoot();
	//ConstructGridFooter();
        
	//GetTotal();
        //alert();
    
}
function OpenRow1(objRef) {
    alert("Deben Existir los Inicios de Cobro!!!! \n Presione Enter para continuar..");
        var chk_name	= objRef.name;
        var total       = objRef.value;        
	var chk_indx	= objRef.name.split("_");
	var i8_periodo=eval("document.form.PER_"+chk_indx[1]+".value");        
        var tables;
	if (!tables || tables.closed){                            
            tables =     window.open("../pl/procesar_abonos.pl?lan=es&appid=NuevoCuscatlan&i8_expediente_id={i8_empresa_id}&generador=empresa&Tarifas="+Tarifas+"&i8_periodo="+i8_periodo+"&total="+total,"Abonos","top=50,left=50 width=400,height=180,resizable=no,status=no,scrollbars=no");                
	}else{tables.focus()}
    
}