var CatalogPictureSwitcher =
{
	_currentPictureIdx:0,
	_imageContainerId:null,
	_nextHandlerId:null,
	_previousHandlerId:null,
	_pictures:null,
	init: function(pictures, imageContainerId, previousHandlerId, nextHandlerId)
	{
		this._pictures = pictures;
		this._imageContainerId = imageContainerId;
		this._nextHandlerId = nextHandlerId;
		this._previousHandlerId = previousHandlerId;
		//console.debug(pictures);
		//console.debug(pictures.length);
		//console.debug(pictures[0]);
	},
	switchPicture: function(direction)
	{
		//$.ajax({url:'somefile.dat',type:'HEAD',error:do_something})
		//console.debug(direction, this._currentPictureIdx, this._pictures.length);
		//console.debug(  (jQuery('#'+this._imageContainerId)).parent()  );
		var parent = (jQuery('#'+this._imageContainerId)).parent();
		var reg=new RegExp("(thumb)", "g");
		if(direction != 'next' && direction != 'previous')
			return false;
		switch(direction)
		{
			case 'next' :
				if(this._currentPictureIdx < this._pictures.length-1)
				{
					this._currentPictureIdx++;
					jQuery('#'+this._imageContainerId).attr("src", this._pictures[this._currentPictureIdx]);
					parent.attr("href", this._pictures[this._currentPictureIdx].replace(reg,'big'));
				}
				if(this._currentPictureIdx >= this._pictures.lengt-1)
					this.desactivateNextHandler();
			break;
			case 'previous' :
				if(this._currentPictureIdx > 0)
				{
					this._currentPictureIdx--;
					jQuery('#'+this._imageContainerId).attr("src", this._pictures[this._currentPictureIdx]);
					parent.attr("href", this._pictures[this._currentPictureIdx].replace(reg,'big'));
				}
				if(this._currentPictureIdx <= 0)
					this.desactivatePreviousHandler();
			break;
			default:
		}
		//console.debug(imageContainerId, direction, nextHandlerId, previousHandlerId);
	},
	
	desactivateNextHandler: function()
	{
		//console.debug('desactivateNextHandler');
	},
	
	desactivatePreviousHandler: function()
	{
		//console.debug('desactivatePreviousHandler');
	}
}


