/********** Ajax News ***************/
var dominio = "http://www.urbes.com.br/";

// funcao ajax para criar o select de atendimentos
var objDiv
function ajaxFree(url,div) { 
objDiv = div
reqAg = null; 
document.getElementById(objDiv).innerHTML = "<img src='imagens/carregando.gif'><br><br>";
  if (window.XMLHttpRequest) { 
  reqAg = new XMLHttpRequest(); 
  reqAg.onreadystatechange = processReqChangeFree; 
  reqAg.open("GET",url,true); 
  reqAg.send(null); 
  } else if (window.ActiveXObject) { 
    reqAg = new ActiveXObject("Microsoft.XMLHTTP"); 
    if (reqAg) { 
    reqAg.onreadystatechange = processReqChangeFree; 
    reqAg.open("GET",url,true); 
    reqAg.send(); 
    } 
  } 
} 

function processReqChangeFree() { 
  if (reqAg.readyState == 4) { 
    if (reqAg.status ==200) { 
    document.getElementById(objDiv).innerHTML = reqAg.responseText; 
    } else { 
    alert("Houve um problema ao obter os dados:n " + reqAg.statusText); 
    } 
  } 
}

// funcao ajax para enviar faleconosco

function postAJAX(url,Formulario) {
var status = false;
var contentType = "application/x-www-form-urlencoded; charset=ISO-8859-1";
  if (window.XMLHttpRequest) {
  request = new XMLHttpRequest();
  request.onreadystatechange = processReqChangePost;
  request.open("post", url, true);
  request.setRequestHeader("Content-Type", contentType);
  request.send(Formulario);
  status = true;
  } else if (window.ActiveXObject) {
     request = new ActiveXObject("Microsoft.XMLHTTP");
     if (request) {
     request.onreadystatechange = processReqChangePost;
     request.open("post", url, true);
     request.setRequestHeader("Content-Type", contentType);
     request.send(Formulario);
     status = true;
     }
  }
  return status;
}

function createQuery(form) {
var elements = form.elements;
var pairs = new Array();
  for (var i = 0; i < elements.length; i++) {
    if ((name = elements[i].name) && (value = elements[i].value))
    pairs.push(name + "=" + encodeURIComponent(value));
  }
return pairs.join("&");
}

function processReqChangePost() { 
  if (request.readyState == 4) { 
    if (request.status ==200) { 
    //document.getElementById('loading').style.display='none';
    texto=unescape(request.responseText.replace(/\+/g," "));
    document.getElementById('centroHome').innerHTML = texto;
    } else { 
    alert("Houve um problema ao obter os dados:n" + request.statusText); 
    } 
  } 
}

function enviaFC(form){
document.getElementById('botaoFC').innerHTML = "<img src='imagens/carregando.gif'>";
url="paginas2/fale_conosco/enviaFC.php?";
postAJAX(url,createQuery(form)); 
}


function compFC(assunto){
url="paginas2/fale_conosco/compFC.php?assunto="+assunto;
ajaxFree(url,'divComplemento');
}

function detalheCartao(val,div,event){
h=document.body.scrollLeft;
w=document.body.scrollTop;
x=event.clientX-h;
y=event.clientY+w;
url="paginas2/fale_conosco/detalheCartao.php";
  if(val==1){
  //alert(x+", "+y);
  ajaxFree(url,div);
  document.getElementById(div).style.left = x;
  document.getElementById(div).style.top = y;
  } else {
  document.getElementById(div).innerHTML="";
  document.getElementById(div).style.top = 0;
  }
}

function enviaFormularioFaleConosco(form) { 
document.getElementById('botaoFC').innerHTML = "<img src='imagens/carregando.gif'>";
url="paginas2/fale_conosco/enviaFormulario.php?";
postAJAX(url,createQuery(form)); 
}

function chamaPaginaDo(end,id) { 
  if(end=="" && id!=""){
  window.open('index.php?pagina_id='+id,'_self'); }
  if(end!="" && id!=""){
  window.open('index.php?conteudo='+end+'&pagina_id='+id,'_self');} 
  if(end=="" && id==""){
  window.open('index.php','_self'); }
  if(end!="" && id==""){
  window.open('index.php?conteudo='+end,'_self'); }
}

function AbreCurso(div) { 
url="paginas2/bilhetagem/Escolar/ajaxCursos.php";
ajaxFree(url,div); 
}

function chamaPesquisaHorarioNome(busca,div){
url="paginas2/transportes/coletivo/horarioResultadoPesquisaLinha.php?busca="+busca;
ajaxFree(url,div);
}

function chamaPesquisaLinhaNome(codlinha,nomelinha,div){
url="paginas2/transportes/coletivo/horarioResultadoPesquisaLinha.php?codlinha="+codlinha+"&nomelinha="+nomelinha;
ajaxFree(url,div);
}

function servInst(id_inst,div){
url="paginas2/servicos/listaServInst.php?id_inst="+id_inst;
ajaxFree(url,div);
}

function resultadoPesquisaIntegracao(codLinha,div){
url="paginas2/transportes/coletivo/listaIntegracao.php?codLinha="+codLinha;
ajaxFree(url,div);
}

function exibeCadastro(cod,div){
url="paginas2/bilhetagem/Escolar/exibeCadastro.php?codigo="+cod;
alert(url);
ajaxFree(url,div);
}

function resultadoConsultaIntegracao(codLinha,div){
url="paginas2/transportes/coletivo/ajaxConsultaIntegracao.php?codLinha="+codLinha;
ajaxFree(url,div);
}

function resultadoPesquisaIntegracaoExt(codLinha,div){
url="listaIntegracaoExt.php?codLinha="+codLinha;
ajaxFree(url,div);
}

function chamaAtendimentoDo(codLinha,div){
url="paginas2/transportes/coletivo/itinerarioAtendimentoAjax.php?codLinha="+codLinha; 
ajaxFree(url,div); 
}

function TrocaImagemSemTransito(img,div){
url="paginas2/transito/semana2009.php?img="+img;
ajaxFree(url,div);
}

function habAssunto(area,div){
url="paginas2/fale_conosco/assuntosFC.php?area="+area; 
ajaxFree(url,div); 
}

function chamaAtendimentoExt(codLinha,div){
url="itinerarioAtendimentoExt.php?codLinha="+codLinha; 
ajaxFree(url,div); 
}

function chamaPesquisaItinerarioDo(codLinha){
window.open('index.php?conteudo=paginas/transportes/coletivo/itinerarioResultadoPesquisaAjax.php&codLinha='+codLinha,'_self'); 
}

function chamaPesquisaItinerarioExt(codLinha){
window.open('cons_itin_linha_externa.php?codLinha='+codLinha,'_self'); 
}

function lerNoticia(idNot,fonte){
window.open('index.php?conteudo=paginas/noticias/lerNoticia.php&idNot='+idNot+'&fonte='+fonte,'_self'); 
}

function todasNoticias(pag,pags){
window.open('index.php?conteudo=paginas/noticias/todasNoticias.php&pag='+pag); 
}

function todasNoticias2(id){
window.open('index.php?conteudo=paginas/noticias/todasNoticias.php&id='+id,'_self'); 
}

function chamaPesquisaPostosDoPaginado(proxima){
window.open('index.php?conteudo=paginas/bilhetagem/postosCredenciadoPasseSocial.php&id='+proxima,'_self');
}

function exibirTodasLicitacoes(){
window.open('index.php?conteudo=paginas/empresa/licitacao/visualizar.php&todas=1','_self');
}

function chamaDescricaoServico(servId){
window.open('index.php?conteudo=paginas/servicos/DescServico.php&id='+servId,'_self');
}

function BuscaSite(busca,tabela){
window.open('index.php?conteudo=paginas/resBuscaSite.php&busca='+busca+'&tabela='+tabela,'_self');
}

function chamaPesquisaHorarioDo(codLinha,dia){
window.open('index.php?conteudo=paginas/transportes/coletivo/horarioResultadoPesquisaHorarioAjax.php&codLinha='+codLinha+'&dia='+dia,'_self'); 
}

function chamaPesquisaHorGreve(codLinha,dia,porc){
window.open('index.php?conteudo=paginas/transportes/coletivo/ResultadoPesquisaHorarioGreve.php&codLinha='+codLinha+'&dia='+dia+'&porc='+porc,'_self'); 
}

function exibeMapaIntegracao(url){
window.open(url,'_self'); 
}

function chamaPesquisaHorarioExt(codLinha,dia){
window.open('cons_hor_linha_externa.php?codLinha='+codLinha+'&dia='+dia,'_self'); 
}

function chamaPesquisaEscolarDo(busca,pag){
window.open('index.php?conteudo=paginas/transportes/escolar/escolarResultadoPesquisaPlaca.php&busca='+busca+'&id='+pag,'_self'); 
}

function chamaPesquisaTaxiDo(busca,pag){
window.open('index.php?conteudo=paginas/transportes/taxi/taxiResultadoPesquisaPlaca.php&busca='+busca+'&id='+pag,'_self'); 
}

function chamaPesquisaFretamentoDo(busca,pag,optBusca){
window.open('index.php?conteudo=paginas/transportes/fretamento/fretamentoResultadoPesquisaPlaca.php&busca='+busca+'&id='+pag+'&optBusca='+optBusca,'_self'); 
}

function chamaVideoSemana(){
window.open('index.php?conteudo=paginas/transito/videoSemana.php','_self');
}

function dadosOperacionais(opt,ano){
window.open('index.php?conteudo=paginas/transportes/coletivo/dadosOperacionais.php&opt='+opt+'&ano='+ano,'_self');
}

function chamaPesquisaIntegracao(codLinha){
window.open('index.php?conteudo=paginas/transportes/coletivo/consultaIntegracao.php&codLinha='+codLinha,'_self'); 
}

function chamaPesquisaIntegracaoExt(codLinha){
window.open('cons_integracao_ext.php?codLinha='+codLinha,'_self'); 
}

function chamaInterbairros(){
window.open('index.php?conteudo=paginas/transportes/coletivo/folder_interbairros.html', '_self');
}