function popup(){
	$(".pop-up").hover(
	  function () {
       	qual = $(this).attr("title")

		$('.pop-up-aberta').hide();
		
		$('#p-'+qual).show();
		popup_fechar();		
      }, 
       function () {
        qual = $(this).attr("title")		
				$('#p-'+qual).hover("" , function() {			   
		  			$('#p-'+qual).hide();
			   });		
      }
    );
}
function popup_fechar(){
	$("#topo-ani").hover( function () {
		$('.pop-up-aberta').hide();
	});
	$(".main-ax").hover( function () {
		$('.pop-up-aberta').hide();
	});	
	$(".main-limpa").hover( function () {
		$('.pop-up-aberta').hide();
	});		
	$(".menu").hover( function () {
		$('.pop-up-aberta').hide();
	});	
	$("#le").hover( function () {
		$('.pop-up-aberta').hide();
	});	
	$(".main").hover( function () {
		$('.pop-up-aberta').hide();
	});
	$(".horas").hover( function () {
		$('.pop-up-aberta').hide();
	});
	$("a.contact").hover( function () {
		$('.pop-up-aberta').hide();
	});
	$("a.login").hover( function () {
		$('.pop-up-aberta').hide();
	});
	
}

// busca no site
 
	function validarApenasCampoVazio_busca(obj, msg) {
        existeErro_busca(obj);

        if (validarCampoVazio_busca(obj)) {
            exibirMsgErro_busca(obj, msg);
        }
        else {
            obj.removeClass("c-error");
        }
    }

    function existeErro_busca(obj) {
        if ($("#" + obj[0].id + "Erro")) {
            $("#" + obj[0].id + "Erro").remove();
        }
    }

    function exibirMsgErro_busca(obj, msg) {
		existeErro_busca(obj);
        obj.after("<div id='" + obj[0].id + "Erro' class='t-error' style='color:red'>" + msg + "</div>");
        obj.addClass("c-error");
        erro = true;
    }

    function validarCampoVazio_busca(campo) {
        if (campo.val().replace(" ", "") == "") {
            return true;
        }
        return false;
    }
	
	// DATA

function Tempo(){
		
		    days = new Array(7)
			days[1] = "Domingo";
			days[2] = "Segunda";
			days[3] = "Terça-feira"; 
			days[4] = "Quarta-feira";
			days[5] = "Quinta-feira";
			days[6] = "Sexta-feira";
			days[7] = "Sábado";
			months = new Array(12)
			months[1] = "Janeiro";
			months[2] = "Fevereiro";
			months[3] = "Março";
			months[4] = "Abril";
			months[5] = "Maio";
			months[6] = "Junho";
			months[7] = "Julho";
			months[8] = "Agosto";
			months[9] = "setembro";
			months[10] = "Outubro"; 
			months[11] = "Novembro";
			months[12] = "Dezembro";
			today = new Date(); day = days[today.getDay() + 1]
			month = months[today.getMonth() + 1]
			date = today.getDate()
			year=today.getYear(); 
		if (year < 2000)
			year = year + 1900;

		document.getElementById("data").innerHTML = "   Belo Horizonte, " + date + " de " + month + " de " + year;  // hora no documento

      }

$(document).ready(function(){
	Tempo();
   $("#btnPesquisa").click(function () {
        erro = false;
        
        if ($("#txtPesquisa").val().length <= 2) {
            erro = true;
			exibirMsgErro_busca($("#txtPesquisa"), "M&iacute;nimo de 2 caracteres")
        }
		
		 if (!erro) {
			window.location = "../"+$("input[name*='tipo']:checked").val()+"/busca.asp?q="+$("#txtPesquisa").val();
			}
    });

	$('#txtPesquisa').keyup(function(event){
	  if (event.keyCode == '13') {
	   $("#btnPesquisa").click();
		  return false;
	  }
	});
		
	$(".search").click(function(){
		$("#txtPesquisa").focus();
								});
		
	// fim da pesquisa no site	
		
		$('#botoes-topo > a').hover(
			 function () {		 
			 //alert(this.title)
  				 $("#botoes-topo").addClass(this.title);
			   },
			   function (){
					$("#botoes-topo").removeClass(this.title);
		});

popup();
$('.pop-up-aberta').hide();

// botoes pagina auxiliar
	
	$('li.botao').hover(
			 function () {		 
				 $(this).animate({ height:"200px"});
			   },
			   function (){
					$(this).animate({ height:"10px"});
				});

});



// Flash ###

function flash(nome,width,height){
document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+width+"' height='"+height+"'>");
   document.write("<param name='movie' value='../"+ nome +"'>");
   document.write("<param name='quality' value='high'>");
   document.write("<embed src='../"+ nome +"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+width+"' height='"+height+"'></embed>");
   document.write("</object>");
}

function flasht(nome,width,height){
document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+width+"' height='"+height+"'>");
   document.write("<param name='movie' value='../"+ nome +"'>");
   document.write("<param name='quality' value='high'>");
   document.write("<param name='wmode' value='transparent'/>");
   document.write("<embed src='../"+ nome +"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+width+"' height='"+height+"' wmode='transparent'></embed>");
   document.write("</object>");
}

function ver_video(nome,width,height){
   document.write("<object width='"+width+"' height='"+height+"' >");
   document.write("<param name='movie' value='http://www.youtube.com/v/"+ nome +"&rel=0&color1=0xffffff&color2=0xffffff&border=1&hl=pt-br'></param>");
   document.write("<param name='wmode' value='transparent'/>");
   document.write("<embed src='http://www.youtube.com/v/"+ nome +"&rel=0&color1=0xffffff&color2=0xffffff&border=1&hl=pt-br' type='application/x-shockwave-flash'  wmode='transparent' width='"+width+"' height='"+height+"'></embed>");
   document.write("</object>");
}
