jQuery(function($){
		   
	jQuery.fn.imgZoom = function(settings){
		settings = jQuery.extend({// Default settings...
			container:  'body',
			src:		'img/fullsize.jpg',
			hideIt:		false
		}, settings);
		return this.each(function(i){
			var set = new Array();
			if($(this).is('img')){
				set.push(this);
			}else{
				$(this).find('img').each(function(){
					set.push(this);
				});
			};
			$(set).each(function(i){
				var global = this;
				var zoomtainer = settings.container;
				var maxH, maxW, helperHalf, scaleFactor, zoomedSize, helperSize;
				var ourSize = { width:$(this).width(), height:$(this).height() };
				$(this).wrap('<div class="zzz_imgzoom"/>');
				var currentContainer = $(this).parent();
				$(currentContainer).css({
					width:		$(this).width(),
					height:		$(this).height(),
					overflow:	'hidden',
					position:	'relative'
				});
				$(zoomtainer).css({
					position:	'relative',
					overflow:	'hidden'
				});
				var shade = $('<div class="zzz_shade"/>').css({ 
					width:		$(currentContainer).width(),
					height:		$(currentContainer).height(),
					display:	'none',
					position:	'absolute',
					top:		0,
					left:		0,
					background:	'url(img/loading.gif) no-repeat center center #fff',
					opacity:	0.75,
					filter:		'alpha(opacity=75)'
				}).appendTo(currentContainer);;
				var helper = $('<div class="zzz_imghelper"/>').css({
					border:		'1px solid #fff',
					background:	'url('+$(this).attr('src')+') no-repeat -1px -1px #fff',
					display:	'none',
					position:	'absolute',
					top:		0,
					left:		0
				}).appendTo(currentContainer);;
				var zoomed = $('<div class="zzz_zoomed"/>').hide().css({
					overflow:	'hidden', 
					background:	'url(img/loading.gif) center center no-repeat #fff',
					position:	'absolute',
					height:		$(zoomtainer).height(),
					width:		$(zoomtainer).width(),
					top:		$(zoomtainer).css('padding-top'),
					left:		$(zoomtainer).css('padding-left')
				}).appendTo(zoomtainer);
				
				$(currentContainer).unbind().hover(function(){
					$(shade).fadeIn(200);
					$(helper).fadeIn(200);
					$(zoomed).fadeIn(200);
					if(settings.hideIt){
						$(zoomtainer).show()
					}
				},function(){
					$(shade).fadeOut(200);
					$(helper).fadeOut(200);
					$(zoomed).fadeOut(200);
					if(settings.hideIt){
						$(zoomtainer).hide()
					}
				});
				zoomedImg.onload = function(){
					zoomedSize = { width:zoomedImg.width, height:zoomedImg.height };
					scaleFactor = { x:(zoomedSize.width/ourSize.width), y:(zoomedSize.height/ourSize.height) };
					helperSize = {
						height: Math.round($(zoomtainer).height()/scaleFactor.y),
						width:	Math.round($(zoomtainer).width()/scaleFactor.x)
					};
					$(helper).css({width:helperSize.width+'px', height:helperSize.height+'px'});
					maxH =	$(global).height()-$(helper).height();
					maxW =	$(global).width()-$(helper).width();
					helperHalf = {width: ($(helper).width()/2), height: ($(helper).height()/2)};
					$(zoomed).css({
						background:	'url('+this.src+') no-repeat 0 0 #fff'
					});
					$(shade).css({
						backgroundImage:	'none', 
						opacity: 			0.75, 
						filter:				'alpha(opacity=75)', 
						background:			'#ccc'
					});
					var us = {width: $(global).width(), height: $(global).height(), top: $(global).offset().top, left: $(global).offset().left}
					$(currentContainer).unbind().hover(function(){
						$(shade).fadeIn(200);
						$(helper).fadeIn(200);
						$(zoomed).fadeIn(200);
						if(settings.hideIt){
							$(zoomtainer).show()
						}
					},function(){
						$(shade).fadeOut(200);
						$(helper).fadeOut(200);
						$(zoomed).fadeOut(200);
						if(settings.hideIt){
							$(zoomtainer).hide()
						}
					}).mousemove(function(e){
						var us = {width: $(global).width(), height: $(global).height(), top: $(global).offset().top, left: $(global).offset().left}
						var top =	(e.pageY - us.top) - helperHalf.height;
						var left =	(e.pageX - us.left) - helperHalf.width;
						var nleft = left > maxW ? maxW : left < 0 ? 0 : left;
						var ntop = top > maxH ? maxH : top < 0 ? 0 : top;
						$(zoomed).css({
							backgroundPosition: '-'+(nleft*scaleFactor.x)+'px -'+(ntop*scaleFactor.y)+'px'
						})
						$(helper).css({
							top:	ntop,
							left:	nleft,
							backgroundPosition: '-'+(nleft+1)+'px -'+(ntop+1)+'px'
						});
					});
				};
				zoomedImg.src = settings.src;
			});
		}); 
	};
});
	
	