function toogle(obj) {
 doc_div = document.getElementById('div_'+obj);
 doc_img = document.getElementById('img_'+obj);
 if(doc_div.style.display == "block") {
  doc_div.style.display = "none";
  doc_img.src = "images/menu/plus.gif";
 } else {
  doc_div.style.display = "block";
  doc_img.src = "images/menu/minus.gif";
 }
 return false;
}

function div_on(obj) {
 document.getElementById('div_'+obj).style.display = "block";
 return false;
}

function div_off(obj) {
 document.getElementById('div_'+obj).style.display = "none";
 return false;
}

function warning(texto) {
 var msg = '<a style="cursor:pointer" onclick="warning(\'off\')" title="Click here to close this warning.">'+texto+'</a>';
 if('off' == texto) msg = "";
 document.getElementById('alert_bar').innerHTML = msg;
 return false;
}

function loading(status) {
 var obj = document.getElementById('loading').style;
 if(status)
  obj.display = 'block';
 else
  obj.display = 'none';
 return false;
}

function page(url) {
 ajax(url, 'page');
}

function select(url, id) {
 ajax(url, id);
}

function ajax(url, id) {
 try {
  xmlhttp = new XMLHttpRequest();
 } catch(ee) {
  try {
   xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch(e) {
   try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   } catch(E) {
    xmlhttp = false;
   }
  }
 }

 //Abre a url
 xmlhttp.open("GET", "?ajx="+url, true);

 //Executada quando o navegador obtiver o código
 xmlhttp.onreadystatechange = function() {
  loading(true);
  if(xmlhttp.readyState == 4) {
   //Lê o texto
   var texto = xmlhttp.responseText;

   //Exibe o texto no div conteúdo
   var conteudo = document.getElementById(id);
   conteudo.innerHTML = texto;
   loading(false);
   //Executa os javasripts
   var scripts = conteudo.getElementsByTagName("script");
   for(i = 0; i < scripts.length; i++) {
    s = scripts[i].innerHTML;
    eval(s);
   }
  }
 }
 
 //var data = "sender=" + messageform.sender.value + "&receiver=" + messageform.receiver.value + "&message=" + messageform.message.value;
 //xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
 //xmlhttp.send(data);
 xmlhttp.send(null);
 return false;
}

function popup(url, width, height) {
 var props = 'scrollBars=yes,resizable=no,titlebar=no,toolbar=no,menubar=no,location=no,directories=no,width='+width+',height='+height;
 var newWindow = window.open(url, 'popup', props);
}