
if(!console) {
	try {
		var console = {
			'log':function (){}, 
			'debug':function (){}, 
			'info':function (){}, 
			'warn':function (){}, 
			'error':function (){}, 
			'assert':function (){}, 
			'dir':function (){}, 
			'dirxml':function (){}, 
			'trace':function (){}, 
			'group':function (){}, 
			'groupEnd':function (){}, 
			'groupCollapsed':function (){}, 
			'time':function (){}, 
			'timeEnd':function (){}, 
			'profile':function (){}, 
			'profileEnd':function (){}, 
			'count':function (){}, 
			'clear':function (){}, 
			'notifyFirebug':function (objs, methodName, eventID) {}, 
			'getFirebugElement':function (){ return null; }, 
			'firebug':'not loaded' 
		};
	} catch(e) {};
}

if( 'undefined' == typeof Function.prototype.magicApply ) {
	Function.prototype.magicApply = function(options){
		var self = this;
		options = options || {};
		return function(event){
			var args = options.arguments;
			if(undefined != args) {
				if( !args.callee ) {
					if( args.length && ('number'==typeof args.length) && 0<args.length ) {
						try {
							var test = args[0];
						} catch(e) {
							args = [event||window.event];
							args[args.length] = args;
						}
					}
				}
			} else {
				args = [event||window.event];
			}
			if(options.event) {
				if( true ) { //!(args[0].type && !args[0].constructor)
					args = [options.event];
				}
			}
			var returns = function(){
				return self.apply(options.bind || null, args);
			};
			if (options.delay) return setTimeout(returns, options.delay);
			if (options.periodical) return setInterval(returns, options.periodical);
			if (options.attempt) {
				try {
					return returns();
				} catch(e) {}
				return null;
			}
			return returns();
		};
	}
}


var scarr = {

	indexOf: function(item, from){
		var len = this.length;
		for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++){
			if (this[i] === item) return i;
		}
		return -1;
	},

	contains: function(item, from){
		return this.indexOf(item, from) != -1;
	}

}

for( var methodName in scarr ) {
	if( 'undefined' == typeof Array.prototype[methodName] ) {
		Array.prototype[methodName] = scarr[methodName];
	}
}
delete scarr;


var Scm = {

	test: function(regex, params){
		return ((typeof regex == 'string') ? new RegExp(regex, params) : regex).test(this);
	},

	contains: function(string, separator){
		return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : this.indexOf(string) > -1;
	},

	trim: function(){
		return this.replace(/^\s+|\s+$/g, '');
	},

	clean: function(){
		return this.replace(/\s+/g, ' ').trim();
	},

	camelCase: function(){
		return this.replace(/-\D/g, function(match){
			return match.charAt(1).toUpperCase();
		});

	},

	hyphenate: function(){
		return this.replace(/[A-Z]/g, function(match){
			return ('-' + match.charAt(0).toLowerCase());
		});
	},

	capitalize: function(){
		return this.replace(/\b[a-z]/g, function(match){
			return match.toUpperCase();
		});
	},

	escapeRegExp: function(){
		return this.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
	},

	toInt: function(base){
		return parseInt(this, base || 10);
	},

	toFloat: function(){
		return parseFloat(this);
	},

	isMailAddr : function checkMailAddr() {
		var addr = this.split("@");
		if(addr.length==1 || addr.length>2) return false;
		var dom = addr[1].split(".");
		if(dom.length == 1) return false;
		var domLen = dom.length
		if(domLen>2 && (dom[domLen-1]).length==0) domLen--;
		if(dom[domLen-1].length<2 || dom[domLen-1].length>6) return false;
		for(var i=0;i<domLen;i++) { if(dom[i].length==0) return false; }
		var acc = addr[0].split(".");
		for(i=0;i<acc.length;i++) { if(acc[i].length==0) return false; }
		var okChars = "abcdefghijklmnopqrstuvwxyz";
		okChars += okChars.toUpperCase()+"0123456789-_";
		var testString = acc.join("")+"."+dom.join("");
		if("."==testString) return false;
		i=0;
		while( i<testString.length ) { 
			if('.'==testString.substr(i,1)) {
				okChars = okChars.substr(0,okChars.length-1);
			} else {
				if(okChars.indexOf(testString.substr(i,1))==-1 ) return false;
			}
			i++;
		}
		return true;
	},
	
	basename : function() {
		var ret = this;
		var pos = Math.max(this.lastIndexOf('/'), this.lastIndexOf('//'));
		if(-1<pos) ret = this.substr(pos+1);
		return ret;
	},

	dirname : function() {
		var ret = this;
		var pos = Math.max(this.lastIndexOf('/'), this.lastIndexOf('//'));
		if(-1<pos) ret = this.substr(0,pos);
		return ret;
	}

};

for( var methodName in Scm ) {
	if( 'undefined' == typeof String.prototype[methodName] ) {
		String.prototype[methodName] = Scm[methodName];
	}
}
delete Scm;

var ElGoodies = {
	hasOwnProperty: function(propertyName) {
		return (!(null==this[propertyName] || void(0)==this[propertyName]));
	},

	getDocument: function(){
		return this.ownerDocument;
	},
	
	getWindow: function(){
		return this.getDocument().getWindow?this.getDocument().getWindow():window;
	},

	dispose: function(){
		return this.parentNode.removeChild(this);
	},

	replaces: function(el){
		if('string'==(typeof el).toLowerCase()) el = document.getElementById(el);
		el.parentNode.replaceChild(this, el);
		return this;
	},

	hasAttribute: function(attributeName) {
		var attr = this.attributes[attributeName];
		if('object'==typeof attr) {
			ret = (''==attr.value ? false : true);
		} else {
			ret = !(void(0)==attr);
		}
		return ret;
	},

	hasClass: function(className){
		return this.className.contains(className, ' ');
	},

	addClass: function(className){
		if (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean();
		return this;
	},

	removeClass: function(className){
		this.className = this.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1').clean();
		return this;
	},

	toggleClass: function(className){
		return this.hasClass(className) ? this.removeClass(className) : this.addClass(className);
	},

	getComputedStyle: function(property){
		var result = null;
		if (this.currentStyle){
			result = this.currentStyle[property.camelCase()];
		} else {
			var computed = this.getWindow().getComputedStyle(this, null);
			if (computed) result = computed.getPropertyValue([property.hyphenate()]);
		}
		return result;
	},

	isBody: function() {
		return this.tagName.toLowerCase() == 'body';
	},

	getPosition: function(relative){
		if (this.isBody()) return {x: 0, y: 0};
		var el = this, position = {x: 0, y: 0};
		while (el){
			position.x += el.offsetLeft;
			position.y += el.offsetTop;
			el = el.offsetParent;
		}
		var rpos = (relative) ? ('string'==(typeof el).toLowerCase() ? document.getElementById(el) : el).getPosition() : {x: 0, y: 0};
		return {x: position.x - rpos.x, y: position.y - rpos.y};
	},

	enrich: function(el){
		if(null==el) return;
		if('string'==(typeof el).toLowerCase()) el = document.getElementById(el);
		if(!el.hasOwnProperty) {
			el['hasOwnProperty'] = this['hasOwnProperty'];
		}
		for( var methodName in this ) {
			if('enrich'==methodName || 'hasOwnProperty'==methodName) continue;
			if(el.hasOwnProperty(methodName)) continue;
			el[methodName] = this[methodName];
		}
	}
};

if('undefined' == typeof OjO_EventUtil) {
	var OjO_EventUtil = {
		opera: ('object'==typeof window.opera && 'function'==typeof window.opera.version && -1<window.opera.version.toString().indexOf('() { [native code] }')),
		addEventHandler: function (oTarget, sEventType, fnHandler) {
			if (oTarget.addEventListener) {
				oTarget.addEventListener(sEventType, fnHandler, false);
			} else if (oTarget.attachEvent) {
				oTarget.attachEvent("on" + sEventType, fnHandler);
			} else {
				oTarget["on" + sEventType] = fnHandler;
			}
		},
		removeEventHandler: function (oTarget, sEventType, fnHandler) {
			if (oTarget.removeEventListener) {
				oTarget.removeEventListener(sEventType, fnHandler, false);
			} else if (oTarget.detachEvent) {
				oTarget.detachEvent("on" + sEventType, fnHandler);
			} else { 
				oTarget["on" + sEventType] = null;
			}
		},
		formatEvent: function (oEvent) {
			if ((null==oEvent.srcElement||oEvent.srcElement) && void(0)==oEvent.eventPhase) {

				oEvent.CAPTURING_PHASE = 1;
				oEvent.AT_TARGET = 2;
				oEvent.BUBBLING_PHASE = 3;

				oEvent.charCode = (oEvent.type == "keypress") ? oEvent.keyCode : 0;
				oEvent.eventPhase = oEvent.AT_TARGET;
				oEvent.isChar = (oEvent.charCode > 0);
				oEvent.pageX = oEvent.clientX + document.body.scrollLeft;
				oEvent.pageY = oEvent.clientY + document.body.scrollTop;
				oEvent.preventDefault = function () {
					this.returnValue = false;
				};

				if (oEvent.type == "mouseout") {
					oEvent.relatedTarget = oEvent.toElement;
				} else if (oEvent.type == "mouseover") {
					oEvent.relatedTarget = oEvent.fromElement;
				} else if (oEvent.type == "mouseleave") {
					oEvent.relatedTarget = oEvent.toElement;
				} else if (oEvent.type == "mouseenter") {
					oEvent.relatedTarget = oEvent.fromElement;
				}

				oEvent.stopPropagation = function () {
					this.cancelBubble = true;
				};

				oEvent.target = oEvent.srcElement;
				oEvent.time = (new Date).getTime();
			}
			return oEvent;
		},
		normalize: function(oEvent) {
			return oEvent||this.formatEvent(window.event);
		},
		getEvent: function() {
			if (window.event) {
				return this.formatEvent(window.event);
			} else {
				return OjO_EventUtil.getEvent.caller.arguments[0];
			}
		},
		dispatchEvent: function (oTarget, oEvent){
			var ret = false;
			try{
				var evt, proprty;
				if(oTarget.fireEvent){
					evt = document.createEventObject();
					for( proprty in evt ) {
						try {
							if('function'==typeof evt[proprty]) continue;
							evt[proprty] = oEvent[proprty];
						} catch(e) { document.title = 'Error: createEventObject('+proprty+')'; }
					}
					ret = oTarget.fireEvent("on"+evt.type, evt);
				} else if(oTarget.dispatchEvent){
					evt = document.createEvent("Events");
					evt.initEvent(oEvent.type, true, true);
					buf = [];
					for( proprty in evt ) {
						try {
							if('function'==typeof evt[proprty]) continue;
							evt[proprty] = oEvent[proprty];
						} catch(e) { document.title = 'Error: createEvent('+proprty+')'; }
					}
					ret = oTarget.dispatchEvent(evt);
				}
			} catch (e){ document.title = 'Error: dispatchEvent() '+e.message; }
			return ret;
		}
	};
} else {
	throw("OjO_EventUtil version conflict");
}

if('undefined'==typeof window.OjO_Xhr) { 
	var OjO_Xhr = function() {
		this.initialize = function() {
			if( null==this.owner ) {
				var msg="No owner object provided"
				throw msg;
			}
		}
		this.setCallback = function(handler, func) {
			var handlerCheck = '|onquerysuccess|onqueryfailure|';
			if(-1<handlerCheck.indexOf('|'+handler+'|')) {
				if('function'==typeof func) {
					this[handler] = func;
				} else {
					alert('callback handler '+handler+' is not a function');
				}
			} else {
				alert('unrecognized callback handler: '+handler)
			}

		}
		this.getConnector = function() {
			var o = null;
			if('undefined'== typeof XMLHttpRequest) {
				var success = false;
				var MSXML_XMLHTTP_PROGIDS = new Array(
					'MSXML2.XMLHTTP.5.0',
					'MSXML2.XMLHTTP.4.0',
					'MSXML2.XMLHTTP.3.0',
					'MSXML2.XMLHTTP',
					'Microsoft.XMLHTTP'
				);
				for (var i=0;i < MSXML_XMLHTTP_PROGIDS.length && !success; i++) {
					try {
						o = new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]);
						success = true;
					} catch (e) {}
				}
			}
			if( null==o && typeof XMLHttpRequest != "undefined") o = new XMLHttpRequest();
			return o;
		};
		this.query = function(parms, url, method, custHeaders, killDelay) {

				var respTimeout = null;
				parms = parms||{};
				url = url||('form'==this.owner.nodeName.toLowerCase()?
						this.owner.action:
						('a'==this.owner.nodeName.toLowerCase() && this.owner.href?
							this.owner.href:
							location.href
						)
					);
				method = (method||('form'==this.owner.nodeName.toLowerCase()?
						this.owner.method:
						'GET'
						)
					).toUpperCase();
				custHeaders = custHeaders||{};
				killDelay   = killDelay||false
				var ret = false;
				var x = this.getConnector();
				if(null==x)  return false;
				var self = this;

				var i, n;
				var post_data;

				if (method == "GET") { 
					if (url.indexOf("?") == -1) url += "?";
					else                        url += "&";
					for( var qparam in parms) { url += qparam+"="+encodeURIComponent(parms[qparam])+"&"; }
					var dt = new Date();
					url += '_'+dt.getTime()+'=1';
					post_data = null;
				} else {
					post_data = "";
					for( var qparam in parms) { post_data += '&'+qparam+"="+encodeURIComponent(parms[qparam]); }
					if(0<post_data.length) {
						if(0==post_data.indexOf('&')) post_data = post_data.substr(1);
					}
				}
				x.onreadystatechange = function() {
					if (x.readyState < 4) return;
					var intStatus = parseFloat(x.status);
					if(null!=respTimeout) {
						clearTimeout(respTimeout);
						respTimeout = null;
					}
					if(0==intStatus) return;
					try {
						if(199<intStatus && 400>intStatus) {
							if(undefined!=self.owner.onquerysuccess) {
								self.owner.onquerysuccess(x);
							} else {
								if(null===self.onquerysuccess) {
									alert('Unhandled server response ('+intStatus+').');
								} else {
									self.onquerysuccess.call(self.owner, x);
								}
							}
						} else {
							if(undefined!=self.owner.onqueryfailure) {
								self.owner.onqueryfailure(x);
							} else {
								if(null===self.onqueryfailure) {
									alert('Unhandled server error response ('+intStatus+').');
								} else {
									self.onqueryfailure.call(self.owner, x);
								}
							}
						}
					} catch(e) {
						alert(e.message);
					}
				}
				try {
					x.open(method, url, true);
					x.setRequestHeader("X_REQUESTED_WITH", "XMLHttpRequest");
					if (method == "POST") {
						x.setRequestHeader("Method", "POST " + url + " HTTP/1.1");
						x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
					}
					if( null!=custHeaders ) {
						var ch;
						for( ch in custHeaders ) {
							try {
								x.setRequestHeader(ch, custHeaders[ch] );
							} 
							catch(e) {
								alert(ch+': '+custHeaders[ch]+"\n"+e.message);
							}
						}
					}
					x.send(post_data);
					if( !isNaN(killDelay) && 0<parseFloat(''+killDelay)) {
						respTimeout = setTimeout(function() { alert('Request timeout (readyState='+x.readyState+')'); clearTimeout(respTimeout); respTimeout = null; if(x.abort) { x.abort(); }; }, killDelay*1000);
					}
					ret = true;
				} catch (e) {
					alert(e);
				}
				if(x) delete x;
				return ret;
		};
		this.owner = (0<arguments.length?arguments[0]:null);
		this.onquerysuccess = null;
		this.onqueryfailure = null;

		this.initialize();
	}
} else {
	throw('OjO_Xhr version conflict');
}

if('undefined'==typeof window.OjO_Cookie) { 
	var OjO_Cookie = {

		set: function(name,value,days) {
			if (days) {
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}
			else var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
		}, 

		setLimitToday: function(name,value) {
			var ts = new Date();
			var date = new Date(ts.getFullYear(), ts.getMonth(), ts.getDate(), 0, 0, 0, 0);
			date.setDate(ts.getDate()+1);
			var expires = "; expires="+date.toGMTString();
			document.cookie = name+"="+value+expires+"; path=/";
		}, 

		unset: function(name) {
			OjO_Cookie.set(name,"",-1);
		},

		get: function(name) {
			var nameEQ = name + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			return null;
		}
	}
} else {
	throw('OjO_Cookie version conflict');
}

function ojoCalHelperInstall() {
	var what;
	var sels = ['year','month','day'];
	while(what=sels.shift()) { this.elements[what].onchange = ojoCalHelper; }
	
}
function ojoCalHelper() {
	if('day'==this.name) {
		var n;
		with(this.form) { n = (new Date(new Number(year.value), new Number(month.value), 0)).getDate(); }
		if(n<this.options.length) {
			var prevIndex = this.selectedIndex;
			this.options.length = (n+1);
			if(0==this.selectedIndex && prevIndex!=this.selectedIndex) {
				this.selectedIndex = (n);
				this.value = this.options[this.selectedIndex].value;
			}
		} else {
			for(var i= new Number(this.options[this.options.length-1].value)+1  ; i<=n; i++) {
				this.options[this.options.length] = new Option(i.toString(),i.toString());
			}
		}
	} else {
		ojoCalHelper.apply(this.form.elements['day'], arguments);
	}
}


function OjO_ImageZoomer(owner, container, zoomScale, opacity) {
	this.msie = void(0)!=document.createEventObject;
	this.autoIncrement++;
	this.id = owner.getAttribute('id');
	this.o = owner;      ElGoodies.enrich(this.o);
	this.c = container;  ElGoodies.enrich(this.c);
	this.zoomFrame = null;
	this.zoomImage = null;
	this.active = false;
	this.MetricsO = {w: 0, h: 0, x:0, y: 0};
	this.MetricsF = {w: 0, h: 0, x:0, y: 0};
	this.MetricsC = {w: 0, h: 0, x:0, y: 0};
	this.zoomFrameBounds = {top:0, right: 0, bottom:0, left:0}
	this.zoomScaleOut = 1/(isNaN(zoomScale)||0==zoomScale ? 1 : zoomScale/100);
	this.zoomScaleIn  = ((isNaN(zoomScale)||0==zoomScale ? 1 : zoomScale/100));
	this.zoomFrameOpacity = isNaN(opacity) ? 0 : parseInt(opacity, 10);
	this.offsetImage = {x:0, y:0, w:1, h:1};
	this.last2c = [{x:null, y:null},{x:null, y:null}];
	this.loadedImages = [];

	this.rideau = null, /* A rendre parametrable */
	this.btRetour = null, /* A rendre parametrable aussi */
	this.usrLang = 'en';

	this.init();
}


OjO_ImageZoomer.prototype.autoIncrement = 0;


OjO_ImageZoomer.prototype.setImages = function(ImageSet) {


	if(this.o.src!=ImageSet.baseURL) {
		if(this.loadedImages.contains(ImageSet.baseURL.dirname().basename()+'¤'+ImageSet.baseURL.basename())) {
			this.o.src = ImageSet.baseURL;
		} else {
			this.o.src = "/images/global/loading.gif";
			this.o.setAttribute('width', '275');
			this.o.setAttribute('height', '200');
			this.o.style.cssText = 'position: absolute; left:130px; top:80px;';

			var imageBaseMonitor = new Image(355, 355);
			imageBaseMonitor.zoomer = this;
			imageBaseMonitor.onload = function() {
				this.zoomer.o.src = this.src;
				this.zoomer.o.setAttribute('width', this.width);
				this.zoomer.o.setAttribute('height', this.height);
				this.zoomer.o.style.cssText = 'margin-top: 13px;';
				this.zoomer.loadedImages.push(this.src.dirname().basename()+'¤'+this.src.basename());
			}
			imageBaseMonitor.onerror = function() {
				this.zoomer.o.src = '/images/no-image-355-'+this.zoomer.usrLang+'.jpg';
				this.zoomer.o.setAttribute('width', '355');
				this.zoomer.o.setAttribute('height', '355');
				this.zoomer.o.style.cssText = 'margin-top: 13px;';
			}
			imageBaseMonitor.src = ImageSet.baseURL;
		}

		/* ~ */
		if(this.loadedImages.contains(ImageSet.zoomURL.dirname().basename()+'¤'+ImageSet.zoomURL.basename())) {
			this.zoomImage.src = ImageSet.zoomURL;
		} else {
			this.zoomImage.src           = "/images/global/loading.gif";
			this.zoomImage.setAttribute('width', '275');
			this.zoomImage.setAttribute('height', '200');
			this.zoomImage.style.cssText = 'position: absolute; left:-15px; top:120px;';
			this.zoomImage.isZoomImage = false;
			var imageZoomMonitor = new Image(1500, 1500);
			imageZoomMonitor.zoomer = this;
			imageZoomMonitor.onload = function() {
				this.zoomer.zoomImage.src = this.src;
				this.zoomer.zoomImage.setAttribute('width', this.width);
				this.zoomer.zoomImage.setAttribute('height', this.height);
				this.zoomer.zoomImage.isZoomImage = true;
				this.zoomer.loadedImages.push(this.src.dirname().basename()+'¤'+this.src.basename());
			}
			imageZoomMonitor.onerror = function() {
				this.zoomer.zoomImage.src = '/images/no-image-160-'+this.zoomer.usrLang+'.jpg';
				this.zoomer.zoomImage.setAttribute('width', '160');
				this.zoomer.zoomImage.setAttribute('height', '160');
				this.zoomer.zoomImage.style.cssText = 'position: absolute;left:50px;top:120px;';
				this.zoomer.zoomImage.isZoomImage = false;
			}
			imageZoomMonitor.src = ImageSet.zoomURL;
		}
	}
}


OjO_ImageZoomer.prototype.setOffsetImage = function() {
	this.offsetImage = {x:this.o.getPosition().x, y:this.o.getPosition().y, w:this.o.width, h:this.o.height};
}


OjO_ImageZoomer.prototype.setActive = function(active) {
	this.active = active;
	if(this.active) {
		this.c.style.display = 'block';
		this.zoomFrame.style.display = 'block';
	} else {
		this.c.style.display = 'none';
		this.zoomFrame.style.display = 'none';
	}
	if(null!=this.btRetour) {
		this.btRetour.style.visibility = this.active ? 'hidden' : 'visible';
	}
}


OjO_ImageZoomer.prototype.prepareZoomImage = function() {
	
	var imageMonitor = new Image(1500, 1500);
	imageMonitor.zoomer = this;
	imageMonitor.onload = function() {
		this.zoomer.zoomImage.src = this.src;
		this.zoomer.zoomImage.setAttribute('width', this.width);
		this.zoomer.zoomImage.setAttribute('height', this.height);
		this.zoomer.zoomImage.style.cssText = 'position: absolute;';
		this.zoomer.zoomImage.isZoomImage = true;
		this.zoomer.loadedImages.push(this.src.dirname().basename()+'¤'+this.src.basename());
	}
	imageMonitor.onerror = function() {
		this.zoomer.zoomImage.src = '/images/no-image-160-'+this.zoomer.usrLang+'.jpg';
		this.zoomer.zoomImage.setAttribute('width', '160');
		this.zoomer.zoomImage.setAttribute('height', '160');
		this.zoomer.zoomImage.style.cssText = 'position: absolute;left:50px;top:120px;';
		this.zoomer.zoomImage.isZoomImage = false;
	}
	imageMonitor.src = this.o.getAttribute('zoomurl');

	this.zoomImage               = document.createElement('img');
	this.zoomImage.setAttribute('width', '275');
	this.zoomImage.setAttribute('height', '200');
	this.zoomImage.src           = "/images/global/loading.gif";
	this.c.appendChild(this.zoomImage);
	this.zoomImage.style.cssText = 'position: absolute; left:-15px; top:120px;';
	this.zoomImage.isZoomImage = false;
}


OjO_ImageZoomer.prototype.prepareZoomFrame = function() {
	var fw = this.MetricsC.w*this.zoomScaleOut, fh = this.MetricsC.h*this.zoomScaleOut;
	this.MetricsF = {
		x: this.MetricsO.x+((this.MetricsO.w-fw)/2), 
		y: this.MetricsO.y+((this.MetricsO.h-fh)/2),
		w: fw,
		h: fh,
		midW: fw/2,
		midH: fh/2

	};

	this.zoomFrameBounds = {
		top: this.MetricsO.y+(fh/2)-5,
		right: this.MetricsO.xw-(fw/2)+5,
		bottom: this.MetricsO.yh-(fh/2)+5,
		left: this.MetricsO.x+(fw/2)-5
	};

	if(null==this.zoomFrame) {
		var opacityStyleAttr;
		if(this.msie) {
			opacityStyleAttr = 'filter: alpha(opacity='+this.zoomFrameOpacity+');';
		} else {
			opacityStyleAttr = 'opacity:'+((100-this.zoomFrameOpacity)/100)+';';
		}

		this.zoomFrame = document.createElement('div');
		this.zoomFrame.id = 'ZoomFrame_'+this.o.id;
		this.zoomFrame.style.cssText = 'position:absolute;display:none;z-index:400;left:0px;top:0px;width:'
										+this.MetricsF.w+'px;height:'
										+this.MetricsF.h+'px;border:1px solid #888;background-color:#fff;'
										+opacityStyleAttr+';cursor:move;';

		document.body.insertBefore(this.zoomFrame, this.o.firstChild);
		ElGoodies.enrich(this.zoomFrame);
	}

}

OjO_ImageZoomer.prototype.upadeZoomCoords = function(e) {
	var ret = false;

	if(null!==this.rideau && 'block'==this.rideau.style.display) {
		this.setActive(false);
		return ret;
	}

	if(this.msie) {
		if(null==this.last2c[0].x || (this.last2c[0].x==this.last2c[1].x && this.last2c[0].y==this.last2c[1].y)) {
			return ret; 
		}
	}

	if(this.MetricsO.x<e.pageX && this.MetricsO.xw>e.pageX && this.MetricsO.y<e.pageY & this.MetricsO.yh>e.pageY) {
		
		if(this.zoomFrameBounds.left<=e.pageX && this.zoomFrameBounds.right>=e.pageX) {
			this.MetricsF.x = e.pageX;
		} else if(this.zoomFrameBounds.left<e.pageX) {
			this.MetricsF.x = this.zoomFrameBounds.right;
		} else if(this.zoomFrameBounds.right>=e.pageX) {
			this.MetricsF.x = this.zoomFrameBounds.left;
		}

		if(this.zoomFrameBounds.top<=e.pageY && this.zoomFrameBounds.bottom>=e.pageY) {
			this.MetricsF.y = e.pageY;
		} else if(this.zoomFrameBounds.top<e.pageY) {
			this.MetricsF.y = this.zoomFrameBounds.bottom;
		} else if(this.zoomFrameBounds.bottom>e.pageY) {
			this.MetricsF.y = this.zoomFrameBounds.top;
		}
		ret = true;
	}
	
	return ret;
}


OjO_ImageZoomer.prototype.zoom = function() {


	if(this.active) {
		var pLeft = (this.MetricsF.x - this.MetricsF.midW);
		var pTop = (this.MetricsF.y - this.MetricsF.midH);
		this.zoomFrame.style.left = pLeft+'px';
		this.zoomFrame.style.top = pTop+'px';

		if(this.zoomImage.isZoomImage /*!/\/loading\.gif$/.test(this.zoomImage.src)*/) {
			this.zoomImage.style.left = -((this.MetricsF.x-this.MetricsO.x-this.MetricsF.midW)*this.zoomScaleIn)+'px';
			this.zoomImage.style.top = -((this.MetricsF.y-this.MetricsO.y-this.MetricsF.midH)*this.zoomScaleIn)+'px';
		}

	}

}

OjO_ImageZoomer.prototype._mousemove = function(e) {

	if(null==e || void(0)==e.pageX) e = OjO_EventUtil.getEvent();
	this.last2c[0] = this.last2c[1];
	this.last2c[1] = {x:e.pageX, y:e.pageY};

	if(this.upadeZoomCoords(e)) {
		this.setActive(true);
		this.zoom();
	} else {
		this.setActive(false);
		return;
	}
}
OjO_ImageZoomer.prototype._windowResized = function(e) {
	this.refreshMetrics();
}


OjO_ImageZoomer.prototype.setMetrics = function() {
	var tmp = this.o.getPosition();
	tmp.w = parseFloat(this.o.getComputedStyle('width'),10);
	tmp.h = parseFloat(this.o.getComputedStyle('height'),10);
	this.MetricsO = {
		x: tmp.x,
		y: tmp.y,
		w: tmp.w,
		h: tmp.h,
		xw: tmp.x+tmp.w,
		yh: tmp.y+tmp.h
	};

	tmp = this.c.getPosition();

	this.MetricsC = {
		x: tmp.x,
		y: tmp.y,
		w: parseFloat(this.c.getComputedStyle('width'),10),
		h: parseFloat(this.c.getComputedStyle('height'),10)
	};
}

OjO_ImageZoomer.prototype.refreshMetrics = function() {
	this.setMetrics();
	this.prepareZoomFrame();
}

OjO_ImageZoomer.prototype.getUserLang = function() {
	var ret = 'en';
	var langs = {'fr':true, 'en':true, 'zh':true, 'ja':true}
	var pTokens = window.location.pathname.split('/');
	for(var i=0; i<pTokens.length; i++) {
		if(-1==pTokens[i].indexOf('.') && langs[pTokens[i]]) {
			ret = pTokens[i];
		}
	}
	return ret;
}

OjO_ImageZoomer.prototype.init = function() {


	this.usrLang = this.getUserLang();
	this.loadedImages.push(this.o.src.dirname().basename()+'¤'+this.o.src.basename());
	this.rideau = document.getElementById('BgPopup'), /* A rendre parametrable */
	this.btRetour = document.getElementById('FromProductToList'), /* A rendre parametrable aussi */

	setTimeout(this.setOffsetImage.magicApply({bind: this}), 100);
	this.setMetrics();

	this.prepareZoomImage();
	this.prepareZoomFrame();

	this.mousemove = this._mousemove.magicApply({bind: this});
	this.windowResized = this._windowResized.magicApply({bind: this});
	OjO_EventUtil.addEventHandler(window.document, 'mousemove', this.mousemove);
	OjO_EventUtil.addEventHandler(window, 'resize', this.windowResized);

}

function upateZoomerImages(zoomerVarname) {

	var ImageZoomer = window[zoomerVarname];

	if('object'==typeof ImageZoomer) {

		var urlTokens;
		var urlPattern = this.src;
		var sizesToUrls = {baseURL: 355, zoomURL: 1500};

		for(var k in sizesToUrls) {
			urlTokens = urlPattern.split('/');
			urlTokens[urlTokens.length-2] = urlTokens[urlTokens.length-2].replace(new String(this.offsetWidth), sizesToUrls[k]);
			sizesToUrls[k] = urlTokens.join('/');
		}
		
		ImageZoomer.setImages(sizesToUrls);
	}

}

function onVignetteContainerClicked() {
	var e = OjO_EventUtil.getEvent();
	var relAttrValue = e.target.parentNode.getAttribute('rel');

	if(relAttrValue) {
		upateZoomerImages.call(e.target, relAttrValue);
	}

	e.preventDefault();
	e.stopPropagation();
}


