(function(){
  var WalletCashout = function() {
    return {

      init: function() {
          var calculateFee = function(fee, amount) {

            amount = ( !amount || amount == '' ) ? 0.00 : parseFloat(amount);

            if( fee == 0 ) {
              var net = amount;
              $('#fee_static').find('span#_fee').html(parseFloat(0.00).toFixed(2));
            } else {
              var fee_amount = ( fee / 100 ) * amount;
              net = amount - fee_amount;
              $('#fee_static').find('span#_fee').html(parseFloat(fee_amount).toFixed(2));
            }

            $('#fee_static').find('span#_net').html(parseFloat(net).toFixed(2));
            
          };

          $('#amount_transfer').on('keyup', function(){
            

            var fee = $(this).data('fee');
            var val = $(this).val();

            calculateFee(fee, val);
          });

          $('#amount_cashout').on('keyup', function(){

               var fee = $(this).data('fee');
              var val = $(this).val();

              calculateFee(fee, val);
          });

        }
    };
  }();

  $(document).ready(function() {
    WalletCashout.init();
  });

})();