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

function criarXMLHttpRequest()
{
   try{ return new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){}
   try{ return new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){}
   try{ return new XMLHttpRequest(); }catch(e){}
   alert("XMLHttpRequest not supported");
   return null;
}
var XHR_criado = criarXMLHttpRequest();

function SetRadio(vradio)
{
  radio = vradio;
}
function pegaradio(prog)
{
 carrega_post_radio(prog,radio)
}

function pegaradioFig(prog)
{ 
 window.location = "fig_anunciar_man_man_corp.php?anuncio="+radio;
}

function mOut(src,cor){
  src.style.cursor = "default";
  src.style.backgroundColor = cor;
}
function mOver(src,cor){
  src.style.cursor = "pointer";
  src.style.backgroundColor = cor;
}

atual=0

function carrega_banner(){
    banner = document.getElementById('banner').value;
    ifr_banner.location = banner;
}

function carrega(prog,id){
if(id==null)
     {
      var conteudo=document.getElementById("conteudo");
     }
    else
     {
      var conteudo=document.getElementById(id);
     } 
    conteudo.innerHTML="<div><table border='0' width='100%' height='100%'><tr><td align='center' valign='middle'><img src='img/loading4.gif'></td></tr></table></div>"
    if(prog.indexOf('?')==-1)
	{
	  random_ = '?'+Math.ceil(Math.random()*100000);
	}
	else
	{
	  random_ = '&'+Math.ceil(Math.random()*100000);
	}
    xmlhttp.open("GET", prog+random_,true);
    xmlhttp.setRequestHeader('Cache-Control', 'no-store, no-cache, must-revalidate');
    xmlhttp.setRequestHeader('Pragma', 'no-cache');
    xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4){
       var texto=xmlhttp.responseText
       texto=texto.replace(/\+/g," ")
       texto=unescape(texto)
    if(id==null)
     {
      var conteudo=document.getElementById("conteudo");
     }
    else
     {
      var conteudo=document.getElementById(id);
     } 
    conteudo.innerHTML=texto
        }
    }
    xmlhttp.send(null)
}

function carrega2(prog,id,loading){
if(id==null)
     {
      var conteudo=document.getElementById("conteudo");
     }
    else
     {
      var conteudo=document.getElementById(id);
     } 
    if(prog.indexOf('?')==-1)
	{
	  random_ = '?'+Math.ceil(Math.random()*100000);
	}
	else
	{
	  random_ = '&'+Math.ceil(Math.random()*100000);
	}
    xmlhttp.open("GET", prog+random_,true);
    xmlhttp.setRequestHeader('Cache-Control', 'no-store, no-cache, must-revalidate');
    xmlhttp.setRequestHeader('Pragma', 'no-cache');
    xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState!=4){
     document.getElementById(id).innerHTML = "Carregando...";
    }
   if (xmlhttp.readyState==4){
       var texto=xmlhttp.responseText
       texto=texto.replace(/\+/g," ")
       texto=unescape(texto)
    if(id==null)
     {
      var conteudo=document.getElementById("conteudo");
     }
    else
     {
      var conteudo=document.getElementById(id);
     } 
    conteudo.innerHTML=texto
        }
    }
    xmlhttp.send(null)
}

function carrega_post_radio(prog,param){
    var conteudo=document.getElementById("conteudo")
    conteudo.innerHTML="<div><table border='0' width='100%' height='100%'><tr><td align='center' valign='middle'><img src='img/loading4.gif'></td></tr></table></div>";
    xmlhttp.open("POST", prog,true);
    xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xmlhttp.setRequestHeader('Cache-Control', 'no-store, no-cache, must-revalidate');
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4){
            var texto=xmlhttp.responseText
            texto=texto.replace(/\+/g," ")
            texto=unescape(texto)
            var conteudo=document.getElementById("conteudo")
            conteudo.innerHTML=texto
        }
    }
	xmlhttp.send("chave="+param);
}
function abreZoom(id,image) {
 if (document.getElementById(id).style.display=="block") {
   document.getElementById(id).style.display="none";
   //document.getElementById(image).src="img/busca_frm.gif"; 
 } else {
   document.getElementById(id).style.display="block";
   //document.getElementById(image).src="img/busca_frm.gif";
 }
}
function abreBuscaMan(id,image) {
 if (document.getElementById(id).style.display=="block") {
   document.getElementById(id).style.display="none";
   document.getElementById(image).src="img/busca.gif"; 
 } else {
   document.getElementById(id).style.display="block";
   document.getElementById(image).src="img/busca.gif";
 }
}
function habilitar(nome_prog,param)
 {
   document.getElementById("excluir").innerHTML="<a href='javascript:'><img border=0 src='img/excluir.gif' alt='Excluir Registro' onClick=javascript:pegaradio('"+nome_prog+"?op=exc"+param+"')></a>";
   document.getElementById("modificar").innerHTML="<a href='javascript:'><img border=0 src='img/modificar.gif' alt='Modificar Registro' onClick=javascript:pegaradio('"+nome_prog+"?op=mod"+param+"')></a>";
   document.getElementById("copiar").innerHTML="<a href='javascript:'><img border=0 src='img/copiar.gif' alt='Copiar Registro' onClick=javascript:pegaradio('"+nome_prog+"?op=cop"+param+"')></a>";
 }

function habilitarFig(nome_prog,param)
 {
   document.getElementById("excluir").innerHTML="<a href=javascript:pegaradio('"+nome_prog+"?op=exc"+param+"') class='menu_topo_index_cat'><img border=0 src='img/excluir.gif' alt='Excluir An&uacute;ncio' onClick=javascript:pegaradio('"+nome_prog+"?op=exc"+param+"')><br>Excluir</a>";
   document.getElementById("modificar").innerHTML="<a href=javascript:pegaradio('"+nome_prog+"?op=mod"+param+"') class='menu_topo_index_cat'><img border=0 src='img/modificar.gif' alt='Modificar An&uacute;ncio' onClick=javascript:pegaradio('"+nome_prog+"?op=mod"+param+"')><br>Modificar</a>";
   document.getElementById("copiar").innerHTML="<a href=javascript:pegaradio('"+nome_prog+"?op=cop"+param+"') class='menu_topo_index_cat'><img border=0 src='img/copiar.gif' alt='Copiar An&uacute;ncio' onClick=javascript:pegaradio('"+nome_prog+"?op=cop"+param+"')><br>Copiar</a>";
   document.getElementById("renovar").innerHTML="<a href=javascript:pegaradio('anunciar_renovar.php?op=ren"+param+"') class='menu_topo_index_cat'><img border=0 src='img/renovar.gif' alt='Renovar An&uacute;ncio' onClick=javascript:pegaradio('anunciar_renovar.php?op=ren"+param+"')><br>Renovar</a>";
   document.getElementById("figura").innerHTML="<a href=javascript:pegaradioFig('"+nome_prog+"?op=fig"+param+"') class='menu_topo_index_cat'><img border=0 src='img/fig.gif' alt='Incluir Fotos no An&uacute;ncio' onClick=javascript:pegaradioFig('"+nome_prog+"?op=fig"+param+"')><br>Fotos do An&uacute;ncios</a>";
 }

function habilitarBanner(nome_prog,param)
 {
   document.getElementById("excluir").innerHTML="<a href=javascript:pegaradio('"+nome_prog+"?op=exc"+param+"') class='menu_topo_index_cat'><img border=0 src='img/excluir.gif' alt='Excluir Banner' onClick=javascript:pegaradio('"+nome_prog+"?op=exc"+param+"')><br>Excluir</a>";
   document.getElementById("modificar").innerHTML="<a href=javascript:pegaradio('"+nome_prog+"?op=mod"+param+"') class='menu_topo_index_cat'><img border=0 src='img/modificar.gif' alt='Modificar Banner' onClick=javascript:pegaradio('"+nome_prog+"?op=mod"+param+"')><br>Modificar</a>";
   document.getElementById("copiar").innerHTML="<a href=javascript:pegaradio('"+nome_prog+"?op=cop"+param+"') class='menu_topo_index_cat'><img border=0 src='img/copiar.gif' alt='Copiar Banner' onClick=javascript:pegaradio('"+nome_prog+"?op=cop"+param+"')><br>Copiar</a>";
 }

function habilitarEnvEmail(nome_prog,param,nome_form)
 {
   var get = document.getElementById(nome_form);
   var count = get.length;
   var send = "";
   var i_ck = 0;
   for(i=0 ; i<=count-1;i++)
     {
        var ck = get.elements[i].checked;
	    if (ck == true) { i_ck++; }
     }
	if (i_ck != 0) {
     document.getElementById("envSolic").innerHTML="<a href='javascript:'><img border=0 src='img/mail.gif' alt='Enviar Solicita&ccedil;&atilde;o' onClick=javascript:EnvCheckBox('"+nome_prog+"?"+param+"','"+nome_form+"')></a>";
	} else {
     document.getElementById("envSolic").innerHTML="<img border=0 src='img/mail_dis.gif' alt='Enviar Solicita&ccedil;&atilde;o'>";
	}
	i_ck = 0;
 }
  
function mostrarDados(url,urlBack,nome_form)
{
  send = pegaFormDados(nome_form);
  enviarDados(url,send,urlBack);
}

function sonum(event) {
  var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
  if (keyCode < 48 || keyCode > 57)
   {
	if (keyCode != 46) {
      return false;
	}
   }
}

function mostrarDadosAnu(url,urlBack,nome_form)
{
	var erro = 0;
	
    var titulo        = document.getElementById('tema');
	var cidade        = document.getElementById('cidade_origem');
	var estado        = document.getElementById('estado_origem');
	var categoria     = document.getElementById('form_anunciar_categoria');
	var sub_categoria = document.getElementById('form_anunciar_sub_categoria');
	var valor         = document.getElementById('valor');
	var anuncio       = document.getElementById('anuncio');

    // Validar Nome
    if(titulo.value == "") {
       if (document.getElementById('tema_div').style.display == 'none') {
		   document.getElementById('tema_div').style.display = '';
	   }
       document.getElementById('tema_div').innerHTML = 'T&iacute;tulo deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('tema_div').style.display = 'none';;
    }

    // Validar Cidade
    if(cidade.value == "") {
       if (document.getElementById('cidade_origem_div').style.display == 'none') {
		   document.getElementById('cidade_origem_div').style.display = '';
	   }
       document.getElementById('cidade_origem_div').innerHTML = 'Cidade deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('cidade_origem_div').style.display = 'none';;
    }
	
    // Validar Estado
    if(estado.value == "") {
       if (document.getElementById('estado_origem_div').style.display == 'none') {
		   document.getElementById('estado_origem_div').style.display = '';
	   }
       document.getElementById('estado_origem_div').innerHTML = 'Estado deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('estado_origem_div').style.display = 'none';;
    }

    // Validar Categoria
    if(categoria.value == "x") {
       if (document.getElementById('categoria_div').style.display == 'none') {
		   document.getElementById('categoria_div').style.display = '';
	   }
       document.getElementById('categoria_div').innerHTML = 'Categoria deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('categoria_div').style.display = 'none';;
    }

    // Validar Sub Categoria
    if(sub_categoria.value == "x") {
       if (document.getElementById('sub_categoria_div').style.display == 'none') {
		   document.getElementById('sub_categoria_div').style.display = '';
	   }
       document.getElementById('sub_categoria_div').innerHTML = 'Sub Categoria deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('sub_categoria_div').style.display = 'none';;
    }
	
    // Validar Anuncio
    if(anuncio.value == "") {
       if (document.getElementById('anuncio_div').style.display == 'none') {
		   document.getElementById('anuncio_div').style.display = '';
	   }
       document.getElementById('anuncio_div').innerHTML = 'An&uacute;nico deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('anuncio_div').style.display = 'none';;
    }

    if(erro==0) {
       send = pegaFormDados(nome_form);
       enviarDados(url,send,urlBack);
	}
}

function mostrarDadosPar(url,urlBack,nome_form)
{
	var erro = 0;
	
    var titulo    = document.getElementById('titulo');
	var site      = document.getElementById('site');
	var banner    = document.getElementById('banner');
	var endpag    = document.getElementById('endpag');
	var categoria = document.getElementById('form_anunciar_categoria');
	var descricao = document.getElementById('descricao');

    // Validar Título
    if(titulo.value == "") {
       if (document.getElementById('titulo_div').style.display == 'none') {
		   document.getElementById('titulo_div').style.display = '';
	   }
       document.getElementById('titulo_div').innerHTML = 'T&iacute;tulo deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('titulo_div').style.display = 'none';
    }

    // Validar Site
    if(site.value == "") {
       if (document.getElementById('site_div').style.display == 'none') {
		   document.getElementById('site_div').style.display = '';
	   }
       document.getElementById('site_div').innerHTML = 'Site deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('site_div').style.display = 'none';
    }
	
    // Validar Banner
    if(banner.value == "") {
       if (document.getElementById('banner_div').style.display == 'none') {
		   document.getElementById('banner_div').style.display = '';
	   }
       document.getElementById('banner_div').innerHTML = 'Banner deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('banner_div').style.display = 'none';
    }

    // Validar EndPag
    if(endpag.value == "") {
       if (document.getElementById('endpag_div').style.display == 'none') {
		   document.getElementById('endpag_div').style.display = '';
	   }
       document.getElementById('endpag_div').innerHTML = 'Endere&ccedil;o da P&aacute;gina deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('endpag_div').style.display = 'none';
    }

    // Validar Categoria
    if(categoria.value == "x") {
       if (document.getElementById('categoria_div').style.display == 'none') {
		   document.getElementById('categoria_div').style.display = '';
	   }
       document.getElementById('categoria_div').innerHTML = 'Deve ser escolhida um categoria!';
	   erro++;
    } else {
       document.getElementById('categoria_div').style.display = 'none';
    }

    // Validar Descricao
    if(descricao.value == "") {
       if (document.getElementById('descricao_div').style.display == 'none') {
		   document.getElementById('descricao_div').style.display = '';
	   }
       document.getElementById('descricao_div').innerHTML = 'Descri&ccedil;&atilde;o deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('descricao_div').style.display = 'none';
    }

    if(erro==0) {
       send = pegaFormDados(nome_form);
       enviarDados(url,send,urlBack);
	}
}

function enviarDados(url,send,urlBack)
  {
    XHR_criado.open("post",url,true);
    XHR_criado.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    XHR_criado.setRequestHeader('Cache-Control', 'no-store, no-cache, must-revalidate');
    XHR_criado.onreadystatechange = SaidaHttpPOST;
    XHR_criado.send(send);
    function SaidaHttpPOST()
    {
      if(XHR_criado.readyState!=4)
	  {
	    document.getElementById("conteudo").innerHTML= "<div><table border='0' width='100%' height='100%'><tr><td align='center' valign='middle'><img src='img/loading4.gif'></td></tr></table></div>";
	  }
	  if(XHR_criado.readyState==4)
	  {
	    //document.getElementById("conteudo").innerHTML= XHR_criado.responseText;
		carrega(urlBack);		
	  }
    }
}

function delDados(url,urlBack)
 {
  XHR_criado.open("get",url,true);
  XHR_criado.onreadystatechange = SaidaHttpPOST;
  XHR_criado.setRequestHeader('Cache-Control', 'no-store, no-cache, must-revalidate'); 
  XHR_criado.send(null);
  function SaidaHttpPOST()
  {
    if(XHR_criado.readyState!=4)
	  {
	    document.getElementById("conteudo").innerHTML= "<div><table border='0' width='100%' height='100%'><tr><td align='center' valign='middle'><img src='img/loading4.gif'></td></tr></table></div>";
	  }
	if(XHR_criado.readyState==4)
	  {
	    //document.getElementById("conteudo").innerHTML= XHR_criado.responseText;
		carrega(urlBack);
	  }
  }
 }

function RenDados(url,urlBack)
 {
  XHR_criado.open("get",url,true);
  XHR_criado.onreadystatechange = SaidaHttpPOST;
  XHR_criado.setRequestHeader('Cache-Control', 'no-store, no-cache, must-revalidate'); 
  XHR_criado.send(null);
  function SaidaHttpPOST()
  {
    if(XHR_criado.readyState!=4)
	  {
	    document.getElementById("conteudo").innerHTML= "<div><table border='0' width='100%' height='100%'><tr><td align='center' valign='middle'><img src='img/loading4.gif'></td></tr></table></div>";
	  }
	if(XHR_criado.readyState==4)
	  {
	    //document.getElementById("conteudo").innerHTML= XHR_criado.responseText;
		carrega(urlBack);
	  }
  }
 }

function setaRadioMan(radio)
 {
	 document.getElementById(radio).checked = true;
 }
function pegaCheckDados(form)
  {
   var get = document.getElementById(form);
   var count = get.length;
   var send = "";
   for(i=0 ; i<=count-1;i++)
     {
	    var valor  = get.elements[i].checked;
	    var campo  = get.elements[i].id;
        if(valor == true)
        {
          send += campo+"*";
        }
     }
  return send.substr(0,send.length-1);
  }
function setaCheckMan(check)
 {
   if (document.getElementById(check).checked == true) {
	 document.getElementById(check).checked = false;
   } else {
	 document.getElementById(check).checked = true;
   }
 }  
function setCheckTodos(form)
  {
   var get = document.getElementById(form);
   var count = get.length;
   var send = "";
   for(i=0 ; i<=count-1;i++)
     {
       get.elements[i].checked = true;
     }
  }
function noSetCheckTodos(form)
  {
   var get = document.getElementById(form);
   var count = get.length;
   var send = "";
   for(i=0 ; i<=count-1;i++)
     {
       get.elements[i].checked = false;
     }
  } 
function EnvCheckBox(nome_prog,nome_form)
 {
  var a = pegaCheckDados(nome_form);
  XHR_criado.open("get",nome_prog+"&dados="+a,true);
  XHR_criado.onreadystatechange = SaidaHttpPOST;
  XHR_criado.setRequestHeader('Cache-Control', 'no-store, no-cache, must-revalidate'); 
  XHR_criado.send(null);
  function SaidaHttpPOST()
  {
    if(XHR_criado.readyState!=4)
	  {
	    document.getElementById("conteudo").innerHTML= "<div><table border='0' width='100%' height='100%'><tr><td align='center' valign='middle'><img src='img/loading4.gif'></td></tr></table></div>";
	  }
	if(XHR_criado.readyState==4)
	  {
	    document.getElementById("conteudo").innerHTML= XHR_criado.responseText;
	  }
  }
 }
 function mostrarDadosRel(url,urlBack,nome_form)
{
  send = pegaFormDados(nome_form);
  enviarDadosRel(url,send,urlBack);
}

function enviarDadosRel(url,send,urlBack)
  {
    XHR_criado.open("post",url,true);
    XHR_criado.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    XHR_criado.setRequestHeader('Cache-Control', 'no-store, no-cache, must-revalidate');
    XHR_criado.onreadystatechange = SaidaHttpPOST;
    XHR_criado.send(send);
    function SaidaHttpPOST()
    {
      if(XHR_criado.readyState!=4)
	  {
	    document.getElementById("conteudo").innerHTML= "<div><table border='0' width='100%' height='100%'><tr><td align='center' valign='middle'><img src='img/loading4.gif'></td></tr></table></div>";
	  }
	  if(XHR_criado.readyState==4)
	  {
	    document.getElementById("conteudo").innerHTML= XHR_criado.responseText;
		//carrega(urlBack);		
	  }
    }
}

function statusBar()
 {
  window.status="E-Sis :: Administração";
  setTimeout("statusBar()",1); 
} 