﻿function oComunic(name)
{    
    this.name = name;
    this.xmlhttp = null;     
    
    //Internet Explorer
    if (window.ActiveXObject)
    {
    try
    {this.xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");}
    catch (e)
    {
        try
        {this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
        catch (e)
        {this.xmlhttp = null;}
    }
    //Mozilla y Safari
    }
    if ((this.xmlhttp == null) && (typeof XMLHttpRequest != 'undefined'))
    {
        try
        {this.xmlhttp = new XMLHttpRequest();}
        catch (e)
        {this.xmlhttp = null;}
    }
    if ((this.xmlhttp == null) && window.createRequest) 
    {
        try
        {this.xmlhttp = window.createRequest();}
        catch (e) 
        {this.xmlhttp = null;}
    }        
    this.cargaDatosAsincrono = fn_cargaDatosAsincrono;
    this.continuar = fn_continuar;
    this.respuesta;
}

function fn_cargaDatosAsincrono (purl, func)
{   
    this.xmlhttp.onreadystatechange = new Function("fn_continuar(" + this.name + "," + func + ")");        
    this.xmlhttp.open ("GET", purl, true);        
    this.xmlhttp.send(null);
}
function fn_continuar(obj, func){
    if (obj.xmlhttp.readyState!=4)
        return;
    obj.respuesta = obj.xmlhttp.responseText;     
    eval(func())    
}


