/**
 * ByngPanel pod base class
 * 
 * @requires Mootools-1.2
 * 
 * @author Ollie Maitland
 * @copyright Byng Systems LLP
 */
Byng.register('byng.panel.pod', 
{
	Implements : [ByngView, Options],
	
	/**
	 * Initialize a pod
	 * 
	 * @param {Object} panel
	 * @param {Object} options
	 */
	initialize : function (panel, options)
	{
		this.panel = panel;
		this.setOptions( options );
	},
	
	/**
	 * Get a hydrated request
	 * 
	 * @param {String} screen
	 * @return ByngRequest
	 */
	getHydratedRequest : function (screen)
	{
		if (!this.options.request) {
			this.options.request = this.getRequest(screen);
			$each(this.panel.subject.identifiers, function (value,key) {
				this.addParam(key,value);
			}.bind(this.options.request));
		}
		return this.options.request.clone(screen);
	},
	
	/**
	 * Generic getPopup() helper method
	 * 
	 * @param {Object} screen
	 * @return ByngInput
	 */
	popup : function ( screen )
	{
		return Byng.input.popup({	'request' : this.getHydratedRequest(screen),
									'onPopup' 	: function (popup) {
										this.form = popup.getElement('form');
									}.bind(this)});
	},
	
	/**
	 * Reload the panel 
	 * 
	 */
	reload : function ()
	{
		var uri = window.location.pathname + '?';		
		$each(this.panel.subject.identifiers, function (value,key) {
			uri += key + '=' + value + '&';	
		});
		window.location.href = uri;
	}
	
});