/*
 * 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 = 180;
		yOffset = 15;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	
	/* PORTFOLIO */
	$("a.portfoliopreview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='portfoliopreview'><img src='"+ this.rel +"' alt='url preview' />"+ c +"</p>");								 
		$("#portfoliopreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#portfoliopreview").remove();
    });	
	$("a.portfoliopreview").mousemove(function(e){
		$("#portfoliopreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});	
	
	/* ART */
	$("a.artpreview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='artpreview'><img src='"+ this.rel +"' alt='url preview' />"+ c +"</p>");								 
		$("#artpreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#artpreview").remove();
    });	
	$("a.artpreview").mousemove(function(e){
		$("#artpreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
	
	/* MUSIC */
	$("a.musicpreview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='musicpreview'><img src='"+ this.rel +"' alt='url preview' />"+ c +"</p>");								 
		$("#musicpreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#musicpreview").remove();
    });	
	$("a.musicpreview").mousemove(function(e){
		$("#musicpreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});	
	
	/* STUFF */
	$("a.stuffpreview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='stuffpreview'><img src='"+ this.rel +"' alt='url preview' />"+ c +"</p>");								 
		$("#stuffpreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#stuffpreview").remove();
    });	
	$("a.stuffpreview").mousemove(function(e){
		$("#stuffpreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});	
};


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