
function C_PostMessageDialog()
{this.window=null;this.show=function(params)
{this.callback=params.callback;this.callbackScope=params.scope;if(!this.window)
{this.form=new Ext.form.FormPanel({baseCls:'x-plain',url:'/data/post-message.php',labelAlign:'right',bodyStyle:'padding:5px 5px 0',buttonAlign:'center',baseParams:{},items:[{xtype:'container',layout:'column',items:[{xtype:'container',width:55,items:[{xtype:'container',html:'<img src="'+g_fullDomainRoot+'/imgstore/rider-portrait/'+params.racingTeamID+'/'+params.riderID+'.jpg" width=47 height=59>'}]},{xtype:'container',layout:'form',hideLabels:true,items:[{xtype:'container',style:'font:13px \'Helvetica Neue\', Arial, sans-serif; color: #888; padding-bottom:3px',html:'<a><b>'+params.riderName+'</b></a> - '+params.teamName},{xtype:'textarea',name:'Message',style:'overflow:hidden',maxLength:255,allowBlank:false,blankText:'You must enter a message',width:465,height:40}]}]},{xtype:'container',cls:'form-spacer',height:2},{xtype:'container',id:'status-msg',style:'display:none',cls:'form-status'}],buttons:[{text:'Post Message',width:100,handler:this.saveButtonClick,scope:this},{text:'Cancel',handler:this.cancelButtonClick,scope:this}],keys:[{key:[10,13],scope:this,stopEvent:true,fn:this.saveButtonClick}]});this.window=new Ext.Window({width:555,title:params.title,autoHeight:true,forceLayout:true,resizable:false,closeAction:'hide',modal:true,bodyStyle:'padding:5px;',items:this.form});this.window.on('show',function(){this.form.getForm().reset();this.form.getForm().baseParams.PostedToID=g_pt;this.setMessage('','black');this.form.getForm().findField('Message').focus(true,300);},this);}
else
{this.window.center();}
this.window.show(params.animateTarget);}
this.cancelButtonClick=function()
{this.window.hide();this.callback.apply(this.callbackScope,[this,false]);}
this.saveButtonClick=function()
{this.setMessage("Posting Message...","black",true);this.window.getEl().mask();this.form.getForm().submit({reset:false,success:this.onPostSuccess,failure:this.onPostFailure,scope:this});}
this.onPostSuccess=function(form,action)
{this.setMessage("Message Posted","green");this.window.getEl().unmask();this.window.hide();this.callback.apply(this.callbackScope,[this,false]);}
this.onPostFailure=function(form,action)
{this.window.getEl().unmask();switch(action.failureType){case Ext.form.Action.CLIENT_INVALID:this.setMessage("Fields marked in red are required","red");break;case Ext.form.Action.SERVER_INVALID:this.setMessage("Error posting message: "+action.result.message,"red");break;case Ext.form.Action.CONNECT_FAILURE:this.setMessage("Error posting message: Server did not respond","red");break;}}
this.setMessage=function(message,color,loading)
{setFormMessage(message,color,loading);this.window.syncSize();}}
