/***************** AJAX Botão voltar ********************/
var appHash = "principal.php";
var browserHash = "";
var isIe = (navigator.userAgent.toLowerCase().indexOf("msie") > -1) ? true : false;
var interval;


function createIFrame() {
 var f = window.location.toString().split("#")[1] != undefined ? window.location.toString().split("#")[1] : appHash;
 var iFrame = document.createElement("iframe");
 iFrame.setAttribute("src", "control-iframe.htm?id="+f);
 iFrame.setAttribute("id", "control-iframe");
 iFrame.style.display = "none";
 document.body.appendChild(iFrame);
}


function makeHistory(newHash) {
 if (isIe === true) {
  $("control-iframe").setAttribute("src", "control-iframe.htm?id=" + newHash);
 }
 window.location.hash = "#" + newHash;
 appHash = newHash;
}


function handleHistory() {
 var browserHash = window.location.toString().split("#")[1];
 if(browserHash != appHash) {
//  alert("appHash: " + appHash + " browserHash: " + browserHash);
  appHash = browserHash;
  if (window.location.toString().indexOf("eventos") > -1) {
   var e = browserHash != "principal.php" ? "palco" : "corpo";
   ajaxGet(browserHash, $(e), true);
  }
  if (window.location.toString().indexOf("eventos") == -1) {
   ajaxGet(browserHash, $("corpo"), true);
  }
 }
}


function initialize() {
 if (isIe === true) {
  createIFrame();
 }
 interval = window.setInterval(handleHistory, 300);
}