var xmlHttp;

function abrir(link,ext){
	if(ext == '1'){
		document.getElementById('div_corpo').innerHTML = "<div style='background:white;padding:5px;'><iframe name=I1 src='" + link + "' frameborder='0' width='100%;' height='560'> </iframe><div>";
	}
	else{
		//cria novo objeto xmlHttp
		xmlHttp= new GetXmlHttpObject();
		if (xmlHttp==null) {
			alert ("Your browser does not support AJAX!");
			return;
		} 
		//configura função para mudança de estado
		xmlHttp.onreadystatechange=stateChanged;
		//configura envio
		xmlHttp.open("GET",link,true);
		//envia
		xmlHttp.send(null);
	}
	
}

//função de mudança de estado
function stateChanged() { 
	if (xmlHttp.readyState==1){	//requisição foi enviada
		document.getElementById("div_corpo").innerHTML="<center><img src='images/loading.gif'></center>";
	}
	if (xmlHttp.readyState==4){ //resposta chegou
		
		document.getElementById("div_corpo").innerHTML=xmlHttp.responseText;
		
	}
}

// funçao que cria o objeto ajax
function GetXmlHttpObject() {
    try {
        xmlHttp = new XMLHttpRequest();
    }
    catch(ee) {
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e) {
            try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e) {
                xmlHttp = false;
            }
        }
    }
    return xmlHttp;
}

