(function($) {	
	$.titleHover = {
		blocked: false,
		defaults: {
			duration: 700,
			event: false,
			separator: '',
			direction: 'left'
		}
	};
	
	$.fn.titleHover = function(settings) {
		settings = $.extend({}, $.titleHover.defaults, settings);
		
		$.fn.titleHover.writetitle(settings,this);
		
		$(this).hover(function(){
			switch(settings.direction){
				case 'left':
				case 'rigth':
					spostamento=$(this).width();
				break;

				case 'top':
				case 'bottom':
					spostamento=$(this).height();
				break;
			}
			
			$.fn.titleHover.sposta(settings,this,spostamento);
		},function(){
			$.fn.titleHover.sposta(settings,this,0);
		});
	}
		
	$.fn.titleHover.writetitle = function(settings,el){
		$(el).each(function(){
			img=$(this).find('img');
						
			testo=img.attr('title');
			
			if(testo!=undefined){
				testo_arr=testo.split(' | ');
				testo=testo_arr.join('<br />');
			}else{
				testo='';
			}
			
			$(this).append('<p>'+testo+'</p>');
		});
	}
	
	$.fn.titleHover.sposta = function(settings,el,spostamento){
		img=$(el).find('img');
		
		img.animate(
			{left:spostamento+'px'},
			{queue:false,duration:settings.duration}
		);
	}
})(jQuery);

