/*
 * 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 = 175;
		yOffset = 30;
		locxOffset = -10;
		locyOffset = -800;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* 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.rel +"' alt='Image preview' />"+ 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");
	});			
	$("a.location").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<div id='back'></div>");
		$("#container").append("<iframe id='location' width=\"800\" height=\"400\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\""+this.rel+"\"></iframe>");	
		$("#container").append("<div id='adres'><p>"+ c +"</p></div>");	
		$("#location").css("top",(220) + "px").fadeIn("fast");						
		$("#adres").css("top",(325) + "px").css("right",(215) + "px").fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#location").remove();
		$("#adres").remove();
		$("#back").remove();
    });	
	$("a.location").mousemove(function(e){
		$("#location")
			//.css("top",(e.pageY - locxOffset) + "px")
			//.css("left",(e.pageX + locyOffset) + "px");
	});			};


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