/*
	ENP Soluções em T.I.
	www.enpsolucoes.com

	ajax javascript module
*/

try{
    var xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            var xmlhttp = false;
        }
    }
}

function load( what, where, params ){
	//Exibe o texto carregando no div conteúdo
    var conteudo=document.getElementById( where );

	if( where != "dvContent"){
		conteudo.className = "block";
	}

	conteudo.innerHTML="<table width='100%' height='100%'><tr valign='center'><td align='center'><img src='img/loader.gif'/><br><br><i>CARREGANDO</i></td></tr></table>";

    //Abre a url
    if( params == ""){
    	xmlhttp.open("GET", "action.php?n="+what,true);
    }else{
    	xmlhttp.open("GET", "action.php?n="+what+"&"+params,true);
    }

    //Executada quando o navegador obtiver o código
    xmlhttp.onreadystatechange=function() {

        if (xmlhttp.readyState==4){

            //Lê o texto
            var texto = xmlhttp.responseText;

            //Desfaz o urlencode
            texto = texto.replace(/\+/g," ");
            texto = unescape(texto);

            //Exibe o texto no div conteúdo
            //var conteudo = document.getElementById( where );
			if( where != "dvContent"){
				conteudo.className = "borda";
			}

            conteudo.innerHTML = texto;
        }
    }

    xmlhttp.send(null);
}

