/*
 * jQuery Delay - A delay function
 * Copyright (c) 2009 Clint Helfers - chelfers(at)gmail(dot)com | http://blindsignals.com
 * Dual licensed under MIT and GPL.
 * Date: 7/01/2009
 * @author Clint Helfers
 * @version 1.0.0
 *
 * http://blindsignals.com/index.php/2009/07/jquery-delay/
 */

$.fn.delay = function( time, name ) {

    return this.queue( ( name || "fx" ), function() {
        var self = this;
        setTimeout(function() { $.dequeue(self); } , time );
    } );

};

/*
 * 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 = 30;
		yOffset = 10;
		iDelay = 500;
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		//var he;
	/* END CONFIG */
	$("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		//var c = (this.t != "") ? /*"<br/>" +*/ this.t : "";
		var c = (this.t != "") ? this.t : "";
		$("body").append("<p id='screenshot'>" + (this.rel?"<img src='"+ this.rel +"' alt='url preview' />":"") + "<span>"+ c +"</span></p>");								 
		$("#screenshot")
			.css("top",(e.pageY - yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px")
			.delay(iDelay)
			.fadeIn("fast");
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px");
	});
};


// starting the script on page load
$(document).ready(function(){
	screenshotPreview();
});
