var lan;
var appid;
var clase;
var id;
var dt_corte_inicial;
var dt_corte_final;
var xmlHttp;
var xmlHttpStream;
function GetFechasCorteFinanciamiento(){
    var str     = "lan="+lan+"&appid="+appid+"&clase="+clase+"&id="+id;
    //alert(str);
    var URL	= "../pl/get_fechas_corte_financiamiento.pl";
    //alert(URL);
    xmlHttp	= GetXmlHttpObject(stateGetFechasCorteFinanciamiento);
    xmlHttp.open("POST",URL,true) ;
    xmlHttp.send(str);
}
function GetFinanciamiento(){
    var adt     = "";
    var cadt    = 0;
    var dsv_adt = parent.list.document.detail.dsv.value.split('~~');
    for(i=0;i<dsv_adt.length-1;i++) {
        var dsv_dt = dsv_adt[i].split('|');
        adt+=dsv_dt[3]+"|";
        cadt++;
    }
    if(cadt==0){alert("Favor Ingresar Fechas de Cuota");return}
    var str     = "lan="+lan+"&appid="+appid+"&clase="+clase+"&id="+id+"&adt="+adt+"&dt_corte="+dt_corte_final+"&dt_corte1="+dt_corte_inicial;
    //alert(str);
    var URL	= "../fwsp.pl";
    //var URL	= "/cgi-bin/bsb_v10/src/pl/fwsp.pl";
    //window.open(URL);
    xmlHttp	= GetXmlHttpObject(stateGetFinanciamiento);
    xmlHttp.open("POST",URL,true) ;
    xmlHttp.send(str);
}
function stateGetFechasCorteFinanciamiento(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
        xmlHttpStream=xmlHttp.responseText;
        if(xmlHttpStream==""){alert("No hay Fechas de Corte, Favor Ingresarlas");return}
        var FCF = xmlHttpStream.split("|");
        dt_corte_inicial = FCF[0];
        dt_corte_final   = FCF[1];
        GetFinanciamiento();
    }
}
function stateGetFinanciamiento(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
        xmlHttpStream=xmlHttp.responseText;
	//alert("stateChangedGetFinanciamiento =>"+xmlHttpStream);
        if(xmlHttpStream!="true"){alert("ha ocurrido un error: "+xmlHttpStream);return}
        parent.opener.document.location.reload();
        setTimeout("parent.document.location.reload()",500);
    }
}
function GetXmlHttpObject(handler){ 
    var objXmlHttp=null
    if (navigator.userAgent.indexOf("Opera")>=0){
	alert("This example doesn't work in Opera") 
	return 
    }
    if (navigator.userAgent.indexOf("MSIE")>=0){ 
	var strName="Msxml2.XMLHTTP"
	if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
	    strName="Microsoft.XMLHTTP"
	} 
	try{ 
	    objXmlHttp=new ActiveXObject(strName)
	    objXmlHttp.onreadystatechange=handler 
	    return objXmlHttp
	}catch(e){ 
	    alert("Error. Scripting for ActiveX might be disabled") 
	    return 
	} 
    } 
    if (navigator.userAgent.indexOf("Mozilla")>=0){
	objXmlHttp=new XMLHttpRequest()
	objXmlHttp.onload=handler
	objXmlHttp.onerror=handler 
	return objXmlHttp
    }
}
function Loan(){
    lan     = parent.list.document.data.lan.value;
    appid   = parent.list.document.data.appid.value;
    clase   = "inmueble_balance";    
    id      = parent.list.document.data.id.value;
    GetFechasCorteFinanciamiento();
}
var isIE = document.all?true:false;
var isNS = document.layers?true:false;
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);
}