/*
 * Tooltip - preview
 *
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by �ukasz Koszela
 * 
 * for more info go to
 * 
 */
var titleText; 

this.PreviewTooltip = function(){	
			
	xCoord = 200; //[PL] ogleg�o�� tooltipa po wsp�rzednej x od pozycji kursora
				 //[EN] tooltip x distance from cursor in pixels 
	yCoord = 20; //[PL] ogleg�o�� tooltipa po wsp�rzednej y od pozycji kursora
				 //[EN] tooltip y distance from cursor in pixels 
				
	$("a.PreviewTooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";	

		if(this.t=='toolImgPrev'){
			 titleText = ($(this).children('img').attr('title') != "" && $(this).children('img').attr('title') != undefined) ? $(this).children('img').attr('title'): "";
			$(this).children('img').attr('title','');
			$("body").append("<p id='toolImgPrev'><img src='"+ $(this).children('img').attr('src') +"' alt='JQuery plugin tootlip' /><br/>"+titleText+"</p>");	
			moveObject('#toolImgPrev',e);
		}else{
			moveObject("."+this.t,e);	
		}
    
		function moveObject(target,e){
			$(target)
				.css("top",(e.pageY - xCoord) + "px")
				.css("left",(e.pageX + yCoord) + "px")
				.css("position","absolute")
				.fadeIn("fast");
		}
	},
	
	function(){
		this.title = this.t;	
		if(this.t=='toolImgPrev'){
			$('#toolImgPrev').remove();
			$(this).children('img').attr('title',titleText);
		}else{
			$("."+this.t).fadeOut("fast");
		}		
		
    });	
	
	$("a.PreviewTooltip").mousemove(function(e){
		$("."+this.t+",#toolImgPrev")
			.css("top",(e.pageY - xCoord) + "px")
			.css("left",(e.pageX + yCoord) + "px");
	});		


};

//[PL] uruchom skrypt po za�adowaniu strony
//[EN] start the script on page load
$(document).ready(function(){
	PreviewTooltip();
});