/*
 * 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 = -100;
  yOffset = -100;
  /* END CONFIG */
  jQuery("a.preview").hover(function(e){
    this.t = this.title;
    this.title = "";	
    var c = (this.t != "") ? "<br/>" + this.t : "";
    jQuery("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");								 
    jQuery("#preview").css("top",window.pageYOffset+"px").css("left",window.pageXOffset+"px").fadeIn("fast");
    this.href_pic = this.href;
    this.href = jQuery(this).parent().next().children()[0].href;
  },function(){
    this.title = this.t;
    this.href = this.href_pic;	
    jQuery("#preview").remove();
  });	
  jQuery("a.preview").mousemove(function(e){
    jQuery("#preview").css("top",window.pageYOffset+"px").css("left",window.pageXOffset+"px");
  });			
};

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

