function anuncio_clique(id,hiperlink,janela){
	$.ajax(
		{
		  url: 'anuncio_registra_clique.php?id_busca='+id,
		  cache: false,
		  beforeSend: function(){
		  		},
		  success: function(html){
			  	if(janela=='n'){
		  			window.location.href=hiperlink;
					} else {
					window.open(hiperlink,'janela');	
					}
				}
			}
		);
	}

function navegador(){

	var navegador = window.navigator.userAgent;
  	if(navegador.indexOf('Firefox')!=-1){
		return "Firefox";
		}
	if(navegador.indexOf('WebKit')!=-1){
		return "WebKit";
		}
	if(navegador.indexOf('MSIE')!=-1){
		return "IE";
		}

	}

function relogio(){ 
		var restante = document.getElementById('tempo_restante').childNodes[0].nodeValue;
		restante = restante-1
		
		var completo='';
		
		var dias = parseInt(restante/86400);		
		if(dias>0){
			
				if(dias==1){
					var rotulo_dias='dia';
					} else {
					var rotulo_dias='dias';
					}
				completo+=dias+' '+rotulo_dias;
			
			}
			
		var restante_horas = parseInt(restante%86400);
		var horas = parseInt(restante_horas/3600);
		
		if(horas>0){
			
			if(dias>0){
				completo+=' e ';
				}
			
				if(horas==1){
					var rotulo_horas='hora';
					} else {
					var rotulo_horas='horas';
					}
				completo+=' '+horas+' '+rotulo_horas;
			
			}
		
		var restante_minutos = parseInt(restante_horas%3600);
		var minutos = parseInt(restante_minutos/60);
	
	if(restante<86400){
			if(minutos>0){
				
					if(minutos==1){
						var rotulo_minutos='minuto';
						} else {
						var rotulo_minutos='minutos';
						}
					completo+=' '+minutos+' '+rotulo_minutos;
				
				}
			
			var segundos = parseInt(restante_minutos%60);
			
				if(segundos==1){
					var rotulo_segundos='segundo';
					} else {
					var rotulo_segundos='segundos';
					}
					
				completo+=' '+segundos+' '+rotulo_segundos;
			}
			
			
			document.getElementById("tempo_restante").childNodes[0].nodeValue = restante;
			document.getElementById("tempo_exibe").childNodes[0].nodeValue = completo;
			
			if(restante==0){
				document.location.reload();
				}
				
			if(restante>0){
				setTimeout("relogio()",1000) 
				}

		} 
		
function numeros(e){

	
	  if(navigator.appName=="Microsoft Internet Explorer"){ // Internet Explorer
		 var tecla = event.keyCode;
	 	 } else {
		 var tecla = e.which;
		 }
	
	  if(tecla > 47 && tecla < 58) // numeros de 0 a 9
		 return true;
	  else {
			if (tecla != 8) // backspace
			  return false;
			else
			  return true;
		 }
	}

function mudarEstilo(alvo,estilo){
	alvo = document.getElementById(alvo);
	alvo.className=estilo;
	}

function alternaEstilo(alvo,estilo1,estilo2){
	alvo = document.getElementById(alvo);
	if(alvo.className==estilo1){
			alvo.className=estilo2;
		} else {
			alvo.className=estilo1;
		}
	}

function mudar_abas(total,atual) {
	for(i=1;i<=total;i++){
		document.getElementById("aba_"+i).className="aba_off";
		}
		document.getElementById("aba_"+atual).className="aba_on";
}
function mudarImg(id,img) {
		alvo = document.getElementById(id)
		alvo.src=img;
}
function mudarImgFundo(id,img) {
		alvo = document.getElementById(id)
		alvo.style.backgroundImage='url('+img+')';
	}
function mudarImagens(imagem,alvo){
	document.images[alvo].src = imagem;
	}
	
//////////////////////////////////////////////////////////

function carregaAjax(url,alvo,carregando,funcao,vars){
	$.ajax(
		{
		  url: url,
		  cache: false,
		  beforeSend: function(){
		  		if((carregando!=undefined) && (carregando!='')){
		  			$(carregando).show();
					}
				$(alvo).hide();
		  		},
		  success: function(html){
		  		if((carregando!=undefined) && (carregando!='')){
					$(carregando).hide();
					}
				$(alvo).show();
				$(alvo).html(html);
				
				if(funcao!=undefined){
					exec = funcao;
					exec(vars);
					}
				
				}
			}
		);
	}

/*

function carregaAjax(url,alvo,carregando){
	$.ajax(
		{
		  url: url,
		  cache: false,
		  beforeSend: function(){
		  		$(carregando).show();
				$(alvo).hide();
		  		},
		  success: function(html){
		  		$(carregando).hide();
				$(alvo).show();
				$(alvo).html(html);
				//$("#conteudo").innerHTML(html); -> ADICIONAR AO CONTEUDO EXISTENTE
				}
			}
		);
	}

*/

///////////////////////////////////////////////////////

function ampliarFoto(foto,legenda){
			tabelafoto = document.getElementById("tabelatransparenciafotoampliada")
			tabelafoto1 = document.getElementById("basefotoampliada")
			tabelafoto1.style.paddingTop=document.body.scrollTop

			var alturatabela = document.body.scrollHeight ;
			tabelafoto.height = alturatabela;

			var alturaTelaCheia = screen.availHeight;
			if(alturaTelaCheia>alturatabela){
				alturatabela = alturaTelaCheia;
				}
				
			tabelafoto1.style.height = screen.availHeight-50;

			alvo = document.getElementById("fotoAmpliada")
			
			if(alvo.style.display=="inline"){
				
					alvo.style.display="none"	
					document.images["foto_ampliada"].src = "imagens/carregando2.gif";
					document.getElementById("legendafotoampliada").childNodes[0].nodeValue = "";
				
					} else {
					
						alvo.style.display="inline"
						
						var imagem_preview = new Image(420,420)
						imagem_preview.src = foto;
					
						var intervalo_foto_ampliada = window.setInterval(
							
							function (){
						
								if(imagem_preview.complete){
									document.images["foto_ampliada"].src = foto;
									document.getElementById("legendafotoampliada").childNodes[0].nodeValue = legenda
									clearInterval(intervalo_foto_ampliada);
									}
									
							}
					,1000);
		
					}
			}

function mudaDisplay(alvo){
	alvo = document.getElementById(alvo)
	if(alvo.style.display=="block"){
		alvo.style.display="none"
		} else {
		alvo.style.display="block"
		}
	}
	
function exibe(alvo){
	alvo = document.getElementById(alvo)
	alvo.style.display="block"
	}
	
function oculta(alvo){
	alvo = document.getElementById(alvo)
	alvo.style.display="none"
	}
	
function mudarTexto(alvo,conteudo){
	document.getElementById(alvo).innerHTML = conteudo;
	}
	
function mudarSrcIframe(alvo,arquivo){
	document.getElementById(alvo).src= arquivo;
	}
	
function pos_x(posicao, alvo){
		$(document).ready(function() {
			$(alvo).animate({left: posicao}, "normal");
		});
	}
	
function pos_y(posicao, alvo){
		$(document).ready(function() {
			$(alvo).animate({top: posicao}, "normal");
		});
	}
	
function tam_x(posicao, alvo){
		$(document).ready(function() {
			$(alvo).animate({width: posicao}, "normal");
		});
	}
	
function tam_y(posicao, alvo){
		$(document).ready(function() {
			$(alvo).animate({height: posicao}, "normal");
		});
	}
	
function verificarCamposForm(campo,form){
	if (document.forms[form].elements[campo].value=="") {
	alert("Preencha o campo selecionado!")
		document.forms[form].elements[campo].focus();
		document.forms[form].elements[campo].className="erro";
		return false
		} else {
		document.forms[form].elements[campo].className="";
		return true
		}
	}

function mudarCorFundo(elem,cor) {
	if (elem.style) {
		elem.style.backgroundColor = cor
		}
	}
function mudarBorda(alvo,cor){
		alvo_borda = document.getElementById(alvo);
		alvo_borda.style.borderColor=cor;
		}