Ext.onReady(function(){

	Ext.QuickTips.init();

	if(obj=Ext.get('calculator-form-sum')){
		new Ext.form.NumberField(
			{
                fieldLabel: 'Сумма перевода ($)',
                name: 'sum',
				maskRe: /[0-9]/,			
				width: 80,
				plugins:[Ext.ux.plugins.RemoteValidator]
				,renderTo: obj
				,rvOptions: {
					url:'/load.php'
					,params: {'do': 'sendmoney/calculate'}
					,callback: function(o,s,response){
						var data = Ext.decode(response.responseText);						
						if(data.valid){
							Ext.getCmp('fee').setValue(data.fee);
							Ext.getCmp('amount').setValue(data.amount);
							//calcResult.body.update('');
						}
						else{
							//calcResult.body.update(tplCalcError.apply(data));
							Ext.getCmp('fee').reset();
							Ext.getCmp('amount').reset();
						}
					}
				}
            }
		)
	};
	if(obj=Ext.get('calculator-form-fee')){
		new Ext.form.NumberField({
			id: 'fee'
			,readOnly: true
			,width: 80
			,fieldLabel: 'Стомость перевода'
			,renderTo: obj
		})
	};
	if(obj=Ext.get('calculator-form-amount')){
		new Ext.form.NumberField({
			id: 'amount'
			,readOnly: true
			,width: 80
			,fieldLabel: 'К оплате'
			,renderTo: obj
		})
	};
	
});
