var xmlHttp1;
var xmlHttpStream1;
var xmlHttpStream;
function GetXmlHttpObject(handler){ 
    var objXmlHttp=null
    if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This program 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 stateChanged(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
        xmlHttpStream=xmlHttp.responseText;
    } 
}
function capturar_usuario(){
    var appid	= "RTM_v30";
    var lan 	= "es";
    
    var URL     = "../pl/capturar_usuario_id.pl?appid="+appid+"&lan="+lan+"";
     
    xmlHttp1	= GetXmlHttpObject(stateChangedCapturar);
    xmlHttp1.open("GET",URL,true) ;
    xmlHttp1.send(null);
}
function stateChangedCapturar(){
    if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete"){ 
        xmlHttpStream1=xmlHttp1.responseText;
        if (xmlHttpStream1!="false" && xmlHttpStream1!=""){
           document.master.i8_user_id.value=xmlHttpStream1;
        }
    } 
}    
function actualizar_usuario(){
    var ultima_operacion=document.master.tmp_ultima_operacion.value;
    
    if(ultima_operacion!="remove"){
        return;
    }
    
    alert("Actualizando el usuario responsable de la eliminacion");
    
    var appid = "RTM_v30";
    var lan = "es";
    
    var i8_user_id      =document.master.i8_user_id.value;
    var i8_inmueble_id  =document.master.i8_inmueble_id.value;
        
    var URL     = "../pl/inmueble_cargo_inicios_actualizar_user.pl?appid="+appid+"&lan="+lan+"&i8_user_id="+i8_user_id+"&i8_inmueble_id="+i8_inmueble_id+"";;

    xmlHttp1	= GetXmlHttpObject(stateChangedActualizar);
    xmlHttp1.open("GET",URL,true) ;
    xmlHttp1.send(null);
}
function stateChangedActualizar(){
    if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete"){ 
        xmlHttpStream1=xmlHttp1.responseText;
        //alert("la stream:"+xmlHttpStream1);
        if (xmlHttpStream1!="true"){
            alert("error al intentar actualizar usuario que elimina registro: "+xmlHttpStream1);
        }
    } 
}
function captura_temporal(ultima_operacion){
    document.master.tmp_ultima_operacion.value      = ultima_operacion;
    capturar_usuario();
}