jQuery.fn.smoothScroll = function(){
	$(this).each(function(){
		var node = $(this);
		$(node).click(function(e){
			var anchor = $(this).attr('href');
			anchor = anchor.split("#");
			anchor = anchor[1];
			var t = 0;
			var found = false;
			var tName = 'a[name='+anchor+']';
			var tId = '#'+anchor;
			if (!!$(tName).length){
				t = $(tName).offset().top;
				if ($(tName).text() == ""){
					t = $(tName).parent().offset().top;
				}
				found = true;
			} else if(!!$(tId).length){
				t = $(tId).offset().top;
				found = true;
			}
			if (found){
				$(window).animate({
					scrollTop: t
				}, 500);
			}
		//e.preventDefault();
		});
	});
	var lAnchor = location.hash;
	if (lAnchor.length > 0){
		lAnchor = lAnchor.split("#");
		lAnchor = lAnchor[1];
		if (lAnchor.length > 0){
			$("body, html").scrollTop(0);
			var lt = 0;
			var lfound = false;
			var ltName = 'a[name='+lAnchor+']';
			var ltId = '#'+lAnchor;
			if (!!$(ltName).length){
				lt = $(ltName).offset().top;
				if ($(ltName).text() == ""){
					lt = $(ltName).parent().offset().top;
				}
				lfound = true;
			} else if(!!$(ltId).length){
				lt = $(ltId).offset().top;
				lfound = true;
			}
			if (lfound){
				$(window).animate({
					scrollTop: lt
				}, 500);
			}
		}
	}
}
jQuery('a.proximo-mes-festa').smoothScroll();		
jQuery(function(){
	jQuery("#header .thickbox").each(function() {
		jQuery(this).find('a').addClass('thickbox');
	});
	
	jQuery(".proximo-mes-festa").click(function() {
		jQuery(this).next().slideToggle('slow').siblings('.toggle:visible').slideToggle('slow');
		jQuery(this).siblings('.toggle').next('.toggle:visible').prev();
	});

	
	jQuery('.id_duby, .id_duby_plus').css({
		"overflow": "hidden"
	});
	jQuery('.id_duby_plus').find('.duby_plus').animate({
		'opacity': 0.2
	});
	jQuery('.id_duby_fade').find('.duby_fade').animate({
		'opacity': 1
	});
	jQuery('.id_duby_plus span').each(function() {
		w = parseInt(jQuery(this).prev().css('width').replace('px', ''));
		jQuery(this).css({
			"display": "block",
			"marginLeft": w+"px", 
			"position": "relative"
		});
	});
	jQuery('.id_duby span').each(function() {
		w = parseInt(jQuery(this).prev().css('width').replace('px', ''));
		jQuery(this).css({
			"display": "block",
			"marginLeft": w+"px", 
			"position": "relative"
		});
	});
	
	jQuery('.id_duby')
	.mouseenter(function(){
		w = parseInt(jQuery(this).find(".duby").css('width').replace('px', ''));
		w = (w - (w * 2));
		var $marginLefty = jQuery(this).find('span.duby_text');
		$marginLefty.stop().animate({
			marginLeft: 0
		});
		
		var $marginLeftyDiv = jQuery(this).find('.duby');
		$marginLeftyDiv.stop().animate({
			marginLeft: w
		});
		
	}).mouseleave(function(){
		w = parseInt(jQuery(this).find('.duby').css('width').replace('px', ''));
		var $marginLefty = jQuery(this).find('span.duby_text');
		$marginLefty.stop().animate({
			marginLeft: w
		});
		
		var $marginLeftyDiv = jQuery(this).find('.duby');
		$marginLeftyDiv.stop().animate({
			marginLeft: 0
		});
	
	});


	jQuery('.id_duby_plus')
	.mouseenter(function(e){
		var $marginLefty = jQuery(this).find('span.duby_text');
		$marginLefty.stop().animate({
			marginLeft: 0
		});
		jQuery(this).find('.duby_plus').stop().animate({
			'opacity': 0.6
		}, {
			duration:500
		});
	}).mouseleave(function(e){
		w = parseInt(jQuery(this).find('.duby_plus').css('width').replace('px', ''));
		var $marginLefty = jQuery(this).find('span.duby_text');
		$marginLefty.stop().animate({
			marginLeft: w
		});
		jQuery(this).find('.duby_plus').stop().animate({
			'opacity': 0.2
		}, {
			duration:500
		});
	});
	
	
	jQuery('.id_duby_fade')
	.mouseenter(function(){
		jQuery(this).find('.duby_fade').stop().animate({
			'opacity': 1
		}, {
			duration:500
		});
		jQuery(this).find('.duby_text').show();
	}).mouseleave(function(){
		jQuery(this).find('.duby_fade').stop().animate({
			'opacity': 1
		}, {
			duration:500
		});
		jQuery(this).find('.duby_text').hide();
	});
});
