function carregajanela(id, divpai, top, left, largura, url){
	adddiv(id, divpai, top ,left, largura);
	pagina(url, id);
}

//id nova div, div pai, top, left, largura
function adddiv(id, divpai, ptop, pleft, largura){
	   
	   var novo_elem = document.createElement("div");
	   //da o nome a div
	   novo_elem.setAttribute('id', id);
	   //da propiedade de stylo pra div
	   novo_elem.style.position = "absolute";
	   novo_elem.style.left =  pleft;
	   novo_elem.style.top =  ptop;
	   novo_elem.style.width = largura;
	   novo_elem.style.height = "auto";
	   novo_elem.style.background = "#FFFFCC";
	   //Aplica as configurações da div criada
       document.getElementById(divpai).appendChild(novo_elem);
}

function removeElement(divpai, divfilho) {
  var d = document.getElementById(divpai);
  var olddiv = document.getElementById(divfilho);
  d.removeChild(olddiv);
}

function escrevediv(onde, texto){
var conteudo = document.getElementById(onde);
var newElement = document.createElement("div");
newElement.appendChild(document.createTextNode(texto));
conteudo.appendChild(newElement);
document.getElementById(onde).style.display = "block";
}

function OcultarDiv(div){
     document.getElementById(div).style.display = "none";  
}

function pagina(page, cdiv){
  ajax = new ObjAjax();
  var div = document.getElementById(cdiv);
  document.getElementById(cdiv).style.display = "block";  
  ajax.onreadystatechange = function(){
    if(ajax.readyState == 1){div.innerHTML="<p align=center>Carregando_aguarde...</p>";}
    if(ajax.readyState == 4){div.innerHTML=ajax.responseText;}
 }
  ajax.open("GET",page,true);
  ajax.setRequestHeader('Content-Type', 'text/html');
  ajax.setRequestHeader("Cache-Control", "no-cache");
  ajax.setRequestHeader("Pragma", "no-cache");
  ajax.send(null);
}

function ObjAjax(){
  try{return new XMLHttpRequest()}
  catch(e){try{return new ActiveXObject("Msxml2.XMLHTTP")}
  catch(e){return new ActiveXObject("Microsoft.XMLHTTP")}}
  return null;
}
