function CreateXmlHttp()
{
    var xmlHttp;
    xmlHttp=false;
    try
    {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(oc)
        {
            xmlHttp = null;
        }
    }
    if(!xmlHttp && typeof XMLHttpRequest != "undefined")
    {
        xmlHttp = new XMLHttpRequest();
    }
    return xmlHttp;
}

function ajax(sfuncion, sDiv, Param)
{
    var xmlHttp = new CreateXmlHttp();
    if (document.getElementById('bAjax' + sDiv) != null){

        if (document.getElementById('bAjax' + sDiv).value=='+')
        {
            document.getElementById('bAjax' + sDiv).value='-';
        } else {
             document.getElementById('bAjax' + sDiv).value='+';
             sfuncion = 'cerrar';
        }
    }
    var ajaxRequest = "http://www.info-moviles.es/ajax.ashx?funcion=" + sfuncion + Param;
    if (sfuncion == 'cerrar')
    {
        ajaxRequest =  ajaxRequest + "&texto=" + sDiv;
    }

    document.getElementById(sDiv).innerHTML = "";
    EnviaRecogeInfo( xmlHttp, sDiv, ajaxRequest );
}
function EnviaRecogeInfo( xmlHttp, sDiv, ajaxRequest )
{
    if (typeof(xmlHttp.onprogress)=='object'){
        xmlHttp.onload = xmlHttp.onerror = xmlHttp.onabort = function(){
        recogeInfo(sDiv,xmlHttp);
    };
    } else {
        xmlHttp.onreadystatechange = function(){
        if (xmlHttp.readyState == 4){
            recogeInfo(sDiv,xmlHttp);
        }
    };
    }
    xmlHttp.open("GET", ajaxRequest, true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send(null);
}
function recogeInfo(sDiv, xmlHttp)
{
    if(xmlHttp.status == 200 || window.location.href.indexOf("http")==-1)
    {
        document.getElementById(sDiv).innerHTML = document.getElementById(sDiv).innerHTML + xmlHttp.responseText;
    }
}

