Ext.ns('Ext.pv.profile');
Ext.pv.profile.BasicInfoDialog = Ext.extend(Ext.Window, {
	width: 500,
	height: 330,
	resizable: true,
	autoScroll: true,
	modal: true,
	layout: 'fit',
	constrain: true,
	stateful: false,
	closable: true,
	onEsc: Ext.emptyFn,
	
	// Localized strings
	title : 'Edit Basic Details',
	okButtonText : 'OK',
	cancelButtonText : 'Cancel',
	alertTitle : 'Message',
	invalidInputMessage : 'Form is invalid.',

	direction : 'ltr',
	personId : 0,
	isSiteCreditEditable : true,
	contextPath : null,
	callback : null,
	

	/**
	 * initComponent
	 * 
	 * @protected
	 */
	initComponent : function() {
		
		if (this.direction=='rtl') {
			this.style = 'direction:rtl';
		}
	
		this.form = new Ext.pv.profile.BasicInfoForm({
			contextPath : this.contextPath,
			personId : this.personId,
			isSiteCreditEditable : this.isSiteCreditEditable
		});
		this.items = [this.form];
		
		// Build the buttons
		this.buttons = [ {
			text : this.okButtonText,
			handler : this.onOk,
			scope : this
		},{
			text : this.cancelButtonText,
			handler : this.onCancel,
			scope : this
		} ];
		
		// super
		Ext.pv.profile.BasicInfoDialog.superclass.initComponent.call(this);
		
		this.on(
			'show',
			function() {
				this.form.reset();
				this.form.load();
			},
			this
		);
	},
	
	onOk : function() {
		var errorMessage = this.form.validate();
		if (errorMessage!=null) {
			Ext.Msg.alert(this.alertTitle,errorMessage);
			return;
		}

		this.form.saveRecord(this.callback);
	},
	
	onCancel : function() {
		this.close();
	}

});
