/*
	BIG THANKS TO Alen Grakalic! WE LOVE YOU!
	
 * Image 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.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 150;
		yOffset = -450;
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.href +"' alt='loading...' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

this.screenshotPreview = function(){	
	/* CONFIG */
		
		xOffset2 = 10;
		yOffset2 = 30;
		
	/* END CONFIG */
	$("a.screenshot").hover(function(e){
		this.t = '';// this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='loading...' />"+ c +"</p>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset2) + "px")
			.css("left",(e.pageX + yOffset2) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset2) + "px")
			.css("left",(e.pageX + yOffset2) + "px");
	});			
};


this.screenshotPreviewLeft = function(){	
	/* CONFIG */
		
		xOffset3 = 10;
		yOffset3 = -200;
		
	/* END CONFIG */
	$("a.screenshotLeft").hover(function(e){
		this.t = '';// this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='screenshotLeft'><img src='"+ this.rel +"' alt='loading...' />"+ c +"</p>");								 
		$("#screenshotLeft")
			.css("top",(e.pageY - xOffset3) + "px")
			.css("left",(e.pageX + yOffset3) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshotLeft").remove();
    });	
	$("a.screenshotLeft").mousemove(function(e){
		$("#screenshotLeft")
			.css("top",(e.pageY - xOffset3) + "px")
			.css("left",(e.pageX + yOffset3) + "px");
	});			
};

// starting the script on page load
$(document).ready(function(){
	imagePreview();
	screenshotPreview();
	screenshotPreviewLeft();
});