/*
 * 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 = 300;
		//yOffset = 20;

		// 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){
		if (this.rev == '1'){yOffset = -50;xOffset = 330;ht = 300;}
		else if (this.rev == '2'){yOffset = -150;xOffset = 330;ht = 300;}
		else if (this.rev == '3'){yOffset = -250;xOffset = 330;ht = 300;}
		else if (this.rev == '4'){yOffset = 20;xOffset = 300;wd = 350;}
		else if (this.rev == '5'){yOffset = 20;xOffset = 175;wd = 175;}
		else if (this.rev == ''){yOffset = 20;xOffset = 300;ht = 400;}
		this.t = this.title;
		this.title = "";
		var c = (this.t != "") ? "<br/><font style='font-family:arial;font-size:9pt'>" + this.t + "</font>" : "";
		if (this.rev == '4') {
		  $("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='url preview' width='"+ wd +"'/>"+ c +"</p>");
		} else if (this.rev == '5') {
		  $("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='url preview' width='"+ wd +"'/>"+ c +"</p>");
		} else {
		  $("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='url preview' height='"+ ht +"'/>"+ 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){
		if (this.rev == '1'){yOffset = -50;xOffset = 330;}
		else if (this.rev == '2'){yOffset = -150;xOffset = 330;}
		else if (this.rev == '3'){yOffset = -250;xOffset = 330;}
		else if (this.rev == '4'){yOffset = 20;xOffset = 300;}
		else if (this.rev == '5'){yOffset = 20;xOffset = 175;}
		else if (this.rev == '') {yOffset = 20;xOffset = 300;}
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});

};

this.screenshot2Preview = function(){
	/* CONFIG */

		x2Offset = 300;
		y2Offset = -400;

		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result

	/* END CONFIG */

	$("a.screenshot2").hover(function(e){
		this.t2 = this.title;
		this.title = "";
		var c2 = (this.t2 != "") ? "<br/><font style='font-family:arial;font-size:9pt'>" + this.t2 + "</font>" : "";
		$("body").append("<p id='screenshot2'><img src='"+ this.rel +"' alt='url preview' height='400'/>"+ c2 +"</p>");
		$("#screenshot2")
			.css("top",(e.pageY - x2Offset) + "px")
			.css("left",(e.pageX + y2Offset) + "px")
			.fadeIn("fast");
    },
	function(){
		this.title = this.t2;
		$("#screenshot2").remove();
    });
	$("a.screenshot2").mousemove(function(e){
		$("#screenshot2")
			.css("top",(e.pageY - x2Offset) + "px")
			.css("left",(e.pageX + y2Offset) + "px");
	});


};

// starting the script on page load
$(document).ready(function(){
	screenshotPreview();
	screenshot2Preview();
});

