if (!OB)
{
	var OB = {};
}
/**
 * PicturePlayer class
 * @constructor
 * @author Hadrien Lanneau
 */
OB.PicturePlayer = function(el, data)
{
	this.el = YAHOO.util.Dom.get(el);
	
	this.data = data;
	
	this.currentPage = 0;
	this.currentPict = 0;
	
	this.diaporama = null;
	this.diaporamaInterval = 4000;
	
	this.played = YAHOO.util.Dom.getElementsByClassName(
		'played',
		null,
		this.el
	)[0];
	this.player = {
		prevPict:	YAHOO.util.Dom.getElementsByClassName(
			'previous',
			null,
			YAHOO.util.Dom.getElementsByClassName(
				'player',
				null,
				this.el
			)[0]
		)[0],
		play:		YAHOO.util.Dom.getElementsByClassName(
			'play',
			null,
			YAHOO.util.Dom.getElementsByClassName(
				'player',
				null,
				this.el
			)[0]
		)[0],
		nextPict:	YAHOO.util.Dom.getElementsByClassName(
			'next',
			null,
			YAHOO.util.Dom.getElementsByClassName(
				'player',
				null,
				this.el
			)[0]
		)[0],
		fullscreen:	YAHOO.util.Dom.getElementsByClassName(
			'fullscreen',
			null,
			YAHOO.util.Dom.getElementsByClassName(
				'player',
				null,
				this.el
			)[0]
		)[0]
	};
	this.pagination = YAHOO.util.Dom.getElementsByClassName(
		'pagination',
		null,
		this.el
	)[0];
	
	// State
	this.ready = false;
	
	// Time on page
	this._lastReload = new Date();
	
	// Last image change time
	this._lastImgChanged = new Date();
	
	OB.PicturePlayer.ACTIVE_PLAYER = this;
	
	this.init();
};
OB.PicturePlayer.PICTS_PER_PAGE = 5;
OB.PicturePlayer.LOCAL_previous;
OB.PicturePlayer.LOCAL_next;
OB.PicturePlayer.IMG_URI_FULL;
OB.PicturePlayer.IMG_URI_BIG;
OB.PicturePlayer.IMG_URI_THUMB;
OB.PicturePlayer.ACTIVE_PLAYER;
OB.PicturePlayer.RELOAD_TRACKER_INTERVAL = 20;
OB.PicturePlayer.RELOAD_AD_AFTER_IMG = 6;

OB.PicturePlayer.prototype =
{
	/**
	 * Initialize object
	 */
	init: function()
	{
		// Search current image in data
		this.getCurrentPicture(
			'src',
			this.played.getAttribute('rel')
		);
		
		this.setControls();
		
		this.setPagination();
		
		this.movePagination(
			{
				absolute: true,
				number: this.currentPict
			}
		);
		
		// Events
		this.el.player = this;
		YAHOO.util.Event.on(
			this.el,
			'mouseenter',
			function(e)
			{
				this.showControls();
			},
			this,
			true
		);
		YAHOO.util.Event.on(
			this.el,
			'mouseleave',
			function(e)
			{
				this.hideControls();
			},
			this,
			true
		);
		YAHOO.util.Event.addListener(
			this.played,
			'click',
			function(e, obj)
			{
				this.stopDiaporama();
				this.displayNextPicture();
			},
			this,
			true
		);
		YAHOO.util.Event.addListener(
			document,
			'keydown',
			function(e)
			{
				if (e.keyCode == e.DOM_VK_RIGHT ||
					e.keyCode == e.DOM_VK_DOWN ||
					e.keyCode == 39 ||
					e.keyCode == 40)
				{
					if (this.diaporama)
					{
						this.stopDiaporama();
						this.startDiaporama();
					}
					else
					{
						this.displayNextPicture();
					}
				}
				if (e.keyCode == e.DOM_VK_LEFT ||
					e.keyCode == e.DOM_VK_UP ||
					e.keyCode == 37 ||
					e.keyCode == 38)
				{
					this.stopDiaporama();
					this.displayPreviousPicture();
				}
			},
			this,
			true
		);
		YAHOO.util.Event.addListener(
			document.body.getElementsByTagName('div')[0],
			'DOMMouseScroll',
			function(e)
			{
				if (!this.mousewheelregion)
				{
					var reg = YAHOO.util.Dom.getRegion(
						this.el
					);
					this.mousewheelregion = {
						from: reg.top,
						to: reg.bottom - reg.top
					};
				}
				// Test if scroll is in player zone
				if (e.pageY > this.mousewheelregion.from &&
					e.pageY < this.mousewheelregion.to)
				{
					if (e.detail > 0)
					{
						this.stopDiaporama();
						this.displayNextPicture(true);
					}
					if (e.detail < 0)
					{
						this.stopDiaporama();
						this.displayPreviousPicture(true);
					}
					YAHOO.util.Event.preventDefault(e);
				}
			},
			this,
			true
		);
		
		// Hidding player
		this.hideControls();
		
		// Preload pictures
		this.preloadPictures();
	},
	/**
	 * Hide control when mouse leave
	 */
	hideControls: function()
	{
		if (this.hideshowFx)
		{
			this.hideshowFx.cancel();
		}
		
		var player = YAHOO.util.Dom.getElementsByClassName(
			'player',
			null,
			this.el
		)[0];
		var reg = YAHOO.util.Dom.getRegion(
			player
		);
		
		(new YAHOO.util.Anim(
			player,
			{
				top: {
					to: '-' +
						parseInt(
							(reg.bottom - reg.top) +
							10
						)
				}
			},
			0.25,
			YAHOO.util.Easing.easeOut
		)).animate();
		
		reg = YAHOO.util.Dom.getRegion(
			this.pagination
		);
		(new YAHOO.util.Anim(
			this.pagination,
			{
				bottom: {
					to: '-' +
						parseInt(
							(reg.bottom - reg.top) +
							10
						)
				}
			},
			0.25,
			YAHOO.util.Easing.easeOut
		)).animate();
	},
	/**
	 * Show control when mouse enter
	 */
	showControls: function()
	{
		if (this.hideshowFx)
		{
			this.hideshowFx.cancel();
		}
		(new YAHOO.util.Anim(
			YAHOO.util.Dom.getElementsByClassName(
				'player',
				null,
				this.el
			)[0],
			{
				top: {
					to: 0
				}
			},
			0.25,
			YAHOO.util.Easing.easeOut
		)).animate();
		
		(new YAHOO.util.Anim(
			this.pagination,
			{
				bottom: {
					to: 0
				}
			},
			0.25,
			YAHOO.util.Easing.easeOut
		)).animate();
	},
	/**
	 * Get index of a picture by one of its values
	 */
	getCurrentPicture: function(key, value)
	{
		if (!value || !key)
		{
			return this.data.pictures[this.currentPict];
		}
		
		for (i in this.data.pictures)
		{
			if (this.data.pictures[i][key] == value)
			{
				this.currentPict = parseInt(i);
			}
		}
		return this.data.pictures[this.currentPict];
	},
	/**
	 * Initialize pagination
	 */
	setPagination: function()
	{
		
		// Prepare pagination
		var as = this.pagination.getElementsByTagName('a');
		for (var i = 0; as[i]; i++)
		{
			as[i].style.display = '';
			as[i].thumb = YAHOO.util.Dom.getElementsByClassName(
				'thumb',
				null,
				as[i]
			);
			if (as[i].thumb[0])
			{
				YAHOO.util.Event.addListener(
					as[i],
					'click',
					function(e, obj)
					{
						obj.player.stopDiaporama();
						obj.player.displayPict(
							this.thumb[0].getAttribute('rel')
						);
						YAHOO.util.Event.preventDefault(e);
					},
					{
						player: this
					}
				);
			}
		}
		
		// Pagination
		YAHOO.util.Event.addListener(
			YAHOO.util.Dom.getElementsByClassName(
				'left',
				null,
				this.pagination
			)[0].getElementsByTagName('a')[0],
			'click',
			function(e)
			{
				this.stopDiaporama();
				this.movePagination(
					{
						number: 5
					}
				);
				
				YAHOO.util.Event.preventDefault(e);
			},
			this,
			true
		);
		
		YAHOO.util.Event.addListener(
			YAHOO.util.Dom.getElementsByClassName(
				'right',
				null,
				this.pagination
			)[0].getElementsByTagName('a')[0],
			'click',
			function(e)
			{
				this.stopDiaporama();
				this.movePagination(
					{
						number: 5,
						right: true
					}
				);
				
				YAHOO.util.Event.preventDefault(e);
			},
			this,
			true
		);
	},
	/**
	 * Move pagination
	 */
	movePagination: function(params)
	{
		if (!params)
		{
			params = {};
		}
		if (!this.thumbWidth)
		{
			var reg = YAHOO.util.Dom.getRegion(
				YAHOO.util.Dom.getElementsByClassName(
					'thumb',
					null,
					this.pagination
				)[0]
			);
			
			this.thumbWidth = parseInt(
				reg.right - reg.left + 10
			);
		}
		
		var container = YAHOO.util.Dom.getElementsByClassName(
			'middle',
			null,
			this.pagination
		)[0].getElementsByTagName('span')[0];
		
		if (params.absolute)
		{
			var newMargin = 0;
		}
		else
		{
			newMargin = parseInt(
				YAHOO.util.Dom.getStyle(
					container,
					'margin-left'
				)
			);
		}
		
		if (params.right || params.absolute)
		{
			if (params.number > this.data.count - 1 &&
				newMargin == 0)
			{
				newMargin = newMargin - this.thumbWidth * (this.data.count - 1);
			}
			else
			{
				newMargin = newMargin - this.thumbWidth * params.number;
			
				if (newMargin < -(this.data.count * this.thumbWidth))
				{
					newMargin = 0;
				}
			}
		}
		else
		{
			if (params.number > this.data.count - 1 &&
				newMargin < 0)
			{
				newMargin = 0;
			}
			else
			{
				newMargin = newMargin + this.thumbWidth * params.number;
				
				if (newMargin > 0)
				{
					newMargin = -((this.data.count - 1) * this.thumbWidth);
				}
			}
		}
		
		// Display hidden thumbs
		var as = YAHOO.util.Dom.getElementsByClassName(
			'middle',
			null,
			this.pagination
		)[0].getElementsByTagName('a');
		var startThumb = Math.abs(
			parseInt(
				parseInt(
					newMargin
				) / this.thumbWidth
			)
		);
		for (var i = 0; i < OB.PicturePlayer.PICTS_PER_PAGE; i++)
		{
			var p = as[startThumb + i];
			
			if (p)
			{
				p = YAHOO.util.Dom.getElementsByClassName(
					'thumb',
					null,
					p
				)[0];
			}
			if (p && !p.style.backgroundImage)
			{
				YAHOO.util.Dom.setStyle(
					p,
					'background-image',
					'url(' +
						OB.PicturePlayer.IMG_URI_THUMB +
						p.getAttribute('rel') +
						')'
				);
			}
		}
		
		// Animation
		if (this._paginationMove)
		{
			this._paginationMove.cancel();
			this._paginationMove = null;
		}
		
		(new YAHOO.util.Anim(
			container,
			{
				'margin-left': {
					to: newMargin
				}
			},
			0.25,
			YAHOO.util.Easing.easeOut
		)).animate();
	},
	/**
	 * Center pagination on a particular picture
	 */
	centerPagination: function(src)
	{
		this.movePagination(
			{
				absolute: true,
				number: this.currentPict
			}
		);
	},
	/**
	 * Initiliaze controls
	 */
	setControls: function()
	{
		// Prev
		var prevLink = false;
		if (this.data.pictures[this.currentPict - 1])
		{
			prevLink = this.data.pictures[this.currentPict - 1].src;
		}
		var a = this.player.prevPict.getElementsByTagName('a')[0];
		if (prevLink)
		{
			a.className = '';
			YAHOO.util.Event.removeListener(
				a,
				'click'
			);
			YAHOO.util.Event.addListener(
				a,
				'click',
				function(e, obj)
				{
					obj.player.stopDiaporama();
					obj.player.displayPreviousPicture();
					
					YAHOO.util.Event.preventDefault(e);
				},
				{
					player: this
				},
				a
			);
			YAHOO.util.Dom.setStyle(
				a,
				'visibility',
				'visible'
			);
		}
		else
		{
			a.className = 'disabled';
			YAHOO.util.Event.removeListener(
				a,
				'click'
			);
			YAHOO.util.Event.addListener(
				a,
				'click',
				function(e)
				{
					YAHOO.util.Event.preventDefault(e);
				}
			);
			YAHOO.util.Dom.setStyle(
				a,
				'visibility',
				'hidden'
			);
		}
		
		// Next
		var nextLink = false;
		if (this.data.pictures[this.currentPict + 1])
		{
			nextLink = this.data.pictures[this.currentPict + 1].src;
		}
		a = this.player.nextPict.getElementsByTagName('a')[0];
		if (nextLink)
		{
			a.className = '';
			YAHOO.util.Event.removeListener(
				a,
				'click'
			);
			YAHOO.util.Event.addListener(
				a,
				'click',
				function(e, obj)
				{
					
					if (obj.player.diaporama)
					{
						obj.player.stopDiaporama();
						obj.player.startDiaporama();
					}
					else
					{
						obj.player.displayNextPicture();
					}
					
					YAHOO.util.Event.preventDefault(e);
				},
				{
					player: this
				},
				a
			);
			YAHOO.util.Dom.setStyle(
				a,
				'visibility',
				'visible'
			);
		}
		else
		{
			a.className = 'disabled';
			YAHOO.util.Event.removeListener(
				a,
				'click'
			);
			YAHOO.util.Event.addListener(
				'click',
				function(e)
				{
					YAHOO.util.Event.preventDefault(e);
				}
			);
			YAHOO.util.Dom.setStyle(
				a,
				'visibility',
				'hidden'
			);
		}
		
		// Play
		a = this.player.play.getElementsByTagName('a')[0];
		if (this.diaporama)
		{
			a.className = 'pause';
			YAHOO.util.Event.removeListener(
				a,
				'click'
			);
			YAHOO.util.Event.addListener(
				a,
				'click',
				function(e, obj)
				{
					this.stopDiaporama();
					
					YAHOO.util.Event.preventDefault(e);
				},
				this,
				true
			);
		}
		else
		{
			YAHOO.util.Event.removeListener(
				a,
				'click'
			);
			YAHOO.util.Event.addListener(
				a,
				'click',
				function(e, obj)
				{
					this.startDiaporama();
					YAHOO.util.Event.preventDefault(e);
				},
				this,
				true
			);
		}
		
		// Remove focus on links
		YAHOO.util.Event.addListener(
			document.getElementsByTagName('a'),
			'focus',
			function(e)
			{
				this.blur();
			}
		);
		
		// Fullscreen
		a = this.player.fullscreen.getElementsByTagName('a')[0];
		YAHOO.util.Event.removeListener(
			a,
			'click'
		);
		YAHOO.util.Event.addListener(
			a,
			'click',
			function(e, obj)
			{
				obj.player.displayFullScreen();
				
				YAHOO.util.Event.preventDefault(e);
			},
			{
				player: this
			},
			a
		);
	},
	/**
	 * Display a picture by its src
	 */
	displayPict: function(src, noFade)
	{
		// Reload ads
		if (new Date() - this._lastImgChanged > OB.PicturePlayer.RELOAD_AD_AFTER_IMG * 1000)
		{
			if (OB.reloadAd)
			{
				OB.reloadAd();
			}
		}
		this._lastImgChanged = new Date();
		
		this.getCurrentPicture(
			'src',
			src
		);
		this.setControls();
		
		if (false &&/*(Browser.Engine.trident ||
			Browser.Engine.presto) &&*/
			!this.ready)
		{
			noFade = true;
		}
		
		if (this.getCurrentPicture().src &&
			this.getCurrentPicture().src == src)
		{
			if (noFade)
			{
				this._displayPict(src, true);
			}
			else
			{
				if (this._dispPictEffect)
				{
					this._dispPictEffect.stop();
					this._dispPictEffect = null;
				}
				// Start fade out effect
				var targets = [];
				var options = {};
				if (this.fullscreenCtn)
				{
					targets.push(this.fullscreenCtn.img);
					options['1'] = {
						'opacity': [0]
					};
				}
				targets.push(this.played);
				options['0'] = {
					'opacity': [0]
				};
				this._dispPictEffect = new YAHOO.util.Anim(
					targets,
					{
						opacity: {
							to: 0
						}
					},
					0.25,
					YAHOO.util.Easing.easeOut
				);
				this._dispPictEffect.onComplete.subscribe(
					function(e, obj)
					{
						this._displayPict(src);
					},
					this,
					true
				);
				this._dispPictEffect.animate();
			}
		}
	},
	/**
	 * display for real
	 */
	_displayPict: function(src, noFade)
	{
		// Set played image
		var targets = [];
		var options = {};
		if (this.fullscreenCtn)
		{
			this.fullscreenCtn.img.src = OB.PicturePlayer.IMG_URI_FULL +
				this.getCurrentPicture().src;
			this.fullscreenCtn.img.player = this;
			targets.push(this.fullscreenCtn.img);
		}
		this.played.src = OB.PicturePlayer.IMG_URI_BIG +
			this.getCurrentPicture().src;
		this.played.player = this;
		targets.push(this.played);
		targets[0].targets = targets;
		options['0'] = {
			'opacity': [0, 1]
		};
		
		YAHOO.util.Event.removeListener(
			targets,
			'load'
		);
		if (!noFade)
		{
			YAHOO.util.Event.addListener(
				targets[0],
				'load',
				function(e, obj)
				{
					if (obj.player._displayPictEnd)
					{
						obj.player._displayPictEnd.cancel();
						obj.player._displayPictEnd = null;
					}
					// Animate
					(new YAHOO.util.Anim(
						this.targets,
						{
							'opacity': {
								from: 0,
								to: 1
							}
						},
						0.25,
						YAHOO.util.Easing.easeOut
					)).animate();
					
					YAHOO.util.Event.removeListener(
						this,
						'load'
					);
					if (obj.player.waitNextPict)
					{
						clearTimeout(
							obj.player.waitNextPict
						);
					}
				},
				{
					player: this
				}
			);
			
			if (false/*(Browser.Engine.trident &&
				Browser.Engine.version == 5) ||
				Browser.Engine.presto*/)
			{
				// Habile subterfuge pour tromper cette bouse de chez redmond
				this.waitNextPict = setTimeout(
					function()
					{
						var e = YAHOO.util.Event.getListeners(
							player.played,
							'load'
						)[0];
						e.fn.apply(e.scope);
					},
					this.ready ?
						1 :
						3000
				);
			}
		}
		this.setControls();
		//this.setPagination();
		this.centerPagination(src);
		
		if (YAHOO.util.Dom.get('pictTitle'))
		{
			YAHOO.util.Dom.get('pictTitle').innerHTML = this.getCurrentPicture().title;
		}
		if (YAHOO.util.Dom.get('pictDescription'))
		{
			YAHOO.util.Dom.get('pictDescription').innerHTML = this.getCurrentPicture().description;
		}
		var tEl = YAHOO.util.Dom.getElementsByClassName(
			'breadcrumb'
		)[0].getElementsByTagName('li');
		if (tEl[3])
		{
			tEl[3].innerHTML = this.getCurrentPicture().title;
		}
		var optionsEl = YAHOO.util.Dom.getElementsByClassName(
			'options'
		)[0];
		tEl = YAHOO.util.Dom.getElementsByClassName(
			'download',
			null,
			optionsEl
		);
		if (tEl[0])
		{
			tEl[0].href = this.getCurrentPicture().url_download.replace(
				/&amp;/gi,
				'&'
			);
		}
		tEl = YAHOO.util.Dom.getElementsByClassName(
			'displayinfos',
			null,
			optionsEl
		);
		if (tEl[0])
		{
			tEl[0].href =
				this.getCurrentPicture().url_download.replace(
					/&amp;/gi,
					'&'
				) +
				YAHOO.util.Dom.getElementsByClassName(
					'displayinfos',
					'a'
				)[0].hash;
		}
		tEl = YAHOO.util.Dom.getElementsByClassName(
			'recommend',
			null,
			optionsEl
		);
		if (tEl[0])
		{
			tEl[0].href = this.getCurrentPicture().url_recommend.replace(
				/&amp;/gi,
				'&'
			);
		}
		tEl = YAHOO.util.Dom.getElementsByClassName(
			'share',
			null,
			optionsEl
		);
		if (tEl[0])
		{
			tEl[0].href = this.getCurrentPicture().url.replace(
				/&amp;/gi,
				'&'
			);
		}
		
		// Preload pictures
		this.preloadPictures();
	},
	/**
	 * Start diaporama
	 */
	startDiaporama: function()
	{
		if (YAHOO.env.ua.ie > 0)
		{
			OB.PicturePlayer.ACTIVE_PLAYER = this;
			this.diaporama = setInterval(
				function()
				{
					OB.PicturePlayer.ACTIVE_PLAYER.displayNextPicture();
					OB.PicturePlayer.ACTIVE_PLAYER.onDiaporamaPlay();
				},
				this.diaporamaInterval
			)
		}
		else
		{
			this.diaporama = setInterval(
				function(player)
				{
					player.displayNextPicture();
					player.onDiaporamaPlay();
				},
				this.diaporamaInterval,
				this
			)
		}
		this.player.play.getElementsByTagName('a')[0].className = 'pause';
		
		this.displayNextPicture();
		
		this.setControls();
	},
	/**
	 * Display next picture
	 */
	displayNextPicture: function(noFade, previous)
	{
		if (previous)
		{
			var newIndex = this.currentPict - 1;
		}
		else
		{
			newIndex = this.currentPict + 1;
		}
		var nextLink = false;
		if (this.data.pictures[newIndex])
		{
			nextLink = this.data.pictures[newIndex].src;
		}
		else if (newIndex == -1)
		{
			nextLink = this.data.pictures[this.data.count - 1].src;
		}
		else
		{
			nextLink = this.data.pictures[0].src;
		}
		
		this.displayPict(
			nextLink,
			noFade
		);
	},
	/**
	 * Display previous picture
	 */
	displayPreviousPicture: function(noFade)
	{
		this.displayNextPicture(
			noFade,
			true
		);
	},
	/**
	 * Stop diaporama
	 */
	stopDiaporama: function()
	{
		if (this.diaporama)
		{
			clearInterval(
				this.diaporama
			);
			this.diaporama = null
			this.player.play.getElementsByTagName('a')[0].className = 'play';
		}
		this.setControls();
	},
	/**
	 * Preload pictures
	 */
	preloadPictures: function()
	{
		// Preload previous and two next picture
		for (var i = -1; i < 3; i++)
		{
			if (this.data.pictures[this.currentPict + i] &&
				!this.data.pictures[this.currentPict + i].preload)
			{
				this.data.pictures[this.currentPict + i].preload = new Image();
				this.data.pictures[this.currentPict + i].preload.src =
					OB.PicturePlayer.IMG_URI_BIG +
					this.data.pictures[this.currentPict + i].src;
			}
		}
		
		if (!this.ready)
		{
			if (this.data.pictures[this.currentPict + 2])
			{
				try
				{
					YAHOO.util.Event.addListener(
						this.data.pictures[this.currentPict + 2].preload,
						'load',
						function(e, obj)
						{
							obj.player.ready = true;
						},
						{
							player: this
						}
					);
				}
				catch (e)
				{
					// IE SUX
					this.data.pictures[this.currentPict + 2].player = this;
					this.data.pictures[this.currentPict + 2].onload = function()
					{
						this.player.ready = true;
					}
				}
			}
			else
			{
				this.ready = true;
			}
		}
	},
	/**
	 * get current photo data
	 */
	getCurrentPhoto: function()
	{
		return this.data.pictures[this.currentPict];
	},
	/**
	 * displayFullScreen
	 */
	displayFullScreen: function()
	{
		this.fullscreenCtn = document.createElement('div');
		this.fullscreenCtn.img = new Image();
		this.fullscreenCtn.img.src = OB.PicturePlayer.IMG_URI_FULL +
			this.data.pictures[this.currentPict].src;
		this.fullscreenCtn.appendChild(this.fullscreenCtn.img);
		this.fullscreenCtn.className = 'fullscreenbg';
		
		YAHOO.util.Dom.setStyle(
			this.fullscreenCtn,
			'top', YAHOO.util.Dom.getDocumentScrollTop() + 'px'
		);
		YAHOO.util.Dom.setStyle(
			this.fullscreenCtn,
			'bottom', YAHOO.util.Dom.getViewportHeight() + 'px'
		);
		YAHOO.util.Dom.setStyle(
			this.fullscreenCtn,
			'line-height', YAHOO.util.Dom.getViewportHeight() + 'px'
		);
		YAHOO.util.Dom.setStyle(
			this.fullscreenCtn,
			'height', YAHOO.util.Dom.getViewportHeight() + 'px'
		);
		YAHOO.util.Dom.setStyle(
			this.fullscreenCtn,
			'opacity', 0
		);
		
		YAHOO.util.Dom.setStyle(
			this.fullscreenCtn.img,
			'opacity', 0
		);
		YAHOO.util.Dom.setStyle(
			this.fullscreenCtn.img,
			'max-height', YAHOO.util.Dom.getViewportHeight() + 'px'
		);
		YAHOO.util.Dom.setStyle(
			this.fullscreenCtn.img,
			'max-width', YAHOO.util.Dom.getViewportWidth() + 'px'
		);
		YAHOO.util.Dom.setStyle(
			this.fullscreenCtn.img,
			'width', 'auto'
		);
		YAHOO.util.Dom.setStyle(
			this.fullscreenCtn.img,
			'height', 'auto'
		);
		
		YAHOO.util.Dom.setStyle(
			document.body,
			'overflow', 'hidden'
		);
		
		this.fullscreenCtn.player = this;
		YAHOO.util.Event.addListener(
			this.fullscreenCtn,
			'click',
			function(e, obj)
			{
				var a = new YAHOO.util.Anim(
					this,
					{
						opacity: {
							from: 1,
							to: 0
						}
					},
					0.25,
					YAHOO.util.Easing.easeOut
				);
				a.onComplete.subscribe(
					function(e, obj)
					{
						this.getEl().parentNode.removeChild(
							this.getEl()
						);
						YAHOO.util.Dom.setStyle(
							document.body,
							'overflow',
							'visible'
						);
						obj.player.fullscreenCtn = null;
						delete this.getEl();
					},
					{
						player: obj.player
					}
				);
				a.animate();
			},
			{
				player: this
			}
		);
		
		document.body.appendChild(this.fullscreenCtn);
		
		// fx
		(new YAHOO.util.Anim(
			this.fullscreenCtn,
			{
				opacity: {
					from: 0,
					to: 1
				}
			},
			0.25,
			YAHOO.util.Easing.easeOut
		)).animate();
		
		this.fullscreenCtn.img.player = this;
		YAHOO.util.Event.addListener(
			this.fullscreenCtn.img,
			'load',
			function(e, obj)
			{
				(new YAHOO.util.Anim(
					this,
					{
						opacity: {
							from: 0,
							to: 1
						}
					},
					0.25,
					YAHOO.util.Easing.easeOut
				)).animate();
				
				if (obj.player.waitingFullScreen)
				{
					clearTimeout(
						obj.player.waitingFullScreen
					);
				}
				YAHOO.util.Event.removeListener(
					this,
					'load'
				);
			},
			{
				player: this
			}
		);
		if (false/*Browser.Engine.trident ||
			Browser.Engine.presto*/)
		{
			OB.PicturePlayer.ACTIVE_PLAYER = this;
			// Habile subterfuge pour tromper cette bouse de chez redmond
			this._waitingFullScreen = setTimeout(
				function()
				{
					var e = YAHOO.util.Event.getListeners(
						OB.PicturePlayer.ACTIVE_PLAYER.fullscreenCtn.img,
						'load'
					)[0];
					e.fn.apply(e.scope);
				},
				this.ready ?
					1 :
					3000
			);
		}
	},
	/**
	 * Event on diaporama play
	 */
	onDiaporamaPlay: function()
	{
		if ((new Date() - this._lastReload) / 1000
				>
					OB.PicturePlayer.RELOAD_TRACKER_INTERVAL)
		{
			this._lastReload = new Date();
			
			// reloading tracker
			try
			{
				oobTracker('hitv2js', 1);
			}
			catch (e)
			{
				if (console && console.debug)
				{
					console.debug('No tracker found');
				}
			}
		}
		
	}
};
