$(function(){
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');

			if ($target.length) {
				var targetOffset = $target.offset().top;
		
				if($('body').hasClass('ie7')) {
					$('html,body').animate({scrollTop: targetOffset}, 800);
				}else{
					$('html,body').animate({scrollTop: (targetOffset - 160)}, 800);
				}
				
				return false;
			}
		}
	});
	
	$('nav li a').hover(function () {
	    $(this).find('span').animate({
	        top: 0
	    }, 250);
	}, function () {
	    $(this).find('span').animate({
	        top: -75
	    }, 250);
	});
	
	$('.destaques').tinycarousel({controls: true, animation: true, interval: true, intervaltime: 5000 });

	if($('body').hasClass('ie7')) {
		$('.img_box').tinycarousel({controls: true, interval: true, intervaltime: 6000 });
	}else{
		$('#about .img_box').tinycarousel({controls: true });
	}	


	$("a[class^='pop']").fancybox({ 'height': 550, 'padding': 0, 'width': 750,  'autoScale': false, 'type': 'iframe', 'scrolling': 'no'});
	$(".zoom").live('click', function(e) {
		e.preventDefault();
		var href = $(this).attr('href');
		//alert(href);
		$.fancybox(
			{ 
			'href':	href,
			'height': 485, 
			'padding': 0, 
			'width': 940,  
			'autoScale': false, 
			'type': 'iframe', 
			'scrolling': 'no',
			'overlayOpacity':	0.7,
			'overlayColor':	'#000'
			}
		);
	});
	
	$(".thumb-port a").animate({"opacity": "0"}, "fast");
	$(".thumb-port a").hover( 
		function () {
			$(this).animate({opacity: 1}, 'slow');
		},
		function () {
			$(this).animate({opacity: 0}, 'slow');
		}
	);
	
	
	$.waypoints.settings.scrollThrottle = 0;
	$('#master').waypoint( function(event, direction) {
	}, {
		offset: '-100%'
	}).find('#mainnav').waypoint(function(event, direction) {
		$(this).toggleClass('bg', direction === "down");
		event.stopPropagation();
	});


	$footer = $('footer'),
	opts = {
		offset: '100%'
	};
	
	
	
});
