// -*- mode: javascript -*-
xmlhttp=false;

function getHTTPRequestObject(){
    try{
        xmlhttp= new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e){
        try{
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        } catch(E){
            xmlhttp=false;
        }
    }
    if(!xmlhttp && typeof XMLHttpRequest!='undefined'){
        xmlhttp=new XMLHttpRequest();
    }
}

function callback(){
    if(xmlhttp.readyState==4){
        if(xmlhttp.status==200){
            try{
	     document.getElementById("servicios").innerHTML = xmlhttp.responseText;
            } catch(e){
                window.status='Error';
            }
        }
    }
}

function getIndicators(from){	
	getHTTPRequestObject();
	if (from == 'servicioseconomia') { 
		requestURL="/services/economia/getIndicators.php";
	} else if (from == 'servicioscapital') {
		requestURL="/services/capital/hoynocircula.php";
	} else if (from == 'servicioscapitalclima') {
		requestURL="/services/capital/clima1.php";
	} else if (from == 'servicioscapitalsemaforo') {		
		requestURL="/services/capital/semaforo.php";
	}
    if(xmlhttp){	
        xmlhttp.open("GET",requestURL, true);
        xmlhttp.onreadystatechange=callback;
        xmlhttp.send(null);
    } else{
        alert('No es posible crear el objeto httpxmlrequest');
    }
}

var servicios = {
        replaceblock: function (link, from) {
		if (document.getElementById("servicios").style.display == 'block'){
			document.getElementById("servicios").style.display="none";
			document.getElementById("btn_indice").src="/v7.0/imagenes/servicios/btn_down.gif";
			document.getElementById("btn_indice").style.cursor="pointer";
		}else{
			if (document.getElementById("servicios").style.display != 'none')
				getIndicators(from);
				document.getElementById("servicios").style.display="block";
				document.getElementById("btn_indice").src="/v7.0/imagenes/servicios/btn_up.gif";
				document.getElementById("btn_indice").style.cursor="pointer";
		}

	}
}

