
	/** AaZ  **/
	
	function letras_bairros() {
		$("#busca .AaZ").prepend("<p></p>");
		letras = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		letras_usadas = "";
		$("#busca .bairros label").each(function(){
			str = $(this).html();
			v = str.split("> ");
			nome_bairro = v[1];
			letras_usadas += nome_bairro.substr(0,1);
		});
		//letras_links = '<a href="#" class="todos">Todos</a>&nbsp;';
		letras_links = '';
		for (i=0;i<=letras.length-1;i++) {
			tem = letras_usadas.indexOf(letras.substr(i,1));
			if (tem>=0) {
				letras_links += '<a href="#" class="letra">'+letras.substr(i,1)+'</a>';
			} else {
				letras_links += letras.substr(i,1);
			}
		}
		$("#busca .AaZ p").html(letras_links);
		$("#busca .AaZ p a.letra").click(function(){
			letra = $(this).html();
			$("#busca .bairros label").each(function(){
				str = $(this).html();
				v = str.split("> ");
				nome_bairro = v[1];
				bletra = nome_bairro.substr(0,1);
				if (bletra==letra) $(this).show(); else $(this).hide();
			});
			return false;
		});
		$("#busca .AaZ p a.todos").click(function(){
			$("#busca .bairros label").show();
			return false;
		});
	}


	/** ENQUETES **/

	function parcial(ide)
	{
		$("#box_enquete").load("inc/lib/fnc_enquetes.php?act=parcial&enquete="+ide);
	}
	function votar(ide)
	{
		f  = document.frme;
		ok = false;
		op = 0; 

		for (i=0;i<f.elements.length;i++){
			if (f.elements[i].type=="radio"){
			if (f.elements[i].checked==true){
					ok=true;
					op=f.elements[i].value;
				}
			}
		}
		if (!ok) { 
			alert("Assinale uma alternativa!!!"); return false; 
		}
		else
		{
			if( $.cookie('enquete_'+ide)!='votou' ) {
				$.get("inc/lib/fnc_enquetes.php?act=votar", { enquete:ide , voto:op },
				function(data){
					alert(data);
					$.cookie('enquete_'+ide, 'votou', { expires: 30 });
				})
			}else{
				alert('Você já votou nesta enquete. Obrigado por participar.')	
			}
		}
	}

	$(document).ready(function(){

		/*
		$('.foto').each(function(){
			var tag = $(this);
			var alt_img = 'vista.imobi/fotos/no_foto_p.jpg';
			
				tag.error(function() { // this adds the onerror event to images
					setTimeou(function(){
						tag.attr("src",alt_img); // change the src attribute of the image
						return true;
					},5000);
				} );
		});
		*/

		//bug flybanner
		$("#topo-banner").css('height','90px');
		$("#topo-banner").hover(
			function(){
	    		$(this).css('height','600px');
			},
			function(){
	    		$(this).css('height','90px');
			}
		);
											   
		//Mostra/esconde o label dos nomes no depoimento
		$("#boxDepoimentos ul").hover(function(){
			$("#boxDepoimentos #depLegenda").slideDown("fast");
		},function(){
			$("#boxDepoimentos #depLegenda").slideUp("fast");
		});
		
		// Muda o texto dos nomes do depoimento
		$("#boxDepoimentos ul a").hover(function(){
			nome = '<p>'+$(this).find("span").html()+'</p>';
			$("#boxDepoimentos #depLegenda").html(nome);
		},function(){}); //esse function é pq o evento hover precisa do evento de saida (out)
		
		// Efeito nos textos dos campos da newsletter
		$("#boxNewsletter fieldset input").focus(function(){
			v = $(this).val();
			if (v=='Nome...' || v=='E-mail...') $(this).val('');
		});
		
		// Balãozinho de help do código da busca
		$("#busca input.codigo").focus(function(){
			$("#busca .balao").fadeIn("fast");
		});
		$("#busca input.codigo").blur(function(){
			$("#busca .balao").fadeOut("fast");
		});

		// Limpador de formulários
		$("#limpar").click(function(){
			$(this).parents("form").find("input, textarea, select").val("");
			return false;
		});
		
		//slidedown bairros
		//if($.browser.msie && ($.browser.version=="6.0" || $.browser.version=="7.0")) {
		//if($.browser.msie) {
			//nao faz slidedown
		//}else{
			$(".bairros").mouseover(function(){
				$(this).css("position","absolute");
				$(this).css("height","100px");
			});
			$(".bairros").mouseout(function(){
				$(this).css("position","absolute");
				$(this).css("height","28px");
			});
		//}
	});
