var Geral = {

	__construct: function() {
		_this = Geral;
       
		Cufon.replace(".cufon",{ fontFamily : "" });
		Cufon.replace(".cufon-hover",{ fontFamily : "", hover:'true' });	
		
	}
}

$(document).ready(function(){
	Geral.__construct();
	
	
	$('#rich').fadeIn(1200);
	$('#rich-btn').click(function(){$('#rich').fadeOut(800);});
	
	// AnimaÃ§Ã£o vitrine
	$('#anima-vitrine')
	.after('<div id="pg-anima">')
	.cycle({
		fx: 'zoom',
		timeout: 15000,
		pager: '#pg-anima'
	});
	//
	
	
	// AnimaÃ§Ã£o agenda
	$('.anima').cycle({
		timeout: 5000
	});
	//
	
	
	
	// MASK
	$('.cep').setMask({mask: '99.999-999'});
	$('.telefone').setMask({mask: '(99) 9999-9999'});
	$('.cpf').setMask({mask: '999.999.999-99'});
	$('.cnpj').setMask({mask: '99.999.999/9999-99'});
	$('.data').setMask({mask: '39/19/2999'});
	$('.uf').setMask({mask: 'zz'}); // Na class ".uf" colocar a seguinte definição: "input.uf{text-transform: uppercase;}"
	$('.dinheiro').setMask({mask: '99,999.999.999.999', type:'reverse'});
	$('.numero').setMask({mask: '999.999.999.999', type:'reverse'});
	//
	
	//colorbox
	$(".zoom").colorbox({current: "{current} de {total}"});
	//
	
	// abrir link externo
	$('.external').attr('target', '_blank');
	//
	
    // Fotos e Fts
	$(".foto_p").fadeTo('', 0.7);
	$(".foto_p").hover(function(){
		$(this).fadeTo('fast', 1);
	}, 
	function(){
		$(this).fadeTo('fast', 0.7);	
	});
	
	$(".foto_g img").css('display','none').fadeIn('slow');
	
	$(".foto_p a").click(function()
	{
		var linkfotao = $(this).attr("href");
        var legenda = $(this).parent('li').find('input[type=hidden]').val();

		var idfoto = $(this).attr("class");
		
		$("#"+idfoto+" img").attr('src', linkfotao);
		$("#"+idfoto+" img").fadeIn('slow');

        $('.legenda').html(legenda);
			
		return false;					 
	});
	//
	
	//Abas
     $(function(){
        $($(".aba").get(0)).show();
        $("#abas a.bt-aba").click(function(){
           $(this).addClass("active").parent().siblings().find('a.active').removeClass('active');
		   $(".aba").hide();
           var div = $(this).attr('href');
           $(div).show();
           return false;
        });
     });
	 //
	 
	// SlideDown - Up ou FadeIn - Out
	jQuery(function( $ ){
	var container = $( "#oculto" );
		$('#oculto').hide();
		$( ".open" ).click(
			function( event ){
			event.preventDefault();
				if (container.is( ":hidden" )){
				container.slideDown(  );
				} else {
				container.slideUp( );
				}
			}
		);		
	});
	// 	 
	
	// Add classe menu
	$.fn.menu = function() {
		var curUrl = window.location.href;
		return this.each(function() {
			$('ul li a', this).each(function() {
				var thisHref = $(this).attr('href');
				var domain   = window.location.hostname;
				var regex    = /^http/;
				if (!regex.test(thisHref))
					url = 'http://' + domain + thisHref;
				else
					url = thisHref;
				if (curUrl == url) {
					$(this).parent().addClass('ativado');
				}
					
			});
		});
	};
	$('.nav').menu();
	
});

