cs.pro.VolumePanel = Ext.extend(Ext.form.FormPanel, {

	initComponent: function()
	{
		this.volumeOptions = new cs.pro.VolumeOptions();

		Ext.apply(this, {
			title: 'Volume',
			frame: true,
			autoHeight: true,
			items:[
				this.volumeOptions
			]
		});

		cs.pro.VolumePanel.superclass.initComponent.apply(this, arguments);
	}
});

cs.pro.VolumeOptions = Ext.extend(Ext.form.FieldSet, {

	getVolume: function()
	{
		var file;
		if((file = cs.pro.viewport.getSelectedFile()) == false) return;
		Ext.Ajax.request({
			url: 'json/pro_job_volume',
			params: {
				file: file.get('id')
			},
			callback: this.gotVolume,
			scope: this
		});
	},

	gotVolume: function(options, success, response)
	{
		if(response = cs.common.lib.errorFilter(success, response, this.getVolume))
		{
			cs.pro.viewport.addTab(response.filename, 'provolume', response.job);
		}
	},

	initComponent: function()
	{
		this.begin = new Ext.Button({
			text: 'Process Selected File',
			handler: this.getVolume,
			scope: this
		});
		
		Ext.apply(this, {
			title: 'Processing Options',
			autoHeight: true,
			buttons: [
				this.begin
			]
		});

		cs.pro.VolumeOptions.superclass.initComponent.apply(this, arguments);
	}
});
