function ObjectBlocGalerieImagesManagerVisitor(element_id, mask_layer_id)
{
	this.maskLayerId = mask_layer_id;
	this.maskLayerObject = null;
	this.elementId = element_id;
	this.containers = $H();
	
	this.navig = $H();
	this.images = $A();
	
	this._init = function()
	{	
		this.containers['main'] = $(this.elementId);
		
		this.containers['imagesClipContainer'] = this.containers['main'].down('.images_clip_container');
		this.containers['imagesContainer'] = this.containers['main'].down('.images_container');
		
		this.containers['leftActionPanel'] = this.containers['main'].down('.left_action_panel');
		this.containers['rightActionPanel'] = this.containers['main'].down('.right_action_panel');
		
		
		this.maskLayerObject = MaskLayerObjects[this.maskLayerId];
		
		this._collectImages();		
		this._prepareNavig();
		this._bindActionsPanels();
	}
	
	this._collectImages = function()
	{
		if(!this.containers['imagesContainer'])
			return;
			
		this.images = $A(this.containers['imagesContainer'].getElementsByClassName('image_element'));		
		var ref = this;
		this.images.each(function(element, index)
		{
			//var intitule = element.down('.image_intitule');
			//Event.observe(intitule, 'mouseover', ref._onIntituleMouseOver.bindAsEventListener(ref,intitule));
			
			var img = element.down('img');
			Event.observe(element, 'mouseover', ref._onImageMouseOver.bindAsEventListener(ref,img));
			Event.observe(element, 'mouseout', ref._onImageMouseOut.bindAsEventListener(ref,img));
			Event.observe(element, 'click', ref._onImageClick.bindAsEventListener(ref,img));
		});	
	}
	
	this._onIntituleMouseOver = function(event, element)
	{
		Event.stop(event);
		element.setOpacity(0.7);
		
		
		var element = element.up();
	}
	
	this._onImageMouseOver = function(event, element)
	{
		Event.stop(event);
		var element = element.up();
		
		var intitule = element.down('.image_intitule');
		
		if(intitule.innerHTML != '')
			intitule.show();
		
		
		//new Effect.Opacity(element, {to:0.7, duration:0.5});
		
		element.setOpacity(0.7);
	}
	
	this._onImageMouseOut = function(event,element)
	{
		Event.stop(event);
		var element = element.up();
		
		var intitule = element.down('.image_intitule');
		
		if(intitule.innerHTML != '')
			intitule.hide();
		
		//new Effect.Opacity(element, {to:1, duration:0.5});
		
		element.setOpacity(1);
	}
	
	this._onImageClick = function(event, element, pos)
	{
		Event.stop(event);
		
		
		var pimg_src = element.name;//element.src.replace('local/cache-vignettes/L174xH130/', 'IMG/jpg/');
		var tmpimg = new Image();
		tmpimg.src = element.name;
		
		var nwidth = 600;
		var nration = tmpimg.width / tmpimg.height;
		var nheight = nwidth / nration;
		
		var pimg = Builder.node('div', {style:'text-align:center;cursor:pointer;'}, 
					[
						Builder.node('img', {src:pimg_src,style:"width:" + nwidth + "px;height:" + nheight +"px;"}),
						Builder.node('div', {style:"color:white;padding:3px;font-weight:bold;font-size:13px;"}, '( cliquez sur l\'image pour fermer )')
					]);
		Event.observe(pimg, 'click', this.maskLayerObject.hide.bind(this.maskLayerObject));
		
		this.maskLayerObject.setElementContent(pimg, {appearEffect:true});
		this.maskLayerObject.show();
	}
	
	
	this._prepareNavig = function()
	{
		if(!this.images.size())		
			return;
	
		this.navig['offsetCurrent'] = 0;
		this.navig['currentClipPage'] = 1;
		this.navig['clipWidth'] = this.containers['imagesClipContainer'].getWidth();
		this.navig['fullWidth'] = this.containers['imagesContainer'].getWidth();
		
		this.navig['imageElementWidth'] = this.navig['fullWidth']/this.images.size();
		
			
		this.navig['numFullImagesPerClip'] = Math.floor(this.navig['clipWidth']/this.navig['imageElementWidth']);		
		this.navig['numClipPages'] = Math.ceil(this.images.size() / this.navig['numFullImagesPerClip']);
		
		
		this.navig['offsetSize'] = this.navig['numFullImagesPerClip']*this.navig['imageElementWidth'];
		this._checkActionsVisibility();
	}


	this._bindActionsPanels = function()
	{
		if(!this.images.size())
			return;
		Event.observe(this.containers['leftActionPanel'], 'click', this._onClickActionLeft.bindAsEventListener(this));		
		Event.observe(this.containers['leftActionPanel'], 'mouseover', this._onMouseOverAction.bindAsEventListener(this, this.containers['leftActionPanel'], 'left_'));
		Event.observe(this.containers['leftActionPanel'], 'mouseout', this._onMouseOutAction.bindAsEventListener(this, this.containers['leftActionPanel'], 'left_'));
		
		Event.observe(this.containers['rightActionPanel'], 'click', this._onClickActionRight.bindAsEventListener(this));
		Event.observe(this.containers['rightActionPanel'], 'mouseover', this._onMouseOverAction.bindAsEventListener(this, this.containers['rightActionPanel'], 'right_'));
		Event.observe(this.containers['rightActionPanel'], 'mouseout', this._onMouseOutAction.bindAsEventListener(this, this.containers['rightActionPanel'], 'right_'));
		
	}
	
	this._onMouseOverAction = function(event, element, class_prefix)
	{
		Event.stop(event);
		element.addClassName(class_prefix+'over');
	}
	
	
	
	this._onMouseOutAction = function(event, element, class_prefix)
	{
		Event.stop(event);
		element.removeClassName(class_prefix+'over');
	}
	
	this._onClickActionLeft = function(event)
	{
		if(!event.detail || event.detail == 1)		
			this.gotoClipPage(this.navig['currentClipPage']-1);
		else if(!event.detail || event.detail == 2)
			this.gotoClipPage(1);		
	}
	
	this._onClickActionRight = function(event)
	{
		if(!event.detail || event.detail == 1)		
			this.gotoClipPage(this.navig['currentClipPage']+1);
		else if(!event.detail || event.detail == 2)
			this.gotoClipPage(this.navig['numClipPages']);		
	}
	
	this.gotoClipPage = function(page_num)
	{
		if(!this.images.size() || page_num < 1 || page_num > this.navig['numClipPages'])		
			return;
			
		
		this.navig['currentClipPage'] = page_num;
		this.navig['offsetCurrent'] = (page_num-1)*this.navig['offsetSize'];
		
		this._checkActionsVisibility();
		
		//new Effect.Opacity(this.containers['imagesClipContainer'], {from:1, to:0.7, duration:0.5});
		
		this.containers['imagesClipContainer'].setOpacity(0.7);
		new Effect.Move(this.containers['imagesContainer'], {x:-this.navig['offsetCurrent'], y:0, mode:'absolute', afterFinish:this.afterGotoClipPageFinished.bind(this)})
		
	}
	
	this._checkActionsVisibility = function()
	{
		if(this.navig['currentClipPage']  == 1)
			this.containers['leftActionPanel'].style.visibility = 'hidden';
		else
			this.containers['leftActionPanel'].style.visibility = 'visible';
			
		if(this.navig['currentClipPage']  == this.navig['numClipPages'])
			this.containers['rightActionPanel'].style.visibility = 'hidden';
		else
			this.containers['rightActionPanel'].style.visibility = 'visible';
	}
	
	this.afterGotoClipPageFinished = function()
	{
		//new Effect.Opacity(this.containers['imagesClipContainer'], {from:0.7, to:1,duration:0.5});
		
		this.containers['imagesClipContainer'].setOpacity(1);
	}
	
	this._init();
}
