var disputeApp = function() {
	
	var forms = {
		main : new Ext.form.FormPanel({
			id:'dispute_form',
			title:'You must be a Buyadate.org member to file a dispute.',
			url:'/do_dispute',
			method:'POST',
			frame:true,
			width:625,
			labelAlign:'top',
			defaults:{
				disabled: isUser ? false : true,
				width: 600,
				allowBlank:false
			},
			items:[
			{
				xtype:'textfield',
				fieldLabel:'Dispute Subject',
				name:'disputesubject'
			},
			{
				xtype:'textarea',
				name:'disputetext',
				fieldLabel:'Dispute Description - please provide as much information as possible.',
				height:200
			}
			],
			buttons:[
			{
				iconCls:'btn-apply',
				text:'Submit',
				handler:function() {
                    this.ownerCt.form.submit({
                        waitMsg: 'Sending Message',
                        success: function(a, b){
                            var confirmationTemplate = new Ext.XTemplate('<tpl for="."><div><h3>Your dispute has been submitted.</h3><p></p>');
                            var markup = confirmationTemplate.apply();
                            document.getElementById('formContainer').innerHTML = markup;
                        },
						failure: function(a,b){
							if(b.result.errors.forceLogin) {
								window.location='/login?required=true&path=/dispute';
							}
						}
                    });				}
			}
			]
		})
	}
	return {
		init : function() {
			forms.main.render('formContainer');
		}
	}
};

var dApp;
Ext.onReady(function() {
	dApp = disputeApp();
	dApp.init();
})
