/*
 * 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.screenshotPreview = function(){	
	/* CONFIG */
		
		xOffset = 60;
		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.screenshot").hover(function(e){
		this.t = this.title;
		this.tipo = this.rev;		
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		var immagine = "";
		var dimW = "320";
		var dimH = "240";
		var imgPreview = "";
		if (this.rel.length > 0)
		{		    
		    switch (this.tipo)
		    {
		        case "1":
		        default:
		            //immagine		 
		            immagine = "<img class='anteprima' src='"+ this.rel +"' alt='url preview' />";
		            break;
		        case "2":		        
		            //video audio		 
		            var nome = this.rel;           
		            if (nome.indexOf(".mp3") != -1)
                    {                        
                        dimW = "265";
                        dimH = "110";                     
                        imgPreview = "../Player/previewAudio.jpg";                     
                    }                    
		            //alert(dimW + "-"+ dimH +"-" + imgPreview);
		            immagine = "<embed type=\"application/x-shockwave-flash\" src=\"../Player/player.swf\" style=\"\" id=\"player\" name=\"player\" quality=\"high\" allowfullscreen=\"true\" allowscriptaccess=\"always\" playlistfile=\"../Player/playlist.xml\" flashvars=\"display.showmute=false&amp;icons=true&amp;controlbar=bottom&amp;screencolor=000000&amp;stretching=none&amp;autostart=True&amp;file="+ this.rel +"&amp;image="+imgPreview+"\" width=\""+dimW+"\" height=\""+dimH+"\" />";
		            //immagine = "<embed type=\"application/x-shockwave-flash\" src=\"../Player/player.swf\" style=\"\" id=\"player\" name=\"player\" quality=\"high\" allowfullscreen=\"true\" allowscriptaccess=\"always\" playlistfile=\"../Player/playlist.xml\" flashvars=\"display.showmute=false&amp;icons=true&amp;controlbar=bottom&amp;screencolor=000000&amp;stretching=none&amp;autostart=True&amp;file="+ this.rel +"&amp;image=\" width=\"320\" height=\"240\" />";
		            break;
		        case "3":		        
		            //testo
		            immagine = this.rel + "<br/>";
		            break;
		    }		    
		}
		
		$("body").append("<p id='screenshot'>" + immagine + c +"</p>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	screenshotPreview();
});
