$(document).ready(function()
{
    $(document).on('change', '.amount', function()
    {
        var paymentCurrency = $('#payment').find('option:selected').data('currency');
        var receiptCurrency = $('#receipt').find('option:selected').data('currency');

        if(receiptCurrency != paymentCurrency)
        {
            $('.transfer').show().find('input').attr('disabled', false);
            $('.money').hide().find('input').attr('disabled', true);

            var transferOutExchangeRate = paymentCurrency == v.mainCurrency ? 1 : '';
            $('#transferOutCurrency').val(paymentCurrency);
            $('#transferOutCurrencyLabel').val(paymentCurrency);
            $('.transferOutExchangeRate').val(transferOutExchangeRate).toggle(paymentCurrency != v.mainCurrency);

            var transferInExchangeRate = receiptCurrency == v.mainCurrency ? 1 : '';
            $('#transferInCurrency').val(receiptCurrency);
            $('#transferInCurrencyLabel').val(receiptCurrency);
            $('.transferInExchangeRate').val(transferInExchangeRate).toggle(receiptCurrency != v.mainCurrency);
        }
        else
        {
            var currency = paymentCurrency;

            $('.money').show().find('input').attr('disabled', false);
            $('.transfer').hide().find('input').attr('disabled', true);

            $('#currency').val(currency);
            $('#currencyLabel').val(currency);
            $('.exchangeRate').toggle(currency != v.mainCurrency);
        }
    });

    $('.amount').change();
})
