this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = 350;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
		

		$(".tooltip").hover(function(e){
			this.t = this.title;
			this.title = "";	
			var c = (this.t != "") ? "<br/>" + this.t : "";
			$("body").append("<p id='tooltip'><img src='"+ this.attributes['tooltip'].value +"' alt='tooltip' />"+ c +"</p>");								 
			$("#tooltip")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px")
				.css("position","absolute")
				.fadeIn("fast");						
	    },
		function(){
			this.title = this.t;	
			$("#tooltip").remove();
	    });	
		$(".tooltip").mousemove(function(e){
			$("#tooltip")
				.css("top",(e.pageY - xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px")
				;
		});		

		$(".imgpreview").hover(function(e){
			
			suffix = this.attributes['suffix'].value;
				
			if (e.pageX < ($(window).width() / 1.5)) {
				$('#cardsright_' + suffix).html("<p id='tooltip'><img src='"+ this.attributes['src'].value +"' alt='tooltip' /></p>");
				$('#cardsright_' + suffix).show();
			}
			else {
				$('#cardsleft_' + suffix).html("<p id='tooltip'><img src='"+ this.attributes['src'].value +"' alt='tooltip' /></p>");
				$('#cardsleft_' + suffix).show();
			}
			
			
	    },
		function(e){
	    	suffix = this.attributes['suffix'].value;
	    	$("#tooltip").remove();
	    	$('#cardsleft_' + suffix).hide();
	    	$('#cardsright_' + suffix).hide();
	    });	
		
		$(".catpreview").hover(function(e){
			
			suffix = this.attributes['suffix'].value;
				
			if (e.pageX < ($(window).width() / 2)) {
				$('#hovright_' + suffix).html("<p id='tooltip'><img src='"+ this.attributes['src'].value +"' alt='tooltip' /></p>");
				//webkit browsers may not have loaded the images yet
				$("<img/>") // Make in memory copy of image to avoid css issues
				    .attr("src", $('#hovright_' + suffix + " img").attr('src') )
				    .load(function() {
				    	height = this.height / this.width   * 256;
						$('#hovright_' + suffix).css("top", (($(window).height() - height) / 2) + $(window).scrollTop() + "px");
						$('#hovright_' + suffix).fadeIn();
				    });

				/*
				$('#hovright_' + suffix).fadeIn();
				$('#hovright_' + suffix).css("top", (($(window).height() - $('#hovright_' + suffix + " img").outerHeight()) / 2) + $(window).scrollTop() + "px");
				
				//webkit browsers may not have loaded the images yet
				$('#hovright_' + suffix + " img").one("load", function(){
				    var img = this;
				    setTimeout(function(){
				    	$('#hovright_' + suffix).css("top", (($(window).height() - $('#hovright_' + suffix + " img").outerHeight()) / 2) + $(window).scrollTop() + "px");
				    }, 0);
				});
				*/
			}
			else {
				$('#hovleft_' + suffix).html("<p id='tooltip'><img src='"+ this.attributes['src'].value +"' alt='tooltip' /></p>");
				//webkit browsers may not have loaded the images yet
				$("<img/>") // Make in memory copy of image to avoid css issues
				    .attr("src", $('#hovleft_' + suffix + " img").attr('src') )
				    .load(function() {
				    	height = this.height / this.width   * 256;
				    	$('#hovleft_' + suffix).css("top", (($(window).height() - height) / 2) + $(window).scrollTop() + "px");
				    	$('#hovleft_' + suffix).fadeIn();
				    });
				/*
				$('#hovleft_' + suffix).fadeIn();
				$('#hovleft_' + suffix).css("top", (($(window).height() - $('#hovleft_' + suffix + " img").outerHeight()) / 2) + $(window).scrollTop() + "px");
				//webkit browsers may not have loaded the images yet
				$('#hovleft_' + suffix + " img").one("load", function(){
				    var img = this;
				    setTimeout(function(){ 
				    	$('#hovleft_' + suffix).css("top", (($(window).height() - $('#hovleft_' + suffix + " img").outerHeight()) / 2) + $(window).scrollTop() + "px");
				    }, 0);
				});
				*/
			}
	    },
		function(e){
	    	suffix = this.attributes['suffix'].value;
	    	$("#tooltip").remove();
	    	$('#hovleft_' + suffix).hide();
	    	$('#hovright_' + suffix).hide();
	    });
		
};


