// Put all your lovely jQuery / Javascript goodies right down here.
  
 

//TOOLTIP
// create custom animation algorithm for jQuery called "bouncy"
$.easing.bouncy = function (x, t, b, c, d) {
    var s = 1.70158;
    if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
    return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
}

// create custom tooltip effect for jQuery Tooltip
$.tools.tooltip.addEffect("bouncy",

	// opening animation
	function(done) {
		this.getTip().animate({top: '+=15'}, 500, 'bouncy', done).show();
	},

	// closing animation
	function(done) {
		this.getTip().animate({top: '-=15'}, 500, 'bouncy', function()  {
			$(this).hide();
			done.call();
		});
	}
);
$(document).ready(function(){
	$(".btn-container").tooltip({ effect: 'bouncy',position: 'top center'});
	$('#coda-slider-2').codaSlider({autoSlide: true,autoSlideInterval: 7000,autoSlideStopWhenClicked: true,autoHeight:false, slideEaseDuration:2000});
	
	$("a[href^=#]").each(function() {
		oldHref=$(this).attr("href") ;
		var oldHash = oldHref.indexOf("#") >= 0 ? oldHref.substring(oldHref.indexOf("#") ) : "";
		$(this).attr("href",window.location.href.replace(document.location.hash, "")+oldHash ) ;
	}) ;
	
	$.waypoints.settings.scrollThrottle = 30;
	$('.inside-download').waypoint(function(event, direction) {
		$(this).parent().toggleClass('sticky', direction === "down");
		event.stopPropagation();
	});
	$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'overlayColor'		: '#000',
				'overlayOpacity'	: 0.9
			});
	$("#video").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});
	$("a.fadeHover").css('display','block') ;
	
	var config = {    
	     over: callFade, // function = onMouseOver callback (REQUIRED)    
	     timeout: 100, // number = milliseconds delay before onMouseOut    
	     out: removeFade, // function = onMouseOut callback (REQUIRED)   
		 interval:50 
	};
	$("a.fadeHover").hoverIntent( config );
	function callFade() {
		$(this).css("background", "#333333 url( assets/templates/heredis-mac/images/"+$(this).attr("hreflang")+".png) center center no-repeat") ;
		$("img", this).stop().animate({ "opacity": 0.2}, 200);
	}
	function removeFade() {
		$("img", this).stop().animate({ "opacity": 1 }, 250);
		$(this).css('background', '') ;
	}
});


