/**
 * @class Roo.gui.SignatureWindow
 * @extends Ext.Window
 *
 * The Signaturewindow shows the authentic information of a plan. It's reached through a icon.
 *
 * @author ssmeman
 * @version 1.0
 */

/**
 * @constructor
 * @param {Object} config Configuration options
 */
Roo.gui.SignatureWindow = Ext.extend(Ext.Window, {
	discPanel_titleText: null
	,buttonClose: messages.button.closeText()

	,constructor: function(config) {
		this.plan = config.plan;

		Roo.gui.SignatureWindow.superclass.constructor.apply(this, arguments);
	}

	,initComponent: function() {

		if (this.plan.versieImro == "IMRO2008") {
			this.discPanel_titleText = messages.signatureWindow.disclaimerPanel.title2008();
		} else {
			this.discPanel_titleText = messages.signatureWindow.disclaimerPanel.title2006PCP();
		}

		var tabs = [{
			xtype: 'panel'
			,id: 'disclaimer-panel'
			,title: this.discPanel_titleText
			,autoLoad: {
				url: './content/disclaimer-' + this.plan.versieImro + '.html?'
				,autoAbort: true
				,timeout: 5
			}
		}];

		// add "digitaal waarmerk" panels if imro2008
		if(this.plan.versieImro == "IMRO2008") {
			tabs.unshift({
				xtype: 'authenticInfoPanel'
				,plan: this.plan
			},{
				xtype: 'certificateInfoPanel'
				,plan: this.plan
			});
		}

		var config = {
			id: 'signature-window'
			,closable: true
			,constrain: true
			,collapsable:false
			,resizable: false
			,modal: true
			,width: 580

			,items: [new Ext.TabPanel({
				activeItem: 0
				,hideMode: 'display'
				,defaults: {
					height: 410
					,width: 560
					,hideMode: 'display'
				}
				,items: tabs
			})]
			,buttons: [{
				text: this.buttonClose
				,handler: function(target, event) {
					target.findParentByType('signatureWindow').close();
				}
			}]
		};

		Ext.apply(this, config);
		Ext.apply(this.initialConfig, config);

		Roo.gui.SignatureWindow.superclass.initComponent.apply(this, arguments);

		this.on({
			scope: this
			,'beforeshow': function(win) {
				win.setTitle(messages.signatureWindow.title(this.plan.naam));
				win.setIconClass('x-icon-' + (this.plan.versieImro=="IMRO2008"?(this.plan.authentic ? 'authentic' : 'notauthentic'):'authenticunknown')  );
			}
		});
	}
	,setPlan: function(plan) {
		this.plan = plan;
	}
});

Ext.reg('signatureWindow', Roo.gui.SignatureWindow);