// JavaScript Document
/**
 * WidgetPlaylist
 * Changes the source of the given iframe with next and previous
 * buttons. (Primarily used within the Video Widget Carousel menu)
 *
 * @uses jquery-1.3.2
 */
function WidgetPlaylist(ul, info)
{
	this.carousel;

	/**
	 * UL HTML element containing a list of all available
	 * items to cycle through
	 *
	 * @var HTML_Element
	 */
	this.ul = $(ul);

	this.info = $(info);

	/**
	 * _init
	 *
	 * Initialisation method. Generates the js DIV wrapper around the iframe
	 * and compiles the next and previous buttons with appropriate event handlers
	 *
	 * @return void
	 */
	this._init = function()
	{
		var obj = this;
		
		$(ul).addClass("jcarousel-widgetplaylist");
		$(ul).jcarousel({
			animation:400,
			easing: 'linear',
			vertical: true,
			itemLoadCallback:function(carousel) 
			{ 
				obj.carousel = carousel;
				obj.showInfo();
			}
		});

		jQuery('div.jcarousel-next').bind('click', function() {
			obj.carousel.next();
			obj.showInfo();
		});
		
		jQuery('div.jcarousel-prev').bind('click', function() {
			obj.carousel.prev();
			obj.showInfo();
		});
	}

	this.showInfo = function()
	{
		this.info.html("Showing " + this.carousel.first + " to " +  this.carousel.last + " (of " + this.carousel.options.size + ")");
	}

	/**
	 * Initialise the _init method
	 */
	this._init();
}