/*
 * 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 = 300;
		yOffset = 50;

		xOffset2 = 300;
		yOffset2 = -700;

		xOffset3 = 300;
		yOffset3 = -575;
		
		xOffset4 = 300;
		yOffset4 = -855;
		
		
		// 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 = "";
		img_src = this.getAttribute('rel');
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ img_src +"' 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");
	});
	
	// ADDED BY CJ - PREVIEW 2
	
	$("a.preview2").hover(function(e){
		this.t = this.title;
		this.title = "";
		img_src = this.getAttribute('rel');
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ img_src +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset2) + "px")
			.css("left",(e.pageX + yOffset2) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview2").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset2) + "px")
			.css("left",(e.pageX + yOffset2) + "px");
	});
	
	// ADDED BY CJ - PREVIEW - FURNITURE
	
	$("a.preview_col2").hover(function(e){
		this.t = this.title;
		this.title = "";
		img_src = this.getAttribute('rel');
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ img_src +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset3) + "px")
			.css("left",(e.pageX + yOffset3) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview_col2").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset3) + "px")
			.css("left",(e.pageX + yOffset3) + "px");
	});
	
	$("a.preview_col3").hover(function(e){
		this.t = this.title;
		this.title = "";
		img_src = this.getAttribute('rel');
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ img_src +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset4) + "px")
			.css("left",(e.pageX + yOffset4) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview_col3").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset4) + "px")
			.css("left",(e.pageX + yOffset4) + "px");
	});
	
	// END ADDED BY CJ


};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});
