/**
 * All intellectual property rights in this Software throughout the world belong to UK Radioplayer, 
 * rights in the Software are licensed (not sold) to subscriber stations, and subscriber stations 
 * have no rights in, or to, the Software other than the right to use it in accordance with the 
 * Terms and Conditions at www.radioplayer.co.uk/terms. You shall not produce any derivate works 
 * based on whole or part of the Software, including the source code, for any other purpose other 
 * than for usage associated with connecting to the UK Radioplayer Service in accordance with these 
 * Terms and Conditions, and you shall not convey nor sublicense the Software, including the source 
 * code, for any other purpose or to any third party, without the prior written consent of UK Radioplayer.
 *
 * sets up a basic overlay
 * @param {String} container CSS selector of the overlay container
 * @constructor
 */
radioplayer.models.RadioplayerOverlay = function (container) {
	this._$container = glow.dom.get(container);
	// set the default to the parent container of the overlay
	this._$parentContainer = this._$container.parent();
	this.overlay = null;
	this._isVisible = false;
};

radioplayer.models.RadioplayerOverlay.prototype = {
	/** show the overlay */
	show: function(speed) {
		var that = this,
			opts = {
				tween: glow.tweens.easeBoth(),
				onStart: function(){
					that._$container.css({'display': 'block'});
					that._isVisible = true;
				}
			};
	
		return glow.anim.css(this._$container, speed, {
				'opacity': {'from': 0, 'to': 1}
			},
			opts);
	},
	
	/** hide the overlay */
	hide: function(speed) {
		var that = this,
			opts = {
				tween: glow.tweens.easeBoth(),
				onComplete: function() {
					that._$container.css('display', 'none');
					that._isVisible = false;
				}
			};

		return glow.anim.css(this._$container, speed, {
			'opacity': {'from': 1, 'to': 0}
		}, opts);
	},
	
	/** toggle the overlay */
	toggle: function(speed) {
		return this._isVisible ? this.hide(speed) : this.show(speed);
	}

};

