/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var xmlhttp = null;

function get_counter(){
    xmlhttp = getXmlHTTPRequest();

    if(xmlhttp == null)
        return;

    var url = "/contador/counter.php";

    xmlhttp.onreadystatechange = stateChanged;

    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);

}

function stateChanged()
{
    if (xmlhttp.readyState==4)
    {
        xmlDoc = xmlhttp.responseXML;

        elem = xmlDoc.getElementsByTagName("contador");

        var result = "<p>Visitantes:<span id='contador'> " +
            elem[0].childNodes[0].nodeValue +
            "</span></p>";

        document.getElementById("contador").innerHTML = result;
        //alert("IP: " + elem[0].getAttribute('ip') );
    }
}

function getXmlHTTPRequest(){
    if (window.XMLHttpRequest)
    {
        return new XMLHttpRequest();
    }
    if (window.ActiveXObject)
    {
        return new ActiveXObject("Microsoft.XMLHTTP");
    }

    return null;
}

