function RSPlug_Zoom (thumb, zoomContainer, fullImgUrl){	this.mouseOverCallback = this.mouseOutCallback = null;	this.containerThumb = null;	this.options = { 		surlayerOpacity: 50,		surlayerBgColor: '#fff',		showIfInsideFor: 0,		hideIfOutsideFor: 0	};		if (typeof(thumb) == 'string'){		thumb = document.getElementById(thumb);	}	if (thumb){		this.thumb = thumb;		if (typeof(zoomContainer) == 'string'){			zoomContainer = document.getElementById(zoomContainer);		}		this.zoomContainer = zoomContainer;				if (arguments.length > 3){			this.init (fullImgUrl, arguments[3]);		} else {			this.init (fullImgUrl);		}	}}RSPlug_Zoom.prototype.init = function (fullImgUrl){	if (arguments.length > 1){		if (arguments[1].surlayerOpacity && !isNaN(arguments[1].surlayerOpacity) && arguments[1].surlayerOpacity <= 100 && arguments[1].surlayerOpacity >= 0){			this.options.surlayerOpacity = arguments[1].surlayerOpacity; 		}		if (arguments[1].surlayerBgColor && typeof(arguments[1].surlayerBgColor) == 'string' && '' != arguments[1].surlayerBgColor){			this.options.surlayerBgColor = arguments[1].surlayerBgColor;		}		if (arguments[1].showIfInsideFor && !isNaN(arguments[1].showIfInsideFor) && arguments[1].showIfInsideFor >= 0){			this.options.showIfInsideFor = arguments[1].showIfInsideFor; 		}		if (arguments[1].hideIfOutsideFor && !isNaN(arguments[1].hideIfOutsideFor) && arguments[1].hideIfOutsideFor >= 0){			this.options.hideIfOutsideFor = arguments[1].hideIfOutsideFor; 		}	}		this.isShowed = false;	this.showIfInsideForTimer = null;	this.hideIfOutsideForTimer = null;	this.lastPosMouse = { x: 0, y: 0 };		this.fullImgUrl = fullImgUrl;	this.deadZone = { x: 0, y: 0 };		this.prepareZoom ();	this.prepareThumb ();}RSPlug_Zoom.prototype.prepareZoom = function (){	this.zoomContainer.style.display = 'none';	this.zoomContainer.style.overflow = 'hidden';		// Preload of the full image	this.bigImg = new Image();	this.bigImg.src = this.fullImgUrl;	this.zoomImg = document.createElement('img');	this.zoomImg.setAttribute('src', this.fullImgUrl);	with (this.zoomImg.style){		position = 'absolute';		left = '0';		top = '0';	}	this.zoomContainer.innerHTML = '';	this.zoomContainer.appendChild(this.zoomImg);};RSPlug_Zoom.prototype.registerPosMouse = function (event){	var posImg = RSPlug_Zoom.findPos (this.thumb);	this.lastPosMouse = RSPlug_Zoom.getMousePos (event, posImg);};RSPlug_Zoom.prototype.mouseMove = function (event){	this.registerPosMouse(event);	if (this.isShowed){		this.execMouseMove(event);	}};RSPlug_Zoom.prototype.execMouseMove = function (event){	var posImg = RSPlug_Zoom.findPos (this.thumb);	var dimImg = RSPlug_Zoom.getDimensions (this.thumb);	var dimBigImg = RSPlug_Zoom.getDimensions (this.bigImg);	var dimContainer = RSPlug_Zoom.getDimensions (this.zoomContainer);		var scaleX = (dimBigImg.width - dimContainer.width) / dimImg.width;	var scaleY = (dimBigImg.height - dimContainer.height) / dimImg.height;	if (scaleX < 0){ scaleX *= -1; }	if (scaleY < 0){ scaleY *= -1; }	if (scaleX == 0){ scaleX = 1; }	if (scaleY == 0){ scaleY = 1; }		var scaleSLX = dimBigImg.width / dimImg.width;	var scaleSLY = dimBigImg.height / dimImg.height;		var dimSurLayer = { 		width: parseInt(dimContainer.width / scaleSLX), 		height: parseInt(dimContainer.height / scaleSLY)	};		this.surLayer.style.width = dimSurLayer.width +'px';	this.surLayer.style.height = dimSurLayer.height +'px';		// Calcul de la bordure css du surlayer afin la prendre en compte dans le calcul de la zone morte (deadZone) 	this.borderSurLayer = { x: 0, y: 0 };	if (this.surLayer.offsetWidth > dimSurLayer.width){		this.borderSurLayer.x = Math.ceil(this.surLayer.offsetWidth) - parseInt(dimSurLayer.width);	}	if (this.surLayer.offsetHeight > dimSurLayer.height){		this.borderSurLayer.y = Math.ceil(this.surLayer.offsetHeight) - parseInt(dimSurLayer.height);	}		this.deadZone.x = (dimSurLayer.width + this.borderSurLayer.x) / 2;	this.deadZone.y = (dimSurLayer.height + this.borderSurLayer.y) / 2;	if (this.deadZone.x > 0){ dimImg.width -= this.deadZone.x *2; }	if (this.deadZone.y > 0){ dimImg.height -= this.deadZone.y *2; }	//var mousePosition = RSPlug_Zoom.getMousePos (event, posImg);	var mousePosition = this.lastPosMouse;		var posMouse = { left: (mousePosition.x - posImg.left), top: (mousePosition.y - posImg.top) };	if (this.deadZone.x > 0){		posMouse.left -= this.deadZone.x;		if (posMouse.left < 0){			posMouse.left = 0;		}		if (posMouse.left > dimImg.width){			posMouse.left = dimImg.width;		}	}	if (this.deadZone.y > 0){		posMouse.top -= this.deadZone.y;		if (posMouse.top < 0){			posMouse.top = 0;		}		if (posMouse.top > dimImg.height){			posMouse.top = dimImg.height;		}	}	var paddingLeft = paddingTop = 0; 		if (dimContainer.width > dimBigImg.width){		paddingLeft = (dimContainer.width - dimBigImg.width) / 2; 	}	if (dimContainer.height > dimBigImg.height){		paddingTop = (dimContainer.height - dimBigImg.height) / 2; 	}		var scaleX = (dimBigImg.width - dimContainer.width) / dimImg.width;	var scaleY = (dimBigImg.height - dimContainer.height) / dimImg.height;	if (scaleX < 0){		scaleX *= -1;	}	if (scaleY < 0){		scaleY *= -1;	}		var bgLeft = (posMouse.left * scaleX * -1) - paddingLeft;	var bgTop = (posMouse.top * scaleY * -1) - paddingTop;		this.zoomImg.style.left = bgLeft + 'px';	this.zoomImg.style.top = bgTop + 'px';		this.surLayer.style.left = (parseInt(posMouse.left)) + 'px';	this.surLayer.style.top = (parseInt(posMouse.top)) + 'px';};RSPlug_Zoom.prototype.execMouseOver = function (event){	this.isShowed = true;	this.zoomContainer.style.display = 'block';	this.surLayer.style.display = 'block';	this.execMouseMove(event);	if (null !== this.mouseOverCallback){		this.mouseOverCallback();	}};RSPlug_Zoom.prototype.execMouseOut = function (event){	this.isShowed = false;	this.zoomContainer.style.display = 'none';	this.surLayer.style.display = 'none';	if (null !== this.mouseOutCallback){		this.mouseOutCallback();	}};RSPlug_Zoom.prototype.mouseOver = function (event){	if (null !== this.hideIfOutsideForTimer){		clearTimeout(this.hideIfOutsideForTimer);		this.hideIfOutsideForTimer = null;	}	if (this.options.showIfInsideFor > 0){		if (null === this.showIfInsideForTimer){			var inst = this;			this.showIfInsideForTimer = setTimeout(function(){ inst.execMouseOver(event); inst.showIfInsideForTimer = null; }, this.options.showIfInsideFor);		}	} else {		this.execMouseOver(event);	}};RSPlug_Zoom.prototype.mouseOut = function (event){	if (null !== this.showIfInsideForTimer){		clearTimeout(this.showIfInsideForTimer);		this.showIfInsideForTimer = null;	}	if (this.options.hideIfOutsideFor > 0){		if (null === this.hideIfOutsideForTimer){			var inst = this;			this.hideIfOutsideForTimer = setTimeout(function(){ inst.execMouseOut(event); inst.hideIfOutsideForTimer = null; }, this.options.hideIfOutsideFor);		}	} else {		this.execMouseOut(event);	}};RSPlug_Zoom.prototype.setMouseOverCallback = function (callback){	this.mouseOverCallback = callback;};RSPlug_Zoom.prototype.setMouseOutCallback = function (callback){	this.mouseOutCallback = callback;};RSPlug_Zoom.prototype.prepareThumb = function (){	if (null !== this.containerThumb){		this.containerThumb.parentNode.insertBefore(this.thumb, this.containerThumb);		this.containerThumb.parentNode.removeChild(this.containerThumb);	}	this.containerThumb = document.createElement('div');	this.containerThumb.style.position = 'relative';	this.thumb.parentNode.insertBefore(this.containerThumb, this.thumb);	this.containerThumb.appendChild(this.thumb);		this.surLayer = document.createElement('div');	this.surLayer.setAttribute('id', 'RSPlug_Zoom_surLayer');	with (this.surLayer.style){		background = this.options.surlayerBgColor;		opacity = (this.options.surlayerOpacity / 100);		MozOpacity = (this.options.surlayerOpacity / 100);		filter = 'alpha(opacity=' + this.options.surlayerOpacity + ')';		display = 'none';		position = 'absolute';		zIndex = '1000';	}	this.containerThumb.appendChild(this.surLayer);		var dimImg = RSPlug_Zoom.getDimensions(this.thumb);	this.zoomEventCapturer = document.createElement('div');	with (this.zoomEventCapturer.style){		position = 'absolute';		top = '0';		left = '0';		zIndex = '1010';		width = '100%';		height = '100%';		/* Pour une compatibilité IE... */		background = 'transparent url(/rsplug/zoom/zoom_transparent.gif) left top repeat';	}	this.containerThumb.appendChild(this.zoomEventCapturer);		var inst = this;	RSPlug_Zoom.addEvent (inst.zoomEventCapturer, 'mousemove', function (e){ inst.mouseMove(e); } );	RSPlug_Zoom.addEvent (inst.zoomEventCapturer, 'mouseover', function (e){ inst.mouseOver(e); } );	RSPlug_Zoom.addEvent (inst.zoomEventCapturer, 'mouseout', function (e){ inst.mouseOut(e); } );};/* Méthodes statiques  /*********************/RSPlug_Zoom.findPos = function (obj) { 	var curleft = curtop = 0;	if (obj.offsetParent) {		do {			curleft += obj.offsetLeft;			curtop += obj.offsetTop;		} while (obj = obj.offsetParent);	} 	return { left: curleft, top: curtop };};RSPlug_Zoom.getMousePos = function (evenement, decalage) { 	if (evenement.pageX){		return {x: evenement.pageX, y: evenement.pageY };	}	return {x: (evenement.offsetX + decalage.left), y: (evenement.offsetY + decalage.top) };};RSPlug_Zoom.getDimensions = function (obj) {	if (obj.tagName.toLowerCase() == 'img'){		return { width: obj.width, height: obj.height };	}	return { width: obj.offsetWidth, height: obj.offsetHeight };};RSPlug_Zoom.addEvent = function (element, eventName, callback){	if (element.addEventListener){		element.addEventListener(eventName, callback, false);	} else if (element.attachEvent){		element.attachEvent('on' + eventName, callback);	}};
