function cur2usd(cur_name, cur_val) {
    if(cur_name == 'USD') return cur_val;
    if(cur_name == 'RUB') return (cur_val/29.7692);
    if(cur_name == 'EUR') return (cur_val*39.4114/29.7692);
    if(cur_name == 'GBP') return (cur_val*47.0056/29.7692);
    else return 0;
}
function curonchange() {
    cur_val = parseFloat(document.getElementById('cur_val').value);
    cur_name = document.getElementById('cur_name').value;
    cur_set = document.getElementById('cur_set');
    cur = cur2usd(cur_name, cur_val);
    cur_set.value = cur.toFixed(2);
}
function curonchanget() {
    cur_val_o = parseFloat(document.getElementById('cur_val_o').value);
    cur_val_t = parseFloat(document.getElementById('cur_val_t').value);
    
    cur_name = document.getElementById('cur_name').value;
    
    cur_set_o = document.getElementById('summax');
    cur_set_t = document.getElementById('sum');
    
    cur = cur2usd(cur_name, cur_val_o);
    cur_set_o.value = cur.toFixed(2);
    cur = cur2usd(cur_name, cur_val_t);
    cur_set_t.value = cur.toFixed(2);
}


