$(document).ready(function(){
    //silent is golden
    $('.like-stats').mouseover(function(){
        $(this).find('span').css( {
            backgroundPosition: "0 0"
        } ).stop().animate({
            backgroundPosition:"(0 -15px)"
        }, {
            duration:500
        })
    })
    .mouseout(function(){
        $(this).find('span').stop().animate({
            backgroundPosition:"(0 0)"
        }, {
            duration:500
        })
    });
                                
    $('.comments-stats').mouseover(function(){
        $(this).find('span').css( {
            backgroundPosition: "0 -2px"
        } ).stop().animate({
            backgroundPosition:"(0 -18px)"
        }, {
            duration:500
        })
    })
    .mouseout(function(){
        $(this).find('span').stop().animate({
            backgroundPosition:"(0 -2px)"
        }, {
            duration:500
        })
    });
                                    
    //projetos
    $('#projects-home li a').hover(
        function(){
            $(this).find('img').stop().animate({
                opacity: 0.7
            }, 500, 'easeInQuint');
            $(this).find('.goto-project').stop().animate({
                opacity: 1
            }, 500, 'easeInQuint');
        },
        function(){
            $(this).find('img').stop().animate({
                opacity: 1
            }, 500, 'easeOutQuint');
            $(this).find('.goto-project').stop().animate({
                opacity: 0
            }, 500, 'easeInQuint');
        }
        );
                    
    //tooltips o3CUE88kfTGd
    /*
                * You'll need your own API key, don't abuse mine please!
                * Get yours here: http://www.websnapr.com/free_services/
                */
    var apiKey = 'o3CUE88kfTGd';

    // Notice the use of the each method to gain access to each element individually
    $('#projects-home li a').each(function() {
        // Grab the URL from our link
        var url = encodeURIComponent( $(this).attr('href') ),
        title = $(this).attr('title');

        // Setup the tooltip with the content
        $(this).qtip(
        {
            content: '<img src="http://images.websnapr.com/?url=' + url + '&key=' + apiKey + '&hash=' + encodeURIComponent(websnapr_hash) + '" alt="Carregando miniatura..." width="202" height="152" /> <br />' + title,
            position: {
                my: 'top center',
                at: 'bottom center',
                viewport: $(window) // Attempt to keep it on screen at all times
            },
            style: {
                classes: 'ui-tooltip-thumbnail ui-tooltip-shadow'
            }
        });
    });
    
    
    var $featured_content = jQuery('#featured-light #main-featured-slider'),
		$featured_readmore_center = $featured_content.find('a.et_centered');
	
	if ( $featured_content.length ) {
		var et_slider_settings = { pauseHoverElement : '#featured-light' };
		
		if ( $featured_content.is('.et_slider_auto') ) {
			var et_slider_autospeed_class_value = /et_slider_autospeed_(\d+)/g
				et_slider_autospeed = et_slider_autospeed_class_value.exec( $featured_content.attr('class') );
			
			et_slider_settings.autoSliderSpeed = et_slider_autospeed[1];
			et_slider_settings.auto = true;
			if ( $featured_content.is('.et_slider_pause') ) et_slider_settings.pauseOnHover = true;
		}
		$featured_content.et_motion_slider( et_slider_settings );
	
		if ( $featured_readmore_center.length ){
			$featured_readmore_center.each( function( i ){
				var $thisLink = jQuery(this),
					divWidth = $thisLink.parent().width(),
					thisLinkWidth = $thisLink.width(),
					thisOffset = Math.ceil( ( divWidth - thisLinkWidth ) / 2 );
				$thisLink.css( { 'marginLeft' : thisOffset, 'visibility' : 'visible' } );
			} );
		}
	}
                
});
