Moving 2.0 development version to main trunk.
[fa-stable.git] / js / budget.js
1 function focus_budget(i) {
2     save_focus(i);
3         i.setAttribute('_last', get_amount(i.name));
4 }
5
6 function blur_budget(i) {
7         var amount = get_amount(i.name);
8         var total = get_amount('Total', 1);
9         
10         if(amount<0) amount = 0;                
11         price_format(i.name, amount, 0);
12         price_format('Total', total+amount-i.getAttribute('_last'), 0, 1, 1);
13 }
14
15
16 var budget_calc = {
17         '.amount': function(e) {
18                 e.onblur = function() {
19                         blur_budget(this);
20                   };
21                 e.onfocus = function() {
22                         focus_budget(this);
23                 };
24         }
25 }
26
27 Behaviour.register(budget_calc);