﻿/*
 * Link Fader 1.1, jQuery plugin
 * 
 * Copyright(c) 2009, Cedric Dugas
 * http://www.position-relative.net
 *	
 * Make any link using the image remplacement technique fade
 * Licenced under the MIT Licence
 */

jQuery(document).ready(function() {
	hoverOpacity.init( '.page-item-home > a', '0px 0px', '0px -45px');
	hoverOpacity.init( '.page-item-707 > a', '-144px 0px', '-144px -45px');
	hoverOpacity.init( '.page-item-794 > a', '-288px 0px', '-288px -45px');
	hoverOpacity.init( '.page-item-1838 > a', '-432px 0px', '-432px -45px');
	hoverOpacity.init( '.page-item-367 > a', '-576px 0px', '-576px -45px');

});

	
	
	
hoverOpacity = {
/*
parametri:
item:l'oggetto su cui viene attivata l'azione
xpos-start:
ypos-start:
xpos-end:
ypos-end:

*/
	init : function(item, xystart, xyend){
		jQuery(item).css({
			position:"relative",
			backgroundPosition:xystart,
			cursor:"pointer"
		})
		jQuery(item).each(function(){
			
			spanFader = document.createElement('span');
			myBG = jQuery(this).css("background-image")
			
			jQuery(this).append(spanFader);
		
			myBG = jQuery(this).css("background-image")
			spanWidth =  jQuery(this).css("width")
			spanHeight =  jQuery(this).css("height")
				
			jQuery(this).find("span").css({
				backgroundImage:myBG,
				backgroundPosition:xyend,
				position:"absolute",
				display:"block",
				cursor:"pointer",
				top:"0px",
				left:"0px",
				width:spanWidth,
				height:spanHeight,
				opacity:0,
				visibility:"visible"
			})
		})
		jQuery(item).hover(function () {
			jQuery(this).find("span").stop()
			jQuery(this).find("span:not(:animated)").animate({opacity: 1}, 300)
		},
		function () {
			jQuery(this).find("span").animate({opacity: 0},250)
		});
	}
}