//FLASH
function flash(src,w,h,string_values) {
    if(string_values==undefined)
        document.write('<object type="application/x-shockwave-flash" data="'+src+'" width="'+w+'" height="'+h+'" wmode="transparent"><param name="movie" value="'+src+'" /><param name="wmode" value="transparent" /></object>');
    else
        document.write('<object type="application/x-shockwave-flash" data="'+src+'" width="'+w+'" height="'+h+'" wmode="transparent"><param name="movie" value="'+src+'" /><param name="wmode" value="transparent" /><param name="FlashVars" value="'+string_values+'" /></object>');
}

//FLASH
function flashNoTransparent(src,w,h,string_values) {
    if(string_values==undefined)
        document.write('<object type="application/x-shockwave-flash" data="'+src+'" width="'+w+'" height="'+h+'"><param name="movie" value="'+src+'" /></object>');
    else
        document.write('<object type="application/x-shockwave-flash" data="'+src+'" width="'+w+'" height="'+h+'" ><param name="movie" value="'+src+'" /><param name="FlashVars" value="'+string_values+'" /></object>');
}

//BROWSER
isOpera = (navigator.userAgent.toLowerCase().indexOf('opera')>-1);
isKonqueror = (navigator.userAgent.toLowerCase().indexOf('konqueror')>-1);
isIE  = ((!isOpera)&&(navigator.userAgent.toLowerCase().indexOf('msie')>-1));
isIE7 = ((!isOpera)&&(navigator.userAgent.toLowerCase().indexOf('msie 7')>-1));
isIE6 = ((isIE)&&(!isIE7));
isMozilla = ((!isOpera)&&(!isKonqueror)&&(!isIE));

//JQUERY
$(document).ready(function() {
   //CARROSSEL
   jQuery('#box-galeria-thumbs, #box-galeria-thumbs1, #box-galeria-thumbs2, #box-galeria-thumbs3, #box-galeria-thumbs4').jcarousel({});

   //PNG FIX
   $('BODY').pngFix();

   //BOX AGENDA
   $('.box-agenda').hover(
      function(){
         $(this).children('.box-data-mod1').css('background-color', '#CB0069');
      },
      function(){
         $(this).children('.box-data-mod1').css('background-color', '#DBDBDB');
      }
   );

   //BLOCO PARTICULARES
   $('#bloco-particulares .box-foto').hover(
      function(){
         $(this).children().find("SPAN, B").css('background-color', '#0DA9F6');
      },
      function(){
         $(this).children().find("SPAN, B").css('background-color', '#CB0069');
      }
   );

   //LINKS TARGET BLANK
   $('.external').click(function() { window.open(this); return false; });

   //RODAP�
   var height = document.documentElement.clientHeight;
   if(($("#layout").height() + $("#rodape").height()) < height){
      $("#layout").height(height - $("#rodape").height());
   }

   //FAKE FILE
   $(".campo-flyer").change(function(){
      $(".campo-fakefile").val($(this).val());
   });

   //Fake Combo
   var valorInicail = $(".lista-combo li:first").text();
   $(".valor-combo").text(valorInicail.substr(0,19));

   $(".combo-mascara").hover(
      function(){
         $(this).find('ul').show();
         $(this).find('ul').children('LI').each(function(){
            $(this).hover(
               function(){
                  $(this).css('background-color', '#FF0084');
               },
               function(){
                  $(this).css('background-color', '#CB0069');
               }
            );
         });
      },
      function(){
         $(this).find('ul').hide();
      }
   );

   $(".lista-combo li").click(function(){
       $(".valor-combo").empty();
       $(this).parent().parent().find('.valor-combo').append($(this).text().substr(0,19));
       $(this).parent().parent().find('input').attr('value', $(this).attr('class'));
   });

   //BOX GALERIA IMAGENS MOD1
   $('.box-galeria-imagens-mod1').hover(
      function(){
         $(this).find('.over').addClass('show');
      },
      function(){
         $(this).find('.over').removeClass('show');
      }
   );

   //BLOCO COMENTARIOS
   $('#bloco-comentarios .box-foto').hover(
      function(){
         $(this).children().find("SPAN, B").css('background-color', '#FF0084');
      },
      function(){
         $(this).children().find("SPAN, B").css('background-color', '#0DA9F6');
      }
   );

   $('#bloco-top-10 .box-foto').hover(
      function(){
         var tipoImg = $(this).children().children(".img-on-off").attr("src");
         $(this).children().children(".img-on-off").attr("src", tipoImg.replace('-off.gif', '-on.gif'));
      },
      function(){
         var tipoImg = $(this).children().children(".img-on-off").attr("src");
         $(this).children().children(".img-on-off").attr("src", tipoImg.replace('-on.gif', '-off.gif'));
      }
   );

   //ABAS
   $('.conteudo-aba').hide();
   $('.conteudo-aba:first').show();
   $('.aba').click(function(){
      $('.conteudo-aba').hide();
      $('.listagem-abas').children('li').removeAttr('class');
      $(this).parent('li').attr('class', 'ativo');
      $('#conteudo-'+$(this).attr('id')).show();
   });
   $('.conteudo-aba-mod2').hide();
   $('.conteudo-aba-mod2:first').show();
   $('.aba').click(function(){
      $('.conteudo-aba-mod2').hide();
      $('.listagem-abas-mod2').children('li').removeAttr('class');
      $(this).parent('li').attr('class', 'ativo');
      $('#conteudo-'+$(this).attr('id')).show();
   });

   //GALERIA
   $(".galeria-imagens .thumb").click(function(){
      var getImg = $(this).find('IMG').attr('src');
      var replaceImg = getImg.replace('thumb-', 'img-');
      $(this).parents('.galeria-imagens').find('.box-galeria-ampliada').children('IMG').attr('src', replaceImg);

      $(this).parents('.jcarousel-list').children('LI').each(function(){
         $(this).removeClass('ativo');
      });
      $(this).addClass('ativo');
      return false;
   });
  
   $(".box-bt-anterior").click(function(){
      $(this).parents('.galeria-imagens').find(".jcarousel-list").children('.ativo').prev().click();
      $(this).parents('.galeria-imagens').find('.jcarousel-prev-horizontal').click();
      return false;
   });
   $(".box-bt-proxima").click(function(){
      $(this).parents('.galeria-imagens').find(".jcarousel-list").children('.ativo').next().click();
      $(this).parents('.galeria-imagens').find('.jcarousel-next-horizontal').click();
      return false;
   });
 

   //EXPANDE E COMPRIME O DETALHES DOS EVENTOS
   $(".evento-mg").toggle(
      function(){
         var caminhoImg = $(this).children("IMG");
         $(this).next(".box-evento-detalhes").slideDown("fast");
         caminhoImg.attr("src", caminhoImg.attr("src").replace("-expandir-off.gif", "-comprimir-off.gif"));
         caminhoImg.attr("alt", "Comprimir Conteúdo");
         caminhoImg.attr("title", "Comprimir Conteúdo");
         $(this).parents('.box-evento').addClass('evento-ativo-click');
      },
      function(){
         var caminhoImg = $(this).children("IMG");
         $(this).next(".box-evento-detalhes").slideUp("fast");
         caminhoImg.attr("src", caminhoImg.attr("src").replace("-comprimir-off.gif", "-expandir-off.gif"));
         caminhoImg.attr("alt", "Expandir Conte�do");
         caminhoImg.attr("title", "Expandir Conte�do");
         $(this).parents('.box-evento').removeClass('evento-ativo-click');
   });
   $(".evento-mg").mouseover(function(){
      $(this).parents('.box-evento').addClass('evento-ativo');
   });
   $(".evento-mg").mouseout(function(){
      $(this).parents('.box-evento').removeClass('evento-ativo');
   });

   //M�scara Senha
   $(".mascara-senha").click(function(){
      $(this).hide();
      $("#campo-senha-cad").focus();
   });
   $(".mascara-repetir-senha").click(function(){
      $(this).hide();
      $("#campo-repetir-senha-cad").focus();
   });
   $("#campo-senha-cad").blur(function(){
      if($(this).attr('value') == ""){
         $(".mascara-senha").show();
      }
   });
   $("#campo-repetir-senha-cad").blur(function(){
      if($(this).attr('value') == ""){
         $(".mascara-repetir-senha").show();
      }
   });

   //EXPANDE E COMPRIME OS GUIAS
   $(".box-guia-mg").toggle(
      function(){
         var caminhoImg = $(this).children("IMG");
         $(this).next(".box-guia-detalhes").show();
         $(this).addClass('guia-ativo-click');
      },
      function(){
         var caminhoImg = $(this).children("IMG");
         $(this).next(".box-guia-detalhes").hide();
         $(this).removeClass('guia-ativo-click');
   });
   $(".box-guia-mg").mouseover(function(){
      $(this).addClass('guia-ativo');
   });
   $(".box-guia-mg").mouseout(function(){
      $(this).removeClass('guia-ativo');
   });
   $(".box-guia-detalhes").each(function(){
      $(this).hide();
   });
   
   //Inicio Máscaras
	$("#campo-nascimento-cad").mask("99/99/9999");
	$("#campo-telefone-cad").mask("(99) 9999-9999");
	$("#campo-celular-cad").mask("(99) 9999-9999");
	$("#campo-telefone-fc").mask("(99) 9999-9999");
	$("#campo-celular-fc").mask("(99) 9999-9999");
	$("#campo-data-busca").mask("99/99/9999");
	
	$("#campo-celular-dados").mask("(99) 9999-9999");
	$("#campo-telefone-dados").mask("(99) 9999-9999");
	
	$("#campo-horario").mask("99:99:99");
	$("#campo-data").mask("99/99/9999");
	$("#campo-telefone").mask("(99) 9999-9999");
	$("#campo-celular").mask("(99) 9999-9999");

	
   //Fim Máscaras   

   //NOME NOS CAMPOS
   $('#campo-email-login').example("email");
   $('#campo-senha-login').example("senha");
   $('#campo-nome').example("nome");
   $('#campo-email').example("email");
   $('#campo-data-busca').example("dd/mm/aaaa");
   $('#campo-evento-busca').example("evento");
   $('#campo-busca-blog').example("busca");
   $('#campo-seu-nome').example("seu nome");
   $('#campo-seu-email').example("seu e-mail");
   $('#text-area-comentario').example("comentário");
   $('#campo-telefone').example("telefone");
   $('#campo-celular').example("celular");
   $('#campo-endereco').example("endereço");
   $('#campo-cidade').example("cidade");
   $('#campo-local').example("local");
   $('#campo-horario').example("horário");
   $('#campo-data').example("data");
   $('#campo-nome-evento').example("nome do evento");
   $('#textarea-descricao').example("descrição");
   $('#campo-nome-fc').example("nome");
   $('#campo-email-fc').example("email");
   $('#campo-telefone-fc').example("telefone");
   $('#campo-celular-fc').example("celular");
   $('#campo-cidade-fc').example("cidade");
   $('#textarea-mensagem-fc').example("mensagem");
   $('#campo-nome-cad').example("nome");
   $('#campo-sobrenome-cad').example("sobrenome");
   $('#campo-nascimento-cad').example("nascimento (dd/mm/aaaa)");
   $('#campo-email-cad').example("email");
   $('#campo-telefone-cad').example("telefone");
   $('#campo-celular-cad').example("celular");
   $('#campo-endereco-cad').example("endereço");
   $('#campo-cidade-cad').example("cidade");
   $('#campo-nome-con').example("nome");
   $('#campo-email-con').example("email");
   $('#campo-telefone-con').example("telefone");
   $('#campo-celular-con').example("celular");
   $('#campo-cidade-con').example("cidade");
   $('#textarea-mensagem-con').example("mensagem");
   $('#campo-nome-destinatario').example("nome do destinatário");
   $('#campo-email-destinatario').example("email do destinatário");
   $('#textarea-mensagem').example("mensagem");

});
