/**
 * This class requires jQuery.
 * This class depends on Scroller.
 *
 * $Id: controls.js,v 1.3 2009/12/05 03:50:53 jmuller Exp $
 *
 * jObj: jQueryfied object that holds controls, .i.e: $('#controls'), if there exists an element like:
 * 					<div id="controls">
 * 						<span id="prev"></span>
 * 						<span class="separator"></span>
 * 						<span id="play"></span>
 * 						<span class="separator"></span>
 * 						<span id="stop"></span>
 * 						<span class="separator"></span>
 * 						<span id="next"></span>
 * 					</div>
 * scroller: the scroller object.
 */

var Controls = function(jObj, scroller) {
	var self = this;

	self.initialize = function(jObj, scroller) {
		self.controls = jObj;
		self.scroller = scroller;

		self.controls.parent().hover(
			function() { self.controls.show(); },
			function() { self.controls.hide(); }
		);
	
		self.buttons = new Array();
		self.buttons.play = self.controls.find('#play');
		self.buttons.stop = self.controls.find('#stop');
		self.buttons.next = self.controls.find('#next');
		self.buttons.prev = self.controls.find('#prev');

		self.buttons.play.click(function() { self.play();});
		self.buttons.stop.click(function() { self.stop();});
		self.buttons.next.click(function() { self.next();});
		self.buttons.prev.click(function() { self.prev();});

		self.controls.find('#play').addClass('disabled');
	};

	self.play = function() {
		self.scroller.start_scrolling();
		self.buttons.stop.removeClass('disabled');
		self.buttons.play.addClass('disabled');
	};

	self.stop = function() {
		self.scroller.stop_scrolling();
		self.buttons.play.removeClass('disabled');
		self.buttons.stop.addClass('disabled');
	}

	self.prev = function() {
		self.scroller.prev();
		self.buttons.play.removeClass('disabled');
		self.buttons.stop.addClass('disabled');
	}

	self.next = function() {
		self.scroller.next();
		self.buttons.play.removeClass('disabled');
		self.buttons.stop.addClass('disabled');
	}

	self.initialize.apply(null, arguments);
}

/**
 * $Log: controls.js,v $
 * Revision 1.3  2009/12/05 03:50:53  jmuller
 * *** empty log message ***
 *
 * Revision 1.2  2009/12/05 03:49:51  jmuller
 * Add documentation.
 *
 * Revision 1.1  2009/12/05 03:41:40  jmuller
 * Initial commit.
 *
 */

