//**************************************************************
// jqzoom allows you to realize a small magnifier window,close
// to the image or images on your web page easily.
// download by http://www.jb51.net
// jqzoom version 2.0
// author doc. ing. renzi marco(www.mind-projects.it)
// first release on dec 05 2007
// i'm searching for a job,pick me up!!!
// mail: renzi.mrc@gmail.com
//**************************************************************
(function($){
$.fn.jqueryzoom = function(options){
var settings = {
xzoom: 200, //zoomed width default width
yzoom: 200, //zoomed div default width
offset: 10, //zoomed div default offset
position: "right", //zoomed div default position,offset position is to the right of the image
preload: 1
};
if(options) {
$.extend(settings, options);
}
var noalt='';
$(this).hover(function(){
var imageleft = this.offsetleft;
var imageright = this.offsetright;
var imagetop = $(this).get(0).offsettop;
var imagewidth = $(this).children('img').get(0).offsetwidth;
var imageheight = $(this).children('img').get(0).offsetheight;
noalt= $(this).children("img").attr("alt");
var bigimage = $(this).children("img").attr("jqimg");
$(this).children("img").attr("alt",'');
if($("div.zoomdiv").get().length == 0){
$(this).after("
");
$(this).append("
");
}
if(settings.position == "right"){
leftpos = imageleft + imagewidth + settings.offset;
}else{
leftpos = imageleft - settings.xzoom - settings.offset;
}
$("div.zoomdiv").css({ top: imagetop,left: leftpos });
$("div.zoomdiv").width(settings.xzoom);
$("div.zoomdiv").height(settings.yzoom);
$("div.zoomdiv").show();
$(document.body).mousemove(function(e){
$("div.jqzoompup").hide();
var bigwidth = $(".bigimg").get(0).offsetwidth;
var bigheight = $(".bigimg").get(0).offsetheight;
var scaley ='x';
var scalex= 'y';
if(isnan(scalex)|isnan(scaley)){
var scalex = (bigwidth/imagewidth);
var scaley = (bigheight/imageheight);
$("div.jqzoompup").width((settings.xzoom)/scalex );
$("div.jqzoompup").height((settings.yzoom)/scaley);
$('div.jqzoompup').show();
$("div.jqzoompup").css('visibility','visible');
}
mouse = new mouseevent(e);
xpos = mouse.x - $("div.jqzoompup").width()/2 - imageleft;
ypos = mouse.y - $("div.jqzoompup").height()/2 - imagetop ;
xpos = (mouse.x - $("div.jqzoompup").width()/2 < imageleft ) ? 0 : (mouse.x + $("div.jqzoompup").width()/2 > imagewidth + imageleft ) ? (imagewidth -$("div.jqzoompup").width() -2) : xpos;
ypos = (mouse.y - $("div.jqzoompup").height()/2 < imagetop ) ? 0 : (mouse.y + $("div.jqzoompup").height()/2 > imageheight + imagetop ) ? (imageheight - $("div.jqzoompup").height() -2 ) : ypos;
$("div.jqzoompup").css({ top: ypos,left: xpos });
$("div.jqzoompup").show();
//scrolly = mouse.y - imagetop - ($("div.zoomdiv").height()*1/scaley)/2 ;
scrolly = ypos;
$("div.zoomdiv").get(0).scrolltop = scrolly * scaley;
scrollx = xpos;
//scrollx = mouse.x - imageleft - ($("div.zoomdiv").width()*1/scalex)/2 ;
$("div.zoomdiv").get(0).scrollleft = (scrollx) * scalex ;
});
},function(){
$(this).children("img").attr("alt",noalt);
$(document.body).unbind("mousemove");
$("div.jqzoompup").remove();
$("div.zoomdiv").remove();
});
count=0;
if(settings.preload){
$('body').append("sdsdssdsd
");
$(this).each(function(){
var imagetopreload= $(this).children("img").attr("jqimg");
var content = jquery('div.jqpreload'+count+'').html();
jquery('div.jqpreload'+count+'').html(content+'');
});
}
}
})(jquery);
function mouseevent(e) {
this.x = e.pagex
this.y = e.pagey
}