function MediaChooser(holderId, prevId, nextId) 
{
	var mediaElements;
	var titles;
	var actualId;
	
	var mediaHolder;
	var prevElement;
	var nextElement;
	
	function construct()
	{
		mediaElements = [];
		titles = [];
		actualId = 0;
		mediaHolder = new YAHOO.util.Element(holderId);
		prevElement = new YAHOO.util.Element(prevId);
		nextElement = new YAHOO.util.Element(nextId);
	}
	
	construct();
	
	function registerMediaElement(element, title)
	{
		mediaElements.push(element);
		titles.push(title);
	}
	
	function show()
	{
		mediaHolder.set('innerHTML', mediaElements[actualId]);
		refreshNavigation();
	}
	
	function refreshNavigation()
	{
		prevElement.setStyle('display', 'none');
		nextElement.setStyle('display', 'none');
		
		if(hasNext())
		{
			nextElement.setStyle('display', 'block');
			nextElement.set('href', 'javascript:app.getMediaChooser().next()');
		}
		
		if(hasPrevious())
		{
			prevElement.setStyle('display', 'block');
			prevElement.set('href', 'javascript:app.getMediaChooser().previous()');
		}
	}
	
	function hasNext()
	{	
		if(actualId >= mediaElements.length-1)
		{
			return false;
		}
		return true;
	}
	
	function hasPrevious()
	{
		if(actualId < 1)
		{
			return false;
		}
		return true;
	}
	
	function getNextTitle()
	{
		if(hasNext())
		{
			return titles[actualId+1];
		}
		return '';
	}
	
	function getPreviousTitle()
	{
		if(hasPrevious())
		{
			return titles[actualId-1];
		}
		return '';
	}
	
	function next()
	{
		actualId++;
		show();
	}
	
	function previous()
	{
		actualId--;
		show();
	}
	
	// public
	return ({
		registerMediaElement : function(element, title)
		{
			registerMediaElement(element, title);
		},
		hasNext: function()
		{
			hasNext();
		},
		hasPrevious: function()
		{
			hasPrevious();
		},
		getActualMediaElement: function()
		{
			return mediaElements[actualId];
		},
		getNextTitle: function()
		{
			getNextTitle();
		},
		getPreviousTitle: function()
		{
			getPreviousTitle();
		},
		next: function()
		{
			next();
		},
		previous: function()
		{
			previous();
		},
		show: function()
		{
			show();
		},
		hasElements: function()
		{
			if(mediaElements.length > 0)
			{
				return true;
			}
			return false;
		}
	});
}