// Posts preview background images - Animates the "background" images of posts preview by fading them to a transparent white when the mouse hovers them.
// JS by enricoripalti.com
// Design by enricoripalti.com
// No anouthorized reproduction is allowed apart from the usage allowed by the purchase/ownership of the theme/website it comes with.

jQuery(document).ready(function(){
	// Fades the Background of posts in the blog home page
	fadeBg();
	fadeBgInverted();
});

// Handles the actual img fading by using the hover event handlers
function fadeBg()
{
	jQuery("img.hoverable_img_up").hover(fadeIn, fadeOut);
}

function fadeIn()
{
	jQuery(this).stop().animate({"opacity": "0.15"}, "normal");
}

function fadeOut()
{
	jQuery(this).stop().animate({"opacity": "1"}, "slow");
}

// inverted versions of the above functions, where the top image gets faded IN
function fadeBgInverted()
{
	var hoverObjects = jQuery("img.hoverable_img_hover_inverted");
	hoverObjects.css({"opacity": "0"}, "normal");
	jQuery("div.slider_block").hover(fadeInInverted, fadeOutInverted);
}

function fadeInInverted()
{
	jQuery(this).children("a.inverted_hover").children("img.hoverable_img_up_inverted").stop(false, true).animate({"opacity": "0.2"}, "normal");
	jQuery(this).children("a.inverted_hover").children("img.hoverable_img_hover_inverted").stop(false, true).animate({"opacity": "1"}, "fast");
	jQuery(this).children("div.block_subtitle").stop(false, true).animate({"right": "+=230"}, "fast");
	jQuery(this).children("div.block_text").stop(false, true).animate({"top": "+=260"}, "fast");
	jQuery(this).children("div.block_shares").stop(false, true).animate({"top": "+=96"}, "fast");
	jQuery(this).children("a.inverted_hover").children("div.block_title").stop(false, true).animate({"bottom": "+=50"}, "fast");
}

function fadeOutInverted()
{
	jQuery(this).children("a.inverted_hover").children("img.hoverable_img_up_inverted").stop(false, true).animate({"opacity": "1"}, "slow");
	jQuery(this).children("div.block_text").stop(false, true).animate({"top": "-=260"}, "fast");
	jQuery(this).children("div.block_subtitle").stop(false, true).animate({"right": "-=230"}, "fast");
	jQuery(this).children("div.block_shares").stop(false, true).animate({"top": "-=96"}, "fast");
	jQuery(this).children("a.inverted_hover").children("div.block_title").stop(false, true).animate({"bottom": "-=50"}, "fast", "swing", function() {
		jQuery(this).parent().parent().children("a.inverted_hover").children("img.hoverable_img_hover_inverted").stop(false, true).animate({"opacity": "0"}, "slow");
	}
	);
}




