(function($){$.fn.xray=function(options){var defaults={x_width:20,x_height:20};var options=$.extend(defaults,options);return this.each(function(){var img_width=$(this).children("img:first").width();var img_height=$(this).children("img:first").height();var imgsrc=$(this).children("img:last").attr("src");var win_width=Math.floor(img_width*(options.x_width/100));var win_height=Math.floor(img_height*(options.x_height/100));$(this).children("img:last").hide();$(this).css({'position':'relative','overflow':'hidden','width':img_width+'px','height':img_height+'px'});$(this).mouseenter(function(){$(this).append("<div id=\"r_window\"></div>");$("#r_window").css({'width':win_width+'px','height':win_height+'px','position':'absolute','z-index':'10'});$("#r_window").css("background","none")});var offset=$(this).children("img:first").offset();var left=Math.round(offset.left);var top=Math.round(offset.top);$(this).mousemove(function(e){var x=(e.pageX-left);var y=(e.pageY-top);position_left=(x-(win_width/2));position_top=(y-(win_height/2));if(y<=(win_height/2)){position_top=((y-((win_height)/2))+img_height)}if(x<(win_width/2)){position_left=((x-(win_width/2))+img_width)}$("#r_window").css("background-image","url(\""+imgsrc+"\")");$("#r_window").css("background-repeat","repeat");$("#r_window").css("background-position","-"+position_left+"px -"+position_top+"px");$("#r_window").position({my:"center",of:e,collision:"none"})});$(this).mouseleave(function(){$("#r_window").remove()})})}})(jQuery);



