﻿/*
 * Url preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.thickboxPreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
		
			$("a.thickbox").hover(function(e){
									   
		
		
			this.t = this.title;
			this.title = "";	
			var c = (this.t != "") ? " " + this.t : "";
			/*$("body").append("<p id='thickbox'><img src='"+ this.rel +"' alt='url preview' />"+ c +"</p>");*/
			
	//CONTROLLO SE IL TITLE ESISTE E SE COSì NON FOSSE NON FACCIO USCIRE
	//IL BOX VUOTO
	//CODICE DI STEFANO CASANOVA NCIWEB.IT
	if (this.t != "")
		{	

			$("body").append("<span id='thickbox'>"+ c +"</span>");
			$("#thickbox")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px")
				.fadeIn("fast");						
	//CHIUDO IL CONTROLLO IF
		}
		
		},
		function(){
			this.title = this.t;	
			$("#thickbox").remove();
		});	
		$("a.thickbox").mousemove(function(e){
			$("#thickbox")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px");
		});			
	};

// starting the script on page load
$(document).ready(function(){
	thickboxPreview();
});
