
window.onload=function()
{
criaElementos();
verificaInt=setInterval("verifica()", 100);
}
page="";
prefix="[as!page]";
index="homeBackState";
is_ie=(navigator.userAgent.toLowerCase().indexOf("msie")!=-1)?true:false;

function criaElementos()
{
var theBody=document.getElementsByTagName("body")[0];
var iframe=document.createElement("iframe");
iframe.setAttribute("src", "as.htm?id="+prefix+index);
iframe.setAttribute("id", "bmr-ajaxControl");
iframe.style.display="none";
theBody.appendChild(iframe);
}

function volta_index()
{

location="http://"+location.host+location.pathname+"#"+prefix+pag;
location.reload();

}
    
function ajax(pag)

    {

var iframe=document.getElementById('bmr-ajaxControl');

    if(is_ie){iframe.src="as.htm?id="+prefix+pag;}
    else{if(pag!=index){location.hash=prefix+pag;}
        else{volta_index();}}}
    
function verifica()
    {var hash=(typeof((hash=location.href.split("#")[1]))!="undefined"?hash:"");
    if(hash!=page) 
        {if(hash!="" && hash.indexOf(prefix)!=-1) 
            {


carregaConteudo('http://www.agorasim.com/cgi-bin/ASPage.pl?q=titulo&t='+hash.replace(prefix,""),'titulo', false);
carregaConteudo(hash.replace(prefix,""), 'ajax', true);
carregaConteudo('http://www.agorasim.com/cgi-bin/ASPage.pl?q=fonte&t='+hash.replace(prefix,""),'fonte', false);
            page=hash; ajax(hash.replace(prefix,""));}
        else {clearInterval(verificaInt);
            location.hash=page; //Index
            ajax(index);}}}
