var urlSite = location.href;
var pathPadrao = location.protocol + "//" + location.host + "/";

function $(id) { return document.getElementById(id) }





var nomeSiteHomolog = "";
if (window.location.href.indexOf('publicador') >-1){var nomeSiteHomolog = "/gente/materias/";}
var pathPadrao = "http://"+location.host+nomeSiteHomolog;


/*-------------------- COMPLEMENTOS AJAX --------------------*/
var secao={
url:[
"/gente"
],

nome:[
"materias"
],

complemento:[
"/materias/complemento/"
]
};

for(_x=0;_x<secao.url.length;_x++){
	if(urlSite.indexOf(secao.url[_x])>-1){
	  secaoNome=secao.nome[_x];
	  secaoComplemento=secao.complemento[_x];
	}
}

function _xStart(){
  if(secaoComplemento!=null)_xCopy(pathPadrao+secaoComplemento);//CARREGA OS COMPLEMENTOS;
}

function getHTTPObject(){if(window.XMLHttpRequest){return new XMLHttpRequest();} else if(window.ActiveXObject){var prefs = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];for(var i = 0; i < prefs.length; i++){try{return new ActiveXObject(prefs[i] + ".XMLHTTP");} catch(e){}}}}

function rx($u){return new RegExp("<"+$u+">(.*)</"+$u+">")}

function _xCopy($path) {
    _objg = new getHTTPObject();
    _n = parseInt(Math.random()*1000000);
    _objg.open('GET', $path+"?" + _n, true);
    _objg.onreadystatechange = function() {
        if(_objg.readyState == 4) {
            if(_objg.status == '200') txt= _objg.responseText.replace(/\r\n/g, "");
        }
    };
    _objg.setRequestHeader('Content-type', 'text/html; charset=ISO-8859-1');
    _objg.send(null);
}

function _xPops($path) {
    _objPops = new getHTTPObject();
    _n = parseInt(Math.random()*1000000);
    _objPops.open('GET', $path+"?" + _n, true);
    _objPops.onreadystatechange = function() {
        if(_objPops.readyState == 4) {
            if(_objPops.status == '200') txtpops= _objPops.responseText.replace(/\r\n/g, "");
        }
    };
    _objPops.setRequestHeader('Content-type', 'text/html; charset=ISO-8859-1');
    _objPops.send(null);
}

var area={//areas que vem por ajax;
  menu_lateral:"menu_lateral",
  rodape:"rodape",
  ultimas_noticias:"ultimas_noticias",
  ultimas_galerias:"ultimas_galerias"
}

var tempo = 100;

function menu(){
  var $u=area.menu_lateral;
  window.setTimeout(function(){try{$("x_"+$u).innerHTML=rx($u).exec(txt)[1];}catch(e){return false}},tempo);
}

function rodape(){
  var $u=area.rodape;
  window.setTimeout(function(){try{$("x_"+$u).innerHTML=rx($u).exec(txt)[1];}catch(e){return false}},tempo);
}

function ultnoticias(){
  var $u=area.ultimas_noticias;
  window.setTimeout(function(){try{$("x_"+$u).innerHTML=rx($u).exec(txt)[1];}catch(e){return false}},tempo);
}

function ultgalerias(){
  var $u=area.ultimas_galerias;
  window.setTimeout(function(){try{$("x_"+$u).innerHTML=rx($u).exec(txt)[1];}catch(e){return false}},tempo);
}

_xStart();


