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

/*
 * 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(path){
	/* CONFIG */

		var xOffset = 10;
		var yOffset = 10;
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result

	/* END CONFIG */
	jQuery("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";
		var winbreite = jQuery(window).width();
		var winhoehe  = jQuery(window).height();
		var c = (this.t != "") ? "<br/>" + this.t : "";
      	var bild  = path + this.rel;
		jQuery("body").append("<p id='preview'><img id='imgpreview' src='"+ bild +"' alt='Image preview' />"+ c +"</p>");
		var posY = e.pageY+xOffset;
		var posX = e.pageX+yOffset;
		
		jQuery("#preview")
			.css("top",(posY) + "px")
			.css("left",(posX) + "px")
			.fadeIn("fast");
			
		var breite = jQuery("#imgpreview").width();
		var hoehe  = jQuery("#imgpreview").height();
		if ((breite+posX) > winbreite  ){
			posX = (posX-breite);
		}
		if ( (hoehe+posY) > winhoehe  && posY > (winhoehe / 2 )  ){
			posY = (posY-hoehe+(2*xOffset));
		}
		jQuery("#preview")
			.css("top",(posY) + "px")
			.css("left",(posX) + "px")
			.fadeIn("fast");
		//alert("posx"+breite+" posY"+hoehe);		
    },
	function(){
		this.title = this.t;
		jQuery("#preview").remove();
    });
	jQuery("a.preview").mousemove(function(e){
		var winbreite = jQuery(window).width();
		var winhoehe  = jQuery(window).height();
		var posY = e.pageY+xOffset;
		var posX = e.pageX+yOffset;
		var breite = jQuery("#imgpreview").width();
		var hoehe  = jQuery("#imgpreview").height();
		if ( (breite+posX) > winbreite ){
			posX = (posX-breite);
		}
		if ((hoehe+posY) > winhoehe &&  posY > (winhoehe/2) ){
			posY = (posY-hoehe-(2*xOffset));
		}
		jQuery("#preview")
			.css("top",(posY) + "px")
			.css("left",(posX) + "px");
	});
};


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