//**************************************************************
// jqzoom allows you to realize a small magnifier window,close
// to the image or images on your web page easily.
//
// jqzoom version 2.1
// 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
lens:1, //zooming lens over the image,by default is 1;
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"){
if(imageleft + imagewidth + settings.offset + settings.xzoom > screen.width){
leftpos = imageleft - settings.offset - settings.xzoom;
}else{
leftpos = imageleft + imagewidth + settings.offset;
}
}else{
leftpos = imageleft - settings.xzoom - settings.offset;
if(leftpos < 0){
leftpos = imageleft + imagewidth + settings.offset;
}
}
$("div.zoomdiv").css({ top: imagetop,left: leftpos });
$("div.zoomdiv").width(settings.xzoom);
$("div.zoomdiv").height(settings.yzoom);
$("div.zoomdiv").show();
if(!settings.lens){
$(this).css('cursor','crosshair');
}
$(document.body).mousemove(function(e){
mouse = new mouseevent(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);
if(settings.lens){
$("div.jqzoompup").css('visibility','visible');
}
}
xpos = mouse.x - $("div.jqzoompup").width()/2 - imageleft;
ypos = mouse.y - $("div.jqzoompup").height()/2 - imagetop ;
if(settings.lens){
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;
}
if(settings.lens){
$("div.jqzoompup").css({ top: ypos,left: xpos });
}
scrolly = ypos;
$("div.zoomdiv").get(0).scrolltop = scrolly * scaley;
scrollx = xpos;
$("div.zoomdiv").get(0).scrollleft = (scrollx) * scalex ;
});
},function(){
$(this).children("img").attr("alt",noalt);
$(document.body).unbind("mousemove");
if(settings.lens){
$("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
}