Event.addBehavior({
  // Focus/Blur/Disabled indicator for input elements
  '*[disabled]' : function() {
    this.addClassName('disabled');
  },
  'input@focus' : function() {
    this.addClassName('focus');
    return true;
  },
  'input@blur' : function() {
    this.removeClassName('focus');
    return true;
  },
  'textarea@focus' : function() {
    this.addClassName('focus');
  },
  'textarea@blur' : function() {
    this.removeClassName('focus');
  },
  'select@focus' : function() {
    this.addClassName('focus');
  },
  'select@blur' : function() {
    this.removeClassName('focus');
  },
  // Focus indicator for buttons
  'button@mouseover' : function() {
    this.addClassName('focus');
  },
  'button@mouseout' : function() {
    this.removeClassName('focus');
  },
  '#btnPayPrePay@click' : function() {
    if ($F('fldTerms') != 1) {
      $('warning').show();
    } else {
      if ($F('radPay10') == 1)
        document.location.href = "https://secure.epayment.ro/order/checkout.php?PRODS=542819&QTY=1&LANG=ro";
      if ($F('radPay20') == 1)
        document.location.href = "https://secure.epayment.ro/order/checkout.php?PRODS=542822&QTY=1&LANG=ro";
      if ($F('radPay30') == 1)
        document.location.href = "https://secure.epayment.ro/order/checkout.php?PRODS=542832&QTY=1&LANG=ro";
      if ($F('radPay50') == 1)
        document.location.href = "https://secure.epayment.ro/order/checkout.php?PRODS=1229072&QTY=1&LANG=ro";
      if ($F('radPay100') == 1)
        document.location.href = "https://secure.epayment.ro/order/checkout.php?PRODS=1229080&QTY=1&LANG=ro";
    }
  },
  '#btnPayInvoice@click' : function() {
    if ($F('fldTerms') != 1) {
      $('warning').show();
    } else {
      if ($F('fldPayCustomValue') > 0) {
        var _url = self.location.pathname;
        var _pars = $H({act: 'calc', fldPayCustomValue: $F('fldPayCustomValue')});
        var _ajxUpd = new Ajax.Updater('customData', _url, {method: 'post', parameters: _pars, onComplete: calc_onComplete});
      }
    }
  },
  'div.form-row' : function() {
    var _in = this.down('input');
    if(_in && _in.title && _in.readAttribute('rel')) {
      var _aa = new Tip(this, _in.title, {title: _in.readAttribute('rel'), className: 'protogrey', border: 2, radius: 2, hook: {mouse: true, tip: 'topRight'}, offset: { x: 0, y: 8 }, stem: 'topRight'});
    }
  }
});

function calc_onComplete() {
  $('onlinePay').submit();
}
